Exemplo n.º 1
0
 private void rotate(final double delta) {
   for (final VNode n : graph.getPaintedShapes()) {
     final float newX =
         (float) ((n.getX() - centerX) * Math.cos(delta) - (n.getY() - centerY) * Math.sin(delta))
             + centerX;
     final float newY =
         (float) ((n.getX() - centerX) * Math.sin(delta) + (n.getY() - centerY) * Math.cos(delta))
             + centerY;
     n.setX(newX);
     n.setY(newY);
     graph.updateEdges(n, false);
   }
   angle += delta;
 }
Exemplo n.º 2
0
 public void startLinkingFrom(final VNode node) {
   VConsole.log("onlink");
   onLink = true;
   linkNode = node;
   startX = node.getX();
   startY = node.getY();
 }
Exemplo n.º 3
0
  private void zoom(final double factor) {
    if (factor < 1) {
      zoomFactor--;
    } else {
      zoomFactor++;
    }
    for (final VNode n : graph.getPaintedShapes()) {
      n.setX((float) ((n.getX() - centerX) * factor) + centerX);
      n.setY((float) ((n.getY() - centerY) * factor) + centerY);

      if (n.getView() instanceof Circle) {
        if (factor > 1) {
          ((Circle) n.getView()).setRadius((((Circle) n.getView()).getRadius() + 1));
        } else {
          ((Circle) n.getView()).setRadius((((Circle) n.getView()).getRadius() - 1));
        }
      }
      graph.updateEdges(n, false);
    }
    client.updateVariable(paintableId, "zoomFactor", zoomFactor, true);
  }
Exemplo n.º 4
0
 private void selectNodesAndEdgesInTheBox(
     final int startX, final int startY, final int endX, final int endY) {
   for (final VNode node : graph.getSelectedShapes()) {
     graph.setNodeSelected(node, false);
   }
   for (final VEdge edge : graph.getSelectedEdges()) {
     graph.setEdgeSelected(edge, false);
   }
   for (final VNode node : graph.getPaintedShapes()) {
     if (isInArea(node.getX(), node.getY(), startX, startY, endX, endY)) {
       graph.setNodeSelected(node, true);
     }
   }
   for (final VEdge edge : graph.getSelectedEdges()) {
     if (graph.getSelectedShapes().contains(edge.getFirstNode())
         && graph.getSelectedShapes().contains(edge.getSecondNode())) {
       graph.setEdgeSelected(edge, true);
     }
   }
   nodeOrEdgeSelectionChanged();
 }