private void splitBendPoints(
     FreeFormConnection startConnection, Connection endConnection, int x, int y) {
   List<Point> points = new ArrayList<Point>();
   GraphicsAlgorithm startGa = startConnection.getStart().getGraphicsAlgorithm();
   if (startGa != null) {
     Point p = StylesFactory.eINSTANCE.createPoint();
     p.setX(startGa.getX());
     p.setY(startGa.getY());
     points.add(p);
   }
   points.addAll(startConnection.getBendpoints());
   GraphicsAlgorithm endGa = startConnection.getEnd().getGraphicsAlgorithm();
   if (endGa != null) {
     Point p = StylesFactory.eINSTANCE.createPoint();
     p.setX(endGa.getX());
     p.setY(endGa.getY());
     points.add(p);
   }
   Point p0 = null;
   int min = -1, minDistance2 = -1;
   for (int i = 0; i < points.size(); i++) {
     Point p1 = points.get(i);
     if (p0 == null) {
       p0 = p1;
     } else {
       int distance2 =
           distance2(x, p0.getX(), y, p0.getX()) + distance2(x, p1.getX(), y, p1.getY());
       if (min < 0 || distance2 < minDistance2) {
         min = i;
         minDistance2 = distance2;
       }
       p0 = p1;
     }
   }
   for (int i = min; i > 0 && i < points.size(); i++) {
     Point p = points.get(i);
     if (p.eContainer() != null) {
       ((List<?>) p.eContainer().eGet(p.eContainingFeature())).remove(p);
     }
     if (endConnection instanceof FreeFormConnection) {
       ((FreeFormConnection) endConnection).getBendpoints().add(p);
     }
   }
 }
 @Deprecated
 protected void moveConnectionBendpoints(FreeFormConnection connection, int deltaX, int deltaY) {
   List<Point> points = connection.getBendpoints();
   for (int i = 0; i < points.size(); i++) {
     Point point = points.get(i);
     int oldX = point.getX();
     int oldY = point.getY();
     points.set(i, Graphiti.getGaCreateService().createPoint(oldX + deltaX, oldY + deltaY));
   }
 }
예제 #3
0
  @Override
  protected void initialize() {
    super.initialize();

    // Points
    EList<Point> points = polygon.getPoints();
    ArrayList<Double> list = new ArrayList<>(points.size());
    for (Point point : points) {
      list.add(new Double(point.getX()));
      list.add(new Double(point.getY()));
    }
    fxPolygon.getPoints().addAll(list);
  }
  private void performMove(Shape labelShape, Point position) {

    // always move within the original container
    GraphicsAlgorithm labelGraphicsAlgorithm = labelShape.getGraphicsAlgorithm();

    if (labelGraphicsAlgorithm != null) {
      Graphiti.getGaService()
          .setLocation(
              labelGraphicsAlgorithm,
              position.getX() - labelGraphicsAlgorithm.getWidth() / 2,
              position.getY(),
              true);
    }
  }