Beispiel #1
0
  private void setToCenter(final BTNode node, final int animationDelay) {
    BTGraphNode graphNode = this.mapDataToGraph.get(node);
    if (graphNode != null) {
      org.eclipse.swt.graphics.Rectangle rectParent = this.graph.getBounds();
      Rectangle rectNode = graphNode.getFigure().getBounds();
      int centerXNode = rectNode.x + rectNode.width / 2;
      int centerYNode = rectNode.y + rectNode.height / 2;

      int centerXParent = rectParent.x + rectParent.width / 2;
      int centerYParent = rectParent.y + rectParent.height / 2;

      final int selisihX = centerXNode - centerXParent;
      final int selisihY = centerYNode - centerYParent;
      Display.getDefault()
          .asyncExec(
              new Runnable() {

                @Override
                public void run() {
                  Animation.markBegin();
                  List nodes = graph.getNodes();

                  for (Object itemNode : nodes) {
                    Point p = ((GraphNode) itemNode).getLocation();
                    ((GraphNode) itemNode).setLocation(p.x - selisihX, p.y - selisihY);
                  }
                  Animation.run(animationDelay);
                  BTGraphNode awal = mapDataToGraph.get(startNode);
                }
              });
    } else {
      System.out.println("Set To Center is failed");
    }
  }
Beispiel #2
0
 private void setInterleaveNodes(ArrayList<BTNode> nodes, int animationDelay) {
   for (BTNode node : nodes) {
     BTGraphNode graphNode = this.mapDataToGraph.get(node);
     if (graphNode != null) {
       graphNode.getFigure().setBackgroundColor(BTColorConstanta.INTERLEAVE_ACTIVE);
     }
   }
 }
Beispiel #3
0
 private void setNonActiveNode(BTNode node, int animationDelay) {
   BTGraphNode graphNode = this.mapDataToGraph.get(node);
   if (graphNode != null) {
     graphNode.getFigure().setBackgroundColor(BTColorConstanta.NOT_ACTIVE);
   }
 }