/** * The API method used to exercise the layout upon the facade description * and produce a separate description of the vertex position and edge * routing changes made. It first builds a representation of the tree using * the inner tree class by doing a depth first search of the graph from the * root. It then lays out the graph using the obtained data * * @param graph * the facade describing the graph and its configuration */ public void run(JGraphFacade graph) { super.run(graph); }
int dist = distance(n1.rightContour, n2.leftContour) / (j - i); distance = Math.max(distance, dist); StandardTreeNode first = getLeftMostX(node); StandardTreeNode last = getRightMostX(node); merge(node.leftContour.next, n.leftContour, i * distance + node.width); merge(node.rightContour.next, n.rightContour, i * distance + node.width);
public void visit(Object parent, Object cell, Object previousSibling, int layer, int sibling) { StandardTreeNode parentNode = getTreeNode(parent); StandardTreeNode childNode = getTreeNode(cell); if (parentNode != null) { parentNode.addChild(childNode); childNode.setParent(parentNode); } } });
/** * Top-level method that performs actual layout of tree for a specific node. * Note this acts upon the internal tree node structure * * @param node * the tree node to be laid out */ protected void layout(StandardTreeNode node) { if (node.children.size() == 0) { // do nothing } else if (node.children.size() == 1) { StandardTreeNode sub = (StandardTreeNode) node.children.get(0); sub.setDepth(node.getDepth() + 1); layout(sub); sub.leftContour.dx = (sub.width - node.width) / 2; sub.rightContour.dx = (sub.width - node.width) / 2; node.leftContour.next = sub.leftContour; node.rightContour.next = sub.rightContour; } else { for (Iterator it = node.children.iterator(); it.hasNext();) { StandardTreeNode n = (StandardTreeNode) it.next(); n.setDepth(node.getDepth() + 1); layout(n); } join(node); } }
private void initializeJPanel() { initiate = true; graph.setGraphLayoutCache(new GraphLayoutCache(new DefaultGraphModel(), new DefaultCellViewFactory(), true)); graph.setEditable(false); for (K key : stateKeys) stateCells.put(key, createCell(key, new Point2D(0, 0))); for (K key : stateKeys) createStateTransitionDiagram(key); graph.getGraphLayoutCache().insert(stateCells.values().toArray()); JGraphFacade facade = new JGraphFacade(graph.getGraphLayoutCache()); facade.setEdgePromotion(false); JGraphTreeLayout layout = new JGraphTreeLayout(); layout.run(facade); Map<?, ?> map = facade.createNestedMap(true, true); graph.getGraphLayoutCache().edit(map); }
StandardTreeNode root = getTreeNode(graph.getRootAt(i)); layout(root); if (combineLevelNodes) { setLevelHeights(root); spaceMultipleTrees(root);
treeBoundary = rootY + bottomMostY + getRightMostX(root).height;
private void initializeJPanel() { initiate = true; graph.setGraphLayoutCache(new GraphLayoutCache(new DefaultGraphModel(), new DefaultCellViewFactory(), true)); graph.setEditable(false); for (int i = 0; i < numberOfStates; i++) { isStateEmpty(stateMachine.states.get(i)); } stateCells = new DefaultGraphCell[numberOfStates]; State<E> parent = getParentState(); stateCells[stateCellIndex] = createCell(parent.getStateEnum().toString(), new Point2d(0, 0), stateCellIndex); stateCellIndex++; createStateMachineDiagram(parent); graph.getGraphLayoutCache().insert(stateCells); JGraphFacade facade = new JGraphFacade(graph.getGraphLayoutCache()); facade.setEdgePromotion(false); JGraphTreeLayout layout = new JGraphTreeLayout(); layout.run(facade); Map<?, ?> map = facade.createNestedMap(true, true); graph.getGraphLayoutCache().edit(map); createDefaultArrows(); createArrowsForStateTransitions(); }
private void initializeJPanel() { initiate = true; graph.setGraphLayoutCache(new GraphLayoutCache(new DefaultGraphModel(), new DefaultCellViewFactory(), true)); graph.setEditable(false); for (int i = 0; i < numberOfStates; i++) { isStateEmpty(stateMachine.states.get(i)); } stateCells = new DefaultGraphCell[numberOfStates]; State<E> parent = getParentState(); stateCells[stateCellIndex] = createCell(parent.getStateEnum().toString(), new Point2D(0, 0), stateCellIndex); stateCellIndex++; createStateMachineDiagram(parent); graph.getGraphLayoutCache().insert(stateCells); JGraphFacade facade = new JGraphFacade(graph.getGraphLayoutCache()); facade.setEdgePromotion(false); JGraphTreeLayout layout = new JGraphTreeLayout(); layout.run(facade); Map<?, ?> map = facade.createNestedMap(true, true); graph.getGraphLayoutCache().edit(map); createDefaultArrows(); createArrowsForStateTransitions(); }