Package org.eclipse.draw2d.geometry

Examples of org.eclipse.draw2d.geometry.PointList


     * @param conn
     */
    @SuppressWarnings("unchecked")
  static void recordFinalState(Connection conn) {
        //$TODO
        PointList points1 = (PointList) initialStates.get(conn);
        PointList points2 = conn.getPoints().getCopy();

        if (points1 != null && points1.size() != points2.size()) {
            Point p = new Point(), q = new Point();

            int size1 = points1.size() - 1;
            int size2 = points2.size() - 1;

            int i1 = size1;
            int i2 = size2;

            double current1 = 1.0;
            double current2 = 1.0;

            double prev1 = 1.0;
            double prev2 = 1.0;

            while (i1 > 0 || i2 > 0) {
                if (Math.abs(current1 - current2) < 0.1 && i1 > 0 && i2 > 0) {
                    //Both points are the same, use them and go on;
                    prev1 = current1;
                    prev2 = current2;
                    i1--;
                    i2--;
                    current1 = (double) i1 / size1;
                    current2 = (double) i2 / size2;
                }
                else if (current1 < current2) {
                    //2 needs to catch up
                    // current1 < current2 < prev1
                    points1.getPoint(p, i1);
                    points1.getPoint(q, i1 + 1);

                    p.x = (int) (((q.x * (current2 - current1) + p.x
                            * (prev1 - current2)) / (prev1 - current1)));
                    p.y = (int) (((q.y * (current2 - current1) + p.y
                            * (prev1 - current2)) / (prev1 - current1)));

                    points1.insertPoint(p, i1 + 1);

                    prev1 = prev2 = current2;
                    i2--;
                    current2 = (double) i2 / size2;

                }
                else {
                    //1 needs to catch up
                    // current2< current1 < prev2

                    points2.getPoint(p, i2);
                    points2.getPoint(q, i2 + 1);

                    p.x = (int) (((q.x * (current1 - current2) + p.x
                            * (prev2 - current1)) / (prev2 - current2)));
                    p.y = (int) (((q.y * (current1 - current2) + p.y
                            * (prev2 - current1)) / (prev2 - current2)));

                    points2.insertPoint(p, i2 + 1);

                    prev2 = prev1 = current1;
                    i1--;
                    current1 = (double) i1 / size1;
                }
View Full Code Here


     */
    @SuppressWarnings("unchecked")
  static void recordInitialState(Connection connection) {
        if (!RECORDING)
            return;
        PointList points = connection.getPoints().getCopy();
        if (points.size() == 2
                && points.getPoint(0).equals(Point.SINGLETON.setLocation(0, 0))
                && points.getPoint(1).equals(
                        Point.SINGLETON.setLocation(100, 100)))
            initialStates.put(connection, null);
        else
            initialStates.put(connection, points);
    }
View Full Code Here

TOP

Related Classes of org.eclipse.draw2d.geometry.PointList

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.