Examples of GeneralPath


Examples of java.awt.geom.GeneralPath

        transform.concatenate(baseTransform);

        // Handle clip area in Graphics, first
        Shape clip = getClip();
        if (clip != null) {
            g.setClip(new GeneralPath(clip).createTransformedShape(transform));
        }

        Shape shape = new GeneralPath(geometry).createTransformedShape(transform);
        getAttributesForRendering(appDA).render((Graphics2D) g, shape, gradient);
    }
View Full Code Here

Examples of java.awt.geom.GeneralPath

                    new LatLonPoint(lat2, lon2), // SE
                    lineType, nsegs, !isClear(fillPaint));
            int size = rects.size();

            for (int i = 0, j = 0; i < size; i += 2, j++) {
                GeneralPath gp = createShape((int[]) rects.get(i),
                        (int[]) rects.get(i + 1),
                        true);

                if (shape == null) {
                    setShape(gp);
View Full Code Here

Examples of java.awt.geom.GeneralPath

   * @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;
  }
View Full Code Here

Examples of java.awt.geom.GeneralPath

   * @param s the size factor (equal to half the height of the triangle).
   * @return A triangle shape.
   */
  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;
  }
View Full Code Here

Examples of java.awt.geom.GeneralPath

   * @param s the size factor (equal to half the height of the triangle).
   * @return A triangle shape.
   */
  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;
  }
View Full Code Here

Examples of java.awt.geom.GeneralPath

    }

    private static Shape generateStar(double x, double y,
                                      double innerRadius, double outerRadius,
                                      int branchesCount) {
        GeneralPath path = new GeneralPath();

        double outerAngleIncrement = 2 * Math.PI / branchesCount;

        double outerAngle = 0.0;
        double innerAngle = outerAngleIncrement / 2.0;

        x += outerRadius;
        y += outerRadius;

        float x1 = (float) (Math.cos(outerAngle) * outerRadius + x);
        float y1 = (float) (Math.sin(outerAngle) * outerRadius + y);

        float x2 = (float) (Math.cos(innerAngle) * innerRadius + x);
        float y2 = (float) (Math.sin(innerAngle) * innerRadius + y);

        path.moveTo(x1, y1);
        path.lineTo(x2, y2);

        outerAngle += outerAngleIncrement;
        innerAngle += outerAngleIncrement;

        for (int i = 1; i < branchesCount; i++) {
            x1 = (float) (Math.cos(outerAngle) * outerRadius + x);
            y1 = (float) (Math.sin(outerAngle) * outerRadius + y);

            path.lineTo(x1, y1);

            x2 = (float) (Math.cos(innerAngle) * innerRadius + x);
            y2 = (float) (Math.sin(innerAngle) * innerRadius + y);

            path.lineTo(x2, y2);

            outerAngle += outerAngleIncrement;
            innerAngle += outerAngleIncrement;
        }

        path.closePath();
        return path;
    }
View Full Code Here

Examples of java.awt.geom.GeneralPath

        return poly;
    }

    // converts circles into polygons
    public static OMPoly convert(OMCircle omCircle, Projection proj) {
        GeneralPath shape = omCircle.getShape();

        // get the PathIterator that defines the outline of the circle
        PathIterator circle = shape.getPathIterator(null);
        Vector initialPoints = new Vector();
        float[] segPoints = new float[2];

        while (!circle.isDone()) {
            // by passing segpoints the array is filled with each x\y
View Full Code Here

Examples of java.awt.geom.GeneralPath

    // scan through the datasets
        for(int lRow = 0; lRow < lNumberOfRows; lRow++)
        {
      // scan through the values in the dataset
      GeneralPath filledPolygon = new GeneralPath(GeneralPath.WIND_EVEN_ODD, lNumberOfColumns);
      for (int lCol = 0; lCol < lNumberOfColumns; lCol++)
      {
        // get the value
                double lValue = m.getValueAt(lRow, lCol).doubleValue();
       
            // determine the scale
            double lMaxValue = maxvalues[lCol];
               
                if(lMaxValue == 0.0) {
                    for(int row = 0; row < lNumberOfRows; row++)
                        lMaxValue = Math.max(lMaxValue, m.getValueAt(row, lCol).doubleValue() * 1.1);
                   
                    maxvalues[lCol] = lMaxValue;
                }
               
            double lScaledValue = lValue / lMaxValue;
            double lLineValue = lRadius * lScaledValue;

        // determine rotation: there are 2PI/noOfCols vertexes, this is vertex no lCol   
        // -1 : we want to rotate clockwise
        // + PI: rotate 180 degree to get the first column pointing up
        double lRotation = (-1 * (2 * Math.PI / lNumberOfColumns) * lCol) + Math.PI;

        // determine the end points
        double lX = center_x + (lLineValue * Math.sin(lRotation));
        double lY = center_y + (lLineValue * Math.cos(lRotation));

        // draw the line
        Line2D lLine = new Line2D.Double(center_x, center_y, lX, lY);
            g.setColor(Color.black);
            g.draw(lLine);

        // add to polygone
        if (lCol == 0) filledPolygon.moveTo((float)lX, (float)lY);
        else filledPolygon.lineTo((float)lX, (float)lY);           
      }
     
      // draw the polygone
      filledPolygon.closePath();
      g.setPaint( rcm.getColor(lRow) );
      g.draw(filledPolygon);
        }
       
        double lRotation;
View Full Code Here

Examples of java.awt.geom.GeneralPath

                    new double[] { x0, y0, x1, y1 };
    }


    private static GeneralPath pathToShape(double[] path, boolean close, LayoutPathImpl lp) {
        GeneralPath result = new GeneralPath(GeneralPath.WIND_EVEN_ODD, path.length);
        result.moveTo((float)path[0], (float)path[1]);
        for (int i = 2; i < path.length; i += 2) {
            result.lineTo((float)path[i], (float)path[i+1]);
        }
        if (close) {
            result.closePath();
        }

        if (lp != null) {
            result = (GeneralPath)lp.mapShape(result);
        }
View Full Code Here

Examples of java.awt.geom.GeneralPath

        // that.  We do need to prevent the two segments which
        // join path0 to path1 from crossing each other.  So, if we
        // traverse path0 from top to bottom, we'll traverse path1 from
        // bottom to top (and vice versa).

        GeneralPath result = pathToShape(path0, false, null);

        boolean sameDirection;
               
        if (isVerticalLine) {
            sameDirection = (path0[1] > path0[path0.length-1]) ==
                            (path1[1] > path1[path1.length-1]);
        }
        else {
            sameDirection = (path0[0] > path0[path0.length-2]) ==
                            (path1[0] > path1[path1.length-2]);
        }

        int start;
        int limit;
        int increment;

        if (sameDirection) {
            start = path1.length-2;
            limit = -2;
            increment = -2;
        }
        else {
            start = 0;
            limit = path1.length;
            increment = 2;
        }

        for (int i = start; i != limit; i += increment) {
            result.lineTo((float)path1[i], (float)path1[i+1]);
        }

        result.closePath();

        return result;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.