Java Code Examples for java.awt.Color#blue()
The following examples show how to use
java.awt.Color#blue() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: buffer_bci File: ColorBlockTest.java License: GNU General Public License v3.0 | 6 votes |
/** * Confirm that the equals() method can distinguish all the required fields. */ @Test public void testEquals() { ColorBlock b1 = new ColorBlock(Color.red, 1.0, 2.0); ColorBlock b2 = new ColorBlock(Color.red, 1.0, 2.0); assertTrue(b1.equals(b2)); assertTrue(b2.equals(b2)); b1 = new ColorBlock(Color.blue, 1.0, 2.0); assertFalse(b1.equals(b2)); b2 = new ColorBlock(Color.blue, 1.0, 2.0); assertTrue(b1.equals(b2)); b1 = new ColorBlock(Color.blue, 1.1, 2.0); assertFalse(b1.equals(b2)); b2 = new ColorBlock(Color.blue, 1.1, 2.0); assertTrue(b1.equals(b2)); b1 = new ColorBlock(Color.blue, 1.1, 2.2); assertFalse(b1.equals(b2)); b2 = new ColorBlock(Color.blue, 1.1, 2.2); assertTrue(b1.equals(b2)); }
Example 2
Source Project: SIMVA-SoS File: BlockBorderTest.java License: Apache License 2.0 | 6 votes |
/** * Confirm that the equals() method can distinguish all the required fields. */ @Test public void testEquals() { BlockBorder b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), Color.red); BlockBorder b2 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), Color.red); assertTrue(b1.equals(b2)); assertTrue(b2.equals(b2)); // insets b1 = new BlockBorder(new RectangleInsets(UnitType.RELATIVE, 1.0, 2.0, 3.0, 4.0), Color.red); assertFalse(b1.equals(b2)); b2 = new BlockBorder(new RectangleInsets(UnitType.RELATIVE, 1.0, 2.0, 3.0, 4.0), Color.red); assertTrue(b1.equals(b2)); // paint b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), Color.blue); assertFalse(b1.equals(b2)); b2 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), Color.blue); assertTrue(b1.equals(b2)); }
Example 3
Source Project: ccu-historian File: ColorBlockTest.java License: GNU General Public License v3.0 | 6 votes |
/** * Confirm that cloning works. */ @Test public void testCloning() { GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue); Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0); ColorBlock b1 = new ColorBlock(gp, 1.0, 2.0); b1.setBounds(bounds1); ColorBlock b2 = null; try { b2 = (ColorBlock) b1.clone(); } catch (CloneNotSupportedException e) { fail(e.toString()); } assertTrue(b1 != b2); assertTrue(b1.getClass() == b2.getClass()); assertTrue(b1.equals(b2)); // check independence bounds1.setRect(1.0, 2.0, 3.0, 4.0); assertFalse(b1.equals(b2)); b2.setBounds(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(b1.equals(b2)); }
Example 4
Source Project: hottub File: MlibOpsTest.java License: GNU General Public License v2.0 | 6 votes |
private static BufferedImage createSrcImage() { BufferedImage img = createImage(); 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(); return img; }
Example 5
Source Project: dragonwell8_jdk File: ConcurrentWritingTest.java License: GNU General Public License v2.0 | 6 votes |
private static BufferedImage createTestImage() { int w = 1024; int h = 768; 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(); return img; }
Example 6
Source Project: openstock File: LegendItemCollectionTest.java License: GNU General Public License v3.0 | 5 votes |
/** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { LegendItemCollection c1 = new LegendItemCollection(); LegendItemCollection c2 = new LegendItemCollection(); assertEquals(c1, c2); assertEquals(c2, c1); LegendItem item1 = new LegendItem("Label", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); LegendItem item2 = new LegendItem("Label", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); c1.add(item1); assertFalse(c1.equals(c2)); c2.add(item2); assertEquals(c1, c2); }
Example 7
Source Project: SIMVA-SoS File: XYDifferenceRendererTest.java License: Apache License 2.0 | 5 votes |
/** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() { XYDifferenceRenderer r1 = new XYDifferenceRenderer(Color.red, Color.blue, false); XYDifferenceRenderer r2 = (XYDifferenceRenderer) TestUtilities.serialised(r1); assertEquals(r1, r2); }
Example 8
Source Project: openjdk-8 File: XTable.java License: GNU General Public License v2.0 | 5 votes |
/** * This method sets read write rows to be blue, and other rows to be their * default rendered colour. */ @Override public TableCellRenderer getCellRenderer(int row, int column) { DefaultTableCellRenderer tcr = (DefaultTableCellRenderer) super.getCellRenderer(row,column); tcr.setToolTipText(getToolTip(row,column)); if (defaultColor == null) { defaultColor = tcr.getForeground(); editableColor = Color.blue; errorColor = Color.red; // this sometimes happens for some reason if (defaultColor == null) { return tcr; } } if (column != VALUE_COLUMN) { tcr.setForeground(defaultColor); return tcr; } if (isCellError(row,column)) { tcr.setForeground(errorColor); } else if (isCellEditable(row, column)) { tcr.setForeground(editableColor); } else { tcr.setForeground(defaultColor); } return tcr; }
Example 9
Source Project: jdk8u60 File: XTable.java License: GNU General Public License v2.0 | 5 votes |
/** * This method sets read write rows to be blue, and other rows to be their * default rendered colour. */ @Override public TableCellRenderer getCellRenderer(int row, int column) { DefaultTableCellRenderer tcr = (DefaultTableCellRenderer) super.getCellRenderer(row,column); tcr.setToolTipText(getToolTip(row,column)); if (defaultColor == null) { defaultColor = tcr.getForeground(); editableColor = Color.blue; errorColor = Color.red; // this sometimes happens for some reason if (defaultColor == null) { return tcr; } } if (column != VALUE_COLUMN) { tcr.setForeground(defaultColor); return tcr; } if (isCellError(row,column)) { tcr.setForeground(errorColor); } else if (isCellEditable(row, column)) { tcr.setForeground(editableColor); } else { tcr.setForeground(defaultColor); } return tcr; }
Example 10
Source Project: jdk8u-dev-jdk File: ConcurrentReadingTest.java License: GNU General Public License v2.0 | 5 votes |
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); } }
Example 11
Source Project: SIMVA-SoS File: XYShapeAnnotationTest.java License: Apache License 2.0 | 5 votes |
/** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { XYShapeAnnotation a1 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.red, Color.blue); XYShapeAnnotation a2 = (XYShapeAnnotation) a1.clone(); assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); }
Example 12
Source Project: SIMVA-SoS File: DefaultTitleEditor.java License: Apache License 2.0 | 5 votes |
/** * Allow the user the opportunity to select a Paint object. For now, we * just use the standard color chooser - all colors are Paint objects, but * not all Paint objects are colors (later we can implement a more general * Paint chooser). */ public void attemptPaintSelection() { Paint p = this.titlePaint.getPaint(); Color defaultColor = (p instanceof Color ? (Color) p : Color.blue); Color c = JColorChooser.showDialog( this, localizationResources.getString("Title_Color"), defaultColor ); if (c != null) { this.titlePaint.setPaint(c); } }
Example 13
Source Project: MeteoInfo File: MeteoInfoScript.java License: GNU Lesser General Public License v3.0 | 5 votes |
private Color getColor(String style) { if (style.contains("r")) { return Color.red; } else if (style.contains("k")) { return Color.black; } else if (style.contains("b")) { return Color.blue; } else if (style.contains("g")) { return Color.green; } else if (style.contains("w")) { return Color.white; } else { return null; } }
Example 14
Source Project: openstock File: XYShapeAnnotationTest.java License: GNU General Public License v3.0 | 5 votes |
/** * Checks that this class implements PublicCloneable. */ @Test public void testPublicCloneable() { XYShapeAnnotation a1 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.red, Color.blue); assertTrue(a1 instanceof PublicCloneable); }
Example 15
Source Project: openjdk-8 File: ReadingInterruptionTest.java License: GNU General Public License v2.0 | 5 votes |
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); } }
Example 16
Source Project: openjdk-jdk8u-backup File: XTable.java License: GNU General Public License v2.0 | 5 votes |
/** * This method sets read write rows to be blue, and other rows to be their * default rendered colour. */ @Override public TableCellRenderer getCellRenderer(int row, int column) { DefaultTableCellRenderer tcr = (DefaultTableCellRenderer) super.getCellRenderer(row,column); tcr.setToolTipText(getToolTip(row,column)); if (defaultColor == null) { defaultColor = tcr.getForeground(); editableColor = Color.blue; errorColor = Color.red; // this sometimes happens for some reason if (defaultColor == null) { return tcr; } } if (column != VALUE_COLUMN) { tcr.setForeground(defaultColor); return tcr; } if (isCellError(row,column)) { tcr.setForeground(errorColor); } else if (isCellEditable(row, column)) { tcr.setForeground(editableColor); } else { tcr.setForeground(defaultColor); } return tcr; }
Example 17
Source Project: buffer_bci File: XYDifferenceRendererTest.java License: GNU General Public License v3.0 | 5 votes |
/** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashcode() { XYDifferenceRenderer r1 = new XYDifferenceRenderer(Color.red, Color.blue, false); XYDifferenceRenderer r2 = new XYDifferenceRenderer(Color.red, Color.blue, false); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); }
Example 18
Source Project: ECG-Viewer File: XYShapeAnnotationTest.java License: GNU General Public License v2.0 | 5 votes |
/** * Checks that this class implements PublicCloneable. */ @Test public void testPublicCloneable() { XYShapeAnnotation a1 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.red, Color.blue); assertTrue(a1 instanceof PublicCloneable); }
Example 19
Source Project: astor File: ChartPanel.java License: GNU General Public License v2.0 | 4 votes |
/** * Constructs a JFreeChart panel. * * @param chart the chart. * @param width the preferred width of the panel. * @param height the preferred height of the panel. * @param minimumDrawWidth the minimum drawing width. * @param minimumDrawHeight the minimum drawing height. * @param maximumDrawWidth the maximum drawing width. * @param maximumDrawHeight the maximum drawing height. * @param useBuffer a flag that indicates whether to use the off-screen * buffer to improve performance (at the expense of * memory). * @param properties a flag indicating whether or not the chart property * editor should be available via the popup menu. * @param copy a flag indicating whether or not a copy option should be * available via the popup menu. * @param save a flag indicating whether or not save options should be * available via the popup menu. * @param print a flag indicating whether or not the print option * should be available via the popup menu. * @param zoom a flag indicating whether or not zoom options should be * added to the popup menu. * @param tooltips a flag indicating whether or not tooltips should be * enabled for the chart. * * @since 1.0.13 */ public ChartPanel(JFreeChart chart, int width, int height, int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth, int maximumDrawHeight, boolean useBuffer, boolean properties, boolean copy, boolean save, boolean print, boolean zoom, boolean tooltips) { setChart(chart); this.chartMouseListeners = new EventListenerList(); this.info = new ChartRenderingInfo(); this.info.setRenderingSource(this); setPreferredSize(new Dimension(width, height)); this.useBuffer = useBuffer; this.refreshBuffer = false; this.minimumDrawWidth = minimumDrawWidth; this.minimumDrawHeight = minimumDrawHeight; this.maximumDrawWidth = maximumDrawWidth; this.maximumDrawHeight = maximumDrawHeight; this.zoomTriggerDistance = DEFAULT_ZOOM_TRIGGER_DISTANCE; // set up popup menu... this.popup = null; if (properties || copy || save || print || zoom) { this.popup = createPopupMenu(properties, copy, save, print, zoom); } enableEvents(AWTEvent.MOUSE_EVENT_MASK); enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK); setDisplayToolTips(tooltips); addMouseListener(this); addMouseMotionListener(this); this.defaultDirectoryForSaveAs = null; this.enforceFileExtensions = true; // initialize ChartPanel-specific tool tip delays with // values the from ToolTipManager.sharedInstance() ToolTipManager ttm = ToolTipManager.sharedInstance(); this.ownToolTipInitialDelay = ttm.getInitialDelay(); this.ownToolTipDismissDelay = ttm.getDismissDelay(); this.ownToolTipReshowDelay = ttm.getReshowDelay(); this.zoomAroundAnchor = false; this.zoomOutlinePaint = Color.blue; this.zoomFillPaint = new Color(0, 0, 255, 63); this.overlays = new java.util.ArrayList(); this.availableMouseHandlers = new java.util.ArrayList(); this.zoomHandler = new ZoomHandler(); this.availableMouseHandlers.add(zoomHandler); PanHandler panHandler = new PanHandler(); int panMask = InputEvent.CTRL_MASK; // for MacOSX we can't use the CTRL key for mouse drags, see: // http://developer.apple.com/qa/qa2004/qa1362.html String osName = System.getProperty("os.name").toLowerCase(); if (osName.startsWith("mac os x")) { panMask = InputEvent.ALT_MASK; } panHandler.setModifier(panMask); this.availableMouseHandlers.add(panHandler); this.auxiliaryMouseHandlers = new java.util.ArrayList(); }
Example 20
Source Project: buffer_bci File: PeriodAxisLabelInfoTest.java License: GNU General Public License v3.0 | 4 votes |
/** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { PeriodAxisLabelInfo info1 = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); PeriodAxisLabelInfo info2 = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); assertTrue(info1.equals(info2)); assertTrue(info2.equals(info1)); Class c1 = Day.class; Class c2 = Month.class; DateFormat df1 = new SimpleDateFormat("d"); DateFormat df2 = new SimpleDateFormat("MMM"); RectangleInsets sp1 = new RectangleInsets(1, 1, 1, 1); RectangleInsets sp2 = new RectangleInsets(2, 2, 2, 2); Font lf1 = new Font("SansSerif", Font.PLAIN, 10); Font lf2 = new Font("SansSerif", Font.BOLD, 9); Paint lp1 = Color.black; Paint lp2 = Color.blue; boolean b1 = true; boolean b2 = false; Stroke s1 = new BasicStroke(0.5f); Stroke s2 = new BasicStroke(0.25f); Paint dp1 = Color.red; Paint dp2 = Color.green; info1 = new PeriodAxisLabelInfo(c2, df1, sp1, lf1, lp1, b1, s1, dp1); info2 = new PeriodAxisLabelInfo(c1, df1, sp1, lf1, lp1, b1, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df1, sp1, lf1, lp1, b1, s1, dp1); assertTrue(info1.equals(info2)); info1 = new PeriodAxisLabelInfo(c2, df2, sp1, lf1, lp1, b1, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp1, lf1, lp1, b1, s1, dp1); assertTrue(info1.equals(info2)); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf1, lp1, b1, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf1, lp1, b1, s1, dp1); assertTrue(info1.equals(info2)); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp1, b1, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp1, b1, s1, dp1); assertTrue(info1.equals(info2)); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b1, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b1, s1, dp1); assertTrue(info1.equals(info2)); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s1, dp1); assertTrue(info1.equals(info2)); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp1); assertTrue(info1.equals(info2)); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp2); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp2); assertTrue(info1.equals(info2)); }