Package java.awt.geom

Examples of java.awt.geom.GeneralPath


        GradientPaint gradient = new GradientPaint(
            x, y, Color.GREEN, x + 50, y, Color.WHITE);
        g2.setPaint(gradient);
        int[] xcoords = { x + 25, x, x + 50 };
        int[] ycoords = { y, y + 50, y + 50 };
        GeneralPath polygon = new GeneralPath(GeneralPath.WIND_EVEN_ODD, xcoords.length);
        polygon.moveTo(x + 25, y);
        for (int i = 0; i < xcoords.length; i++)
        {
            polygon.lineTo(xcoords[i], ycoords[i]);
        }
        polygon.closePath();
        g2.fill(polygon);
        BasicStroke wideStroke = new BasicStroke(2.0f);
        g2.setColor(Color.black);
        g2.setStroke(wideStroke);
        g2.draw(polygon);
View Full Code Here


            GradientPaint gradient = new GradientPaint(
                x, y, Color.GREEN, x + 50, y, Color.WHITE);
            g2.setPaint(gradient);
            int[] xcoords = { x + 25, x, x + 50 };
            int[] ycoords = { y, y + 50, y + 50 };
            GeneralPath polygon = new GeneralPath(GeneralPath.WIND_EVEN_ODD, xcoords.length);
            polygon.moveTo(x + 25, y);
            for (int i = 0; i < xcoords.length; i++)
            {
                polygon.lineTo(xcoords[i], ycoords[i]);
            }
            polygon.closePath();
            g2.fill(polygon);
            BasicStroke wideStroke = new BasicStroke(2.0f);
            g2.setColor(Color.black);
            g2.setStroke(wideStroke);
            g2.draw(polygon);
View Full Code Here

            GradientPaint gradient = new GradientPaint(
                x, y, Color.YELLOW, x + 50, y, Color.WHITE);
            g2.setPaint(gradient);
            int[] xcoords = { x + 10, x, x + 50, x + 40 };
            int[] ycoords = { y, y + 50, y + 50, y };
            GeneralPath polygon = new GeneralPath(GeneralPath.WIND_EVEN_ODD, xcoords.length);
            polygon.moveTo(x + 25, y);
            for (int i = 0; i < xcoords.length; i++)
            {
                polygon.lineTo(xcoords[i], ycoords[i]);
            }
            polygon.closePath();
            g2.fill(polygon);
            BasicStroke wideStroke = new BasicStroke(2.0f);
            g2.setColor(Color.black);
            g2.setStroke(wideStroke);
            g2.draw(polygon);
View Full Code Here

   * @param geometry the geometry to convert
   * @return a Shape representing the geometry
   */
  public Shape toShape(Geometry geometry)
  {
    if (geometry.isEmpty()) return new GeneralPath();
    if (geometry instanceof Polygon) return toShape((Polygon) geometry);
    if (geometry instanceof LineString)       return toShape((LineString) geometry);
    if (geometry instanceof MultiLineString)   return toShape((MultiLineString) geometry);
    if (geometry instanceof Point)       return toShape((Point) geometry);
    if (geometry instanceof GeometryCollection) return toShape((GeometryCollection) geometry);
View Full Code Here

    return shape;
  }

  private GeneralPath toShape(MultiLineString mls)
  {
    GeneralPath path = new GeneralPath();

    for (int i = 0; i < mls.getNumGeometries(); i++) {
      LineString lineString = (LineString) mls.getGeometryN(i);
      path.append(toShape(lineString), false);
    }
    return path;
  }
View Full Code Here

    return path;
  }

  private GeneralPath toShape(LineString lineString)
  {
    GeneralPath shape = new GeneralPath();
    Point2D viewPoint = toPoint(lineString.getCoordinateN(0));
    shape.moveTo((float) viewPoint.getX(), (float) viewPoint.getY());

    for (int i = 1; i < lineString.getNumPoints(); i++) {
      viewPoint = toPoint(lineString.getCoordinateN(i));
      shape.lineTo((float) viewPoint.getX(), (float) viewPoint.getY());
    }
    return shape;
  }
