Example usage for java.awt.geom GeneralPath lineTo

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

Introduction

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

Prototype

public abstract void lineTo(double x, double y);

Source Link

Document

Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates specified in double precision.

Usage

From source file:Main.java

public static void main(String[] args) {
    GeneralPath shape = new GeneralPath();
    shape.moveTo(1, 1);/*from  w w  w.  j  a  va2 s. com*/
    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);/*from  w ww . j ava 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;// www.  j  av  a  2s .  c om

    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:grafix.graficos.comparativo.ConstrutorGraficoComparativos.java

private static JFreeChart criarChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart("Comparativo da Evoluo de Papis", "Perodo",
            "Evoluo (%)", dataset, true, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    GeneralPath zigzag = new GeneralPath();
    zigzag.moveTo(-6.0f, 0.0f);//from  www .j av a  2 s  . c  o m
    zigzag.lineTo(-3.0f, 6.0f);
    zigzag.lineTo(3.0f, -6.0f);
    zigzag.lineTo(6.0f, 0.0f);
    renderer.setLegendLine(zigzag);
    return chart;

}

From source file:Main.java

/**
 * Creates a triangle shape that points downwards.
 *
 * @param s  the size factor (equal to half the height of the triangle).
 *
 * @return A triangle shape.// w  ww.  j a  va 2 s .  c o  m
 */
public static Shape createDownTriangle(final float s) {
    final GeneralPath p0 = new GeneralPath();
    p0.moveTo(0.0f, s);
    p0.lineTo(s, -s);
    p0.lineTo(-s, -s);
    p0.closePath();
    return p0;
}

From source file:Main.java

/**
 * Creates a triangle shape that points upwards.
 *
 * @param s  the size factor (equal to half the height of the triangle).
 *
 * @return A triangle shape.//from w  w  w  . j a v a2 s  . c om
 */
public static Shape createUpTriangle(final float s) {
    final GeneralPath p0 = new GeneralPath();
    p0.moveTo(0.0f, -s);
    p0.lineTo(s, s);
    p0.lineTo(-s, s);
    p0.closePath();
    return p0;
}

From source file:Main.java

/**
 * Creates a diamond shape.//  ww w. j a v  a2s. c o m
 *
 * @param s  the size factor (equal to half the height of the diamond).
 *
 * @return A diamond shape.
 */
public static Shape createDiamond(final float s) {
    final GeneralPath p0 = new GeneralPath();
    p0.moveTo(0.0f, -s);
    p0.lineTo(s, 0.0f);
    p0.lineTo(0.0f, s);
    p0.lineTo(-s, 0.0f);
    p0.closePath();
    return p0;
}

From source file:Main.java

/**
 * Creates a diagonal cross shape.//  ww  w  . ja va2 s . co  m
 *
 * @param l  the length of each 'arm'.
 * @param t  the thickness.
 *
 * @return A diagonal cross shape.
 */
public static Shape createRegularCross(final float l, final float t) {
    final GeneralPath p0 = new GeneralPath();
    p0.moveTo(-l, t);
    p0.lineTo(-t, t);
    p0.lineTo(-t, l);
    p0.lineTo(t, l);
    p0.lineTo(t, t);
    p0.lineTo(l, t);
    p0.lineTo(l, -t);
    p0.lineTo(t, -t);
    p0.lineTo(t, -l);
    p0.lineTo(-t, -l);
    p0.lineTo(-t, -t);
    p0.lineTo(-l, -t);
    p0.closePath();
    return p0;
}

From source file:Main.java

/**
 * Creates a diagonal cross shape./*from  w  w w  . j a  v a 2  s  .  c o m*/
 *
 * @param l  the length of each 'arm'.
 * @param t  the thickness.
 *
 * @return A diagonal cross shape.
 */
public static Shape createDiagonalCross(final float l, final float t) {
    final GeneralPath p0 = new GeneralPath();
    p0.moveTo(-l - t, -l + t);
    p0.lineTo(-l + t, -l - t);
    p0.lineTo(0.0f, -t * SQRT2);
    p0.lineTo(l - t, -l - t);
    p0.lineTo(l + t, -l + t);
    p0.lineTo(t * SQRT2, 0.0f);
    p0.lineTo(l + t, l - t);
    p0.lineTo(l - t, l + t);
    p0.lineTo(0.0f, t * SQRT2);
    p0.lineTo(-l + t, l + t);
    p0.lineTo(-l - t, l - t);
    p0.lineTo(-t * SQRT2, 0.0f);
    p0.closePath();
    return p0;
}

From source file:net.sf.maltcms.chromaui.annotations.XYSelectableShapeAnnotation.java

/**
 *
 * @param x/*from  w  w  w.  ja  va  2s.co  m*/
 * @param y
 * @param w
 * @param h
 * @return
 */
public static Shape getCrosshairShape(double x, double y, double w, double h) {
    // draw GeneralPath (polyline)
    //we draw two lines, one from
    //x-5,y to x+5,y and one from
    //x,y-5 to x,y+5
    double x2Points[] = { x - w, x + w, x, x };
    double y2Points[] = { y, y, y - h, y + h };
    GeneralPath crosshair = new GeneralPath(GeneralPath.WIND_EVEN_ODD, x2Points.length);

    crosshair.moveTo(x2Points[0], y2Points[0]);
    crosshair.lineTo(x2Points[1], y2Points[1]);
    crosshair.moveTo(x2Points[2], y2Points[2]);
    crosshair.lineTo(x2Points[3], y2Points[3]);

    return crosshair;

}