List of usage examples for java.awt Graphics2D drawString
public abstract void drawString(AttributedCharacterIterator iterator, float x, float y);
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Ellipse2D e1 = new Ellipse2D.Double(20.0, 20.0, 80.0, 70.0); Ellipse2D e2 = new Ellipse2D.Double(20.0, 70.0, 40.0, 40.0); Area a1 = new Area(e1); Area a2 = new Area(e2); a1.subtract(a2);/*from w w w. j av a 2 s .c om*/ g2.setColor(Color.orange); g2.fill(a1); g2.setColor(Color.black); g2.drawString("subtract", 20, 140); System.out.println(a1.isRectangular()); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Ellipse2D e1 = new Ellipse2D.Double(20.0, 20.0, 80.0, 70.0); Ellipse2D e2 = new Ellipse2D.Double(20.0, 70.0, 40.0, 40.0); Area a1 = new Area(e1); Area a2 = new Area(e2); a1.subtract(a2);//from w w w. j a va 2 s . c om g2.setColor(Color.orange); g2.fill(a1); g2.setColor(Color.black); g2.drawString("subtract", 20, 140); System.out.println(a1.isPolygonal()); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Ellipse2D e1 = new Ellipse2D.Double(20.0, 20.0, 80.0, 70.0); Ellipse2D e2 = new Ellipse2D.Double(20.0, 70.0, 40.0, 40.0); Area a1 = new Area(e1); Area a2 = new Area(e2); a1.subtract(a2);/*from w w w .j a va2 s . c o m*/ g2.setColor(Color.orange); g2.fill(a1); g2.setColor(Color.black); g2.drawString("subtract", 20, 140); System.out.println(a1.contains(new Rectangle(50, 50, 5, 5))); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Ellipse2D e1 = new Ellipse2D.Double(20.0, 20.0, 80.0, 70.0); Ellipse2D e2 = new Ellipse2D.Double(20.0, 70.0, 40.0, 40.0); Area a1 = new Area(e1); Area a2 = new Area(e2); a1.subtract(a2);//from w w w . ja v a2s . c om g2.setColor(Color.orange); g2.fill(a1); g2.setColor(Color.black); g2.drawString("subtract", 20, 140); System.out.println(a1.isSingular()); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Ellipse2D e1 = new Ellipse2D.Double(20.0, 20.0, 80.0, 70.0); Ellipse2D e2 = new Ellipse2D.Double(20.0, 70.0, 40.0, 40.0); Area a1 = new Area(e1); Area a2 = new Area(e2); a1.subtract(a2);/*www .j a v a 2 s .co m*/ g2.setColor(Color.orange); g2.fill(a1); g2.setColor(Color.black); g2.drawString("subtract", 20, 140); System.out.println(a1.createTransformedArea(null)); }
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);/* ww w . j a v a2 s. co 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 open arc Arc2D.Float arc = new Arc2D.Float(Arc2D.OPEN); arc.setFrame(140, 100, 67, 46);/*from w w w .j ava 2 s. c o 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: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);//w w w .j a v a 2 s . c o m 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:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; String s = "\"www.java2s.com,\" www.java2s.com"; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font plainFont = new Font("Times New Roman", Font.PLAIN, 24); AttributedString as = new AttributedString(s); as.addAttribute(TextAttribute.FONT, plainFont); g2.drawString(as.getIterator(), 24, 70); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Ellipse2D e1 = new Ellipse2D.Double(20.0, 20.0, 80.0, 70.0); Ellipse2D e2 = new Ellipse2D.Double(20.0, 70.0, 40.0, 40.0); Area a1 = new Area(e1); Area a2 = new Area(e2); a1.intersects(20, 20, 300, 300);/*from w w w. j a va 2s .c om*/ g2.setColor(Color.orange); g2.fill(a1); g2.setColor(Color.black); g2.drawString("intersect", 20, 140); }