Examples of JGraphHierarchyNode


Examples of com.jgraph.layout.hierarchical.model.JGraphHierarchyNode

    Object rootsArray[] = null;
    if (model.roots != null) {
      rootsArray = new Object[model.roots.length];
      for (int i = 0; i < model.roots.length; i++) {
        Object node = model.roots[i];
        JGraphHierarchyNode internalNode = (JGraphHierarchyNode) model.getVertexMapping()
        .get(node);
        rootsArray[i] = internalNode;
      }
    }

    model.dfs(new JGraphFacade.CellVisitor() {
      public void visit(Object parent, Object cell,
          Object connectingEdge, int layer, int seen) {
        // Check if the cell is in it's own ancestor list, if so
        // invert the connecting edge and reverse the target/source
        // relationship to that edge in the parent and the cell
        if (((JGraphHierarchyNode)cell).isAncestor((JGraphHierarchyNode)parent)) {
          ((JGraphHierarchyEdge) connectingEdge).invert();
          ((JGraphHierarchyNode) parent).connectsAsSource
              .remove(connectingEdge);
          ((JGraphHierarchyNode) parent).connectsAsTarget
              .add(connectingEdge);
          ((JGraphHierarchyNode) cell).connectsAsTarget
              .remove(connectingEdge);
          ((JGraphHierarchyNode) cell).connectsAsSource
              .add(connectingEdge);
        }
        seenNodes.add(cell);
        unseenNodes.remove(cell);
      }
    }, rootsArray, true, null);
   
    Set possibleNewRoots = null;
    if (unseenNodes.size() > 0) {
      possibleNewRoots = new HashSet(unseenNodes);
    }
    // If there are any nodes that should be nodes that the dfs can miss
    // these need to be processed with the dfs and the roots assigned
    // correctly to form a correct internal model
    Set seenNodesCopy = new HashSet(seenNodes);
    // Pick a random cell and dfs from it
    model.dfs(new JGraphFacade.CellVisitor() {
      public void visit(Object parent, Object cell,
          Object connectingEdge, int layer, int seen) {
        // Check if the cell is in it's own ancestor list, if so
        // invert the connecting edge and reverse the target/source
        // relationship to that edge in the parent and the cell
        if (((JGraphHierarchyNode)cell).isAncestor((JGraphHierarchyNode)parent)) {
          ((JGraphHierarchyEdge) connectingEdge).invert();
          ((JGraphHierarchyNode) parent).connectsAsSource
          .remove(connectingEdge);
          ((JGraphHierarchyNode) parent).connectsAsTarget
          .add(connectingEdge);
          ((JGraphHierarchyNode) cell).connectsAsTarget
          .remove(connectingEdge);
          ((JGraphHierarchyNode) cell).connectsAsSource
          .add(connectingEdge);
        }
        seenNodes.add(cell);
        unseenNodes.remove(cell);
      }
    }, unseenNodes.toArray(), true, seenNodesCopy);

    if (possibleNewRoots != null && possibleNewRoots.size() > 0) {
      Iterator iter = possibleNewRoots.iterator();
      List roots = facade.getRoots();
      while (iter.hasNext()) {
        JGraphHierarchyNode node = (JGraphHierarchyNode)iter.next();
        Object realNode = node.cell;
        int numIncomingEdges = facade.getIncomingEdges(realNode,
            null, true, false).size();
        if (numIncomingEdges == 0) {
          roots.add(realNode);
View Full Code Here

Examples of com.jgraph.layout.hierarchical.model.JGraphHierarchyNode

    boolean boundsWarning = false;
    while (iter.hasNext()) {
      JGraphAbstractHierarchyCell cell = (JGraphAbstractHierarchyCell) iter
          .next();
      if (cell.isVertex()) {
        JGraphHierarchyNode node = (JGraphHierarchyNode) cell;
        Rectangle2D bounds = facade.getBounds(node.cell);
        if (bounds != null) {
          if (orientation == SwingConstants.NORTH
              || orientation == SwingConstants.SOUTH) {
            cell.width = bounds.getWidth();
View Full Code Here

Examples of com.jgraph.layout.hierarchical.model.JGraphHierarchyNode

      boolean boundsWarning = false;
      while (iter.hasNext()) {
        JGraphAbstractHierarchyCell cell = (JGraphAbstractHierarchyCell) iter
            .next();
        if (cell.isVertex()) {
          JGraphHierarchyNode node = (JGraphHierarchyNode) cell;
          Rectangle2D bounds = facade.getBounds(node.cell);
          if (bounds != null) {
            if (orientation == SwingConstants.NORTH
                || orientation == SwingConstants.SOUTH) {
              cell.width = bounds.getWidth();
View Full Code Here

Examples of com.jgraph.layout.hierarchical.model.JGraphHierarchyNode

        Iterator iter = rank.iterator();
        while (iter.hasNext()) {
          JGraphAbstractHierarchyCell cell = (JGraphAbstractHierarchyCell) iter
              .next();
          if (cellType == 0 && cell.isVertex()) {
            JGraphHierarchyNode node = (JGraphHierarchyNode) cell;
            Object realCell = node.cell;
            vertices.add(realCell);
            double positionX = node.x[0] - node.width / 2;
            double positionY = node.y[0] - node.height / 2;
            if (orientation == SwingConstants.NORTH
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.