コード例 #1
0
 @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));
   }
 }
コード例 #2
0
ファイル: FxPolygon.java プロジェクト: johnsteele/graphitiFX
  @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);
  }
コード例 #3
0
  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);
    }
  }
コード例 #4
0
  public boolean layout(ILayoutContext context) {
    boolean anythingChanged = false;
    ContainerShape containerShape = (ContainerShape) context.getPictogramElement();
    GraphicsAlgorithm containerGa = containerShape.getGraphicsAlgorithm();

    // height
    if (containerGa.getHeight() < MIN_HEIGHT) {
      containerGa.setHeight(MIN_HEIGHT);
      anythingChanged = true;
    }

    // width
    if (containerGa.getWidth() < MIN_WIDTH) {
      containerGa.setWidth(MIN_WIDTH);
      anythingChanged = true;
    }

    int containerWidth = containerGa.getWidth();

    for (Shape shape : containerShape.getChildren()) {
      GraphicsAlgorithm graphicsAlgorithm = shape.getGraphicsAlgorithm();
      IGaService gaService = Graphiti.getGaService();
      IDimension size = gaService.calculateSize(graphicsAlgorithm);
      if (containerWidth != size.getWidth()) {
        if (graphicsAlgorithm instanceof Polyline) {
          Polyline polyline = (Polyline) graphicsAlgorithm;
          Point secondPoint = polyline.getPoints().get(1);
          Point newSecondPoint = gaService.createPoint(containerWidth, secondPoint.getY());
          polyline.getPoints().set(1, newSecondPoint);
          anythingChanged = true;
        } else {
          gaService.setWidth(graphicsAlgorithm, containerWidth);
          anythingChanged = true;
        }
      }
    }
    return anythingChanged;
  }
 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);
     }
   }
 }