当前位置: 首页>>代码示例>>Java>>正文


Java GraphicsManager类代码示例

本文整理汇总了Java中edu.mit.blocks.codeblockutil.GraphicsManager的典型用法代码示例。如果您正苦于以下问题:Java GraphicsManager类的具体用法?Java GraphicsManager怎么用?Java GraphicsManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GraphicsManager类属于edu.mit.blocks.codeblockutil包,在下文中一共展示了GraphicsManager类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBevelImage

import edu.mit.blocks.codeblockutil.GraphicsManager; //导入依赖的package包/类
/**
 * Static method to return bufferedImage of a Beveled outline of a block
 */
public static Image getBevelImage(int width, int height, Area s) {
    BevelCacheKey key = new BevelCacheKey(width, height, s);
    BufferedImage img;
    img = bevelCache.get(key);
    if (img != null) {
        //System.out.println("Found cached bevel!");
        return img;
    }
    //System.out.println("Not found cached bevel!");
    //generic light vector - "chosen to look good"
    float[] light = ShapeBevel.getLightVector(-1, -2, 2);
    int bevelSize = 3;
    //create image
    img = GraphicsManager.gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT);
    Graphics2D g2 = (Graphics2D) img.getGraphics();
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setColor(ShapeBevel.getFrontFaceOverlay(light));
    g2.fill(s);
    ShapeBevel.createShapeBevel(g2, s, 0.1, bevelSize, bevelSize, light);
    // Make a copy of the Area to prevent aliasing.
    BevelCacheKey key2 = new BevelCacheKey(width, height, new Area(s));
    bevelCache.put(key2, img);
    return img;
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:28,代码来源:BlockShapeUtil.java

示例2: hierarchyChanged

import edu.mit.blocks.codeblockutil.GraphicsManager; //导入依赖的package包/类
/*************************************************************
 * HierarchyListener method for the RB is added to or removed
 * from a parent component
 *************************************************************/
@Override
public void hierarchyChanged(HierarchyEvent he) {
    if (rb.getParent() == null) {
        this.removeFromParent();
        GraphicsManager.recycleGCCompatibleImage(hImage);
        hImage = null;
    }
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:13,代码来源:RBHighlightHandler.java

示例3: clearBufferedImage

import edu.mit.blocks.codeblockutil.GraphicsManager; //导入依赖的package包/类
/**
 * Clears the BufferedImage of this
 */
public void clearBufferedImage() {
	GraphicsManager.recycleGCCompatibleImage(buffImg);
	buffImg = null;
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:8,代码来源:RenderableBlock.java

示例4: updateBuffImg

import edu.mit.blocks.codeblockutil.GraphicsManager; //导入依赖的package包/类
/**
 * Redraws the entire buffer on a Graphics2D, called by paintCompnent() only
 * if the buffer has been cleared.
 */
private void updateBuffImg() {
	if (GraphicsEnvironment.isHeadless()) {
		return;
	}

	// if label text has changed, then resync labels/sockets and reform
	// shape
	if (!synchronizeLabelsAndSockets()) {
		reformBlockShape();// if updateLabels is true, we don't need to
							// reform AGAIN
	}

	// create image
	// note: need to add twice the highlight stroke width so that the
	// highlight does not get cut off
	GraphicsManager.recycleGCCompatibleImage(buffImg);
	buffImg = GraphicsManager.getGCCompatibleImage(
			blockArea.getBounds().width, blockArea.getBounds().height);
	Graphics2D buffImgG2 = (Graphics2D) buffImg.getGraphics();

	// update bounds of this renderableBlock as bounds of the shape
	Dimension updatedDimensionRect = new Dimension(blockArea.getBounds()
			.getSize());

	// get size of block to determine size needed for bevel image
	Image bevelImage = BlockShapeUtil.getBevelImage(
			updatedDimensionRect.width, updatedDimensionRect.height,
			blockArea);

	// need antialiasing to remove color fill artifacts outside the bevel
	buffImgG2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_ON);

	// ADD BLOCK COLOR
	Color blockColor = this.getBLockColor();
	buffImgG2.setColor(blockColor);
	buffImgG2.fill(blockArea);

	// draw the bevel on the shape -- comment this line to not apply
	// beveling
	buffImgG2.drawImage(bevelImage, 0, 0, null);

	// DRAW BLOCK IMAGES
	repositionBlockImages(blockArea.getBounds().width,
			blockArea.getBounds().height);
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:51,代码来源:RenderableBlock.java

示例5: updateImage

import edu.mit.blocks.codeblockutil.GraphicsManager; //导入依赖的package包/类
public void updateImage() {
    if (GraphicsEnvironment.isHeadless()) {
        return;
    }

    // cache the focus so it'll know when it needs to redraw later.
    hasFocus = rb.getBlock().hasFocus();

    Color color = null;
    if (hColor != null) {
        color = hColor;
    } else if (rb.getBlock().hasFocus()) {
        color = new Color(200, 200, 255); //Color.BLUE);
    } else if (isSearchResult) {
        color = new Color(255, 255, 120); //Color.YELLOW);
    } else if (rb.getBlock().isBad()) {
        color = new Color(255, 100, 100); //Color.RED);
    } else {
        GraphicsManager.recycleGCCompatibleImage(hImage);
        hImage = null;
        return; // if we're not highlighting, destroy the image and just return
    }

    if (!rb.isVisible()) {
        GraphicsManager.recycleGCCompatibleImage(hImage);
        hImage = null;
        return; // if we're not highlighting, destroy the image and just return
    }

    hImage = GraphicsManager.getGCCompatibleImage(rb.getBlockWidth() + HIGHLIGHT_STROKE_WIDTH, rb.getBlockHeight() + HIGHLIGHT_STROKE_WIDTH);

    Graphics2D hg = (Graphics2D) hImage.getGraphics();
    hg.addRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
    hg.setColor(color);
    hg.translate(HIGHLIGHT_STROKE_WIDTH / 2, HIGHLIGHT_STROKE_WIDTH / 2);
    hg.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .2f));
    for (int i = 0; i < HIGHLIGHT_STROKE_WIDTH; i++) {
        hg.setStroke(new BasicStroke(i));
        hg.draw(rb.getBlockArea());
    }
    hg.setColor(new Color(0, 0, 0, 0));
    hg.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, 1));
    hg.fill(rb.getBlockArea());
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:45,代码来源:RBHighlightHandler.java

示例6: componentHidden

import edu.mit.blocks.codeblockutil.GraphicsManager; //导入依赖的package包/类
@Override
public void componentHidden(ComponentEvent arg0) {
    GraphicsManager.recycleGCCompatibleImage(hImage);
    hImage = null;
}
 
开发者ID:heqichen,项目名称:openblocks,代码行数:6,代码来源:RBHighlightHandler.java


注:本文中的edu.mit.blocks.codeblockutil.GraphicsManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。