List of usage examples for java.awt Graphics2D draw
public abstract void draw(Shape s);
From source file:RectangleDemo2D.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.gray);/*w ww. j a v a2 s. c o m*/ int x = 5; int y = 7; g2.setStroke(stroke); g2.draw(new Rectangle2D.Double(x, y, 200, 200)); g2.drawString("Rectangle2D", x, 250); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; int w = getSize().width; int h = getSize().height; Arc2D arc = new Arc2D.Double(0.0, 0.0, w, h, 0.0, 60.0, Arc2D.CHORD); System.out.println(arc.contains(new Rectangle(5, 6, 20, 20))); g2.draw(arc); arc = new Arc2D.Float(0.0f, 0.0f, w, h, 80.0f, 110.0f, Arc2D.PIE); g2.fill(arc);/*from w w w .j a v a 2 s. c o m*/ arc = new Arc2D.Float(0.0f, 0.0f, w, h, 210.0f, 130.0f, Arc2D.OPEN); g2.draw(arc); }
From source file:DashedRectangleDemo2D.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.gray);/*from w ww . j av a 2 s . co m*/ int x = 5; int y = 7; g2.setStroke(dashed); g2.draw(new RoundRectangle2D.Double(x, y, 200, 200, 10, 10)); g2.drawString("RoundRectangle2D", x, 250); }
From source file:MyCanvas.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; //Draw the open arc Arc2D.Float arc = new Arc2D.Float(Arc2D.OPEN); arc.setFrame(140, 100, 67, 46);/*from ww w . j a v a 2 s. co m*/ arc.setAngleStart(45); arc.setAngleExtent(270); g2.setColor(Color.gray); g2.draw(arc); g2.setColor(Color.green); g2.fill(arc); g2.setColor(Color.black); g2.drawString("Arc2D.OPEN", 140, 90); }
From source file:ArcDemo2D.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.gray);//ww w . j a v a 2s .co m int x = 5; int y = 7; g2.setStroke(wideStroke); g2.draw(new Arc2D.Double(x, y, 200, 200, 90, 135, Arc2D.OPEN)); g2.drawString("Arc2D", x, 250); }
From source file:MyCanvas.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; // Draw the pie chart Arc2D.Float arc = new Arc2D.Float(Arc2D.PIE); arc.setFrame(140, 200, 67, 46);//from www .j av a 2s . c o m arc.setAngleStart(45); arc.setAngleExtent(270); g2.setColor(Color.gray); g2.draw(arc); g2.setColor(Color.red); g2.fill(arc); g2.setColor(Color.black); g2.drawString("Arc2D.PIE", 140, 190); }
From source file:MyCanvas.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; //Draw the chord Arc2D.Float arc1 = new Arc2D.Float(Arc2D.CHORD); arc1.setFrame(140, 30, 67, 46);/*www . j a va 2s. com*/ arc1.setAngleStart(45); arc1.setAngleExtent(270); g2.setColor(Color.blue); g2.draw(arc1); g2.setColor(Color.gray); g2.fill(arc1); g2.setColor(Color.black); g2.drawString("Arc2D.CHORD", 140, 20); }
From source file:com.anrisoftware.prefdialog.miscswing.lists.RubberBandingList.java
private void drawSelectionRubberBand(Graphics2D g) { g.setPaint(getSelectionBackground()); g.draw(rubberBand); g.setComposite(ALPHA);//from w w w . java 2 s. c o m g.setPaint(selectionColor); g.fill(rubberBand); }
From source file:RotateTransformed.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Ellipse2D e = new Ellipse2D.Double(0, 0, 80, 130); for (double i = 0; i < 360; i += 5) { AffineTransform at = AffineTransform.getTranslateInstance(400 / 2, 400 / 2); at.rotate(Math.toRadians(i)); g2.draw(at.createTransformedShape(e)); }/*from ww w. j a va2s.c o m*/ }
From source file:DashedStrokeDemo.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; float dash[] = { 10.0f }; g2.setStroke(new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f)); g2.setPaint(Color.blue);//from ww w .j av a2 s.c om Rectangle r = new Rectangle(5, 5, 200, 200); g2.draw(r); }