View Full Code Here

                        }

                        // Determine invalid destination region.
                        Point[] indices = getTileIndices(dstRegionBounds);
                        int numIndices = indices != null ? indices.length : 0;
                        GeneralPath gp = null;

                        for(int i = 0; i < numIndices; i++) {
                            if (i % 1000 == 0 && gp != null)
        gp = new GeneralPath(new Area(gp));

                            Rectangle dstRect =
                                getTileRect(indices[i].x, indices[i].y);
                            Rectangle srcRect =
                                oldOpImage.mapDestRect(dstRect, idx);
                            if(srcRect == null) {
                                gp = null;
                                break;
                            }
                            if(srcInvalidRegion.intersects(srcRect)) {
                                if(gp == null) {
                                    gp = new GeneralPath(dstRect);
                                } else {
                                    gp.append(dstRect, false);
                                }
                            } else {
                                if(validTiles == null) {
                                    validTiles = new ArrayList();
                                }
View Full Code Here

        }
        g.fill(path);
        break;

      case GRAD:
        final GeneralPath p = new GeneralPath(path);//TODO checks if useful the create an other path
        final IPoint tl  = shape.getTopLeftPoint();
        final IPoint br  = shape.getBottomRightPoint();
        IPoint pt1      = ShapeFactory.createPoint((tl.getX()+br.getX())/2., tl.getY());
        IPoint pt2      = ShapeFactory.createPoint((tl.getX()+br.getX())/2., br.getY());
        double angle    = shape.getGradAngle()%(2*Math.PI);
        double gradMidPt = shape.getGradMidPt();

        p.setWindingRule(Path2D.WIND_NON_ZERO);

        if(angle<0.)
          angle = 2.*Math.PI + angle;

        if(angle>=Math.PI) {
View Full Code Here

    /**
     * Some checks for the serialization of a GeneralPath instance.
     */
    public void testGeneralPathSerialization() {
        GeneralPath g1 = new GeneralPath();
        g1.moveTo(1.0f, 2.0f);
        g1.lineTo(3.0f, 4.0f);
        g1.curveTo(5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f);
        g1.quadTo(1.0f, 2.0f, 3.0f, 4.0f);
        g1.closePath();
        GeneralPath g2 = null;
        try {
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            ObjectOutputStream out = new ObjectOutputStream(buffer);
            SerialUtilities.writeShape(g1, out);
            out.close();
View Full Code Here

                final double ae = stream.readDouble(); // Angle Extent
                final int at = stream.readInt();       // Arc type
                result = new Arc2D.Double(x, y, w, h, as, ae, at);
            }
            else if (c.equals(GeneralPath.class)) {
                final GeneralPath gp = new GeneralPath();
                final float[] args = new float[6];
                boolean hasNext = stream.readBoolean();
                while (!hasNext) {
                    final int type = stream.readInt();
                    for (int i = 0; i < 6; i++) {
                        args[i] = stream.readFloat();
                    }
                    switch (type) {
                        case PathIterator.SEG_MOVETO :
                            gp.moveTo(args[0], args[1]);
                            break;
                        case PathIterator.SEG_LINETO :
                            gp.lineTo(args[0], args[1]);
                            break;
                        case PathIterator.SEG_CUBICTO :
                            gp.curveTo(args[0], args[1], args[2],
                                    args[3], args[4], args[5]);
                            break;
                        case PathIterator.SEG_QUADTO :
                            gp.quadTo(args[0], args[1], args[2], args[3]);
                            break;
                        case PathIterator.SEG_CLOSE :
                            gp.closePath();
                            break;
                        default :
                            throw new RuntimeException(
                                    "JFreeChart - No path exists");
                    }
                    gp.setWindingRule(stream.readInt());
                    hasNext = stream.readBoolean();
                }
                result = gp;
            }
            else {
View Full Code Here

TOP

Related Classes of java.awt.geom.GeneralPath

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.