Search in sources :

Example 21 with Graphics

use of java.awt.Graphics in project jdk8u_jdk by JetBrains.

the class MultiResolutionToolkitImageTest method generateImage.

static void generateImage(int scale) throws Exception {
    BufferedImage image = new BufferedImage(scale * IMAGE_WIDTH, scale * IMAGE_HEIGHT, BufferedImage.TYPE_INT_RGB);
    Graphics g = image.getGraphics();
    g.setColor(scale == 1 ? COLOR_1X : COLOR_2X);
    g.fillRect(0, 0, scale * IMAGE_WIDTH, scale * IMAGE_HEIGHT);
    File file = new File(scale == 1 ? IMAGE_NAME_1X : IMAGE_NAME_2X);
    ImageIO.write(image, "png", file);
}
Also used : Graphics(java.awt.Graphics) File(java.io.File) BufferedImage(java.awt.image.BufferedImage)

Example 22 with Graphics

use of java.awt.Graphics in project jdk8u_jdk by JetBrains.

the class MultiResolutionCachedImageTest method createImage.

private static Image createImage(int width, int height) {
    BufferedImage buffImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    Graphics g = buffImage.createGraphics();
    g.setColor(TEST_COLOR);
    g.fillRect(0, 0, width, height);
    return buffImage;
}
Also used : Graphics(java.awt.Graphics) BufferedImage(java.awt.image.BufferedImage)

Example 23 with Graphics

use of java.awt.Graphics in project jdk8u_jdk by JetBrains.

the class IconTest method generateImage.

private static BufferedImage generateImage(int scale, Color c) {
    int x = SZ * scale;
    BufferedImage img = new BufferedImage(x, x, BufferedImage.TYPE_INT_RGB);
    Graphics g = img.getGraphics();
    try {
        if (g != null) {
            g.setColor(c);
            g.fillRect(0, 0, x, x);
            g.setColor(Color.GREEN);
            g.drawRect(0, 0, x - 1, x - 1);
        }
    } finally {
        g.dispose();
    }
    return img;
}
Also used : Graphics(java.awt.Graphics) BufferedImage(java.awt.image.BufferedImage)

Example 24 with Graphics

use of java.awt.Graphics in project jdk8u_jdk by JetBrains.

the class MultiResolutionTrayIconTest method generateImage.

private static BufferedImage generateImage(int w, int h, int scale, Color c) {
    int x = w * scale, y = h * scale;
    BufferedImage img = new BufferedImage(x, y, BufferedImage.TYPE_INT_RGB);
    Graphics g = img.getGraphics();
    g.setColor(c);
    g.fillRect(0, 0, x, y);
    g.setColor(Color.WHITE);
    g.fillRect(x / 3, y / 3, x / 3, y / 3);
    return img;
}
Also used : Graphics(java.awt.Graphics) BufferedImage(java.awt.image.BufferedImage)

Example 25 with Graphics

use of java.awt.Graphics in project jdk8u_jdk by JetBrains.

the class DestTypeTest method createTestImage.

public static BufferedImage createTestImage(int type) {
    int w = 100;
    int h = 500;
    BufferedImage bi = new BufferedImage(3 * w, h, type);
    Graphics g = bi.createGraphics();
    g.setColor(Color.red);
    g.fillRect(0, 0, w, h);
    g.setColor(Color.green);
    g.fillRect(w, 0, w, h);
    g.setColor(Color.blue);
    g.fillRect(2 * w, 0, w, h);
    return bi;
}
Also used : Graphics(java.awt.Graphics) BufferedImage(java.awt.image.BufferedImage)

Aggregations

Graphics (java.awt.Graphics)158 BufferedImage (java.awt.image.BufferedImage)91 Graphics2D (java.awt.Graphics2D)22 Dimension (java.awt.Dimension)20 Color (java.awt.Color)19 File (java.io.File)18 Frame (java.awt.Frame)14 JFrame (javax.swing.JFrame)13 Point (java.awt.Point)12 Rectangle (java.awt.Rectangle)12 Component (java.awt.Component)11 IOException (java.io.IOException)11 JComponent (javax.swing.JComponent)9 FontMetrics (java.awt.FontMetrics)8 GraphicsConfiguration (java.awt.GraphicsConfiguration)8 Insets (java.awt.Insets)8 Panel (java.awt.Panel)8 ImageIcon (javax.swing.ImageIcon)8 GraphicsDevice (java.awt.GraphicsDevice)6 Window (java.awt.Window)6