Package org.eclipse.draw2d.geometry

Examples of org.eclipse.draw2d.geometry.PointList


    }
    graphics.drawRectangle(tempRect);

    // Paint the shadow by reusing the temporary rectangle already
    // initialized by super.paint()
    PointList plt = new PointList();
    plt.addPoint(tempRect.x + 1 + tempRect.width,
           tempRect.y + getShadowWidth());
    plt.addPoint(tempRect.x + tempRect.width + 1,
           tempRect.y + tempRect.height + 1);
    plt.addPoint(tempRect.x + getShadowWidth(),
           tempRect.y + tempRect.height + 1);
    plt.addPoint(tempRect.x + getShadowWidth(),
           tempRect.y + tempRect.height + getShadowWidth());
    plt.addPoint(tempRect.x + tempRect.width + getShadowWidth(),
           tempRect.y + tempRect.height + getShadowWidth());
    plt.addPoint(tempRect.x + tempRect.width + getShadowWidth(),
           tempRect.y + getShadowWidth());
    graphics.setBackgroundColor(ColorConstants.lightGray);
    graphics.fillPolygon(plt);
  }
View Full Code Here


  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

  static boolean playbackState(Connection conn) {
    if (!PLAYBACK) {
      return false;
    }

    PointList list1 = (PointList) initialStates.get(conn);
    PointList list2 = (PointList) finalStates.get(conn);
    if (list1 == null) {
      conn.setVisible(false);
      return true;
    }
    if (list1.size() == list2.size()) {
      Point pt1 = new Point(), pt2 = new Point();
      PointList points = conn.getPoints();
      points.removeAllPoints();
      for (int i = 0; i < list1.size(); i++) {
        list1.getPoint(pt2, i);
        list2.getPoint(pt1, i);
        pt1.x = (int) Math.round(pt1.x * progress + (1 - progress) * pt2.x);
        pt1.y = (int) Math.round(pt1.y * progress + (1 - progress) * pt2.y);
        points.addPoint(pt1);
      }
      conn.setPoints(points);
    }
    return true;
  }
View Full Code Here

    return true;
  }

  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

  protected void drawAnchors(Graphics graphics, Rectangle rect) {
    Color foreground = graphics.getForegroundColor();
    Color background = graphics.getBackgroundColor();
    graphics.setBackgroundColor(ColorConstants.gray);
    int capacity = inputCapacity + outputCapacity;
    PointList pointlist;
    if (direction == PositionConstants.EAST) {
      int y1;
      int x1 = rect.x;
      int end;
      int height = rect.height;
      if (leftSide) {
        end = x1;
        pointlist = connector;
      }
      else {
        end = x1 + rect.width;
        pointlist = bottomConnector;
      }
      for (int i = 0; i < capacity; i++) {
        y1 = rect.y + (2 * i + 1) * height / (capacity * 2);
        graphics.setForegroundColor(ColorConstants.gray);
        pointlist.translate(end, y1);
        graphics.fillPolygon(pointlist);
        graphics.drawPolygon(pointlist);
        pointlist.translate(-end, -y1);
      }
    }
    else {
      int x1;
      int y1 = rect.y;
      int width = rect.width;
      int bottom;
      if (leftSide) {
        bottom = y1;
        pointlist = connector;
      }
      else {
        bottom = y1 + rect.height;
        pointlist = bottomConnector;
      }
      for (int i = 0; i < capacity; i++) {
        x1 = rect.x + (2 * i + 1) * width / (capacity * 2);
        graphics.setForegroundColor(ColorConstants.gray);
        pointlist.translate(x1, bottom);
        graphics.fillPolygon(pointlist);
        graphics.drawPolygon(pointlist);
        pointlist.translate(-x1, -bottom);
      }
    }
    graphics.setForegroundColor(foreground);
    graphics.setBackgroundColor(background);
  }
View Full Code Here

      bottomConnector.transpose();
    }
  }

  private void createPointLists() {
    connector = new PointList();
    bottomConnector = new PointList();

    connector.addPoint(-3, 0);
    connector.addPoint(-3, 6);
    connector.addPoint(3, 6);
    connector.addPoint(3, 0);
View Full Code Here

        }
        graphics.drawRectangle(tempRect);

        // Paint the shadow by reusing the temporary rectangle already
        // initialized by super.paint()
        PointList plt = new PointList();
        plt.addPoint(tempRect.x + 1 + tempRect.width, tempRect.y
                + getShadowWidth());
        plt.addPoint(tempRect.x + tempRect.width + 1, tempRect.y
                + tempRect.height + 1);
        plt.addPoint(tempRect.x + getShadowWidth(), tempRect.y
                + tempRect.height + 1);
        plt.addPoint(tempRect.x + getShadowWidth(), tempRect.y
                + tempRect.height + getShadowWidth());
        plt.addPoint(tempRect.x + tempRect.width + getShadowWidth(), tempRect.y
                + tempRect.height + getShadowWidth());
        plt.addPoint(tempRect.x + tempRect.width + getShadowWidth(), tempRect.y
                + getShadowWidth());
        graphics.setBackgroundColor(ColorConstants.lightGray);
        graphics.fillPolygon(plt);
    }
View Full Code Here

      path.setStartPoint(start);
      path.setEndPoint(end);

      if (!constraint.isEmpty()) {
        PointList bends = new PointList(constraint.size());
        for (int i = 0; i < constraint.size(); i++) {
          Bendpoint bp = (Bendpoint) constraint.get(i);
          bends.addPoint(bp.getLocation());
        }
        path.setBendPoints(bends);
      }
      else
        path.setBendPoints(null);
View Full Code Here

      for (int i = 0; i < updated.size(); i++) {
        Path path = (Path) updated.get(i);
        current = (Connection) path.data;
        current.revalidate();

        PointList points = path.getPoints().getCopy();
        Point ref1, ref2, start, end;
        ref1 = new PrecisionPoint(points.getPoint(1));
        ref2 = new PrecisionPoint(points.getPoint(points.size() - 2));
        current.translateToAbsolute(ref1);
        current.translateToAbsolute(ref2);

        start = current.getSourceAnchor().getLocation(ref1).getCopy();
        end = current.getTargetAnchor().getLocation(ref2).getCopy();

        current.translateToRelative(start);
        current.translateToRelative(end);
        points.setPoint(start, 0);
        points.setPoint(end, points.size() - 1);

        current.setPoints(points);
      }
      ignoreInvalidate = false;
    }
View Full Code Here

     */
    static boolean playbackState(Connection conn) {
        if (!PLAYBACK)
            return false;

        PointList list1 = (PointList) initialStates.get(conn);
        PointList list2 = (PointList) finalStates.get(conn);
        if (list1 == null) {
            conn.setVisible(false);
            return true;
        }
        if (list1.size() == list2.size()) {
            Point pt1 = new Point(), pt2 = new Point();
            PointList points = conn.getPoints();
            points.removeAllPoints();
            for (int i = 0; i < list1.size(); i++) {
                list1.getPoint(pt2, i);
                list2.getPoint(pt1, i);
                pt1.x = (int) Math.round(pt1.x * progress + (1 - progress)
                        * pt2.x);
                pt1.y = (int) Math.round(pt1.y * progress + (1 - progress)
                        * pt2.y);
                points.addPoint(pt1);
            }
            conn.setPoints(points);
        }
        return true;
    }
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.