@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); }
/** * Returns the result of converting <code>polar</code> to Cartesian coordinates. */ public static Point2D polarToCartesian(PolarPoint polar) { return polarToCartesian(polar.getTheta(), polar.getRadius()); }
public PolarPoint transform(ONDEXConcept arg0) { return new PolarPoint(); } });
private Point2D _transform(Point2D graphPoint) { if(graphPoint == null) return null; Point2D viewCenter = getViewCenter(); double viewRadius = getViewRadius(); double ratio = getRatio(); // transform the point from the graph to the view Point2D viewPoint = graphPoint; // calculate point from center double dx = viewPoint.getX() - viewCenter.getX(); double dy = viewPoint.getY() - viewCenter.getY(); // factor out ellipse dx *= ratio; Point2D pointFromCenter = new Point2D.Double(dx, dy); PolarPoint polar = PolarPoint.cartesianToPolar(pointFromCenter); double theta = polar.getTheta(); double radius = polar.getRadius(); if(radius > viewRadius) return viewPoint; double mag = magnification; radius *= mag; radius = Math.min(radius, viewRadius); Point2D projectedPoint = PolarPoint.polarToCartesian(theta, radius); projectedPoint.setLocation(projectedPoint.getX()/ratio, projectedPoint.getY()); Point2D translatedBack = new Point2D.Double(projectedPoint.getX()+viewCenter.getX(), projectedPoint.getY()+viewCenter.getY()); return translatedBack; }
/** * override base class to un-project the fisheye effect */ private Point2D _inverseTransform(Point2D viewPoint) { viewPoint = delegate.inverseTransform(viewPoint); Point2D viewCenter = getViewCenter(); double viewRadius = getViewRadius(); double ratio = getRatio(); double dx = viewPoint.getX() - viewCenter.getX(); double dy = viewPoint.getY() - viewCenter.getY(); // factor out ellipse dx *= ratio; Point2D pointFromCenter = new Point2D.Double(dx, dy); PolarPoint polar = PolarPoint.cartesianToPolar(pointFromCenter); double radius = polar.getRadius(); if(radius > viewRadius) return viewPoint; double mag = magnification; radius /= mag; polar.setRadius(radius); Point2D projectedPoint = PolarPoint.polarToCartesian(polar); projectedPoint.setLocation(projectedPoint.getX()/ratio, projectedPoint.getY()); Point2D translatedBack = new Point2D.Double(projectedPoint.getX()+viewCenter.getX(), projectedPoint.getY()+viewCenter.getY()); return translatedBack; }
protected void setPolars(List<V> kids, Point2D parentLocation, double parentRadius) { int childCount = kids.size(); if(childCount == 0) return; // handle the 1-child case with 0 limit on angle. double angle = Math.max(0, Math.PI / 2 * (1 - 2.0/childCount)); double childRadius = parentRadius*Math.cos(angle) / (1 + Math.cos(angle)); double radius = parentRadius - childRadius; double rand = Math.random(); for(int i=0; i< childCount; i++) { V child = kids.get(i); double theta = i* 2*Math.PI/childCount + rand; radii.put(child, childRadius); PolarPoint pp = new PolarPoint(theta, radius); polarLocations.put(child, pp); Point2D p = PolarPoint.polarToCartesian(pp); p.setLocation(p.getX()+parentLocation.getX(), p.getY()+parentLocation.getY()); locations.put(child, p); setPolars(new ArrayList<V>(graph.getChildren(child)), p, childRadius); } }
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 Point2D transform(ONDEXConcept v) { PolarPoint pp = polarLocations.get(v); Point2D c = getMaxXY(); c.setLocation(c.getX() / 2, c.getY() / 2); Point2D cartesian = PolarPoint.polarToCartesian(pp); cartesian.setLocation(cartesian.getX() + c.getX(), cartesian.getY() + c.getY()); return cartesian; }
/** * Returns the result of converting <code>point</code> to polar coordinates. */ public static PolarPoint cartesianToPolar(Point2D point) { return cartesianToPolar(point.getX(), point.getY()); }
Point2D pointFromCenter = new Point2D.Double(dx, dy); PolarPoint polar = PolarPoint.cartesianToPolar(pointFromCenter); double theta = polar.getTheta(); double radius = polar.getRadius(); Point2D projectedPoint = PolarPoint.polarToCartesian(theta, radius); projectedPoint.setLocation(projectedPoint.getX()/ratio, projectedPoint.getY()); Point2D translatedBack = new Point2D.Double(projectedPoint.getX()+viewCenter.getX(),
PolarPoint polar = PolarPoint.cartesianToPolar(pointFromCenter); double radius = polar.getRadius(); if(radius > viewRadius) return delegate.inverseTransform(viewPoint); double mag = Math.tan(Math.PI/2*magnification); radius /= mag; polar.setRadius(radius); Point2D projectedPoint = PolarPoint.polarToCartesian(polar); projectedPoint.setLocation(projectedPoint.getX()/ratio, projectedPoint.getY()); Point2D translatedBack = new Point2D.Double(projectedPoint.getX()+viewCenter.getX(),
protected void setPolars(List<V> kids, Point2D parentLocation, double parentRadius) { int childCount = kids.size(); if(childCount == 0) return; // handle the 1-child case with 0 limit on angle. double angle = Math.max(0, Math.PI / 2 * (1 - 2.0/childCount)); double childRadius = parentRadius*Math.cos(angle) / (1 + Math.cos(angle)); double radius = parentRadius - childRadius; double rand = Math.random(); for(int i=0; i< childCount; i++) { V child = kids.get(i); double theta = i* 2*Math.PI/childCount + rand; radii.put(child, childRadius); PolarPoint pp = new PolarPoint(theta, radius); polarLocations.put(child, pp); Point2D p = PolarPoint.polarToCartesian(pp); p.setLocation(p.getX()+parentLocation.getX(), p.getY()+parentLocation.getY()); locations.put(child, p); setPolars(new ArrayList<V>(graph.getChildren(child)), p, childRadius); } }
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 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; }
/** * @param point the input location * @return the result of converting <code>point</code> to polar coordinates. */ public static PolarPoint cartesianToPolar(Point2D point) { return cartesianToPolar(point.getX(), point.getY()); }
Point2D pointFromCenter = new Point2D.Double(dx, dy); PolarPoint polar = PolarPoint.cartesianToPolar(pointFromCenter); double theta = polar.getTheta(); double radius = polar.getRadius(); if(radius > viewRadius) return viewPoint; Point2D projectedPoint = PolarPoint.polarToCartesian(theta, radius); projectedPoint.setLocation(projectedPoint.getX()/ratio, projectedPoint.getY()); Point2D translatedBack = new Point2D.Double(projectedPoint.getX()+viewCenter.getX(),
/** * override base class to un-project the fisheye effect */ public Point2D inverseTransform(Point2D viewPoint) { Point2D viewCenter = getViewCenter(); double viewRadius = getViewRadius(); double ratio = getRatio(); double dx = viewPoint.getX() - viewCenter.getX(); double dy = viewPoint.getY() - viewCenter.getY(); // factor out ellipse dx *= ratio; Point2D pointFromCenter = new Point2D.Double(dx, dy); PolarPoint polar = PolarPoint.cartesianToPolar(pointFromCenter); double radius = polar.getRadius(); if(radius > viewRadius) return delegate.inverseTransform(viewPoint); double mag = magnification; radius /= mag; polar.setRadius(radius); Point2D projectedPoint = PolarPoint.polarToCartesian(polar); projectedPoint.setLocation(projectedPoint.getX()/ratio, projectedPoint.getY()); Point2D translatedBack = new Point2D.Double(projectedPoint.getX()+viewCenter.getX(), projectedPoint.getY()+viewCenter.getY()); return delegate.inverseTransform(translatedBack); }
@Override public void setLocation(ONDEXConcept v, Point2D location) { Point2D c = getMaxXY(); c.setLocation(c.getX() / 2, c.getY() / 2); Point2D pv = new Point2D.Double(location.getX() - c.getX(), location.getY() - c.getY()); PolarPoint newLocation = PolarPoint.cartesianToPolar(pv); polarLocations.get(v).setLocation(newLocation); }