Package org.eclipse.draw2d.geometry

Examples of org.eclipse.draw2d.geometry.Point


    }
  }

  @Override
  public Point getReferencePoint() {
    Point reference = mgr.getReferencePoint(this);
    if (reference == null) {
      return super.getReferencePoint();
    } else {
      return reference;
    }
View Full Code Here


      }
    }

    int xdirec = 0;
    int ydirec = 0;
    Point p = Point.SINGLETON;
    Point f = conn.getPoints().getFirstPoint();
    Point l = conn.getPoints().getLastPoint();

    if (l.x > f.x) {
      xdirec = 1;
    } else {
      xdirec = -1;
    }

    if (l.y > f.y) {
      ydirec = 1;
    } else {
      ydirec = -1;
    }
    if (pos.equals(ParameterPosition.West)
        || pos.equals(ParameterPosition.NorthWest)
        || pos.equals(ParameterPosition.SouthWest)) {
      Point refP = conn.getPoints().getFirstPoint().getCopy();
      conn.getParent().translateToAbsolute(refP);
      p.setLocation(refP.x + (dec * xdirec), refP.y + (dec * ydirec));
    } else if (pos.equals(ParameterPosition.East)
        || pos.equals(ParameterPosition.NorthEast)
        || pos.equals(ParameterPosition.SouthEast)) {
      Point refP = conn.getPoints().getLastPoint().getCopy();
      conn.getParent().translateToAbsolute(refP);
      p.setLocation(refP.x - (dec * xdirec), refP.y - (dec * ydirec));
    } else {
      Point refP = conn.getPoints().getMidpoint().getCopy();
      conn.getParent().translateToAbsolute(refP);
      p.setLocation(refP.x - (dec * xdirec), refP.y - (dec * ydirec));
    }

    return p;
View Full Code Here

      owner = (Polygon) getOwner().getChildren().get(0);
    } else {
      throw new NullPointerException();
    }

    Point center = getReferencePoint();
    if (reference.x == center.x && reference.y == center.y) {
      return center;
    }

    // The line run
    float run = (reference.x - center.x);

    PointList pointList = owner.getPoints();
    for (int i = 0; i < pointList.size() - 1; i++) {
      Point start = pointList.getPoint(i);
      Point end = pointList.getPoint(i + 1);

      // Translate from relative to absolute coordinates
      owner.translateToAbsolute(start);
      owner.translateToAbsolute(end);

      // Check intersection
      if (Geometry.linesIntersect(center.x, center.y, reference.x,
          reference.y, start.x, start.y, end.x, end.y)) {
        float p = ((float) (start.y - end.y))
            / ((float) (start.x - end.x));
        float d = start.y - p * start.x;

        // Compute xAnchor
        int xAnchor;
        if (run == 0) {
          // Line equation: x = center.x
          xAnchor = center.x;
        } else {
          // Line equation: y = ax + b = px + d =>
          // x = (d - b) / (a - p)
          float rise = (reference.y - center.y);
          float a = rise / run;
          float b = center.y - a * center.x;
          xAnchor = (int) ((d - b) / (a - p));
        }

        // yAnchor is just y = px + d
        int yAnchor = (int) (p * xAnchor + d);
        return new Point(xAnchor, yAnchor);
      }
    }

    // Should never happen
    return center;
View Full Code Here

    return center;
  }

  @Override
  public Point getReferencePoint() {
    Point reference = mgr.getReferencePoint(this);
    if (reference == null) {
      return super.getReferencePoint();
    } else {
      return reference;
    }
View Full Code Here

    mgr = new PortAnchorReferenceManager(figure, portName, isOutput);
  }

  @Override
  public Point getLocation(Point reference) {
    Point mgrReference = mgr.getReferencePoint(this);
    if (mgrReference == null) {
      return super.getLocation(reference);
    } else {
      return mgrReference;
    }
View Full Code Here

    }
  }

  @Override
  public Point getReferencePoint() {
    Point reference = mgr.getReferencePoint(this);
    if (reference == null) {
      return super.getReferencePoint();
    } else {
      return reference;
    }
View Full Code Here

        Rectangle bounds = label.getBounds();
        int x = bounds.x + bounds.width + 5;
        int y = bounds.y + bounds.height / 2;

        Point ref = new Point(x, y);
        label.translateToAbsolute(ref);

        return ref;
      } else {
        label = figure.getInputPortLabel(portName);
        if (label == null) {
          return null;
        }

        Rectangle bounds = label.getBounds();
        int x = bounds.x - 5;
        int y = bounds.y + bounds.height / 2;

        Point ref = new Point(x, y);
        label.translateToAbsolute(ref);

        return ref;
      }
    }
View Full Code Here

  }

  @Override
  public void setDimension(Dimension dim) {
    removeAllPoints();
    setStart(new Point(0, dim.height));
    addPoint(new Point(dim.width / 2, 0));
    addPoint(new Point(dim.width, dim.height - 1));
    addPoint(new Point(0, dim.height - 1));
  }
View Full Code Here

        }
        return null; //Not found, add at the end.
    }

    private int getFeedbackIndexFor(Request request) {
        Point mouseLocation = getLocationFromRequest(request);
        double minDistance = ActionGraphUtils.ACTION_SIZE;
        int candidate = -1;
        List<GraphicalEditPart> children = getHost().getChildren();
        for (int i = 0; i < children.size(); i++) {
            double distance = getAbsoluteBounds(children.get(i)).getCenter().getDistance(mouseLocation);
View Full Code Here

        int epIndex = getFeedbackIndexFor(request);
        if (epIndex == -1) {
            epIndex = getHost().getChildren().size();
        }
        Point feedbackPoint = ActionGraphUtils.getActionFigureLocation(
                ((GraphicalEditPart) getHost()).getFigure(),
                epIndex, getHost().getChildren().size(), true);
        getFeedbackFigure().setLocation(feedbackPoint);
        addFeedback(getFeedbackFigure());
    }
View Full Code Here

TOP

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

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.