Package diva.util.java2d

Examples of diva.util.java2d.Polyline2D


            public void init() throws Exception {
                shapes[0] = new Rectangle2D.Double(10, 20, 30, 40);
                shapes[1] = new Ellipse2D.Double(10, 20, 30, 40);
                shapes[2] = new Area(ShapeUtilities.createSwatchShape());

                Polyline2D polyline = new Polyline2D.Double(10, 20, 30, 40);
                polyline.lineTo(50, 60);
                polyline.lineTo(50, 60);

                Polygon2D polygon = new Polygon2D.Double(10, 20);
                polygon.lineTo(20, 30);
                polygon.lineTo(40, 50);
                polygon.lineTo(60, 70);
View Full Code Here


            public void init() throws Exception {
                shapes[0] = new Area(ShapeUtilities.createSwatchShape());
                shapes[1] = new Rectangle2D.Double(10, 20, 30, 40);
                shapes[2] = new Ellipse2D.Double(10, 20, 30, 40);

                Polyline2D polyline = new Polyline2D.Double(10, 20, 30, 40);
                polyline.lineTo(50, 60);
                polyline.lineTo(50, 60);

                Polygon2D polygon = new Polygon2D.Double(10, 20);
                polygon.lineTo(20, 30);
                polygon.lineTo(40, 50);
                polygon.lineTo(60, 70);
View Full Code Here

            processPaintedPathAttributes(pp, attributes);
            return pp;
        } else if (type.equals("polyline")) {
            double[] coords = parseCoordString((String) attributes
                    .get("points"));
            Polyline2D poly = new Polyline2D.Double();
            poly.moveTo(coords[0], coords[1]);

            for (int i = 2; i < coords.length; i += 2) {
                poly.lineTo(coords[i], coords[i + 1]);
            }

            PaintedPath pp = new PaintedPath(poly);
            processPaintedPathAttributes(pp, attributes);
            return pp;
        } else if (type.equals("polygon")) {
            double[] coords = parseCoordString((String) attributes
                    .get("points"));
            Polygon2D poly = new Polygon2D.Double();
            poly.moveTo(coords[0], coords[1]);

            for (int i = 2; i < coords.length; i += 2) {
                poly.lineTo(coords[i], coords[i + 1]);
            }

            poly.closePath();

            PaintedShape ps = new PaintedShape(poly);
            processPaintedShapeAttributes(ps, attributes);
            return ps;
        } else if (type.equals("text")) {
View Full Code Here

            coords[3] = coords[1] + r.getHeight();
            return convertCoords(coords, coords.length);
        }

        if (shape instanceof Polyline2D) {
            Polyline2D p = (Polyline2D) shape;
            int n = p.getVertexCount();
            coords = new double[n * 2];
            for (int i = 0; i < n; i++) {
                coords[i * 2] = p.getX(i);
                coords[i * 2 + 1] = p.getY(i);
            }
            return convertCoords(coords, coords.length);
        }

        if (shape instanceof Polygon2D) {
            Polygon2D p = (Polygon2D) shape;
            int n = p.getVertexCount();
            coords = new double[n * 2];
            for (int i = 0; i < n; i++) {
                coords[i * 2] = p.getX(i);
                coords[i * 2 + 1] = p.getY(i);
            }
            return convertCoords(coords, coords.length);
        }

        // For Path2D, the integer path type is inserted before the coordinates of each segment
        if (shape instanceof Path2D) {
            Path2D p = (Path2D) shape;
            StringBuffer buf = new StringBuffer();
            coords = new double[6];
            PathIterator pathIter = p.getPathIterator(null);
            while (!pathIter.isDone()) {
                int subPathType = pathIter.currentSegment(coords);
                buf.append(subPathType).append(" ");
                if (subPathType == PathIterator.SEG_MOVETO || subPathType == PathIterator.SEG_LINETO) {
                    buf.append(convertCoords(coords, 2)).append(" ");
View Full Code Here

TOP

Related Classes of diva.util.java2d.Polyline2D

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.