Package java.awt.geom

Examples of java.awt.geom.PathIterator


                    // 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


            int width = SLDs.width(SLDs.stroke(pointSymbolizer));
            if (width < 0) {
                width = 0;
            }
            float[] point = new float[6];
            PathIterator pathIterator = shape.getPathIterator(null);
            pathIterator.currentSegment(point);

            SLDStyleFactory styleFactory = new SLDStyleFactory();
            Style2D tmp = null;
            try {
                tmp = styleFactory.createStyle(feature, pointSymbolizer, new NumberRange(Double.class, Double.NEGATIVE_INFINITY,
View Full Code Here

        curveTo(20,10,30,20,30,30);//4
        quadTo(40,40, 50, 10);//3
        close();//5
       
        PathToPathIteratorAdapter pi=new PathToPathIteratorAdapter(p);
        PathIterator i = gp.getPathIterator(new AffineTransform());
       
        while(!i.isDone()){
            assertFalse("More content then we expected", pi.isDone());
           
            float[] expected=new float[6];
            float[] actual=new float[6];
            int expectedSegment = i.currentSegment(expected);
            int actualSegement = pi.currentSegment(actual);
           
            assertEquals(toName(expectedSegment), toName(actualSegement));
           
            for( int j = 0; j < actual.length; j++ ) {
                assertEquals(expected[j], actual[j], 0);
            }
            i.next();
            pi.next();
        }
        assertTrue("Less content then we expected", pi.isDone());
       
        pi=new PathToPathIteratorAdapter(p);
        i = gp.getPathIterator(new AffineTransform());
       
        while(!i.isDone()){
            assertFalse(pi.isDone());
           
            float[] expected=new float[6];
            float[] actual=new float[6];
           
            assertEquals(i.currentSegment(expected),
                    pi.currentSegment(actual));
           
            for( int j = 0; j < actual.length; j++ ) {
                assertEquals(expected[j], actual[j], 0);
            }
            i.next();
            pi.next();
        }
        assertTrue(pi.isDone());
       
    }
View Full Code Here

        if (arc == null) {
            return null;
        }

        double flatness = calculateMaxDistanceToCurve(arc, pointsPerQuadrant);
        PathIterator pathIterator = arc.getPathIterator((AffineTransform) null, flatness);
        List<Coordinate> coords = new LinkedList<Coordinate>();

        double[] coordsHolder = new double[6];

        while( !pathIterator.isDone() ) {
            int pathSegType = pathIterator.currentSegment(coordsHolder);
            double x = coordsHolder[0];
            double y = coordsHolder[1];
            switch( pathSegType ) {
            case PathIterator.SEG_MOVETO:
                assert coords.size() == 0;
                break;
            case PathIterator.SEG_LINETO:
                // ok
                break;
            default:
                throw new IllegalStateException("Unexpected path segment type: " + pathSegType);
            }
            coords.add(new Coordinate(x, y));
            pathIterator.next();
        }

        Coordinate[] coordinates = coords.toArray(new Coordinate[coords.size()]);
        LineString line = gf.createLineString(coordinates);
        return line;
View Full Code Here

    /**
     * @see org.locationtech.udig.project.render.ViewportGraphics#draw(java.awt.Shape)
     */
    public void draw( Shape s ) {
        PathIterator p = s.getPathIterator(transform, 1);
        if (p.isDone())
            return;

        Path path = AWTSWTImageUtils.createPath(p, display);
        gc.drawPath(path);
        float[] points = path.getPathData().points;
View Full Code Here

    /**
     * @see org.locationtech.udig.project.render.ViewportGraphics#draw(java.awt.Shape)
     */
    public void fill( Shape s ) {
        gc.setBackground(fore);
        PathIterator p = s.getPathIterator(transform);
        Path path = AWTSWTImageUtils.createPath(p, display);
        gc.fillPath(path);
        path.dispose();
        gc.setBackground(back);
    }
View Full Code Here

            return handler.isLockOwner(this) && eventType==EventType.RELEASED && e.button==MapMouseEvent.BUTTON1;
        }

        public UndoableMapCommand getCommand( EditToolHandler handler, MapMouseEvent e, EventType eventType ) {
            try{
                PathIterator iter = drawCommand.getShape().getPathIterator(AffineTransform.getTranslateInstance(0,0), 1.0);
                UndoableComposite commands=new UndoableComposite();
                commands.getCommands().add(handler.getContext().getEditFactory().createNullEditFeatureCommand());
                EditBlackboard bb = handler.getEditBlackboard(handler.getEditLayer());
                commands.getCommands().add(new DeselectEditGeomCommand(handler, bb.getGeoms()));
                ShapeType shapeType = determineLayerType(handler);
View Full Code Here

     * @param shape
     * @return the shape converted to a {@link Path} object.
     */
    public static Path convertToPath( Shape shape, Device device  ) {
        AWTSWTImageUtils.checkAccess();
        PathIterator p = shape.getPathIterator(SWTGraphics.AFFINE_TRANSFORM);
   
        return AWTSWTImageUtils.createPath(p, device);
    }
View Full Code Here

            return path;
        }

        protected void draw(Graphics g, Shape shape, Color[] colors) {
            final float[] coords = new float[6];
            final PathIterator i = shape.getPathIterator(null);
            int moveX = 0;
            int moveY = 0;
            int curX = 0;
            int curY = 0;
            int x;
            int y;
            int loop = 0;
            while (!i.isDone()) {
                g.setColor(colors[loop++]);
                final int type = i.currentSegment(coords);
                switch (type) {
                    case PathIterator.SEG_MOVETO:
                        curX = moveX = (int) coords[0];
                        curY = moveY = (int) coords[1];
                        break;
                    case PathIterator.SEG_LINETO:
                        x = (int) coords[0];
                        y = (int) coords[1];
                        g.drawLine(curX, curY, x, y);
                        curX = x;
                        curY = y;
                        break;
                    case PathIterator.SEG_CLOSE:
                        g.drawLine(moveX, moveY, curX, curY);
                        break;
                    case PathIterator.SEG_CUBICTO:
                        drawCurve(g, curX, curY, coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
                        curX = (int) coords[4];
                        curY = (int) coords[5];
                        break;
                    case PathIterator.SEG_QUADTO:
//                  log.debug("QUADTO not implemented yet");
                        // Not implemented yet
                        break;
                }
                i.next();
            }
        }
View Full Code Here

  implements Testlet
{
  public void test(TestHarness harness)
  {
    Line2D line1 = new Line2D.Double(1.0, 2.0, 3.0, 4.0);
    PathIterator iterator = line1.getPathIterator(null);
    double[] c = new double[6];
   
    harness.check(!iterator.isDone());                                  
    harness.check(iterator.currentSegment(c), PathIterator.SEG_MOVETO)
    harness.check(c[0], 1.0);                                      
    harness.check(c[1], 2.0);  

    iterator.next();
    harness.check(!iterator.isDone());                                  
    harness.check(iterator.currentSegment(c), PathIterator.SEG_LINETO)
    harness.check(c[0], 3.0);                                      
    harness.check(c[1], 4.0)

    iterator.next();
    harness.check(iterator.isDone());
  }
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.