Examples of PointList


Examples of org.eclipse.draw2d.geometry.PointList

  @Override
  public List<IRecord> createLayoutRecords(Rectangle layout,
      boolean onlyCreateNewRecords) {
    generatePointList();

    PointList points = this.points.getCopy();
    if (points.size() == 0)
      points.addAll(getDefaultPoints(layout));

    Rectangle bounds = points.getBounds();
    // calculate difference
    Dimension delta = bounds.getLocation()
        .getDifference(layout.getLocation()).negate();

    // perform translate
    points.translate(delta.width, delta.height);

    // calculate scale
    double sx = ((double) layout.width) / ((double) bounds.width);
    double sy = ((double) layout.height) / ((double) bounds.height);
View Full Code Here

Examples of org.eclipse.draw2d.geometry.PointList

   *
   * @param points
   * @return normalized point list
   */
  protected PointList getNormalizedPointList(PointList points) {
    PointList ps = new PointList(points.size());
    int[] rawPoints = points.toIntArray();
    if (rawPoints.length == 0)
      return ps;
    ps.addPoint(rawPoints[0], rawPoints[1]);
    if (rawPoints.length == 2)
      return ps;
    ps.addPoint(rawPoints[2], rawPoints[3]);
    if (rawPoints.length == 4) {
      return ps;
    }

    int p1 = 0, p2 = 2, p3 = 4;

    while (true) {
      if (!collinear(rawPoints, p1, p2, p3, getPixelTolerance())) {
        ps.addPoint(rawPoints[p1], rawPoints[p1 + 1]);
        p1 = p2;
      } else {
        // even if collinear we have to check whether p1 and p3 are on
        // different sides
        if (rawPoints[p1] < rawPoints[p2]
            && rawPoints[p3] < rawPoints[p2]
            || rawPoints[p1] > rawPoints[p2]
            && rawPoints[p3] > rawPoints[p2]
            || rawPoints[p1 + 1] < rawPoints[p2 + 1]
            && rawPoints[p3 + 1] < rawPoints[p2 + 1]
            || rawPoints[p1 + 1] > rawPoints[p2 + 1]
            && rawPoints[p3 + 1] > rawPoints[p2 + 1]) {
          // if so, add the middle point and increment a first time
          ps.addPoint(rawPoints[p2], rawPoints[p2 + 1]);
          p1 = p3;
          p2 = p3;
          p3 += 2;
          if (p3 >= rawPoints.length)
            break;
        }
      }
      p2 = p3;
      p3 += 2;
      if (p3 >= rawPoints.length)
        break;
    }
    // If the last check was collinear (if and only if p2-p1>4) we still
    // have to add p1
    if (p2 - p1 > 4) {
      ps.addPoint(rawPoints[p1], rawPoints[p1 + 1]);
    }
    ps.addPoint(rawPoints[p2], rawPoints[p2 + 1]);

    return ps;
  }
View Full Code Here

Examples of org.eclipse.draw2d.geometry.PointList

   * @return the translated PointList from the request
   */
  protected PointList getPointListFor(CreatePointlistRequest request) {
    IFigure figure = getLayoutContainer();

    PointList points = getNormalizedPointList(request.getPoints());

    figure.translateToRelative(points);
    figure.translateFromParent(points);
    points.translate(getLayoutOrigin().getNegated());

    return points;
  }
View Full Code Here

Examples of org.eclipse.draw2d.geometry.PointList

        && getHost() instanceof ElementRecordPart) {
      try {

        LayoutElementRecord parent = (LayoutElementRecord) getHost()
            .getModel();
        PointList points = getPointListFor(request);

        // pencil on root only
        parent = LayoutUtils.translateToAndGetRoot(points, parent);

        PolylineRecordCreateCommand cmd = new PolylineRecordCreateCommand();
View Full Code Here

Examples of org.eclipse.draw2d.geometry.PointList

    return points;
  }

  public void addPoint(Point p) {
    if (points == null)
      points = new PointList();
    points.addPoint(p);
  }
View Full Code Here

Examples of org.eclipse.draw2d.geometry.PointList

  private static Polyline getPencilIconFigure() {
    Polyline line = new Polyline();
    int[] rawPoints = { 11, 3, 6, 3, 6, 4, 3, 4, 3, 5, 2, 5, 1, 6, 1, 8, 2,
        8, 2, 9, 3, 9, 4, 9, 5, 8, 7, 8, 7, 7, 8, 7, 8, 6, 13, 6, 14,
        7, 14, 10, 13, 10, 13, 11, 9, 11, 9, 12, 7, 12 };
    PointList points = new PointList(rawPoints);
    line.setPoints(points);
    line.setForegroundColor(black);
    return line;
  }
View Full Code Here

Examples of org.eclipse.draw2d.geometry.PointList

  public 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

Examples of org.eclipse.draw2d.geometry.PointList

  }

  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

Examples of org.eclipse.draw2d.geometry.PointList

  public 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

Examples of org.eclipse.draw2d.geometry.PointList

{
  protected List createSelectionHandles()
  {
    List<ConnectionBendpointHandle> list = new ArrayList<ConnectionBendpointHandle>();
    ConnectionEditPart connEP = (ConnectionEditPart) getHost();
    PointList points = getConnection().getPoints();
    List<Bendpoint> bendPoints = (List<Bendpoint>) getConnection().getRoutingConstraint();
    int bendPointIndex = 0;
    Point currBendPoint = null;

    if (bendPoints == null)
    {
      bendPoints = new ArrayList<Bendpoint>();
    }
    else if (!bendPoints.isEmpty())
    {
      currBendPoint = (bendPoints.get(0)).getLocation();
    }

    for (int i = 0; i < points.size() - 1; i++)
    {
      //Put a create handle on the middle of every segment
      list.add(new ConnectionBendpointHandle(connEP,
        bendPointIndex,
        i,
        "create"));

      //If the current user bendpoint matches a bend location, show a move handle
      if (i < points.size() - 1
        && bendPointIndex < bendPoints.size()
        && currBendPoint.equals(points.getPoint(i + 1)))
      {
        list.add(new ConnectionBendpointHandle(connEP,
          bendPointIndex,
          i + 1,
          "move"));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.