Search in sources :

Example 31 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 32 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 33 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 34 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 35 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)217 BufferedImage (java.awt.image.BufferedImage)104 Dimension (java.awt.Dimension)35 Point (java.awt.Point)32 Graphics2D (java.awt.Graphics2D)31 Color (java.awt.Color)28 JPanel (javax.swing.JPanel)22 Insets (java.awt.Insets)21 Rectangle (java.awt.Rectangle)21 JLabel (javax.swing.JLabel)19 BorderLayout (java.awt.BorderLayout)18 File (java.io.File)18 FontMetrics (java.awt.FontMetrics)16 Frame (java.awt.Frame)16 MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)16 MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)16 Component (java.awt.Component)15 Font (java.awt.Font)15 GridBagLayout (java.awt.GridBagLayout)15 JScrollPane (javax.swing.JScrollPane)15