org.jfree.chart
Class CrosshairInfo

java.lang.Object
  extended byorg.jfree.chart.CrosshairInfo

public class CrosshairInfo
extends java.lang.Object

Maintains information about crosshairs on a plot.

Author:
David Gilbert

Constructor Summary
CrosshairInfo()
          Default constructor.
CrosshairInfo(boolean calculateDistanceInDataSpace)
          Creates a new info object.
 
Method Summary
 double getCrosshairX()
          Get the x-value for the crosshair point.
 double getCrosshairY()
          Get the y-value for the crosshair point.
 void setAnchor(java.awt.geom.Point2D anchor)
          Sets the anchor point.
 void setAnchorX(double x)
          Set the x-value for the anchor point.
 void setAnchorY(double y)
          Set the y-value for the anchor point.
 void setCrosshairDistance(double distance)
          Sets the distance.
 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 dataX, double dataY, double viewX, double viewY)
          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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CrosshairInfo

public CrosshairInfo()
Default constructor.


CrosshairInfo

public CrosshairInfo(boolean calculateDistanceInDataSpace)
Creates a new info object.

Parameters:
calculateDistanceInDataSpace - a flag that controls whether the distance is calculated in data space or Java2D space.
Method Detail

setCrosshairDistance

public void setCrosshairDistance(double distance)
Sets the distance.

Parameters:
distance - the distance.

updateCrosshairPoint

public void updateCrosshairPoint(double dataX,
                                 double dataY,
                                 double viewX,
                                 double viewY)
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.

Parameters:
dataX - x position of candidate for the new crosshair point.
dataY - y position of candidate for the new crosshair point.
viewX - x in Java2D space.
viewY - y in Java2D space.

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.

Parameters:
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.

Parameters:
candidateY - y position of the candidate for the new crosshair point.

setAnchorX

public void setAnchorX(double x)
Set the x-value for the anchor point.

Parameters:
x - the x position.

setAnchorY

public void setAnchorY(double y)
Set the y-value for the anchor point.

Parameters:
y - the y position.

setAnchor

public void setAnchor(java.awt.geom.Point2D anchor)
Sets the anchor point.

Parameters:
anchor - the anchor point.

getCrosshairX

public double getCrosshairX()
Get the x-value for the crosshair point.

Returns:
the x position of the crosshair point.

setCrosshairX

public void setCrosshairX(double x)
Sets the x coordinate for the crosshair.

Parameters:
x - the coordinate.

getCrosshairY

public double getCrosshairY()
Get the y-value for the crosshair point.

Returns:
the y position of the crosshair point.

setCrosshairY

public void setCrosshairY(double y)
Sets the y coordinate for the crosshair.

Parameters:
y - the y coordinate.