Package java.awt

Examples of java.awt.Polygon


    Vector2f v1 = pts[0];
    Vector2f v2 = pts[1];
    Vector2f v3 = pts[2];
    Vector2f v4 = pts[3];
   
    Polygon pol = new Polygon();
    pol.addPoint((int) v1.x,(int) v1.y);
    pol.addPoint((int) v2.x,(int) v2.y);
    pol.addPoint((int) v3.x,(int) v3.y);
    pol.addPoint((int) v4.x,(int) v4.y);
   
    if (fill) {
      g.fill(pol);
    } else {
      g.draw(pol);
View Full Code Here


 
  private int layout() {
    // Generate the curves intervals
    this.midcurve = this.spline.intervals(this.interval);
   
    Polygon polygon;
    double[][] left = new double[2][];
    double[][] right = new double[2][];
    this.leftcurve = new ArrayList<double[]>();
    this.rightcurve = new ArrayList<double[]>();
    double[][] p = new double[5][2];
      int last = this.midcurve.size() - 1;
   
    // Clear the current list of polygons
    this.polygons.clear();
   
    // Project the first left and right curve interval
    p[1] = this.midcurve.get(0);
    p[2] = this.midcurve.get(1);
    Vector2D.vector(p[3], p[1][0], p[1][1], p[2][0], p[2][1]);
    projectEdges(p, left, right);
    left[1] = left[0];
    right[1] = right[0];
   
    // Project the left and right curve intervals
    for (int i = 1; i < last; i++) {
      p[0] = this.midcurve.get(i - 1);
      p[1] = this.midcurve.get(i);
        p[2] = this.midcurve.get(i + 1);
        Vector2D.vector(p[3], p[0][0], p[0][1], p[1][0], p[1][1]);
          Vector2D.vector(p[4], p[1][0], p[1][1], p[2][0], p[2][1]);
          Vector2D.add(p[3], p[4]);
        projectEdges(p, left, right);
       
        //if (intervalsIntersect(left, right)) {
          // Work out which control point we're closest to
        //  int closest = (int)Math.round((i / this.interval)) + 1;
        //  straightenCorner(closest);
        //  return i;
        //}

      // Add the polygon
      polygon = new Polygon();
      polygon.addPoint((int) left[0][0], (int) left[0][1]);
      polygon.addPoint((int) left[1][0], (int) left[1][1]);
      polygon.addPoint((int) right[1][0], (int) right[1][1]);
      polygon.addPoint((int) right[0][0], (int) right[0][1]);
      this.polygons.add(polygon);

      // Remember current left/right points
      left[1] = left[0];
      right[1] = right[0];
    }
   
   
    // Project the last left and right curve interval
    p[0] = this.midcurve.get(last - 1);
    p[1] = this.midcurve.get(last);
    Vector2D.vector(p[3], p[0][0], p[0][1], p[1][0], p[1][1]);
    projectEdges(p, left, right);
   
    // Add the last polygon
    polygon = new Polygon();
    polygon.addPoint((int) left[0][0], (int) left[0][1]);
    polygon.addPoint((int) left[1][0], (int) left[1][1]);
    polygon.addPoint((int) right[1][0], (int) right[1][1]);
    polygon.addPoint((int) right[0][0], (int) right[0][1]);
    this.polygons.add(polygon);
   
    return -1;
  }
View Full Code Here

    /**
     * Return a cubic spline.
     */
    public Polygon getPolyline()
    {
        Polygon p = new Polygon();
        if (pts.npoints >= 2)
        {
            Cubic[] X = calcNaturalCubic(pts.npoints - 1, pts.xpoints);
            Cubic[] Y = calcNaturalCubic(pts.npoints - 1, pts.ypoints);
             // very crude technique - just break each segment up into steps lines
            int x = (int) Math.round(X[0].eval(0));
            int y = (int) Math.round(Y[0].eval(0));
            p.addPoint(x, boundY(y));
            for (int i = 0; i < X.length; i++)
            {
                for (int j = 1; j <= STEPS; j++)
                {
                    float u = j / (float) STEPS;
                    x = Math.round(X[i].eval(u));
                    y = Math.round(Y[i].eval(u));
                    p.addPoint(x, boundY(y));
                }
            }
        }
        return p;
    }
View Full Code Here

    int maxHeight = -1;
    int minHeight = -1;

    public ControlCurve()
    {
        pts = new Polygon();
    }
View Full Code Here

                int x1 = (int) Math.round(dx * (i - 1));
                int y1 = ((int) Math.round((h * values[i] / 100)));
                y1 = curve.boundY(y1);
                curve.addPoint(x1, y1);
            }
            Polygon spline = curve.getPolyline();
            if (gradient != null)
            {
                for (int i=0;i<(spline.npoints-1);i++)
                {
                    g.setColor(gradient[spline.ypoints[i]]);
View Full Code Here

     * @see          java.awt.Graphics#fillPolygon(int[],int[],int)
     * @see          java.awt.Graphics#drawPolyline
     */
    public void drawPolygon(int[] xPoints, int[] yPoints,
                            int nPoints){
        Polygon polygon = new Polygon(xPoints, yPoints, nPoints);
        draw(polygon);
    }
View Full Code Here

     * @param        nPoints   a the total number of points.
     * @see          java.awt.Graphics#drawPolygon(int[], int[], int)
     */
    public void fillPolygon(int[] xPoints, int[] yPoints,
                            int nPoints){
        Polygon polygon = new Polygon(xPoints, yPoints, nPoints);
        fill(polygon);
    }
View Full Code Here

        }
        draw(path);
    }

    public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) {
        draw(new Polygon(xPoints, yPoints, nPoints));
    }
View Full Code Here

    public void drawPolygon(Polygon p) {
        draw(p);
    }

    public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
        fill(new Polygon(xPoints, yPoints, nPoints));
    }
View Full Code Here

     * @param yPoints
     * @param npoints
     * @see java.awt.Graphics#drawPolygon(int[], int[], int)
     */
    public final void drawPolygon(int[] xPoints, int[] yPoints, int npoints) {
        draw(new Polygon(xPoints, yPoints, npoints));
    }
View Full Code Here

TOP

Related Classes of java.awt.Polygon

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.