Package java.awt.geom

Examples of java.awt.geom.PathIterator


            double dx = xoff;//bounds.getX();
            double dy = yoff;//bounds.getY();
            //don't subtract off the translation just yet
            //dx = xoff;
            //dy = yoff;
            PathIterator it = area.getPathIterator(null);
            while(!it.isDone()) {
                double[] coords = new double[6];
                int n = it.currentSegment(coords);
                if(n == PathIterator.SEG_MOVETO) {
                    out.println(".moveTo("+(coords[0]-dx)+","+(coords[1]-dy)+")");
                }
                if(n == PathIterator.SEG_LINETO) {
                    out.println(".lineTo("+(coords[0]-dx)+","+(coords[1]-dy)+")");
                }
                if(n == PathIterator.SEG_CUBICTO) {
                    out.println(".curveTo("+
                            (coords[0]-dx)+","+(coords[1]-dy)+","+(coords[2]-dx)+","+(coords[3]-dy)+
                            ","+(coords[4]-dx)+","+(coords[5]-dy)+")"
                    );
                }
                if(n == PathIterator.SEG_CLOSE) {
                    out.println(".closeTo()");
                    break;
                }
                it.next();
            }
            out.println(".build()");
            out.outdent();
            out.outdent();
            out.println(")");
View Full Code Here


            out.attr("transform","translate("+ shape.getTranslateX()+","+ shape.getTranslateY()+")");
            //the vector data
            StringBuffer data = new StringBuffer();
            int count = 0;
            Area area = shape.toArea();
            PathIterator it = area.getPathIterator(new AffineTransform());
            while(!it.isDone()) {
                double[] coords = new double[6];
                int n = it.currentSegment(coords);
                if(n == PathIterator.SEG_MOVETO) {
                    data.append(" M "+coords[0]+" "+coords[1]);
                }
                if(n == PathIterator.SEG_LINETO) {
                    data.append(" L " + coords[0]+" " +coords[1]);
                }
                if(n == PathIterator.SEG_CUBICTO) {
                    data.append(" C "
                            +coords[0]+" "+coords[1] + " "
                            +coords[2]+" "+coords[3] + " "
                            +coords[4]+" "+coords[5] + " "
                            );
                }
                if(n == PathIterator.SEG_CLOSE) {
                    data.append(" z");
                    break;
                }
                it.next();
            }
            out.attr("d", data.toString());
