/** * Returns the result of converting <code>point</code> to polar coordinates. */ public static PolarPoint cartesianToPolar(Point2D point) { return cartesianToPolar(point.getX(), point.getY()); }
/** * @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()); }
@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 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); }
@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); }
@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 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); }
/** * 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; }
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; }
Point2D pointFromCenter = new Point2D.Double(dx, dy); PolarPoint polar = PolarPoint.cartesianToPolar(pointFromCenter); double theta = polar.getTheta(); double radius = polar.getRadius();
Point2D pointFromCenter = new Point2D.Double(dx, dy); PolarPoint polar = PolarPoint.cartesianToPolar(pointFromCenter); double theta = polar.getTheta(); double radius = polar.getRadius();
Point2D pointFromCenter = new Point2D.Double(dx, dy); PolarPoint polar = PolarPoint.cartesianToPolar(pointFromCenter); double theta = polar.getTheta(); double radius = polar.getRadius();
PolarPoint polar = PolarPoint.cartesianToPolar(pointFromCenter);
PolarPoint polar = PolarPoint.cartesianToPolar(pointFromCenter);
Point2D pointFromCenter = new Point2D.Double(dx, dy); PolarPoint polar = PolarPoint.cartesianToPolar(pointFromCenter); double theta = polar.getTheta(); double radius = polar.getRadius();
/** * 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); }