/** * Sets the angle and radius of this point to those of {@code p}. * @param p the point whose location is copied into this instance */ public void setLocation(PolarPoint p) { this.theta = p.getTheta(); this.radius = p.getRadius(); } }
/** * Sets the angle and radius of this point to those of {@code p}. */ public void setLocation(PolarPoint p) { this.theta = p.getTheta(); this.radius = p.getRadius(); } }
/** * Returns the result of converting <code>polar</code> to Cartesian coordinates. */ public static Point2D polarToCartesian(PolarPoint polar) { return polarToCartesian(polar.getTheta(), polar.getRadius()); }
/** * @param polar the input location to convert * @return the result of converting <code>polar</code> to Cartesian coordinates. */ public static Point2D polarToCartesian(PolarPoint polar) { return polarToCartesian(polar.getTheta(), polar.getRadius()); }
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; }
double theta = polar.getTheta(); double radius = polar.getRadius();
double theta = polar.getTheta(); double radius = polar.getRadius(); if(radius > viewRadius) return viewPoint;
double theta = polar.getTheta(); double radius = polar.getRadius(); if(radius > viewRadius) return viewPoint;
double theta = polar.getTheta(); double radius = polar.getRadius(); if(radius > viewRadius) return viewPoint;