Search in sources :

Example 51 with Color

use of java.awt.Color in project opennms by OpenNMS.

the class MetadataFieldReaderTest method testValidTheme.

@Test
public void testValidTheme() throws Exception {
    final PollerTheme theme = getReader("target/test-classes/metadata.properties").getTheme();
    assertEquals("Foo", theme.getTitle());
    assertEquals(new URL("http://blah/"), theme.getImage());
    assertEquals(new Color(0xffffff), theme.getForegroundColor());
    assertEquals(new Color(0x000000), theme.getBackgroundColor());
    assertEquals(new Color(0xff0000), theme.getDetailColor());
}
Also used : PollerTheme(org.opennms.netmgt.poller.remote.PollerTheme) Color(java.awt.Color) URL(java.net.URL) Test(org.junit.Test)

Example 52 with Color

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

the class WrongBackgroundColor method main.

public static void main(final String[] args) throws InvocationTargetException, InterruptedException {
    SwingUtilities.invokeAndWait(() -> {
        UIDefaults ui = UIManager.getDefaults();
        ui.put("control", new ColorUIResource(54, 54, 54));
        final JDialog dialog = new JDialog();
        final JFrame frame = new JFrame();
        frame.pack();
        dialog.pack();
        final Color dialogBackground = dialog.getBackground();
        final Color frameBackground = frame.getBackground();
        frame.dispose();
        dialog.dispose();
        if (!dialogBackground.equals(frameBackground)) {
            System.err.println("Expected:" + frameBackground);
            System.err.println("Actual:" + dialogBackground);
            throw new RuntimeException("Wrong background color");
        }
    });
}
Also used : UIDefaults(javax.swing.UIDefaults) JFrame(javax.swing.JFrame) Color(java.awt.Color) ColorUIResource(javax.swing.plaf.ColorUIResource) JDialog(javax.swing.JDialog)

Example 53 with Color

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

the class LinearGradientPrintingTest method doPaint.

public void doPaint(Graphics2D g2d) {
    g2d.translate(DIM * 0.2, DIM * 0.2);
    Shape s = new Rectangle2D.Float(0, 0, DIM * 2, DIM * 2);
    Point2D.Double p1 = new Point2D.Double(0.0, 0.0);
    Point2D.Double p2 = new Point2D.Double(DIM / 2.0, DIM / 2.0);
    // LinearGradientPaint
    //g2d.translate(DIM*2.2, 0);
    Color[] colors = { Color.red, Color.blue };
    float[] fractions = { 0.0f, 1.0f };
    LinearGradientPaint lgp = new LinearGradientPaint(p1, p2, fractions, colors, LinearGradientPaint.CycleMethod.NO_CYCLE);
    g2d.setPaint(lgp);
    g2d.fill(s);
    g2d.translate(DIM * 2.2, 0);
    Color[] colors1 = { Color.red, Color.blue, Color.green, Color.white };
    float[] fractions1 = { 0.0f, 0.3f, 0.6f, 1.0f };
    LinearGradientPaint lgp1 = new LinearGradientPaint(p1, p2, fractions1, colors1, LinearGradientPaint.CycleMethod.REFLECT);
    g2d.setPaint(lgp1);
    g2d.fill(s);
    g2d.translate(-DIM * 2.2, DIM * 2.2);
    Color[] colors2 = { Color.red, Color.blue, Color.green, Color.white };
    float[] fractions2 = { 0.0f, 0.3f, 0.6f, 1.0f };
    LinearGradientPaint lgp2 = new LinearGradientPaint(p1, p2, fractions2, colors2, LinearGradientPaint.CycleMethod.REPEAT);
    g2d.setPaint(lgp2);
    g2d.fill(s);
}
Also used : Shape(java.awt.Shape) Point2D(java.awt.geom.Point2D) Color(java.awt.Color) LinearGradientPaint(java.awt.LinearGradientPaint)

Example 54 with Color

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

the class MultimonFullscreenTest method renderDimensions.

