@Override public void setLocation(V v, Point2D location) { Point2D c = getCenter(); Point2D pv = new Point2D.Double(location.getX() - c.getX(), location.getY() - c.getY()); PolarPoint newLocation = PolarPoint.cartesianToPolar(pv); PolarPoint currentLocation = polarLocations.get(v); if (currentLocation == null) polarLocations.put(v, newLocation); else currentLocation.setLocation(newLocation); }
@Override public void setSize(Dimension size) { this.size = size; buildTree(); }
private void setRadialLocations() { Point2D max = getMaxXY(); double maxx = max.getX(); double maxy = max.getY(); maxx = Math.max(maxx, size.width); double theta = 2*Math.PI/maxx; double deltaRadius = size.width/2/maxy; for(Map.Entry<V, Point2D> entry : locations.entrySet()) { V v = entry.getKey(); Point2D p = entry.getValue(); PolarPoint polarPoint = new PolarPoint(p.getX()*theta, (p.getY() - this.distY)*deltaRadius); polarLocations.put(v, polarPoint); } } }
radialLayout = new RadialTreeLayout<String,Integer>(graph); radialLayout.setSize(new Dimension(600,600)); vv = new VisualizationViewer<String,Integer>(treeLayout, new Dimension(600,600)); vv.setBackground(Color.white);
@Override public Point2D apply(V v) { PolarPoint pp = polarLocations.get(v); double centerX = getSize().getWidth()/2; double centerY = getSize().getHeight()/2; Point2D cartesian = PolarPoint.polarToCartesian(pp); cartesian.setLocation(cartesian.getX()+centerX,cartesian.getY()+centerY); return cartesian; }
@Override protected void buildTree() { super.buildTree(); this.polarLocations = new HashMap<V, PolarPoint>(); setRadialLocations(); }
private Collection<Double> getDepths() { Set<Double> depths = new HashSet<Double>(); Map<String,PolarPoint> polarLocations = radialLayout.getPolarLocations(); for(String v : graph.getVertices()) { PolarPoint pp = polarLocations.get(v); depths.add(pp.getRadius()); } return depths; }
radialLayout = new RadialTreeLayout<String,Integer>(graph); radialLayout.setSize(new Dimension(600,600)); vv = new VisualizationViewer<String,Integer>(treeLayout, new Dimension(600,600)); vv.setBackground(Color.white);
@Override public Point2D transform(V v) { PolarPoint pp = polarLocations.get(v); double centerX = getSize().getWidth()/2; double centerY = getSize().getHeight()/2; Point2D cartesian = PolarPoint.polarToCartesian(pp); cartesian.setLocation(cartesian.getX()+centerX,cartesian.getY()+centerY); return cartesian; }
@Override protected void buildTree() { super.buildTree(); this.polarLocations = new HashMap<V, PolarPoint>(); setRadialLocations(); }
private Collection<Double> getDepths() { Set<Double> depths = new HashSet<Double>(); Map<String,PolarPoint> polarLocations = radialLayout.getPolarLocations(); for(String v : graph.getVertices()) { PolarPoint pp = polarLocations.get(v); depths.add(pp.getRadius()); } return depths; }
@Override public void setLocation(V v, Point2D location) { Point2D c = getCenter(); Point2D pv = new Point2D.Double(location.getX() - c.getX(), location.getY() - c.getY()); PolarPoint newLocation = PolarPoint.cartesianToPolar(pv); PolarPoint currentLocation = polarLocations.get(v); if (currentLocation == null) polarLocations.put(v, newLocation); else currentLocation.setLocation(newLocation); }
collapser = new TreeCollapser(); radialLayout = new RadialTreeLayout<String,Integer>(graph); radialLayout.setSize(new Dimension(600,600)); vv = new VisualizationViewer<String,Integer>(layout, new Dimension(600,600)); vv.setBackground(Color.white);
@Override public void setSize(Dimension size) { this.size = size; buildTree(); }
private void setRadialLocations() { Point2D max = getMaxXY(); double maxx = max.getX(); double maxy = max.getY(); maxx = Math.max(maxx, size.width); double theta = 2*Math.PI/maxx; double deltaRadius = size.width/2/maxy; for(Map.Entry<V, Point2D> entry : locations.asMap().entrySet()) { V v = entry.getKey(); Point2D p = entry.getValue(); PolarPoint polarPoint = new PolarPoint(p.getX()*theta, (p.getY() - this.distY)*deltaRadius); polarLocations.put(v, polarPoint); } } }
private Collection<Double> getDepths() { Set<Double> depths = new HashSet<Double>(); Map<String,PolarPoint> polarLocations = radialLayout.getPolarLocations(); for(String v : graph.getVertices()) { PolarPoint pp = polarLocations.get(v); depths.add(pp.getRadius()); } return depths; }
public void paint(Graphics g) { g.setColor(Color.gray); Graphics2D g2d = (Graphics2D)g; Point2D center = radialLayout.getCenter(); Ellipse2D ellipse = new Ellipse2D.Double(); for(double d : depths) { ellipse.setFrameFromDiagonal(center.getX()-d, center.getY()-d, center.getX()+d, center.getY()+d); Shape shape = vv.getRenderContext().getMultiLayerTransformer().transform(ellipse); g2d.draw(shape); } }
radialLayout = new RadialTreeLayout<String,Integer>(graph); radialLayout.setSize(new Dimension(600,600));
private Collection<Double> getDepths() { Set<Double> depths = new HashSet<Double>(); Map<String,PolarPoint> polarLocations = radialLayout.getPolarLocations(); for(String v : graph.getVertices()) { PolarPoint pp = polarLocations.get(v); depths.add(pp.getRadius()); } return depths; }
public void paint(Graphics g) { g.setColor(Color.lightGray); Graphics2D g2d = (Graphics2D)g; Point2D center = radialLayout.getCenter(); Ellipse2D ellipse = new Ellipse2D.Double(); for(double d : depths) { ellipse.setFrameFromDiagonal(center.getX()-d, center.getY()-d, center.getX()+d, center.getY()+d); Shape shape = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).transform(ellipse); g2d.draw(shape); } }