/*
        for(int i=0; i<points.size(); i++) {
            if(i == 0) {
View Full Code Here

            }
        }
        if(shape instanceof SArea) {
            SArea area = (SArea) shape;
            Area jarea = area.toArea();
            PathIterator it = jarea.getPathIterator(null);
            while(!it.isDone()) {
                double[] coords = new double[6];
                int n = it.currentSegment(coords);
                if(n == PathIterator.SEG_MOVETO) {
                    out.start("move","x",""+coords[0],"y",""+coords[1]).end();
                }
                if(n == PathIterator.SEG_LINETO) {
                    out.start("lineto","x",""+coords[0],"y",""+coords[1]).end();
                }
                if(n == PathIterator.SEG_CUBICTO) {
                    out.start("curveto",
                            "cx1",""+coords[0],"cy1",""+coords[1],
                            "cx2",""+coords[2],"cy2",""+coords[3],
                            "x2",""+coords[4],"y2",""+coords[5]
                    ).end();
                }
                if(n == PathIterator.SEG_CLOSE) {
                    out.start("close").end();
                    break;
                }
                it.next();
            }
        }
        exportProperties(out,shape);

    }
View Full Code Here

                    double dx = bounds.getX();
                    double dy = bounds.getY();
                    out.println("ctx.translate("+dx+","+dy+");");
                    out.println("ctx.beginPath()");

                    PathIterator it = area.getPathIterator(null);
                    while(!it.isDone()) {
                        double[] coords = new double[6];
                        int n = it.currentSegment(coords);
                        if(n == PathIterator.SEG_MOVETO) {
                            out.println("ctx.moveTo("+(coords[0]-dx)+","+(coords[1]-dy)+");");
                        }
                        if(n == PathIterator.SEG_LINETO) {
                            out.println("ctx.lineTo("+(coords[0]-dx)+","+(coords[1]-dy)+");");
                        }
                        if(n == PathIterator.SEG_CUBICTO) {
                            out.println("ctx.bezierCurveTo("+
                                    (coords[0]-dx)+","+(coords[1]-dy)+","+(coords[2]-dx)+","+(coords[3]-dy)+
                                    ","+(coords[4]-dx)+","+(coords[5]-dy)+");"
                            );
                        }
                        if(n == PathIterator.SEG_CLOSE) {
                            out.println("ctx.closePath();");
                            break;
                        }
                        it.next();
                    }

                    out.println("ctx.fill();");
                    if(shape.getStrokeWidth() > 0 && shape.getStrokePaint() != null) {
                        out.println("ctx.strokeStyle = \"rgb("+serialize(shape.getStrokePaint())+");\"");
View Full Code Here

                    // isn't met we are SOL.
                    float [] pts = new float[6];
                    int count = 0;
                    int type = -1;

                    PathIterator pi = gbounds.getPathIterator(null);
                    Point2D.Float firstPt = null;
                    if (isVertical()) {
                        if (glyphOrientationAuto) {
                            if (isLatinChar(ch))
                                glyphOrientationAngle = 90;
                            else
                                glyphOrientationAngle = 0;
                        }
                    }

                    while (!pi.isDone()) {
                        type = pi.currentSegment(pts);
                        if ((type == PathIterator.SEG_MOVETO) ||
                            (type == PathIterator.SEG_LINETO)) {
                            // LINETO or MOVETO
                            if (count > 4) break; // too many lines...
                            if (count == 4) {
                                // make sure we are just closing it..
                                if ((firstPt == null)     ||
                                    (firstPt.x != pts[0]) ||
                                    (firstPt.y != pts[1]))
                                    break;
                            } else {
                                Point2D.Float pt;
                                pt = new Point2D.Float(pts[0], pts[1]);
                                if (count == 0) firstPt = pt;
                                // Use sides of  rectangle...
                                switch (count) {
                                case 0: botPts[ptIdx]   = pt; break;
                                case 1: topPts[ptIdx]   = pt; break;
                                case 2: topPts[ptIdx+1] = pt; break;
                                case 3: botPts[ptIdx+1] = pt; break;
                                }
                            }
                        } else if (type == PathIterator.SEG_CLOSE) {
                                // Close in the wrong spot?
                            if ((count < 4) || (count > 5)) break;
                        } else {
                            // QUADTO or CUBETO
                            break;
                        }

                        count++;
                        pi.next();
                    }
                    if (pi.isDone()) {
                        // Sucessfully Expressed as a quadralateral...
                        if ((botPts[ptIdx]!=null) &&
                            ((topPts[ptIdx].x != topPts[ptIdx+1].x) ||
                             (topPts[ptIdx].y != topPts[ptIdx+1].y)))
                            // box isn't empty so use it's points...
View Full Code Here

  }

  private String shapeCoordinates(Shape shape)
  {
    final StringBuilder sb = new StringBuilder();
    final PathIterator pi = shape.getPathIterator(null, 1.0);
    final float[] coords = new float[6];
    final float[] lastMove = new float[2];
    while (!pi.isDone())
    {
      switch (pi.currentSegment(coords))
      {
        case PathIterator.SEG_MOVETO :
          if (sb.length() != 0)
          {
            sb.append(",");
          }
          sb.append(Math.round(coords[0]));
          sb.append(",");
          sb.append(Math.round(coords[1]));
          lastMove[0] = coords[0];
          lastMove[1] = coords[1];
          break;
        case PathIterator.SEG_LINETO :
          if (sb.length() != 0)
          {
            sb.append(",");
          }
          sb.append(Math.round(coords[0]));
          sb.append(",");
          sb.append(Math.round(coords[1]));
          break;
        case PathIterator.SEG_CLOSE :
          if (sb.length() != 0)
          {
            sb.append(",");
          }
          sb.append(Math.round(lastMove[0]));
          sb.append(",");
          sb.append(Math.round(lastMove[1]));
          break;
      }
      pi.next();
    }
    return sb.toString();
  }
View Full Code Here

                    // isn't met we are SOL.
                    float [] pts = new float[6];
                    int count = 0;
                    int type = -1;

                    PathIterator pi = gbounds.getPathIterator(null);
                    Point2D.Float firstPt = null;

                    while (!pi.isDone()) {
                        type = pi.currentSegment(pts);
                        if ((type == PathIterator.SEG_MOVETO) ||
                            (type == PathIterator.SEG_LINETO)) {
                            // LINETO or MOVETO
                            if (count > 4) break; // too many lines...
                            if (count == 4) {
                                // make sure we are just closing it..
                                if ((firstPt == null)     ||
                                    (firstPt.x != pts[0]) ||
                                    (firstPt.y != pts[1]))
                                    break;
                            } else {
                                Point2D.Float pt;
                                pt = new Point2D.Float(pts[0], pts[1]);
                                if (count == 0) firstPt = pt;
                                // Use sides of  rectangle...
                                switch (count) {
                                case 0: botPts[ptIdx]   = pt; break;
                                case 1: topPts[ptIdx]   = pt; break;
                                case 2: topPts[ptIdx+1] = pt; break;
                                case 3: botPts[ptIdx+1] = pt; break;
                                }
                            }
                        } else if (type == PathIterator.SEG_CLOSE) {
                                // Close in the wrong spot?
                            if ((count < 4) || (count > 5)) break;
                        } else {
                            // QUADTO or CUBETO
                            break;
                        }

                        count++;
                        pi.next();
                    }
                    if (pi.isDone()) {
                        // Sucessfully Expressed as a quadralateral...
                        if ((botPts[ptIdx]!=null) &&
                            ((topPts[ptIdx].x != topPts[ptIdx+1].x) ||
                             (topPts[ptIdx].y != topPts[ptIdx+1].y)))
                            // box isn't empty so use it's points...
View Full Code Here

            // Special optimization in case of Rectangle Shape
            Rectangle2D r = (Rectangle2D) s;
            gen.defineRect(r.getX(), r.getY(), r.getWidth(), r.getHeight());
            return PathIterator.WIND_NON_ZERO;
        } else {
            PathIterator iter = s.getPathIterator(IDENTITY_TRANSFORM);
            processPathIterator(iter);
            return iter.getWindingRule();
        }
    }
View Full Code Here

                return;
            }
        }
        applyStroke(getStroke());

        PathIterator iter = s.getPathIterator(IDENTITY_TRANSFORM);
        processPathIterator(iter);
        doDrawing(false, true, false);
        if (newClip || newTransform) {
            currentStream.write("Q\n");
            graphicsState.pop();
View Full Code Here

    protected void writeClip(Shape s) {
        if (s == null) {
            return;
        }
        preparePainting();
        PathIterator iter = s.getPathIterator(IDENTITY_TRANSFORM);
        processPathIterator(iter);
        // clip area
        currentStream.write("W\n");
        currentStream.write("n\n");
    }
View Full Code Here

TOP

Related Classes of java.awt.geom.PathIterator

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.