Package java.awt.geom

Examples of java.awt.geom.GeneralPath


        Object first = extraPoints.get(0);
        extraPoints.remove(0);
        extraPoints.add(first);

        GeneralPath path = new GeneralPath();

        int m = extraPoints.size();
        ensureBases(m);

        segments.clear();

        // Iterate over segments:
        for (int i=3; i<m-1; i++) {

            Polynomial xNum = new Polynomial(0);
            Polynomial yNum = new Polynomial(0);

            Polynomial xDen = new Polynomial(0);
            Polynomial yDen = new Polynomial(0);

            // Iterate over control points:
            for (int j=0; j<m; j++) {

                Point2D p = (Point2D) extraPoints.get(j);

                BasisFunction basis = (BasisFunction) Bases.get(j);

                double px = p.getX();
                double py = p.getY();

                Polynomial xSegNum = basis.getSegment(i).multiply(px * Weight);
                Polynomial ySegNum = basis.getSegment(i).multiply(py * Weight);

                Polynomial xSegDen = basis.getSegment(i).multiply(Weight);
                Polynomial ySegDen = basis.getSegment(i).multiply(Weight);

                xNum = xNum.add(xSegNum);
                yNum = yNum.add(ySegNum);

                xDen = xDen.add(xSegDen);
                yDen = yDen.add(ySegDen);
            }
            Shape curve = Polynomial.createRationalShape(
                xNum, xDen, yNum, yDen, i, i + 1, .1
            );
            segments.add(curve);
            path.append(curve, true);
        }
        path.closePath();
        shape = path;
    }
View Full Code Here


        Object first = extraPoints.get(0);
        extraPoints.remove(0);
        extraPoints.add(first);

        GeneralPath path = new GeneralPath();

        int m = extraPoints.size();
        ensureBases(m);

        segments.clear();

        // Iterate over segments:
        for (int i=3; i<m-1; i++) {

            Polynomial xNum = new Polynomial(0);
            Polynomial yNum = new Polynomial(0);

            Polynomial xDen = new Polynomial(0);
            Polynomial yDen = new Polynomial(0);

            // Iterate over control points:
            for (int j=0; j<m; j++) {

                Point2D p = (Point2D) extraPoints.get(j);

                BasisFunction basis = (BasisFunction) Bases.get(j);

                double px = p.getX();
                double py = p.getY();

                Polynomial xSegNum = basis.getSegment(i).multiply(px * Weight);
                Polynomial ySegNum = basis.getSegment(i).multiply(py * Weight);

                Polynomial xSegDen = basis.getSegment(i).multiply(Weight);
                Polynomial ySegDen = basis.getSegment(i).multiply(Weight);

                xNum = xNum.add(xSegNum);
                yNum = yNum.add(ySegNum);

                xDen = xDen.add(xSegDen);
                yDen = yDen.add(ySegDen);
            }
            Shape curve = Polynomial.createRationalShape(
                xNum, xDen, yNum, yDen, i, i + 1, .1
            );
            segments.add(curve);
            path.append(curve, true);
        }
        path.closePath();
        shape = path;
    }
View Full Code Here

        backgroundStroke = new BasicStroke(3f * radius / 8f);

        float x = (float) point.getX();
        float y = (float) point.getY();

        shape = new GeneralPath();
        shape.moveTo(x, y - radius);
        shape.lineTo(x, y - radius / 2);
        shape.moveTo(x, y + radius / 2);
        shape.lineTo(x, y + radius);
        shape.moveTo(x - radius, y);
View Full Code Here

        ArrayList extraPoints = new ArrayList(points);
        extraPoints.add(0, points.get(points.size() - 1));
        extraPoints.add(points.get(0));

        GeneralPath path = new GeneralPath();

        int m = extraPoints.size();
        ensureBases(m);

        segments.clear();

        // Iterate over segments:
        for (int i=2; i<m; i++) {

            Polynomial xPoly = new Polynomial(0);
            Polynomial yPoly = new Polynomial(0);

            // Iterate over control points:
            for (int j=0; j<m; j++) {

                Point2D p = (Point2D) extraPoints.get(j);

                BasisFunction basis = (BasisFunction) Bases.get(j);

                double px = p.getX();
                double py = p.getY();

                Polynomial xSeg = basis.getSegment(i).multiply(px);
                Polynomial ySeg = basis.getSegment(i).multiply(py);

                xPoly = xPoly.add(xSeg);
                yPoly = yPoly.add(ySeg);
            }
            xPoly = xPoly.translate(i);
            yPoly = yPoly.translate(i);

            Shape curve = Polynomial.createShape(xPoly, yPoly);
            segments.add(curve);
            path.append(curve, true);
        }
        path.closePath();
        shape = path;
    }