public void renderDimensions(Graphics g, Rectangle rectWndBounds, GraphicsConfiguration gc) {
    g.setColor(new Color(rnd.nextInt(0xffffff)));
    g.fillRect(0, 0, rectWndBounds.width, rectWndBounds.height);
    g.setColor(new Color(rnd.nextInt(0xffffff)));
    Rectangle rectStrBounds;
    g.setFont(f);
    rectStrBounds = g.getFontMetrics().getStringBounds(rectWndBounds.toString(), g).getBounds();
    rectStrBounds.height += 30;
    g.drawString(rectWndBounds.toString(), 50, rectStrBounds.height);
    int oldHeight = rectStrBounds.height;
    String isFSupported = "Exclusive Fullscreen mode supported: " + gc.getDevice().isFullScreenSupported();
    rectStrBounds = g.getFontMetrics().getStringBounds(isFSupported, g).getBounds();
    rectStrBounds.height += (10 + oldHeight);
    g.drawString(isFSupported, 50, rectStrBounds.height);
    oldHeight = rectStrBounds.height;
    String isDMChangeSupported = "Display Mode Change supported: " + gc.getDevice().isDisplayChangeSupported();
    rectStrBounds = g.getFontMetrics().getStringBounds(isDMChangeSupported, g).getBounds();
    rectStrBounds.height += (10 + oldHeight);
    g.drawString(isDMChangeSupported, 50, rectStrBounds.height);
    oldHeight = rectStrBounds.height;
    String usingBS = "Using BufferStrategy: " + useBS;
    rectStrBounds = g.getFontMetrics().getStringBounds(usingBS, g).getBounds();
    rectStrBounds.height += (10 + oldHeight);
    g.drawString(usingBS, 50, rectStrBounds.height);
    final String m_strQuitMsg = "Double-click to dispose FullScreen Window";
    rectStrBounds = g.getFontMetrics().getStringBounds(m_strQuitMsg, g).getBounds();
    g.drawString(m_strQuitMsg, (rectWndBounds.width - rectStrBounds.width) / 2, (rectWndBounds.height - rectStrBounds.height) / 2);
}
Also used : Color(java.awt.Color) Rectangle(java.awt.Rectangle)

Example 55 with Color

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

the class DisplayChangeVITest method initBackbuffer.

private void initBackbuffer() {
    createBackbuffer();
    int res = bb.validate(getGraphicsConfiguration());
    if (res == VolatileImage.IMAGE_INCOMPATIBLE) {
        bb = null;
        createBackbuffer();
        bb.validate(getGraphicsConfiguration());
        res = VolatileImage.IMAGE_RESTORED;
    }
    if (res == VolatileImage.IMAGE_RESTORED) {
        Graphics g = bb.getGraphics();
        g.setColor(new Color(rnd.nextInt(0x00ffffff)));
        g.fillRect(0, 0, bb.getWidth(), bb.getHeight());
        volSprite = createVolatileImage(100, 100);
    }
    volSprite.validate(getGraphicsConfiguration());
}
Also used : Graphics(java.awt.Graphics) Color(java.awt.Color)

Aggregations

Color (java.awt.Color)2973 Graphics2D (java.awt.Graphics2D)396 Font (java.awt.Font)250 BufferedImage (java.awt.image.BufferedImage)236 Dimension (java.awt.Dimension)193 JPanel (javax.swing.JPanel)193 Point (java.awt.Point)188 BasicStroke (java.awt.BasicStroke)177 ArrayList (java.util.ArrayList)173 Test (org.junit.Test)156 JLabel (javax.swing.JLabel)148 Paint (java.awt.Paint)140 Rectangle (java.awt.Rectangle)109 GradientPaint (java.awt.GradientPaint)108 Insets (java.awt.Insets)103 GridBagConstraints (java.awt.GridBagConstraints)96 IOException (java.io.IOException)96 Stroke (java.awt.Stroke)94 JScrollPane (javax.swing.JScrollPane)93 File (java.io.File)89