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());
}
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");
}
});
}
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);
}
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);
}
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());
}
Aggregations