Package org.codemap.util.geom

Examples of org.codemap.util.geom.CubicCurve2D


        fourPoints[1] = parent;
        fourPoints[2] = child;
        fourPoints[3] = grandChild;

        Shape shape = edge.getShape();
        CubicCurve2D myCurve;
        if (shape == null) {
            myCurve = new CubicCurve2D.Double();
            edge.setShape(myCurve);
        } else {
            myCurve = (CubicCurve2D)shape;
        }
       
        BezierSpline.computeOneSpline(grandParent, parent, child, grandChild, myCurve);

        // 11. Now do some tweaking of the control points to ensure continuity.
        // need to tweak the first control point to be collinear with the parent
        // and the grandparent and have the same distance as the
        // parent-grandparent
        double parentGrandDist = grandParent.distance(parent);

        Vector2D grandToParent = new Vector2D(grandParent, parent);
        //System.out.println(grandToParent);
        //now take the grandToParent vector, scale by parentGrandDistance, add
        // it to the parent vector
       
          Point2D collinShift = new Point2D.Double(parentGrandDist
                * grandToParent.getNormalized().getX() + parent.getX(),
                parentGrandDist * grandToParent.getNormalized().getY()
                        + parent.getY());
        //System.out.println("before: " + myCurve.getP1() + ", "
        // +myCurve.getCtrlP1() + ", " + myCurve.getCtrlP2() + ", " +
        // myCurve.getP2() );
        myCurve.setCurve(myCurve.getP1(), collinShift, myCurve.getCtrlP2(),
                myCurve.getP2());
        GraphicsGems.checkNaN(myCurve.getP1());
        GraphicsGems.checkNaN(myCurve.getP2());
        GraphicsGems.checkNaN(myCurve.getCtrlP1());
        GraphicsGems.checkNaN(myCurve.getCtrlP2());
       
        //System.out.println("after: " + myCurve.getP1() + ", "
        // +myCurve.getCtrlP1() + ", " + myCurve.getCtrlP2() + ", " +
        // myCurve.getP2() );

        //System.out.println("CollinShift dist: " +
        // collinShift.distance(parent) + " and p-GP dist: " + parentGrandDist);

        // 10. Need to set the previous control point for the child node
        Node otherItem = edge.getSecondNode();
        otherItem.setPrevControlPoint(myCurve.getCtrlP2());

        //System.out.println("Prev Control Point for " +
        // ((FlowNode)otherItem.getEntity()).toStringId() + " was set to prev
        // control point: " + grandParent);
       
        if ((m_additiveEdges) && (shiftPoint != null)) {
           
       
            // 12. Now shift the bezier points to line up properly with the horizontal translation
            // that takes into account the thickness of the curve. We do this by shifting
            // the first two points of every bezier to get it to line up in the appropriate place
            Point2D grandParentShift = new Point2D.Double(myCurve.getP1().getX()+shiftPoint.getX(),
                myCurve.getP1().getY()+shiftPoint.getY());
            Point2D parentShift = new Point2D.Double(myCurve.getCtrlP1().getX()+shiftPoint.getX(),
                myCurve.getCtrlP1().getY()+shiftPoint.getY());
            myCurve.setCurve(grandParentShift, parentShift, myCurve.getCtrlP2(), myCurve.getP2());
        }
        GraphicsGems.checkNaN(myCurve.getP1());
        GraphicsGems.checkNaN(myCurve.getP2());
        GraphicsGems.checkNaN(myCurve.getCtrlP1());
        GraphicsGems.checkNaN(myCurve.getCtrlP2());

        return displayWidth;
    }   
View Full Code Here


    // given a list of points to interpolate through (catmull rom points),
    // returns a List
    // of CubicCurve2D objects with the curves to interpolate through
    public static Collection<CubicCurve2D> computeSplines(Point2D[] points) {
        List<CubicCurve2D> newCubics = new ArrayList<CubicCurve2D>();
        CubicCurve2D bezierCurve;
        int i;

        // now separate out the points. we assume that there are at least 4
        // points,
        // of which the first and last are dummy points (so there are only 2
View Full Code Here

TOP

Related Classes of org.codemap.util.geom.CubicCurve2D

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.