Examples of FlatteningPathIterator


Examples of com.google.code.appengine.awt.geom.FlatteningPathIterator

  public PathIterator getPathIterator(AffineTransform t) {
    return new AreaPathIterator(this, t);
  }
 
  public PathIterator getPathIterator(AffineTransform t, double flatness) {
    return new FlatteningPathIterator(getPathIterator(t), flatness);
  }
View Full Code Here

Examples of com.google.code.appengine.awt.geom.FlatteningPathIterator

    public PathIterator getPathIterator(AffineTransform t) {
        return new Iterator(this, t);
    }

    public PathIterator getPathIterator(AffineTransform t, double flatness) {
        return new FlatteningPathIterator(getPathIterator(t), flatness);
    }
View Full Code Here

Examples of com.google.code.appengine.awt.geom.FlatteningPathIterator

        int y2 = (int)Math.ceil(getMaxY());
        return new Rectangle(x1, y1, x2 - x1, y2 - y1);
    }

    public PathIterator getPathIterator(AffineTransform t, double flatness) {
        return new FlatteningPathIterator(getPathIterator(t), flatness);
    }
View Full Code Here

Examples of com.google.code.appengine.awt.geom.FlatteningPathIterator

    public PathIterator getPathIterator(AffineTransform t) {
        return new Iterator(this, t);
    }

    public PathIterator getPathIterator(AffineTransform at, double flatness) {
        return new FlatteningPathIterator(getPathIterator(at), flatness);
    }
View Full Code Here

Examples of com.google.code.appengine.awt.geom.FlatteningPathIterator

    public PathIterator getPathIterator(AffineTransform t) {
        return new Iterator(this, t);
    }

    public PathIterator getPathIterator(AffineTransform t, double flatness) {
        return new FlatteningPathIterator(getPathIterator(t), flatness);
    }
View Full Code Here

Examples of java.awt.geom.FlatteningPathIterator

        if (getNeedToRegenerate() || shape == null) {
            return distance;
        }

        PathIterator pi2 = shape.getPathIterator(null);
        FlatteningPathIterator pi = new FlatteningPathIterator(pi2, .25);
        double[] coords = new double[6];
        int count = 0;
        double startPntX = 0;
        double startPntY = 0;
        double endPntX = 0;
        double endPntY = 0;

        while (!pi.isDone()) {
            int type = pi.currentSegment(coords);
            float dist;

            if (type == PathIterator.SEG_LINETO) {
                startPntX = endPntX;
                startPntY = endPntY;
                endPntX = coords[0];
                endPntY = coords[1];

                dist = (float) Line2D.ptSegDist(startPntX,
                        startPntY,
                        endPntX,
                        endPntY,
                        (double) x,
                        (double) y);

                if (dist < distance) {
                    distance = dist;
                }

                if (Debug.debugging("omgraphicdetail")) {
                    Debug.output("Type: " + type + "(" + (count++) + "), "
                            + startPntX + ", " + startPntY + ", " + endPntX
                            + ", " + endPntY + ", " + x + ", " + y
                            + ", distance: " + distance);
                }

            } else {

                // This should be the first and last
                // condition, SEG_MOVETO and SEG_CLOSE
                startPntX = coords[0];
                startPntY = coords[1];
                endPntX = coords[0];
                endPntY = coords[1];
            }

            pi.next();
        }

        return distance;
    }
View Full Code Here

Examples of java.awt.geom.FlatteningPathIterator

     * FlatteningPathIterator, controlling the scope of the path
     * traversal.
     */
    public static void describeShapeDetail(Shape shape, double flattening) {
        PathIterator pi2 = shape.getPathIterator(null);
        FlatteningPathIterator pi = new FlatteningPathIterator(pi2, flattening);
        double[] coords = new double[6];
        int pointCount = 0;

        Debug.output(" -- start describeShapeDetail with flattening["
                + flattening + "]");
        while (!pi.isDone()) {
            int type = pi.currentSegment(coords);
            Debug.output(" Shape point [" + type + "] (" + (pointCount++)
                    + ") " + coords[0] + ", " + coords[1]);
            pi.next();
        }

        Debug.output(" -- end (" + pointCount + ")");
    }
View Full Code Here

