Examples of PointList


Examples of org.eclipse.draw2d.geometry.PointList

  public static PointList getAdjustedPointList(PointList points, double zoom, double lw) {
    Rectangle zoomedBounds = points.getBounds().getCopy().scale(zoom);
    double middlex = zoomedBounds.x + (zoomedBounds.width / 2);
    double middley = zoomedBounds.y + (zoomedBounds.height / 2);

    PointList ret = new PointList();
    for (int i = 0; i < points.size(); i++) {
      Point point = points.getPoint(i);
      point.scale(zoom);

      // translate all points towards the middle depending on the
      // line-width, so that the polyline remains inside the bounds
      // Note, that the delta has to be rounded up/down depending on the
      // relative location from point to middle.
      double dx;
      double dy;
      if (point.x < middlex) {
        dx = Math.ceil(((middlex - point.x) / zoomedBounds.width) * lw);
      } else {
        dx = Math.floor(((middlex - point.x) / zoomedBounds.width) * lw);
      }
      if (point.y < middley) {
        dy = Math.ceil(((middley - point.y) / zoomedBounds.height) * lw);
      } else {
        dy = Math.floor(((middley - point.y) / zoomedBounds.height) * lw);
      }

      point.translate((int) dx, (int) dy);

      ret.addPoint(point);
    }
    return ret;
  }
View Full Code Here

Examples of org.eclipse.draw2d.geometry.PointList

    // getTranslatedPoints()),
    // better do the calculation again by first zooming and then translating
    // to avoid rounding errors.
    final int lineWidth = 1;
    final double zoom = 1.0;
    PointList points = FigureUtil.getAdjustedPointList(getPoints(), zoom, lineWidth);

    List<BezierPoint> bezierPoints = getBezierPoints(points, zoom);
    boolean isClosed = bezierPoints.get(0).equals(bezierPoints.get(bezierPoints.size() - 1));

    Path path = FigureUtil.getBezierPath(bezierPoints, isClosed);
View Full Code Here

