Package java.awt.geom

Examples of java.awt.geom.PathIterator


                return;
            }
        }

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


            if (!clip.getBounds().contains(bounds)) {
                return;
            }
        }

        PathIterator it = shape.getPathIterator(transform);
        double[] prev = null;
        double[] coords = new double[6];
        double[] first = new double[6];
        if(!it.isDone()) it.currentSegment(first); //first point
        while(!it.isDone()){
            int type = it.currentSegment(coords);
            if (prev != null ){
                Line line = new Line(group);
                if (stroke instanceof BasicStroke){
                    BasicStroke bs = (BasicStroke)stroke;
                    line.setLineWidth(bs.getLineWidth());
                    float[] dash = bs.getDashArray();
                    if (dash != null) line.setLineDashing(Line.PEN_DASH);
                }
                if(getColor() != null) line.setLineColor(getColor());
                if (type == PathIterator.SEG_LINETO) {
                    line.setAnchor(new java.awt.Rectangle((int)prev[0](int)prev[1], (int)(coords[0] - prev[0]), (int)(coords[1] - prev[1])));
                } else if (type == PathIterator.SEG_CLOSE){
                    line.setAnchor(new java.awt.Rectangle((int)coords[0](int)coords[1], (int)(first[0] - coords[0]), (int)(first[1] - coords[1])));
                }
                group.addShape(line);
            }
            prev = new double[]{coords[0],  coords[1]};
            it.next();
        }

    }
