/** * @param v the vertex whose center is to be returned * @return the coordinates of {@code v}'s parent, or the center of this layout's area if it's a root. */ public Point2D getCenter(V v) { V parent = graph.getParent(v); if(parent == null) { return getCenter(); } return locations.getUnchecked(parent); }
@Override public void setLocation(V v, Point2D location) { Point2D c = getCenter(v); Point2D pv = new Point2D.Double(location.getX()-c.getX(),location.getY()-c.getY()); PolarPoint newLocation = PolarPoint.cartesianToPolar(pv); polarLocations.get(v).setLocation(newLocation); Point2D center = getCenter(v); pv.setLocation(pv.getX()+center.getX(), pv.getY()+center.getY()); locations.put(v, pv); }
protected void setRootPolar(V root) { PolarPoint pp = new PolarPoint(0,0); Point2D p = getCenter(); polarLocations.put(root, pp); locations.put(root, p); }
/** * Returns the coordinates of {@code v}'s parent, or the * center of this layout's area if it's a root. */ public Point2D getCenter(V v) { V parent = graph.getParent(v); if(parent == null) { return getCenter(); } return locations.get(parent); }
@Override public void setLocation(V v, Point2D location) { Point2D c = getCenter(v); Point2D pv = new Point2D.Double(location.getX()-c.getX(),location.getY()-c.getY()); PolarPoint newLocation = PolarPoint.cartesianToPolar(pv); polarLocations.getUnchecked(v).setLocation(newLocation); Point2D center = getCenter(v); pv.setLocation(pv.getX()+center.getX(), pv.getY()+center.getY()); locations.put(v, pv); }
protected void setRootPolars() { List<V> roots = TreeUtils.getRoots(graph); if(roots.size() == 1) { // its a Tree V root = roots.get(0); setRootPolar(root); setPolars(new ArrayList<V>(graph.getChildren(root)), getCenter(), getSize().width/2); } else if (roots.size() > 1) { // its a Forest setPolars(roots, getCenter(), getSize().width/2); } }
protected void setRootPolars() { List<V> roots = TreeUtils.getRoots(graph); if(roots.size() == 1) { // its a Tree V root = roots.get(0); setRootPolar(root); setPolars(new ArrayList<V>(graph.getChildren(root)), getCenter(), getSize().width/2); } else if (roots.size() > 1) { // its a Forest setPolars(roots, getCenter(), getSize().width/2); } }
protected void setRootPolar(V root) { PolarPoint pp = new PolarPoint(0,0); Point2D p = getCenter(); polarLocations.put(root, pp); locations.put(root, p); }