Example usage for java.awt.geom GeneralPath GeneralPath

List of usage examples for java.awt.geom GeneralPath GeneralPath

Introduction

In this page you can find the example usage for java.awt.geom GeneralPath GeneralPath.

Prototype

public GeneralPath() 

Source Link

Document

Constructs a new empty single precision GeneralPath object with a default winding rule of #WIND_NON_ZERO .

Usage

From source file:Main.java

public static void main(String[] args) {
    GeneralPath shape = new GeneralPath();
    shape.moveTo(1, 1);//from   w  ww  .j  a  v a  2s  . c  o m
    shape.lineTo(2, 2);
    shape.quadTo(3, 3, 4, 4);
    shape.curveTo(5, 5, 6, 6, 7, 7);
    shape.closePath();
}

From source file:Main.java

public static void main(String[] args) {
    GeneralPath shape = new GeneralPath();
    shape.moveTo(1, 1);// ww w  .j  a va  2  s  .c  o  m
    shape.lineTo(2, 2);
    shape.quadTo(3, 3, 4, 4);
    shape.curveTo(5, 5, 6, 6, 7, 7);
    shape.closePath();

    System.out.println("done");
}

From source file:Main.java

public static Area getArrowFromTo(Point2D.Double from, Point2D.Double to) {
    double dx = 8;
    double dy = Math.floor(dx / 2);
    if (from.getX() < to.getX())
        dx *= -1;//ww  w.j a va 2s  . c  o  m

    GeneralPath arrowHeadFrom = new GeneralPath();
    arrowHeadFrom.moveTo(to.getX() + dx, to.getY() - dy);
    arrowHeadFrom.lineTo(to.getX(), to.getY());
    arrowHeadFrom.lineTo(to.getX() + dx, to.getY() + dy);
    arrowHeadFrom.lineTo(to.getX() + dx, to.getY() + 0.1);
    arrowHeadFrom.lineTo(from.getX(), from.getY() + 0.1);
    arrowHeadFrom.lineTo(from.getX(), from.getY() - 0.1);
    arrowHeadFrom.lineTo(to.getX() + dx, to.getY() - 0.1);
    arrowHeadFrom.lineTo(to.getX() + dx, to.getY() - dy);

    Area b = new Area(arrowHeadFrom);

    return b;
}

From source file:edu.gmu.cs.sim.util.media.chart.ScatterPlotSeriesAttributes.java

static Shape[] buildShapes() {
    Shape[] s = new Shape[7];
    GeneralPath g = null;/* www.  ja  v a  2s .  c  om*/

    // Circle
    s[0] = new Ellipse2D.Double(-3, -3, 6, 6);

    // Rectangle
    Rectangle2D.Double r = new Rectangle2D.Double(-3, -3, 6, 6);
    s[1] = r;

    // Diamond
    s[2] = AffineTransform.getRotateInstance(Math.PI / 4.0).createTransformedShape(r);

    // Cross +
    g = new GeneralPath();
    g.moveTo(-0.5f, -3);
    g.lineTo(-0.5f, -0.5f);
    g.lineTo(-3, -0.5f);
    g.lineTo(-3, 0.5f);
    g.lineTo(-0.5f, 0.5f);
    g.lineTo(-0.5f, 3);
    g.lineTo(0.5f, 3);
    g.lineTo(0.5f, 0.5f);
    g.lineTo(3, 0.5f);
    g.lineTo(3, -0.5f);
    g.lineTo(0.5f, -0.5f);
    g.lineTo(0.5f, -3);
    g.closePath();
    s[3] = g;

    // X 
    s[4] = g.createTransformedShape(AffineTransform.getRotateInstance(Math.PI / 4.0));

    // Up Triangle
    g = new GeneralPath();
    g.moveTo(0f, -3);
    g.lineTo(-3, 3);
    g.lineTo(3, 3);
    g.closePath();
    s[5] = g;

    // Down Triangle
    s[6] = g.createTransformedShape(AffineTransform.getRotateInstance(Math.PI));

    return s;
}

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 www .j  av  a 2  s  . c om*/

    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: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  ww w.  ja va  2 s.c om

    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: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);/*  ww  w .j  ava  2s .  com*/

    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   w w  w .  j a v a  2s. com

    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.  j  a  v a2  s  .co  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);//from w ww .  ja  v  a 2s.  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);

}