private void adjustLocations(Dimension oldSize, Dimension size) { int xOffset = (size.width - oldSize.width) / 2; int yOffset = (size.height - oldSize.height) / 2; // now, move each vertex to be at the new screen center while(true) { try { for(V v : getGraph().getVertices()) { offsetVertex(v, xOffset, yOffset); } break; } catch(ConcurrentModificationException cme) { } } }
/** * When a visualization is resized, it presumably wants to fix the * locations of the vertices and possibly to reinitialize its data. The * current method calls <tt>initializeLocations</tt> followed by <tt>initialize_local</tt>. */ public void setSize(Dimension size) { if(size != null && graph != null) { Dimension oldSize = this.size; this.size = size; initialize(); if(oldSize != null) { adjustLocations(oldSize, size); } } }
public Point2D apply(V v) { return getCoordinates(v); }
/** * @param v the vertex whose coordinates are to be offset * @param xOffset the change to apply to this vertex's x coordinate * @param yOffset the change to apply to this vertex's y coordinate */ protected void offsetVertex(V v, double xOffset, double yOffset) { Point2D c = getCoordinates(v); c.setLocation(c.getX()+xOffset, c.getY()+yOffset); setLocation(v, c); }
/** * @see java.awt.event.ComponentAdapter#componentResized(java.awt.event.ComponentEvent) */ @Override public void componentResized(ComponentEvent arg0) { super.componentResized(arg0); System.err.println("resized"); layout.setSize(arg0.getComponent().getSize()); }});
public void process() { try { if (g.getVertexCount() < 100) { layout.lock(true); //add a vertex Integer v1 = new Integer(g.getVertexCount()); Relaxer relaxer = vv.getModel().getRelaxer(); relaxer.pause(); g.addVertex(v1); System.err.println("added node " + v1); // wire it to some edges if (v_prev != null) { g.addEdge(g.getEdgeCount(), v_prev, v1); // let's connect to a random vertex, too! int rand = (int) (Math.random() * g.getVertexCount()); g.addEdge(g.getEdgeCount(), v1, rand); } v_prev = v1; layout.initialize(); relaxer.resume(); layout.lock(false); } else { done = true; } } catch (Exception e) { System.out.println(e); } }
public void setGraph(Graph<V,E> graph) { this.graph = graph; if(size != null && graph != null) { initialize(); } }
/** * @param lock {@code true} to lock all vertices in place, {@code false} to unlock all vertices */ public void lock(boolean lock) { for(V v : graph.getVertices()) { lock(v, lock); } } }
/** * Get the graph to be layouted. */ public Graph getGraph() { if(layers==null) layoutLayers(); if(!positions) setPositions(); return super.getGraph(); }
@Override public void setSize(Dimension size) { if(initialized == false) { setInitializer(new RandomLocationTransformer<V>(size)); } super.setSize(size); max_dimension = Math.max(size.height, size.width); }
/** * @param v * @param xOffset * @param yOffset */ protected void offsetVertex(V v, double xOffset, double yOffset) { Point2D c = getCoordinates(v); c.setLocation(c.getX()+xOffset, c.getY()+yOffset); setLocation(v, c); }
public void setGraph(Graph<V,E> graph) { this.graph = graph; if(size != null && graph != null) { initialize(); } }
/** * Locks all vertices in place if {@code lock} is {@code true}, otherwise unlocks all vertices. */ public void lock(boolean lock) { for(V v : graph.getVertices()) { lock(v, lock); } } }
Graph graph = super.getGraph(); List rootnodes = new ArrayList(); List leafnodes = new ArrayList();
@Override public void setSize(Dimension size) { if(initialized == false) { setInitializer(new RandomLocationTransformer<V>(size)); } super.setSize(size); max_dimension = Math.max(size.height, size.width); }
private void adjustLocations(Dimension oldSize, Dimension size) { int xOffset = (size.width - oldSize.width) / 2; int yOffset = (size.height - oldSize.height) / 2; // now, move each vertex to be at the new screen center while(true) { try { for(V v : getGraph().getVertices()) { offsetVertex(v, xOffset, yOffset); } break; } catch(ConcurrentModificationException cme) { } } }
/** * When a visualization is resized, it presumably wants to fix the * locations of the vertices and possibly to reinitialize its data. The * current method calls <tt>initializeLocations</tt> followed by <tt>initialize_local</tt>. */ public void setSize(Dimension size) { if(size != null && graph != null) { Dimension oldSize = this.size; this.size = size; initialize(); if(oldSize != null) { adjustLocations(oldSize, size); } } }
public Point2D transform(V v) { return getCoordinates(v); }
@Override public void setSize(Dimension size) { if(initialized == false) { setInitializer(new RandomLocationTransformer<V>(size)); } super.setSize(size); max_dimension = Math.max(size.height, size.width); }