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


Java Graphics2D.dispose方法代码示例

本文整理汇总了Java中java.awt.Graphics2D.dispose方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics2D.dispose方法的具体用法?Java Graphics2D.dispose怎么用?Java Graphics2D.dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Graphics2D的用法示例。


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

示例1: draw

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void draw(Graphics g, Map map) {
  if (drawGhost) {
    final Point p = map.componentCoordinates(getGhostPosition());

    final Graphics2D g2d = (Graphics2D) g.create();
    g2d.transform(
       AffineTransform.getRotateInstance(-PI_180 * tempAngle,
                                         p.x + centerX(),
                                         p.y + centerY()));
    g2d.setComposite(
       AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
    g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                         RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                         RenderingHints.VALUE_ANTIALIAS_ON);
    piece.draw(g2d, p.x, p.y, map.getView(), map.getZoom());
    g2d.dispose();
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:20,代码来源:FreeRotator.java

示例2: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D) g.create();
    super.paintComponent(g2d);
    int gridSize = 10;
    int majorGridSize = 100;
    g2d.setColor(new Color(0x484848));
    for (int i = 0; i < Math.max(getWidth(), getHeight()); i += gridSize) {
        if (i < getWidth()) {
            g2d.drawLine(i, 0, i, getHeight());
        }
        if (i < getHeight()) {
            g2d.drawLine(0, i, getWidth(), i);
        }
    }
    g2d.setColor(new Color(0x585858));
    for (int i = 0; i < Math.max(getWidth(), getHeight()); i += majorGridSize) {
        if (i < getWidth()) {
            g2d.drawLine(i, 0, i, getHeight());
        }
        if (i < getHeight()) {
            g2d.drawLine(0, i, getWidth(), i);
        }
    }
    g2d.dispose();
}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:27,代码来源:JNodeContainer.java

示例3: createTestImage

