java.awt.GradientPaint Java Examples
The following examples show how to use
java.awt.GradientPaint.
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 File: MinMaxCategoryRendererTest.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Check that the equals() method distinguishes all fields. */ @Test public void testEquals() { MinMaxCategoryRenderer r1 = new MinMaxCategoryRenderer(); MinMaxCategoryRenderer r2 = new MinMaxCategoryRenderer(); assertEquals(r1, r2); r1.setDrawLines(true); assertFalse(r1.equals(r2)); r2.setDrawLines(true); assertTrue(r1.equals(r2)); r1.setGroupPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertFalse(r1.equals(r2)); r2.setGroupPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertTrue(r1.equals(r2)); r1.setGroupStroke(new BasicStroke(1.2f)); assertFalse(r1.equals(r2)); r2.setGroupStroke(new BasicStroke(1.2f)); assertTrue(r1.equals(r2)); }
Example #2
Source File: LegendTitleTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { XYPlot plot = new XYPlot(); Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0); LegendTitle t1 = new LegendTitle(plot); t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); t1.setBounds(bounds1); LegendTitle t2 = (LegendTitle) t1.clone(); assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2)); // check independence bounds1.setFrame(40.0, 30.0, 20.0, 10.0); assertFalse(t1.equals(t2)); t2.setBounds(new Rectangle2D.Double(40.0, 30.0, 20.0, 10.0)); assertTrue(t1.equals(t2)); }
Example #3
Source File: CrosshairOverlayTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Basic checks for cloning. */ @Test public void testCloning() throws CloneNotSupportedException { CrosshairOverlay o1 = new CrosshairOverlay(); o1.addDomainCrosshair(new Crosshair(99.9)); o1.addRangeCrosshair(new Crosshair(1.23, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue), new BasicStroke(1.1f))); CrosshairOverlay o2 = (CrosshairOverlay) o1.clone(); assertTrue(o1 != o2); assertTrue(o1.getClass() == o2.getClass()); assertTrue(o1.equals(o2)); o1.addDomainCrosshair(new Crosshair(3.21)); o1.addRangeCrosshair(new Crosshair(4.32)); assertFalse(o1.equals(o2)); }
Example #4
Source File: BalloonManager.java From netbeans with Apache License 2.0 | 6 votes |
@Override protected void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D)g; g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ); Composite oldC = g2d.getComposite(); Shape s = getMask( getWidth(), getHeight() ); g2d.setComposite( AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.25f*currentAlpha ) ); g2d.setColor( Color.black ); g2d.fill( getShadowMask(s) ); g2d.setColor( UIManager.getColor( "ToolTip.background" ) ); //NOI18N g2d.setComposite( AlphaComposite.getInstance( AlphaComposite.SRC_OVER, currentAlpha ) ); Point2D p1 = s.getBounds().getLocation(); Point2D p2 = new Point2D.Double(p1.getX(), p1.getY()+s.getBounds().getHeight()); if( isMouseOverEffect ) g2d.setPaint( new GradientPaint( p2, getMouseOverGradientStartColor(), p1, getMouseOverGradientFinishColor() ) ); else g2d.setPaint( new GradientPaint( p2, getDefaultGradientStartColor(), p1, getDefaultGradientFinishColor() ) ); g2d.fill(s); g2d.setColor( Color.black ); g2d.draw(s); g2d.setComposite( oldC ); }
Example #5
Source File: EditorPalette.java From blog-codes with Apache License 2.0 | 6 votes |
/** * */ public void paintComponent(Graphics g) { if (gradientColor == null) { super.paintComponent(g); } else { Rectangle rect = getVisibleRect(); if (g.getClipBounds() != null) { rect = rect.intersection(g.getClipBounds()); } Graphics2D g2 = (Graphics2D) g; g2.setPaint(new GradientPaint(0, 0, getBackground(), getWidth(), 0, gradientColor)); g2.fill(rect); } }
Example #6
Source File: LookupPaintScaleTest.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * A test for the equals() method. */ @Test public void testEquals() { LookupPaintScale g1 = new LookupPaintScale(); LookupPaintScale g2 = new LookupPaintScale(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new LookupPaintScale(1.0, 2.0, Color.red); assertFalse(g1.equals(g2)); g2 = new LookupPaintScale(1.0, 2.0, Color.red); assertTrue(g1.equals(g2)); g1.add(1.5, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(g1.equals(g2)); g2.add(1.5, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(g1.equals(g2)); }
Example #7
Source File: StackedXYAreaRendererTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Test that the equals() method distinguishes all fields. */ @Test public void testEquals() { StackedXYAreaRenderer r1 = new StackedXYAreaRenderer(); StackedXYAreaRenderer r2 = new StackedXYAreaRenderer(); assertEquals(r1, r2); assertEquals(r2, r1); r1.setShapePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.green)); assertFalse(r1.equals(r2)); r2.setShapePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.green)); assertTrue(r1.equals(r2)); Stroke s = new BasicStroke(1.23f); r1.setShapeStroke(s); assertFalse(r1.equals(r2)); r2.setShapeStroke(s); assertTrue(r1.equals(r2)); }
Example #8
Source File: DialTextAnnotationTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() { // test a default instance DialTextAnnotation a1 = new DialTextAnnotation("A1"); DialTextAnnotation a2 = (DialTextAnnotation) TestUtilities.serialised(a1); assertEquals(a1, a2); // test a custom instance a1 = new DialTextAnnotation("A1"); a1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); a2 = (DialTextAnnotation) TestUtilities.serialised(a1); assertEquals(a1, a2); }
Example #9
Source File: DialCapTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() { // test a default instance DialCap c1 = new DialCap(); DialCap c2 = (DialCap) TestUtilities.serialised(c1); assertEquals(c1, c2); // test a custom instance c1 = new DialCap(); c1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.green)); c1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.gray)); c1.setOutlineStroke(new BasicStroke(2.0f)); c2 = (DialCap) TestUtilities.serialised(c1); assertEquals(c1, c2); }
Example #10
Source File: MeterPlotTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization1() { MeterPlot p1 = new MeterPlot(null); p1.setDialBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); p1.setDialOutlinePaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f, 1.0f, Color.blue)); p1.setNeedlePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); p1.setTickLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); p1.setTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); MeterPlot p2 = (MeterPlot) TestUtilities.serialised(p1); assertEquals(p1, p2); }
Example #11
Source File: SunGraphics2D.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Sets the Paint in the current graphics state. * @param paint The Paint object to be used to generate color in * the rendering process. * @see java.awt.Graphics#setColor * @see GradientPaint * @see TexturePaint */ public void setPaint(Paint paint) { if (paint instanceof Color) { setColor((Color) paint); return; } if (paint == null || this.paint == paint) { return; } this.paint = paint; if (imageComp == CompositeType.SrcOverNoEa) { // special case where compState depends on opacity of paint if (paint.getTransparency() == Transparency.OPAQUE) { if (compositeState != COMP_ISCOPY) { compositeState = COMP_ISCOPY; } } else { if (compositeState == COMP_ISCOPY) { compositeState = COMP_ALPHA; } } } Class<? extends Paint> paintClass = paint.getClass(); if (paintClass == GradientPaint.class) { paintState = PAINT_GRADIENT; } else if (paintClass == LinearGradientPaint.class) { paintState = PAINT_LIN_GRADIENT; } else if (paintClass == RadialGradientPaint.class) { paintState = PAINT_RAD_GRADIENT; } else if (paintClass == TexturePaint.class) { paintState = PAINT_TEXTURE; } else { paintState = PAINT_CUSTOM; } validFontInfo = false; invalidatePipe(); }
Example #12
Source File: WaterfallBarRenderer.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Constructs a new renderer with default values for the bar colors. */ public WaterfallBarRenderer() { this(new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 0.0f, 0.0f, new Color(0x66, 0x66, 0xFF)), new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x66, 0xFF, 0x66)), new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 0.0f, 0.0f, new Color(0xFF, 0x66, 0x66)), new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0xFF, 0x22), 0.0f, 0.0f, new Color(0xFF, 0xFF, 0x66))); }
Example #13
Source File: PaintListTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Tests the equals() method when the list contains a GradientPaint * instance. */ public void testEquals3() { // check two separate (but equal) colors PaintList l1 = new PaintList(); Paint p1 = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue); l1.setPaint(0, p1); PaintList l2 = new PaintList(); Paint p2 = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue); l2.setPaint(0, p2); assertEquals(l1, l2); }
Example #14
Source File: CompositeTitleTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { CompositeTitle t1 = new CompositeTitle(new BlockContainer()); CompositeTitle t2 = new CompositeTitle(new BlockContainer()); assertEquals(t1, t2); assertEquals(t2, t1); // margin t1.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertFalse(t1.equals(t2)); t2.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertTrue(t1.equals(t2)); // frame t1.setFrame(new BlockBorder(Color.red)); assertFalse(t1.equals(t2)); t2.setFrame(new BlockBorder(Color.red)); assertTrue(t1.equals(t2)); // padding t1.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertFalse(t1.equals(t2)); t2.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertTrue(t1.equals(t2)); // contained titles t1.getContainer().add(new TextTitle("T1")); assertFalse(t1.equals(t2)); t2.getContainer().add(new TextTitle("T1")); assertTrue(t1.equals(t2)); t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertFalse(t1.equals(t2)); t2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertTrue(t1.equals(t2)); }
Example #15
Source File: BufferedPaints.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
static void setPaint(RenderQueue rq, SunGraphics2D sg2d, Paint paint, int ctxflags) { if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) { setColor(rq, sg2d.pixel); } else { boolean useMask = (ctxflags & BufferedContext.USE_MASK) != 0; switch (sg2d.paintState) { case SunGraphics2D.PAINT_GRADIENT: setGradientPaint(rq, sg2d, (GradientPaint)paint, useMask); break; case SunGraphics2D.PAINT_LIN_GRADIENT: setLinearGradientPaint(rq, sg2d, (LinearGradientPaint)paint, useMask); break; case SunGraphics2D.PAINT_RAD_GRADIENT: setRadialGradientPaint(rq, sg2d, (RadialGradientPaint)paint, useMask); break; case SunGraphics2D.PAINT_TEXTURE: setTexturePaint(rq, sg2d, (TexturePaint)paint, useMask); break; default: break; } } }
Example #16
Source File: BufferedPaints.java From Bytecoder with Apache License 2.0 | 5 votes |
private static void setGradientPaint(RenderQueue rq, SunGraphics2D sg2d, GradientPaint paint, boolean useMask) { setGradientPaint(rq, (AffineTransform)sg2d.transform.clone(), paint.getColor1(), paint.getColor2(), paint.getPoint1(), paint.getPoint2(), paint.isCyclic(), useMask); }
Example #17
Source File: DialCapTest.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { // test a default instance DialCap c1 = new DialCap(); DialCap c2 = (DialCap) c1.clone(); assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // test a customised instance c1 = new DialCap(); c1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.green)); c1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.gray)); c1.setOutlineStroke(new BasicStroke(2.0f)); c2 = (DialCap) c1.clone(); assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); c1.addChangeListener(l1); assertTrue(c1.hasListener(l1)); assertFalse(c2.hasListener(l1)); }
Example #18
Source File: StandardDialRangeTest.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { StandardDialRange r1 = new StandardDialRange(); StandardDialRange r2 = new StandardDialRange(); assertTrue(r1.equals(r2)); // lowerBound r1.setLowerBound(1.1); assertFalse(r1.equals(r2)); r2.setLowerBound(1.1); assertTrue(r1.equals(r2)); // upperBound r1.setUpperBound(11.1); assertFalse(r1.equals(r2)); r2.setUpperBound(11.1); assertTrue(r1.equals(r2)); // paint r1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(r1.equals(r2)); r2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(r1.equals(r2)); // check an inherited attribute r1.setVisible(false); assertFalse(r1.equals(r2)); r2.setVisible(false); assertTrue(r1.equals(r2)); }
Example #19
Source File: StandardBarPainter.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Paints a single bar instance. * * @param g2 the graphics target. * @param renderer the renderer. * @param row the row index. * @param column the column index. * @param selected is the item selected? * @param bar the bar * @param base indicates which side of the rectangle is the base of the * bar. */ public void paintBar(Graphics2D g2, BarRenderer renderer, int row, int column, boolean selected, RectangularShape bar, RectangleEdge base) { Paint itemPaint = renderer.getItemPaint(row, column, selected); GradientPaintTransformer t = renderer.getGradientPaintTransformer(); if (t != null && itemPaint instanceof GradientPaint) { itemPaint = t.transform((GradientPaint) itemPaint, bar); } g2.setPaint(itemPaint); g2.fill(bar); // draw the outline... if (renderer.isDrawBarOutline()) { // && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { Stroke stroke = renderer.getItemOutlineStroke(row, column, selected); Paint paint = renderer.getItemOutlinePaint(row, column, selected); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(bar); } } }
Example #20
Source File: PopupPanel.java From Open-Realms-of-Stars with GNU General Public License v2.0 | 5 votes |
/** * Draw gradient border * @param gr Graphics2D used for drawing * @param x X coordinate where to start * @param y Y coordinate where to start * @param width border width * @param height border height */ protected void drawGradientBorder(final Graphics2D gr, final int x, final int y, final int width, final int height) { GradientPaint gradient = new GradientPaint(x, y, GuiStatics.COLOR_COOL_SPACE_BLUE_DARKER, x + width, y + width, GuiStatics.COLOR_COOL_SPACE_BLUE, false); gr.setPaint(gradient); int borderSize = 3; gr.fillRect(x, y, width, borderSize); gr.fillRect(x, y + borderSize, borderSize, height - borderSize); gr.fillRect(x + borderSize, y + height - borderSize, width - borderSize, borderSize); gr.fillRect(x + width - borderSize, y + borderSize, borderSize, height - borderSize); }
Example #21
Source File: CategoryMarkerTest.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() { CategoryMarker m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(1.1f)); CategoryMarker m2 = (CategoryMarker) TestUtilities.serialised(m1); assertEquals(m1, m2); }
Example #22
Source File: RingPlotTest.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() { RingPlot p1 = new RingPlot(null); GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.red); p1.setSeparatorPaint(gp); RingPlot p2 = (RingPlot) TestUtilities.serialised(p1); assertEquals(p1, p2); }
Example #23
Source File: CategoryAxisTest.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() { CategoryAxis a1 = new CategoryAxis("Test Axis"); a1.setTickLabelPaint("C1", new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); CategoryAxis a2 = (CategoryAxis) TestUtilities.serialised(a1); assertEquals(a1, a2); }
Example #24
Source File: SchemeChooserPanel.java From iBioSim with Apache License 2.0 | 5 votes |
/** * updates the gradients, min, max, and apply to values * based on which species is currently selected * and which values have been saved */ private void updatePanelValues() { String speciesID = cellID; if (cellType != GlobalConstants.SPECIES) speciesID += "__" + cellSpecies.get(speciesChooser.getSelectedIndex()); Scheme speciesScheme = movieScheme.getSpeciesScheme(speciesID); if (speciesScheme != null) { //get the scheme data for the species that was selected GradientPaint colorGradient = speciesScheme.getColorGradient(); int min = speciesScheme.getMin(); int max = speciesScheme.getMax(); String opacityOption = speciesScheme.getOpacityState() ? opacityOptions[1] : opacityOptions[0]; String sizeOption = speciesScheme.getSizeState() ? sizeOptions[1] : sizeOptions[0]; if (colorGradient != null) colorChooser.setSelectedItem(colorGradient.getColor2()); else colorChooser.setSelectedItem(colorsArray[0]); minChooser.setText(Integer.toString(min)); maxChooser.setText(Integer.toString(max)); opacityChooser.setSelectedItem(opacityOption); sizeChooser.setSelectedItem(sizeOption); } else { colorChooser.setSelectedItem(colorsArray[0]); opacityChooser.setSelectedItem(opacityOptions[0]); sizeChooser.setSelectedItem(sizeOptions[0]); } //re-render the color combobox so that it shows the stored item colorChooser.setRenderer(new ComboBoxRenderer()); }
Example #25
Source File: XMLDiagram.java From ramus with GNU General Public License v3.0 | 5 votes |
private void paintYPin(Graphics2D g, int number) { double y = top; for (int i = 0; i < number; i++) { y += yBounds[i].getSize().getHeight(); } g.setColor(Color.black); double max = 6; g.setPaint(new GradientPaint(new Point2D.Double(LEFT - max, y - max), Color.green, new Point2D.Double(LEFT + max, y + max), Color.black)); GeneralPath path1 = new GeneralPath(Path2D.WIND_EVEN_ODD, 4); GeneralPath path2 = new GeneralPath(Path2D.WIND_EVEN_ODD, 4); path1.moveTo(LEFT - 5, y); path1.lineTo(LEFT - 5 - max, y + max / 2); path1.lineTo(LEFT - 5 - max, y - max / 2); path1.lineTo(LEFT - 5, y); path2.moveTo(5 + LEFT + width, y); path2.lineTo(5 + LEFT + width + max, y + max / 2); path2.lineTo(5 + LEFT + width + max, y - max / 2); path2.lineTo(5 + LEFT + width, y); g.fill(path1); g.setPaint(new GradientPaint(new Point2D.Double(LEFT + width - max, y - max), Color.black, new Point2D.Double(LEFT + max + width, y + max), Color.green)); g.fill(path2); g.setColor(Color.gray); g.draw(path1); g.draw(path2); }
Example #26
Source File: AnnotationDrawer.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
/** * Draws indicator in case the annotation text overflows on the y axis. * * @param g * the graphics context to draw upon * @param loc * the location of the annotation * @param printing * if we are currently printing */ private void drawOverflowIndicator(final Graphics2D g, final Rectangle2D loc, final boolean printing) { if (printing) { // never draw them for printing return; } Graphics2D g2 = (Graphics2D) g.create(); int size = 20; int xOffset = 10; int yOffset = 10; int stepSize = size / 4; int dotSize = 3; int x = (int) loc.getMaxX() - size - xOffset; int y = (int) loc.getMaxY() - size - yOffset; GradientPaint gp = new GradientPaint(x, y, Color.WHITE, x, y + size * 1.5f, Color.LIGHT_GRAY); g2.setPaint(gp); g2.fillRect(x, y, size, size); g2.setColor(Color.BLACK); g2.drawRect(x, y, size, size); g2.fillOval(x + stepSize, y + stepSize * 2, dotSize, dotSize); g2.fillOval(x + stepSize * 2, y + stepSize * 2, dotSize, dotSize); g2.fillOval(x + stepSize * 3, y + stepSize * 2, dotSize, dotSize); g2.dispose(); }
Example #27
Source File: GradientPaintReadHandler.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * At the end of parsing the element, the gradient paint is constructed. * * @throws XmlReaderException if there is a parsing error. */ protected void doneParsing() throws XmlReaderException { if (this.point1Handler == null || this.point2Handler == null || this.color1Handler == null || this.color2Handler == null) { throw new XmlReaderException("Not all required subelements are defined."); } this.gradient = new GradientPaint ((Point2D) this.point1Handler.getObject(), (Color) this.color1Handler.getObject(), (Point2D) this.point2Handler.getObject(), (Color) this.color2Handler.getObject()); }
Example #28
Source File: XYErrorRendererTest.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() { XYErrorRenderer r1 = new XYErrorRenderer(); r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); XYErrorRenderer r2 = (XYErrorRenderer) TestUtilities.serialised(r1); assertEquals(r1, r2); }
Example #29
Source File: BufferedPaints.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void setGradientPaint(RenderQueue rq, SunGraphics2D sg2d, GradientPaint paint, boolean useMask) { setGradientPaint(rq, (AffineTransform)sg2d.transform.clone(), paint.getColor1(), paint.getColor2(), paint.getPoint1(), paint.getPoint2(), paint.isCyclic(), useMask); }
Example #30
Source File: PaintMapTest.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * A check for serialization. */ @Test public void testSerialization2() { PaintMap m1 = new PaintMap(); m1.put("K1", Color.red); m1.put("K2", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); PaintMap m2 = (PaintMap) TestUtilities.serialised(m1); assertEquals(m1, m2); }