View Full Code Here

            if (bounds.height == 0) bounds.height = 1;
             if (!clip.getBounds().contains(bounds)) {
                return;
            }
        }
        PathIterator it = shape.getPathIterator(transform);
        ArrayList pnt = new ArrayList();
        double[] coords = new double[6];
        while(!it.isDone()){
            int type = it.currentSegment(coords);
            if (type != PathIterator.SEG_CLOSE) {
                pnt.add(new Point((int)coords[0], (int)coords[1]));
            }
            it.next();
        }
        int[] xPoints= new int[pnt.size()];
        int[] yPoints= new int[pnt.size()];
        for (int i = 0; i < pnt.size(); i++) {
            Point p = (Point)pnt.get(i);
View Full Code Here

     * Builds a proxy <tt>GraphicsNode</tt> for the input <tt>Marker</tt> to be
     * drawn at the start position
     */
    protected ProxyGraphicsNode buildStartMarkerProxy() {

        PathIterator iter = getShape().getPathIterator(null);

        // Get initial point on the path
        double coords[] = new double[6];
        int segType = 0;

        if (iter.isDone()) {
            return null;
        }

        segType = iter.currentSegment(coords);
        if (segType != iter.SEG_MOVETO) {
            return null;
        }
        iter.next();

        Point2D markerPosition = new Point2D.Double(coords[0], coords[1]);

        // If the marker's orient property is NaN,
        // the slope needs to be computed
        double rotation = startMarker.getOrient();
        if (Double.isNaN(rotation)) {
            if (!iter.isDone()) {
                double next[] = new double[6];
                int nextSegType = 0;
                nextSegType = iter.currentSegment(next);
                if(nextSegType == PathIterator.SEG_CLOSE){
                    nextSegType = PathIterator.SEG_LINETO;
                    next[0] = coords[0];
                    next[1] = coords[1];
                }
View Full Code Here

     * Builds a proxy <tt>GraphicsNode</tt> for the input <tt>Marker</tt> to be
     * drawn at the end position.
     */
    protected ProxyGraphicsNode buildEndMarkerProxy() {

        PathIterator iter = getShape().getPathIterator(null);

        int nPoints = 0;

        // Get first point, in case the last segment on the
        // path is a close
        if (iter.isDone()) {
            return null;
        }
 
        double coords[] = new double[6];
        double moveTo[] = new double[2];
        int segType = 0;
        segType = iter.currentSegment(coords);
        if (segType != iter.SEG_MOVETO) {
            return null;
        }
        nPoints++;
        moveTo[0] = coords[0];
        moveTo[1] = coords[1];

        iter.next();
       
        // Now, get the last two points on the path
        double[] lastButOne = new double[6];
        double[] last = {coords[0], coords[1], coords[2],
                         coords[3], coords[4], coords[5] }, tmp = null;
        int lastSegType = segType;
        int lastButOneSegType = 0;

        while (!iter.isDone()) {
            tmp = lastButOne;
            lastButOne = last;
            last = tmp;
            lastButOneSegType = lastSegType;

            lastSegType = iter.currentSegment(last);

            if (lastSegType == PathIterator.SEG_MOVETO) {
                moveTo[0] = last[0];
                moveTo[1] = last[1];
            } else if (lastSegType == PathIterator.SEG_CLOSE) {
                lastSegType = PathIterator.SEG_LINETO;
                last[0] = moveTo[0];
                last[1] = moveTo[1];
            }

            iter.next();
            nPoints++;
        }

        if (nPoints < 2) {
            return null;
View Full Code Here

     * Builds a proxy <tt>GraphicsNode</tt> for the input <tt>Marker</tt> to be
     * drawn at the middle positions
     */
    protected ProxyGraphicsNode[] buildMiddleMarkerProxies() {

        PathIterator iter = getShape().getPathIterator(null);

        double[] prev = new double[6];
        double[] cur = new double[6];
        double[] next = new double[6], tmp = null;
        int prevSegType = 0, curSegType = 0, nextSegType = 0;

        // Get the first three points on the path
        if (iter.isDone()) {
            return null;
        }

        prevSegType = iter.currentSegment(prev);
        double[] moveTo = new double[2];

        if (prevSegType != PathIterator.SEG_MOVETO) {
            return null;
        }

        moveTo[0] = prev[0];
        moveTo[1] = prev[1];
        iter.next();

        if (iter.isDone()) {
            return null;
        }
 
        curSegType = iter.currentSegment(cur);

        if (curSegType == PathIterator.SEG_MOVETO) {
            moveTo[0] = cur[0];
            moveTo[1] = cur[1];
        } else if (curSegType == PathIterator.SEG_CLOSE) {
            curSegType = PathIterator.SEG_LINETO;
            cur[0] = moveTo[0];
            cur[1] = moveTo[1];
        }

        iter.next();

        Vector proxies = new Vector();
        while (!iter.isDone()) {
            nextSegType = iter.currentSegment(next);

            if (nextSegType == PathIterator.SEG_MOVETO) {
                moveTo[0] = next[0];
                moveTo[1] = next[1];
            } else if (nextSegType == PathIterator.SEG_CLOSE) {
                nextSegType = PathIterator.SEG_LINETO;
                next[0] = moveTo[0];
                next[1] = moveTo[1];
            }
     
            proxies.addElement(createMiddleMarker(prev, prevSegType,
                                                  cur, curSegType,
                                                  next, nextSegType));
           
            tmp = prev;
            prev = cur;
            prevSegType = curSegType;
            cur = next;
            curSegType = nextSegType;
            next = tmp;
           
            iter.next();
        }

        ProxyGraphicsNode [] gn = new ProxyGraphicsNode[proxies.size()];
        proxies.copyInto(gn);

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

        if (!nativePen) {
            super.draw(s);
            return;
        }

        PathIterator pi = s.getPathIterator(transform, 0.5);
        int len = getPathArray(pi);
        drawShape(gi, pathArray, len, pi.getWindingRule());
    }
View Full Code Here

            MultiRectArea mra = jsr.rasterize(s, 0.5);
            super.fillMultiRectAreaPaint(mra);
            return;
        }

        PathIterator pi = s.getPathIterator(transform, 0.5);
        int len = getPathArray(pi);
        fillShape(gi, pathArray, len, pi.getWindingRule());
    }
View Full Code Here

    public void draw(Shape s) {
        if (stroke instanceof BasicStroke && ((BasicStroke)stroke).getLineWidth() <= 1) {
            //TODO: Think about drawing the shape in one fillMultiRectArea call
            BasicStroke bstroke = (BasicStroke)stroke;
            JavaLineRasterizer.LineDasher ld = (bstroke.getDashArray() == null)?null:new JavaLineRasterizer.LineDasher(bstroke.getDashArray(), bstroke.getDashPhase());
            PathIterator pi = s.getPathIterator(transform, 0.5);
            float []points = new float[6];
            int x1 = Integer.MIN_VALUE;
            int y1 = Integer.MIN_VALUE;
            int cx1 = Integer.MIN_VALUE;
            int cy1 = Integer.MIN_VALUE;
            while (!pi.isDone()) {
                switch (pi.currentSegment(points)) {
                    case PathIterator.SEG_MOVETO:
                        x1 = (int)Math.floor(points[0]);
                        y1 = (int)Math.floor(points[1]);
                        cx1 = x1;
                        cy1 = y1;
                        break;
                    case PathIterator.SEG_LINETO:
                        int x2 = (int)Math.floor(points[0]);
                        int y2 = (int)Math.floor(points[1]);
                        fillMultiRectArea(JavaLineRasterizer.rasterize(x1, y1, x2, y2, null, ld, false));
                        x1 = x2;
                        y1 = y2;
                        break;
                    case PathIterator.SEG_CLOSE:
                        x2 = cx1;
                        y2 = cy1;
                        fillMultiRectArea(JavaLineRasterizer.rasterize(x1, y1, x2, y2, null, ld, false));
                        x1 = x2;
                        y1 = y2;
                        break;
                }
                pi.next();
            }
        } else {
            s = stroke.createStrokedShape(s);
            s = transform.createTransformedShape(s);
            fillMultiRectArea(jsr.rasterize(s, 0.5));
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.