public void setGraph(Graph<V,E> graph) { if(graph instanceof Forest) { this.graph = (Forest<V,E>)graph; buildTree(); } else { throw new IllegalArgumentException("graph must be a Forest"); } }
public void setGraph(Graph<V,E> graph) { if(graph instanceof Forest) { this.graph = (Forest<V,E>)graph; buildTree(); } else { throw new IllegalArgumentException("graph must be a Forest"); } }
/** * Creates an instance for the specified graph, X distance, and Y distance. */ public TreeLayout(Forest<V,E> g, int distx, int disty) { if (g == null) throw new IllegalArgumentException("Graph must be non-null"); if (distx < 1 || disty < 1) throw new IllegalArgumentException("X and Y distances must each be positive"); this.graph = g; this.distX = distx; this.distY = disty; buildTree(); }
/** * Creates an instance for the specified graph, X distance, and Y distance. * @param g the graph on which the layout algorithm is to operate * @param distx the horizontal spacing between adjacent siblings * @param disty the vertical spacing between adjacent siblings */ public TreeLayout(Forest<V,E> g, int distx, int disty) { if (g == null) throw new IllegalArgumentException("Graph must be non-null"); if (distx < 1 || disty < 1) throw new IllegalArgumentException("X and Y distances must each be positive"); this.graph = g; this.distX = distx; this.distY = disty; buildTree(); }
@Override protected void buildTree() { super.buildTree(); this.polarLocations = new HashMap<V, PolarPoint>(); setRadialLocations(); }
@Override protected void buildTree() { super.buildTree(); this.polarLocations = new HashMap<V, PolarPoint>(); setRadialLocations(); }
protected void buildTree() { this.m_currentPoint = new Point(0, 20); Collection<V> roots = TreeUtils.getRoots(graph); if (roots.size() > 0 && graph != null) { calculateDimensionX(roots); for(V v : roots) { calculateDimensionX(v); m_currentPoint.x += this.basePositions.get(v)/2 + this.distX; buildTree(v, this.m_currentPoint.x); } } }
protected void buildTree(V v, int x) { if (alreadyDone.add(v)) { //go one level further down this.m_currentPoint.y += this.distY; this.m_currentPoint.x = x; this.setCurrentPositionFor(v); int sizeXofCurrent = basePositions.get(v); int lastX = x - sizeXofCurrent / 2; int sizeXofChild; int startXofChild; for (V element : graph.getSuccessors(v)) { sizeXofChild = this.basePositions.get(element); startXofChild = lastX + sizeXofChild / 2; buildTree(element, startXofChild); lastX = lastX + sizeXofChild + distX; } this.m_currentPoint.y -= this.distY; } }
protected void buildTree(V v, int x) { if (!alreadyDone.contains(v)) { alreadyDone.add(v); //go one level further down this.m_currentPoint.y += this.distY; this.m_currentPoint.x = x; this.setCurrentPositionFor(v); int sizeXofCurrent = basePositions.get(v); int lastX = x - sizeXofCurrent / 2; int sizeXofChild; int startXofChild; for (V element : graph.getSuccessors(v)) { sizeXofChild = this.basePositions.get(element); startXofChild = lastX + sizeXofChild / 2; buildTree(element, startXofChild); lastX = lastX + sizeXofChild + distX; } this.m_currentPoint.y -= this.distY; } }
protected void buildTree() { this.m_currentPoint = new Point(0, 20); Collection<V> roots = TreeUtils.getRoots(graph); if (roots.size() > 0 && graph != null) { calculateDimensionX(roots); for(V v : roots) { calculateDimensionX(v); m_currentPoint.x += this.basePositions.get(v)/2 + this.distX; buildTree(v, this.m_currentPoint.x); } } int width = 0; for(V v : roots) { width += basePositions.get(v); } }