Exemplo n.º 1
0
  /**
   * @param startNode
   * @return the finish node corresponding to the start node
   */
  private TableNodeItem finishNode(TableNodeItem startNode) {

    TableNodeItem nodeFinish = null;
    String startNodeName = startNode.getString(NAME);
    String finishNodeName = startNodeName.substring(0, startNodeName.lastIndexOf(START)) + "Finish";
    int startNodes = 1;
    int finishNodes = 0;
    Iterator nodes = (startNode.getGraph()).nodes();

    while (nodes.hasNext()) {
      TableNodeItem node = (TableNodeItem) nodes.next();
      if (node.getInt(ID) > startNode.getInt(ID) && (node.getString(NAME)).equals(startNodeName)) {
        startNodes++;
      }
      if (node.getInt(ID) > startNode.getInt(ID) && (node.getString(NAME)).equals(finishNodeName)) {
        finishNodes++;
      }

      if (startNodes == finishNodes) {
        nodeFinish = node;
        break;
      }
    }

    return nodeFinish;
  }
Exemplo n.º 2
0
 /**
  * checks whether the edge between two invisible nodes is a control flow ("CF") type edge
  *
  * @param source
  * @param target
  * @return true if the edge is a control flow edge, false otherwise
  */
 private boolean checkInvisibleFlow(TableNodeItem source, TableNodeItem target) {
   Edge edge = (source.getGraph()).getEdge(source, target);
   if (edge.getString(TYPE).equals(CONTROL_FLOW)) {
     return true;
   } else {
     return false;
   }
 }
Exemplo n.º 3
0
  /**
   * collapses nodes between a start node and a finish node when the start node is clicked expand
   * nodes between a start and finish node when the step connecting them is clicked
   *
   * @param item
   */
  public String collapseExpand(VisualItem item) {

    if (item instanceof TableNodeItem && item.getString(TYPE).equals(START)) {

      TableNodeItem nodeItem = (TableNodeItem) item;

      if (finishNode(nodeItem) != null && getChild(finishNode(nodeItem)) != null) {

        setNodesAndEdgesInvisible(nodeItem, finishNode(nodeItem));
        setStepVisible(nodeItem);
        setIsolatedNodesInvisible(nodeItem.getGraph());

        Visualization vis = item.getVisualization();
        vis.run("layout");
      }

      return START;
    }

    if (item instanceof TableNodeItem && item.getString(TYPE).equals(STEP)) {

      TableNodeItem nodeItem = (TableNodeItem) item;
      TableNodeItem startNode = getStepParent(nodeItem);
      startId = (getChild(startNode)).getInt(ID);
      TableNodeItem finishNode = getStepChild(nodeItem);

      setStepInvisible(nodeItem);
      setNodesAndEdgesVisible(startNode, finishNode, true);
      setIsolatedNodesVisible(nodeItem.getGraph());

      Visualization vis = item.getVisualization();
      vis.run("layout");

      return STEP;
    }

    return "Other";
  }
Exemplo n.º 4
0
 /**
  * alternative for method getOutDegree() from class node. Finds the number of visible incident
  * edges.
  *
  * @param node
  * @return
  */
 private int getOutVDegree(TableNodeItem node) {
   Iterator neighbors = node.neighbors();
   TableNodeItem neighbor;
   TableEdgeItem edge;
   int outVDegree = 0;
   while (neighbors.hasNext()) {
     neighbor = (TableNodeItem) neighbors.next();
     edge = (TableEdgeItem) (node.getGraph()).getEdge(node, neighbor);
     if (edge != null && edge.isVisible()) {
       outVDegree++;
     }
   }
   return outVDegree;
 }
Exemplo n.º 5
0
  /**
   * replaces method children() from class Node
   *
   * @param n
   * @return an iterator over neighbors connected to n by outgoing edges
   */
  private Iterator<TableNodeItem> children(TableNodeItem n) {

    Iterator neighbors = n.neighbors();
    TableNodeItem neighbor;
    TableEdgeItem nodeNeighborEdge;
    List<TableNodeItem> childrenList = new ArrayList<TableNodeItem>();

    while (neighbors.hasNext()) {
      neighbor = (TableNodeItem) neighbors.next();
      nodeNeighborEdge = (TableEdgeItem) (n.getGraph()).getEdge(neighbor, n);

      if (nodeNeighborEdge != null) {
        childrenList.add(neighbor);
      }
    }

    return childrenList.iterator();
  }
Exemplo n.º 6
0
  /**
   * replaces method getFirstChild() from class Node
   *
   * @param node
   * @return the first neighbor connected to node by an outgoing, control flow ("CF") type edge
   */
  private TableNodeItem getChild(TableNodeItem node) {

    TableNodeItem child = null;
    Iterator neighbors = node.neighbors();
    TableNodeItem neighbor;
    Edge nodeNeighborEdge;

    while (neighbors.hasNext()) {
      neighbor = (TableNodeItem) neighbors.next();
      nodeNeighborEdge = (node.getGraph()).getEdge(neighbor, node);

      if (nodeNeighborEdge != null) {
        if (nodeNeighborEdge.getString(TYPE).equals(CONTROL_FLOW)) {
          child = neighbor;
          break;
        }
      }
    }

    return child;
  }
Exemplo n.º 7
0
  /**
   * returns the first child of a "Step" type node
   *
   * @param node
   * @return the first neighbor connected to the node by an incoming, "Step" type edge
   */
  public TableNodeItem getStepChild(TableNodeItem node) {

    TableNodeItem stepChild = null;
    Iterator neighbors = node.neighbors();
    TableNodeItem neighbor;
    Edge nodeNeighborEdge;

    while (neighbors.hasNext()) {
      neighbor = (TableNodeItem) neighbors.next();
      nodeNeighborEdge = (node.getGraph()).getEdge(neighbor, node);

      if (nodeNeighborEdge != null) {
        if (nodeNeighborEdge.getString(TYPE).equals(STEP)) {
          stepChild = neighbor;
          break;
        }
      }
    }

    return stepChild;
  }