List of usage examples for java.awt.geom GeneralPath moveTo
public abstract void moveTo(double x, double y);
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; RenderingHints rh = g2.getRenderingHints(); rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHints(rh);/*from w ww. j a v a2 s. c o m*/ BasicStroke bs = new BasicStroke(36.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND); g2.setStroke(bs); GeneralPath path = new GeneralPath(); path.moveTo(30.0f, 90.0f); path.lineTo(150.0f, 20.0f); path.lineTo(270.0f, 90.0f); g2.draw(path); }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; RenderingHints rh = g2.getRenderingHints(); rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHints(rh);//from www . ja va2 s .co m BasicStroke bs = new BasicStroke(36.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER); g2.setStroke(bs); GeneralPath path = new GeneralPath(); path.moveTo(30.0f, 90.0f); path.lineTo(150.0f, 20.0f); path.lineTo(270.0f, 90.0f); g2.draw(path); }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; RenderingHints rh = g2.getRenderingHints(); rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHints(rh);//from ww w . ja v a 2 s . c o m BasicStroke bs = new BasicStroke(36.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL); g2.setStroke(bs); GeneralPath path = new GeneralPath(); path.moveTo(30.0f, 90.0f); path.lineTo(150.0f, 20.0f); path.lineTo(270.0f, 90.0f); g2.draw(path); }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; RenderingHints rh = g2.getRenderingHints(); rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHints(rh);// w w w. j av a 2 s. c om BasicStroke bs = new BasicStroke(36.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND); g2.setStroke(bs); GeneralPath path = new GeneralPath(); path.moveTo(30.0f, 90.0f); path.lineTo(150.0f, 20.0f); path.lineTo(270.0f, 90.0f); g2.draw(path); }
From source file:MyCanvas.java
public void paint(Graphics g) { Graphics2D g2D = (Graphics2D) g; Point2D.Float point = new Point2D.Float(100, 100); // store start point GeneralPath p = new GeneralPath(GeneralPath.WIND_NON_ZERO); p.moveTo(point.x, point.y); p.lineTo(point.x + 20.0f, point.y - 5.0f); // Line from start to A point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x + 5.0f, point.y - 20.0f); // Line from A to B point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x + 5.0f, point.y + 20.0f); // Line from B to C point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x + 20.0f, point.y + 5.0f); // Line from C to D point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x - 20.0f, point.y + 5.0f); // Line from D to E point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x - 5.0f, point.y + 20.0f); // Line from E to F point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x - 5.0f, point.y - 20.0f); // Line from F to g p.closePath(); // Line from G to start g2D.draw(p);//from w ww .java2 s . c o m }
From source file:Hypnosis1.java
private Shape createShape() { GeneralPath path = new GeneralPath(); path.moveTo(coordinates[0], coordinates[1]); for (int i = 2; i < coordinates.length; i += 4) path.quadTo(coordinates[i], coordinates[i + 1], coordinates[i + 2], coordinates[i + 3]); path.closePath();/*from ww w . jav a 2 s. c o m*/ return path; }
From source file:BezLab.java
public void paint(Graphics g) { for (int i = 0; i < 4; i++) { if (i == 0 || i == 3) g.setColor(Color.blue); else/*from w ww .ja v a2s . com*/ g.setColor(Color.cyan); g.fillOval(xs[i] - 6, ys[i] - 6, 12, 12); } Graphics2D g2d = (Graphics2D) g; g2d.setColor(Color.black); GeneralPath path = new GeneralPath(); path.moveTo(xs[0], ys[0]); path.curveTo(xs[1], ys[1], xs[2], ys[2], xs[3], ys[3]); g2d.draw(path); }
From source file:GeneralPathOpenDemo2D.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 va 2 s . c o m int x = 5; int y = 7; // draw GeneralPath (polyline) int xPoints[] = { x, 200, x, 200 }; int yPoints[] = { y, 200, 200, y }; GeneralPath polyline = new GeneralPath(GeneralPath.WIND_EVEN_ODD, xPoints.length); polyline.moveTo(xPoints[0], yPoints[0]); for (int index = 1; index < xPoints.length; index++) { polyline.lineTo(xPoints[index], yPoints[index]); } g2.draw(polyline); g2.drawString("GeneralPath (open)", x, 250); }
From source file:GeneralPathDemo2D.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.gray);/* w w w . j a v a 2 s . c o m*/ int x = 5; int y = 7; // draw GeneralPath (polygon) int xPoints[] = { x, 200, x, 200 }; int yPoints[] = { y, 200, 200, y }; GeneralPath polygon = new GeneralPath(GeneralPath.WIND_EVEN_ODD, xPoints.length); polygon.moveTo(xPoints[0], yPoints[0]); for (int index = 1; index < xPoints.length; index++) { polygon.lineTo(xPoints[index], yPoints[index]); } polygon.closePath(); g2.draw(polygon); g2.drawString("GeneralPath", x, 250); }
From source file:FilledGeneralPath.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int x = 5;/*from www. ja v a 2 s . co m*/ int y = 7; // fill and stroke GeneralPath int xPoints[] = { x, 200, x, 200 }; int yPoints[] = { y, 200, 200, y }; GeneralPath filledPolygon = new GeneralPath(GeneralPath.WIND_EVEN_ODD, xPoints.length); filledPolygon.moveTo(xPoints[0], yPoints[0]); for (int index = 1; index < xPoints.length; index++) { filledPolygon.lineTo(xPoints[index], yPoints[index]); } filledPolygon.closePath(); g2.setPaint(Color.red); g2.fill(filledPolygon); g2.setPaint(Color.black); g2.draw(filledPolygon); g2.drawString("Filled and Stroked GeneralPath", x, 250); }