org.jfree.chart.plot
Class CrosshairState
java.lang.Object
org.jfree.chart.plot.CrosshairState
Maintains state information about crosshairs on a plot.
double | getCrosshairX() - Get the x-value for the crosshair point.
|
double | getCrosshairY() - Get the y-value for the crosshair point.
|
void | setAnchor(Point2D anchor) - Sets the anchor point.
|
void | setCrosshairDistance(double distance) - Sets the distance between the anchor point and the current crosshair
point.
|
void | setCrosshairX(double x) - Sets the x coordinate for the crosshair.
|
void | setCrosshairY(double y) - Sets the y coordinate for the crosshair.
|
void | updateCrosshairPoint(double x, double y, double transX, double transY, PlotOrientation orientation) - Evaluates a data point and if it is the closest to the anchor point it
becomes the new crosshair point.
|
void | updateCrosshairX(double candidateX) - Evaluates an x-value and if it is the closest to the anchor point it
becomes the new crosshair point.
|
void | updateCrosshairY(double candidateY) - Evaluates a y-value and if it is the closest to the anchor point it
becomes the new crosshair point.
|
CrosshairState
public CrosshairState(boolean calculateDistanceInDataSpace)
Creates a new info object.
calculateDistanceInDataSpace
- a flag that controls whether the
distance is calculated in data
space or Java2D space.
getCrosshairX
public double getCrosshairX()
Get the x-value for the crosshair point.
- The x position of the crosshair point.
getCrosshairY
public double getCrosshairY()
Get the y-value for the crosshair point. This is the coordinate in data
space measured against the range axis.
- The y position of the crosshair point.
setAnchor
public void setAnchor(Point2D anchor)
Sets the anchor point. This is usually the mouse click point in a chart
panel, and the crosshair point will often be the data item that is
closest to the anchor point.
anchor
- the anchor point.
setCrosshairDistance
public void setCrosshairDistance(double distance)
Sets the distance between the anchor point and the current crosshair
point. As each data point is processed, its distance to the anchor
point is compared with this value and, if it is closer, the data point
becomes the new crosshair point.
setCrosshairX
public void setCrosshairX(double x)
Sets the x coordinate for the crosshair. This is the coordinate in data
space measured against the domain axis.
setCrosshairY
public void setCrosshairY(double y)
Sets the y coordinate for the crosshair.
updateCrosshairPoint
public void updateCrosshairPoint(double x,
double y,
double transX,
double transY,
PlotOrientation orientation)
Evaluates a data point and if it is the closest to the anchor point it
becomes the new crosshair point.
To understand this method, you need to know the context in which it will
be called. An instance of this class is passed to an
XYItemRenderer
as
each data point is plotted. As the point is plotted, it is passed to
this method to see if it should be the new crosshair point.
x
- x coordinate (measured against the domain axis).y
- y coordinate (measured against the range axis).transX
- x translated into Java2D space.transY
- y translated into Java2D space.orientation
- the plot orientation.
updateCrosshairX
public void updateCrosshairX(double candidateX)
Evaluates an x-value and if it is the closest to the anchor point it
becomes the new crosshair point.
Used in cases where only the x-axis is numerical.
candidateX
- x position of the candidate for the new crosshair
point.
updateCrosshairY
public void updateCrosshairY(double candidateY)
Evaluates a y-value and if it is the closest to the anchor point it
becomes the new crosshair point.
Used in cases where only the y-axis is numerical.
candidateY
- y position of the candidate for the new crosshair
point.