List of usage examples for java.awt Graphics2D setPaint
public abstract void setPaint(Paint paint);
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.black); g2.draw(new Rectangle2D.Float(10, 20, 30, 40)); AffineTransform at = AffineTransform.getTranslateInstance(75, 75); g2.transform(at);// w ww .ja v a 2s . co m g2.setPaint(Color.red); g2.draw(new Rectangle2D.Float(10, 20, 30, 40)); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.black); g2.draw(new Rectangle2D.Float(10, 20, 30, 40)); AffineTransform at = AffineTransform.getTranslateInstance(75, 75); g2.setTransform(at);/*from w w w . j a v a 2 s .co m*/ g2.setPaint(Color.red); g2.draw(new Rectangle2D.Float(10, 20, 30, 40)); }
From source file:MainClass.java
public void paint(Graphics g) { Point2D.Double startQ = new Point2D.Double(50, 75); // Start point Point2D.Double endQ = new Point2D.Double(150, 75); // End point Point2D.Double control = new Point2D.Double(80, 25); // Control point // Points for cubic curve Point2D.Double startC = new Point2D.Double(50, 150); // Start point Point2D.Double endC = new Point2D.Double(150, 150); // End point Point2D.Double controlStart = new Point2D.Double(80, 100); // 1st control // point Point2D.Double controlEnd = new Point2D.Double(160, 100); // 2nd control // point QuadCurve2D.Double quadCurve; // Quadratic curve CubicCurve2D.Double cubicCurve; // Cubic curve quadCurve = new QuadCurve2D.Double( // Create quadratic curve startQ.x, startQ.y, // Segment start point control.x, control.y, // Control point endQ.x, endQ.y); // Segment end point cubicCurve = new CubicCurve2D.Double( // Create cubic curve startC.x, startC.y, // Segment start point controlStart.x, controlStart.y, // Control point for start controlEnd.x, controlEnd.y, // Control point for end endC.x, endC.y); // Segment end point Graphics2D g2D = (Graphics2D) g; // Get a 2D device context // Draw the curves g2D.setPaint(Color.BLUE); g2D.draw(quadCurve);/*from w w w. ja v a 2 s.c o m*/ g2D.draw(cubicCurve); }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.black); g2.draw(shape);/*from w w w . j a va 2 s.c o m*/ }
From source file:D20140128.ApacheXMLGraphicsTest.TilingPatternExample.java
private void paintText(Graphics2D g2d) { g2d.setPaint(paint); Font font = new Font("serif", Font.BOLD, 80); GlyphVector gv = font.createGlyphVector(g2d.getFontRenderContext(), "Java"); g2d.translate(100, 180);//from w ww. j a v a 2 s.c om g2d.fill(gv.getOutline()); }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; GradientPaint p = new GradientPaint(0, 0, Color.white, getWidth(), getHeight(), Color.gray); g2d.setPaint(p); g2d.fillRect(0, 0, getWidth(), getHeight()); }
From source file:D20140128.ApacheXMLGraphicsTest.TilingPatternExample.java
private void paintShapes(Graphics2D g2d) { g2d.setPaint(paint); Rectangle rect = new Rectangle(10, 50, 30, 30); g2d.fill(rect);/*from ww w . ja va 2s . co m*/ rect = new Rectangle(10, 90, 40, 20); g2d.fill(rect); Polygon poly = new Polygon(new int[] { 50, 100, 150 }, new int[] { 100, 20, 100 }, 3); g2d.fill(poly); }
From source file:ec.util.chart.swing.JTimeSeriesRendererSupport.java
static void drawToolTip(Graphics2D g2, double x, double y, double anchorOffset, String label, Font font, Paint paint, Paint fillPaint, Paint outlinePaint, Stroke outlineStroke) { LabelBlock block = new LabelBlock(label/*.replace("\n", "")*/, font, paint); block.setMargin(3, 3, 3, 3);// www . j a v a2 s.c om Rectangle2D hotspot = createHotspot(g2, x, y, anchorOffset + 10, block.arrange(g2)); Shape shape = createShape(x, y, hotspot); if (fillPaint != null) { g2.setPaint(fillPaint); g2.fill(shape); } if (outlinePaint != null && outlineStroke != null) { g2.setStroke(outlineStroke); g2.setPaint(outlinePaint); g2.draw(shape); } block.draw(g2, hotspot); }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.black); g2.draw(shape);/*ww w.j a va2 s .co m*/ AffineTransform at = AffineTransform.getTranslateInstance(75, 75); g2.transform(at); g2.setPaint(Color.red); g2.draw(shape); }
From source file:LineDemo2D.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.gray); int x = 5;// ww w . j av a 2 s.c o m int y = 7; g2.draw(new Line2D.Double(x, y, 200, 200)); g2.drawString("Line2D", x, 250); }