Examples of org.eclipse.draw2d.geometry.PointList

      realDelta = realDelta.getScaled(zoom);
      midPoint.x += realDelta.x;
      midPoint.y += realDelta.y;
    } else {
      Connection conn = getConnection();
      PointList points = conn.getPoints();
      Point p1;
      Point p2;
      int size = points.size();
      if (size % 2 == 0) {
        int i = points.size() / 2;
        int j = i - 1;
        p1 = points.getPoint(j);
        p2 = points.getPoint(i);

        double value = Math.atan2(p1.y-p2.y, p1.x-p2.x);
        double angle = Math.toDegrees(value);
        if ((angle > 0 && angle < 90) || (angle > -180 && angle < -90)) {
          midPoint.y -= 12;
        }
      } else {
        int index = size / 2;
        p1 = points.getPoint(index - 1);
        p2 = points.getPoint(index + 1);
       
        if (p1.x > midPoint.x && p2.x > midPoint.x) {
          midPoint.x += 8;
        }
        if (p1.y > midPoint.y && p2.y > midPoint.y) {
View Full Code Here

Examples of org.eclipse.draw2d.geometry.PointList

  {   
    final HashKey connectionKey = new HashKey(conn);

    if( this.connections.containsKey( connectionKey ) )
    {
      PointList points = new PointList();
      points.addPoint(getNodeLocation(conn.getSourceNode()));
      points.addPoint(getNodeLocation(conn.getTargetNode()));

      int index  = getNextConnectionIndex(connectionKey);
      addConnectionKey(conn, connectionKey, index);

      Point bendpoint = handleCollision(points, index);
View Full Code Here

Examples of org.eclipse.draw2d.geometry.PointList

  private void paintSubmenuIndicator(Graphics graphics, Rectangle newRect) {
    int x = newRect.x;
    int y = newRect.y;
    int w = newRect.width;
    int h = newRect.height;
    PointList pl = new PointList();
    pl.addPoint(x + w, y + h * 3 / 4);
    pl.addPoint(x + w, y + h);
    pl.addPoint(x + w * 3 / 4, y + h);

    preparePaintIndicator(graphics);
    graphics.drawPolygon(pl);
    graphics.fillPolygon(pl);
  }
View Full Code Here

Examples of org.eclipse.draw2d.geometry.PointList

  private static double MIN_CONTROLPT_DIST = 18;
  private static double MAX_CONTROLPT_DIST = 36;
 
  public void route(Connection conn)
  {
        PointList points = conn.getPoints();
        points.removeAllPoints();
   
    Point ref1, ref2;
    ref1 = conn.getTargetAnchor().getReferencePoint();
    ref2 = conn.getSourceAnchor().getReferencePoint();
        PrecisionPoint startPoint = new PrecisionPoint(conn.getSourceAnchor().getLocation(ref1));
        conn.translateToRelative(startPoint);
      PrecisionPoint endPoint = new PrecisionPoint(conn.getTargetAnchor().getLocation(ref2));     
      conn.translateToRelative(endPoint);

      DoublePoint p1, p2, p3, p4;
      p1 = new DoublePoint(startPoint.preciseX(), startPoint.preciseY());
      p4 = new DoublePoint(endPoint.preciseX(), endPoint.preciseY());
      double dist = PathUtil.dist(p1, p4) / 3;
      if (dist < MIN_CONTROLPT_DIST)
        dist = MIN_CONTROLPT_DIST;
      if (dist > MAX_CONTROLPT_DIST)
        dist = MAX_CONTROLPT_DIST;
      p2 = new DoublePoint(startPoint.preciseX() + dist * 2, startPoint.y - dist * 1.5);
      p3 = new DoublePoint(endPoint.preciseX() + dist * 2, endPoint.y + dist * 1.5);
      List<Double> doubles = new ArrayList<Double>();
    PathUtil.recursiveBezier(p1.x, p1.y,
        p2.x, p2.y,
        p3.x, p3.y,
        p4.x, p4.y,
        4, doubles);
       
      points.addPoint(startPoint);
      for (int i = 2; i < doubles.size() - 2; )
      {
        PrecisionPoint p = new PrecisionPoint(doubles.get(i), doubles.get(i+1));
        points.addPoint(p);
        i += 2;
      }
      points.addPoint(endPoint);
      conn.setPoints(points);
  }
View Full Code Here

Examples of org.eclipse.draw2d.geometry.PointList

  graphics.setForegroundColor(ColorConstants.white);
  graphics.setBackgroundColor(LogicColorConstants.ghostFillColor);
 
  graphics.translate(getLocation());
 
  PointList outline = new PointList();
 
  outline.addPoint(0, 0);
  outline.addPoint(rect.width - getCornerSize(), 0);
  outline.addPoint(rect.width - 1, getCornerSize());
  outline.addPoint(rect.width - 1, rect.height - 1);
  outline.addPoint(0, rect.height - 1);
 
  graphics.fillPolygon(outline);
 
  // draw the inner outline
  PointList innerLine = new PointList();

  innerLine.addPoint(rect.width - getCornerSize() - 1, 0);
  innerLine.addPoint(rect.width - getCornerSize() - 1, getCornerSize());
  innerLine.addPoint(rect.width - 1, getCornerSize());
  innerLine.addPoint(rect.width - getCornerSize() - 1, 0);
  innerLine.addPoint(0, 0);
  innerLine.addPoint(0, rect.height - 1);
  innerLine.addPoint(rect.width - 1, rect.height - 1);
  innerLine.addPoint(rect.width - 1, getCornerSize());

  graphics.drawPolygon(innerLine);
 
  graphics.drawLine(rect.width - getCornerSize() - 1, 0, rect.width - 1, getCornerSize());
 
View Full Code Here

Examples of org.eclipse.draw2d.geometry.PointList

  Rectangle rect = getBounds().getCopy();

  graphics.translate(getLocation());

  // fill the note
  PointList outline = new PointList();
 
  outline.addPoint(0, 0);
  outline.addPoint(rect.width - cornerSize, 0);
  outline.addPoint(rect.width - 1, cornerSize);
  outline.addPoint(rect.width - 1, rect.height - 1);
  outline.addPoint(0, rect.height - 1);
 
  graphics.fillPolygon(outline);
 
  // draw the inner outline
  PointList innerLine = new PointList();
 
  innerLine.addPoint(rect.width - cornerSize - 1, 0);
  innerLine.addPoint(rect.width - cornerSize - 1, cornerSize);
  innerLine.addPoint(rect.width - 1, cornerSize);
  innerLine.addPoint(rect.width - cornerSize - 1, 0);
  innerLine.addPoint(0, 0);
  innerLine.addPoint(0, rect.height - 1);
  innerLine.addPoint(rect.width - 1, rect.height - 1);
  innerLine.addPoint(rect.width - 1, cornerSize);
 
  graphics.drawPolygon(innerLine);
 
  graphics.translate(getLocation().getNegated());
}
View Full Code Here

Examples of org.kaminoite.ranka.kido.ipad.tools.go.specification.PointList

        @param type The type of the markup from Node.MARK_TYPES. */
    public void addMarked(GoPoint point, MarkType type)
    {
        assert point != null;
        Map<MarkType,PointList> marked = createMarked();
        PointList pointList = (PointList)marked.get(type);
        if (pointList == null)
        {
            pointList = new PointList(1);
            pointList.add(point);
            marked.put(type, pointList);
        }
        else if (! pointList.contains(point))
            pointList.add(point);
    }
View Full Code Here

Examples of org.kaminoite.ranka.kido.ipad.tools.go.specification.PointList

        @param type Type of the markup from Node.MARK_TYPES. */
    public void removeMarked(GoPoint point, MarkType type)
    {
        assert point != null;
        Map<MarkType,PointList> marked = createMarked();
        PointList pointList = (PointList)marked.get(type);
        if (pointList != null)
            pointList.remove(point);
    }
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.