Examples of java.awt.geom.FlatteningPathIterator

        if (toShape == null) {
            return addShape;
        }

        PathIterator pi2 = addShape.getPathIterator(null);
        FlatteningPathIterator pi = new FlatteningPathIterator(pi2, .25);
        double[] coords = new double[6];

        while (!pi.isDone()) {
            int type = pi.currentSegment(coords);
            if (lineTo) {
                if (DEBUG) {
                    Debug.output(" adding point [" + type + "] ("
                            + (pointCount++) + ") " + (float) coords[0] + ", "
                            + (float) coords[1]);
                }
                toShape.lineTo((float) coords[0], (float) coords[1]);

            } else {
                if (DEBUG) {
                    Debug.output("Creating new shape, first point "
                            + (float) coords[0] + ", " + (float) coords[1]);
                }
                toShape.moveTo((float) coords[0], (float) coords[1]);
                lineTo = true;
            }
            pi.next();
        }

        if (DEBUG) {
            Debug.output(" -- end point (" + pointCount + ")");
        }
View Full Code Here

Examples of java.awt.geom.FlatteningPathIterator

        // flatness might need to be calculated, based
        // on scale or something. Depends on how many
        // points there should be for an accurate
        // shape rendition.
        float flatness = .25f;
        FlatteningPathIterator pi = new FlatteningPathIterator(pi2, flatness);

        double[] coords = new double[6];
        double pntx = 0;
        double pnty = 0;
        double pntz = baselineHeight;

        HashSet set = new HashSet();
        Shape3D shape3D = null;

        Debug.message("3detail",
                "OMGraphicUtil.createShape3D(): figuring out coordinates");

        // Creating the data[]

        while (!pi.isDone()) {
            int type = pi.currentSegment(coords);

            switch (type) {
            case PathIterator.SEG_MOVETO:
                if (dataIndex != 0) {
                    shape3D = createShape3D(data,
                            dataIndex,
                            stripCount,
                            color,
                            filled);
                    if (shape3D != null) {
                        set.add(shape3D);
                    }
                    data = expandArrayD(bufferSize, null);
                    dataIndex = 0;
                }
            case PathIterator.SEG_LINETO:

                // SEG_MOVETO is the first point of
                // the shape, SEG_LINETO are the
                // middle and end points. SEG_CLOSE
                // confirms the close, but we don't
                // need it.
                pntx = coords[0];
                pnty = coords[1];

                if (Debug.debugging("3detail")) {
                    Debug.output("Shape coordinates: " + pntx + ", " + pnty);
                }

                // Get Z here, if you want to set the height of the
                // coordinate...
                // pntz =

                // See if there is space in the buffer.
                if (dataIndex >= data.length) {
                    data = expandArrayD(bufferSize, data);
                    refreshCounter = bufferSize;
                }

                data[dataIndex++] = pntx;
                data[dataIndex++] = pntz;
                data[dataIndex++] = pnty;

                //              data[dataIndex++] = pntx;
                //              data[dataIndex++] = pnty;
                //              data[dataIndex++] = pntz;

                stripCount[0]++;

                refreshCounter -= 3;
                break;
            default:
                // Do nothing, because it's a repeat
                // of the last SEG_LINETO point.

                Debug.message("3detail", "Shape coordinates: " + coords[0]
                        + ", " + coords[1] + " rounding out SEG_CLOSE");
            }

            pi.next();
        }

        if (dataIndex != 0) {
            shape3D = createShape3D(data, dataIndex, stripCount, color, filled);
            if (shape3D != null) {
View Full Code Here

Examples of java.awt.geom.FlatteningPathIterator

        double oldx = -1, oldy = -1;

        final double flateness = 0.8;
        final double inset = 4;

        FlatteningPathIterator i = new FlatteningPathIterator(iterator, flateness);
        while(!i.isDone()) {
            switch(i.currentSegment(coord)) {
                case FlatteningPathIterator.SEG_MOVETO:
                    oldx = coord[0];
                    oldy = coord[1];
                    break;

                case FlatteningPathIterator.SEG_LINETO:
                    double nx = coord[0];
                    double ny = coord[1];

                    double rx1 = Math.min(oldx, nx);
                    double ry1 = Math.min(oldy, ny);
                    double rx2 = Math.max(oldx, nx);
                    double ry2 = Math.max(oldy, ny);

                    if(Math.abs(rx1-rx2)<inset || Math.abs(ry1-ry2)<inset) {
                        rx1 -= inset;
                        ry1 -= inset;
                        rx2 += inset;
                        ry2 += inset;
                    }

                    if(x>=rx1 && x<=rx2 && y>=ry1 && y<=ry2)
                        return true;

                    oldx = nx;
                    oldy = ny;
                    break;
            }
            i.next();
        }
        return false;
    }
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.