import java.awt.Graphics2D; //导入方法依赖的package包/类
protected BufferedImage createTestImage(int numColors) {

        IndexColorModel icm = createTestICM(numColors);
        int w = numColors * 10;
        int h = 20;

        BufferedImage img = new BufferedImage(w, h,
                BufferedImage.TYPE_BYTE_INDEXED, icm);

        Graphics2D g = img.createGraphics();
        for (int i = 0; i < numColors; i++) {
            int rgb = icm.getRGB(i);
            //System.out.printf("pixel %d, rgb %x\n", i, rgb);
            g.setColor(new Color(rgb));
            g.fillRect(i * 10, 0, w - i * 10, h);
        }
        g.dispose();

       return img;
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:ShortHistogramTest.java

示例4: drawBoxes

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draw symbols boxes and None symbols locations on control image.
 *
 * @param controlPath target path for control image
 * @throws java.io.IOException in case of IO problem
 */
public void drawBoxes (Path controlPath)
        throws IOException
{
    BufferedImage ctrl = new BufferedImage(
            initialImg.getWidth(),
            initialImg.getHeight(),
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g = ctrl.createGraphics();
    g.drawImage(initialImg, null, null);

    drawSymbols(annotations.getSymbols(), g);

    g.dispose();
    Files.createDirectories(controlPath.getParent());
    ImageIO.write(ctrl, OUTPUT_IMAGES_FORMAT, controlPath.toFile());
}
 
开发者ID:Audiveris,项目名称:omr-dataset-tools,代码行数:23,代码来源:SheetProcessor.java

示例5: redimensionaImg

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Redimensiona a imagem do caminho passado por parâmetro
 *
 * @param image imagem
 * @param razao proporção do redimensionamento
 * @return retorna a imagem redimensionada
 */
public static ImageIcon redimensionaImg(Image image, double razao) {
    double new_w, new_h;
    ImageIcon img = new ImageIcon(image);
    new_w = img.getIconWidth();
    new_h = img.getIconHeight();
    new_w *= razao;
    new_h *= razao;
    BufferedImage new_img = new BufferedImage((int) new_w, (int) new_h, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = new_img.createGraphics();
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
    g.drawImage(image, 0, 0, (int) new_w, (int) new_h, null);
    g.dispose();
    return new ImageIcon(new_img);
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:24,代码来源:Img.java

示例6: flip

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void flip(final LWComponentPeer<?, ?> peer, final Image backBuffer,
                 final int x1, final int y1, final int x2, final int y2,
                 final BufferCapabilities.FlipContents flipAction) {
    final Graphics g = peer.getGraphics();
    try {
        g.drawImage(backBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
    } finally {
        g.dispose();
    }
    if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
        final Graphics2D bg = (Graphics2D) backBuffer.getGraphics();
        try {
            bg.setBackground(peer.getBackground());
            bg.clearRect(0, 0, backBuffer.getWidth(null),
                         backBuffer.getHeight(null));
        } finally {
            bg.dispose();
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:CGLGraphicsConfig.java

示例7: flipHoriz

import java.awt.Graphics2D; //导入方法依赖的package包/类
public static BufferedImage flipHoriz(BufferedImage image) {
    BufferedImage newImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics2D gg = newImage.createGraphics();
    gg.drawImage(image, image.getHeight(), 0, -image.getWidth(), image.getHeight(), null);
    gg.dispose();
    return newImage;
}
 
开发者ID:marcelrv,项目名称:XiaomiRobotVacuumProtocol,代码行数:8,代码来源:RRDraw.java

示例8: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g.create();
    g2.setColor(Color.WHITE);
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.5f));
    g2.fillRect(0, 0, getWidth(), getHeight());
    g2.dispose();
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:9,代码来源:StartupPanel.java

示例9: paintBorder

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
	Graphics2D g2d = (Graphics2D) g.create();
	g2d.setRenderingHints(ProcessDrawer.HI_QUALITY_HINTS);
	g2d.setStroke(new BasicStroke(2f));

	// clear edges, otherwise they will be in the color of the component background
	if (drawRoundFrame && !c.getBackground().equals(c.getParent().getBackground())) {
		Shape frame = new Rectangle2D.Float(x + 2, y + 2, width - 4, height - 4);
		g2d.setPaint(c.getParent().getBackground());
		g2d.draw(frame);
	}

	g2d.setPaint(paint);
	g2d.setFont(new Font("Dialog", Font.BOLD, 21));

	if (drawRoundFrame) {
		Shape roundFrame = new RoundRectangle2D.Float(x + 2, y + 2, width - 4, height - 4, 10, 10);
		g2d.draw(roundFrame);
	}

	if (number > 0) {
		Shape circle = new Ellipse2D.Float(20, 20, 34, 34);
		g2d.fill(circle);
		g2d.setPaint(Color.WHITE);
		g2d.drawString(String.valueOf(number), 29, 44);
	}

	if (key != null) {
		g2d.setPaint(paint);
		g2d.drawString(key, 60, 44);
	}

	g2d.dispose();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:36,代码来源:RoundTitledBorder.java

示例10: main

import java.awt.Graphics2D; //导入方法依赖的package包/类
public static void main(final String[] args)
        throws NoninvertibleTransformException {
    final BufferedImage bi = new BufferedImage(300, 300,
                                               BufferedImage.TYPE_INT_RGB);
    final Graphics2D g = (Graphics2D) bi.getGraphics();
    test(g);
    g.translate(2.0, 2.0);
    test(g);
    g.translate(-4.0, -4.0);
    test(g);
    g.scale(2.0, 2.0);
    test(g);
    g.scale(-4.0, -4.0);
    test(g);
    g.rotate(Math.toRadians(90));
    test(g);
    g.rotate(Math.toRadians(90));
    test(g);
    g.rotate(Math.toRadians(90));
    test(g);
    g.rotate(Math.toRadians(90));
    test(g);
    g.dispose();
    if (!status) {
        throw new RuntimeException("Test failed");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:28,代码来源:Test8004859.java

示例11: createTestFile

import java.awt.Graphics2D; //导入方法依赖的package包/类
private static void createTestFile() {
    int w = 1280;
    int h = 1024;

    BufferedImage img = new
        BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = img.createGraphics();
    Color[] colors = { Color.red, Color.green, Color.blue };
    float[] dist = {0.0f, 0.5f, 1.0f };
    Point2D center = new Point2D.Float(0.5f * w, 0.5f * h);

    RadialGradientPaint p =
        new RadialGradientPaint(center, 0.5f * w, dist, colors);
    g.setPaint(p);
    g.fillRect(0, 0, w, h);
    g.dispose();

    try {
        System.out.println("Create test image " + file.getAbsolutePath());
        boolean b = ImageIO.write(img, "JPEG", file);
        if (!b) {
            throw new RuntimeException("Failed to create test image.");
        }
    } catch (IOException e) {
        throw new RuntimeException("Test failed", e);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:ConcurrentReadingTest.java

示例12: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g.create();
    g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    g2.setColor(Color.BLACK);
    /* Using the assistant now instead of text ontop of the glasspane.
     * josh: I need to delete all of the previous code related to the showMenubarWarning boolean
    if(showMenubarWarning) {
        g2.drawString("You cannot add a menu component to a form without a menubar.", 5, getHeight()-30);
    }*/
    g2.dispose();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:MenuEditLayer.java

示例13: getGradientColor

import java.awt.Graphics2D; //导入方法依赖的package包/类
private static Color getGradientColor(int w, int h, Color c1, Color c2) {
    GradientPaint gradient = new GradientPaint(0, 0, c1, 0, h, c2,
            true);
    BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = img.createGraphics();
    g.setPaint(gradient);
    g.fillRect(0, 0, w, h);
    g.dispose();
    return new Color(img.getRGB(w / 2, h / 2));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:ButtonGradientTest.java

示例14: getSourceGold

import java.awt.Graphics2D; //导入方法依赖的package包/类
private static BufferedImage getSourceGold(GraphicsConfiguration gc,
                                           int size) {
    final BufferedImage bi = gc.createCompatibleImage(size, size);
    Graphics2D g2d = bi.createGraphics();
    g2d.setColor(Color.RED);
    g2d.fillRect(0, 0, size, size);
    g2d.dispose();
    return bi;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:IncorrectClipXorModeSurface2Surface.java

示例15: step1

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws standard JMenuBar.
 */
private BufferedImage step1(final JMenuBar menubar) {
    final BufferedImage bi1 = new BufferedImage(W, H, TYPE_INT_ARGB_PRE);
    final Graphics2D g2d = bi1.createGraphics();
    g2d.scale(2, 2);
    g2d.setColor(Color.RED);
    g2d.fillRect(0, 0, W, H);
    menubar.paintAll(g2d);
    g2d.dispose();
    return bi1;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:MisplacedBorder.java


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