View Full Code Here

        double start, double end, double inc
    ) {
        double oldX = xNum.evaluate(start) / xDen.evaluate(start);
        double oldY = yNum.evaluate(start) / yDen.evaluate(start);

        GeneralPath path = new GeneralPath();
        for (double t=start; t<=end; t+=inc) {
            double newX = xNum.evaluate(t) / xDen.evaluate(t);
            double newY = yNum.evaluate(t) / yDen.evaluate(t);
            Line2D line = new Line2D.Double(oldX, oldY, newX, newY);
            path.append(line, true);
            oldX = newX;
            oldY = newY;
        }
        return path;
    }
View Full Code Here

        Object first = extraPoints.get(0);
        extraPoints.remove(0);
        extraPoints.add(first);

        GeneralPath path = new GeneralPath();

        int m = extraPoints.size();
        ensureBases(m);

        segments.clear();

        // Iterate over segments:
        for (int i=3; i<m-1; i++) {

            Polynomial xPoly = new Polynomial(0);
            Polynomial yPoly = new Polynomial(0);

            // Iterate over control points:
            for (int j=0; j<m; j++) {

                Point2D p = (Point2D) extraPoints.get(j);

                BasisFunction basis = (BasisFunction) Bases.get(j);

                double px = p.getX();
                double py = p.getY();

                Polynomial xSeg = basis.getSegment(i).multiply(px);
                Polynomial ySeg = basis.getSegment(i).multiply(py);

                xPoly = xPoly.add(xSeg);
                yPoly = yPoly.add(ySeg);
            }
            xPoly = xPoly.translate(i);
            yPoly = yPoly.translate(i);

            Shape curve = Polynomial.createShape(xPoly, yPoly);
            segments.add(curve);
            path.append(curve, true);
        }
        path.closePath();
        shape = path;
    }
View Full Code Here

        if (points.size() < 2) {
            shape = null;
            segments.clear();
            return;
        }
        GeneralPath path = new GeneralPath();

        segments.clear();

        Point2D p = (Point2D) points.get(0);
        for (int n=1; n<points.size(); n++) {
            Point2D q = (Point2D) points.get(n);
            Line2D line =
                new Line2D.Double(p.getX(), p.getY(), q.getX(), q.getY());
            segments.add(line);
            path.append(line, true);
            p = q;
        }
        path.closePath();
        shape = path;
    }
View Full Code Here

                int numBins = bins[c].length;

                int zeroY = s.yscale(0);
                float xstep = (width+1) / numBins;

                GeneralPath gp = new GeneralPath();

                gp.moveTo(minx, zeroY);
                float lastx = minx;
                float lasty = zeroY;
                for (int i = 0; i < numBins; i++) {
                    int y = s.yscale(bins[c][i]);
                    float x = xstep * i + minx;
                    if (lasty != zeroY || y != zeroY) {
                        gp.lineTo(x, y);
                        lastx = x;
                        lasty = y;
                    }
                }
                if (lasty != zeroY)
                    gp.lineTo(lastx, zeroY);

                g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
                g2d.fill(gp);
                g2d.setComposite(AlphaComposite.SrcOver);
                g2d.draw(gp);
View Full Code Here

        isManualWidthSet = true;
    }

    void updateShape() {
        if (points.size() != 2) {
            shape = new GeneralPath();
            return;
        }
        Point2D p1 = (Point2D) points.get(0);
        Point2D p2 = (Point2D) points.get(1);

        double minX = Math.min(p1.getX(), p2.getX());
        double minY = Math.min(p1.getY(), p2.getY());
        double maxX = Math.max(p1.getX(), p2.getX());
        double maxY = Math.max(p1.getY(), p2.getY());

        double x = minX;
        double y = minY;
        double w = maxX - minX;
        double h = maxY - minY;

        Rectangle2D bounds = new Rectangle2D.Double(x, y, w, h);

        Shape ne = new Arc2D.Double(bounds, -45, 180, Arc2D.OPEN);
        Shape sw = new Arc2D.Double(bounds, 135, 180, Arc2D.OPEN);

        segments.clear();
        segments.add(ne);
        segments.add(sw);

        float[] start = new float[6];
        ne.getPathIterator(null).currentSegment(start);

        GeneralPath path = new GeneralPath();
        path.moveTo(start[0], start[1]);
        path.append(ne, true);
        path.append(sw, true);
        path.closePath();

        shape = path;
    }
View Full Code Here

        if (points.size() < 2) {
            shape = null;
            segments.clear();
            return;
        }
        GeneralPath path = new GeneralPath();

        int[] xPts = new int[points.size()];
        int[] yPts = new int[points.size()];

        int count = 0;
        for (Iterator i=points.iterator(); i.hasNext(); ) {
            Point2D p = (Point2D) i.next();
            xPts[count] = (int) p.getX();
            yPts[count] = (int) p.getY();
            count++;
        }
        Cubic[] xPoly = calcNaturalCubic(xPts);
        Cubic[] yPoly = calcNaturalCubic(yPts);

        segments.clear();
        for (int n=0; n<count; n++) {
            Shape curve = Cubic.createShape(xPoly[n], yPoly[n]);
            segments.add(curve);
            path.append(curve, true);
        }
        path.closePath();
        shape = path;
    }
View Full Code Here

TOP

Related Classes of java.awt.geom.GeneralPath

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.