Maintains state information about crosshairs on a plot between successive
calls to the renderer's draw method. This class is used internally by
JFreeChart - it is not intended for external use.
| Method from org.jfree.chart.plot.CrosshairState Detail: |
public Point2D getAnchor() {
return this.anchor;
}
Returns the anchor point. |
public double getAnchorX() {
return this.anchorX;
}
Returns the x-coordinate (in data space) for the anchor point. |
public double getAnchorY() {
return this.anchorY;
}
Returns the y-coordinate (in data space) for the anchor point. |
public double getCrosshairDistance() {
return this.distance;
}
Returns the distance between the anchor point and the current crosshair
point. |
public double getCrosshairX() {
return this.crosshairX;
}
Get the x-value for the crosshair point. |
public double getCrosshairY() {
return this.crosshairY;
}
Get the y-value for the crosshair point. This is the coordinate in data
space measured against the range axis. |
public int getDomainAxisIndex() {
return this.domainAxisIndex;
}
Returns the domain axis index for the crosshair x-value. |
public int getRangeAxisIndex() {
return this.rangeAxisIndex;
}
Returns the range axis index for the crosshair y-value. |
public void setAnchor(Point2D anchor) {
this.anchor = 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.
Note that the x and y coordinates (in data space) are not updated by
this method - the caller is responsible for ensuring that this happens
in sync. |
public void setAnchorX(double x) {
this.anchorX = x;
}
Sets the x-coordinate (in data space) for the anchor point. Note that
this does NOT update the anchor itself - the caller is responsible for
ensuring this is done in sync. |
public void setAnchorY(double y) {
this.anchorY = y;
}
Sets the y-coordinate (in data space) for the anchor point. Note that
this does NOT update the anchor itself - the caller is responsible for
ensuring this is done in sync. |
public void setCrosshairDistance(double distance) {
this.distance = 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. |
public void setCrosshairX(double x) {
this.crosshairX = x;
}
Sets the x coordinate for the crosshair. This is the coordinate in data
space measured against the domain axis. |
public void setCrosshairY(double y) {
this.crosshairY = y;
}
Sets the y coordinate for the crosshair. |
public void updateCrosshairPoint(double x,
double y,
double transX,
double transY,
PlotOrientation orientation) {
updateCrosshairPoint(x, y, 0, 0, transX, transY, orientation);
} Deprecated! Use - #updateCrosshairPoint(double, double, int, int,
double, double, PlotOrientation) . See bug report 1086307.
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
org.jfree.chart.renderer.xy.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. |
public void updateCrosshairPoint(double x,
double y,
int domainAxisIndex,
int rangeAxisIndex,
double transX,
double transY,
PlotOrientation orientation) {
if (this.anchor != null) {
double d = 0.0;
if (this.calculateDistanceInDataSpace) {
d = (x - this.anchorX) * (x - this.anchorX)
+ (y - this.anchorY) * (y - this.anchorY);
}
else {
double xx = this.anchor.getX();
double yy = this.anchor.getY();
if (orientation == PlotOrientation.HORIZONTAL) {
double temp = yy;
yy = xx;
xx = temp;
}
d = (transX - xx) * (transX - xx)
+ (transY - yy) * (transY - yy);
}
if (d < this.distance) {
this.crosshairX = x;
this.crosshairY = y;
this.domainAxisIndex = domainAxisIndex;
this.rangeAxisIndex = rangeAxisIndex;
this.distance = d;
}
}
}
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
org.jfree.chart.renderer.xy.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. |
public void updateCrosshairX(double candidateX) {
updateCrosshairX(candidateX, 0);
} Deprecated! Use - #updateCrosshairX(double, int) . See bug report
1086307.
|
public void updateCrosshairX(double candidateX,
int domainAxisIndex) {
double d = Math.abs(candidateX - this.anchorX);
if (d < this.distance) {
this.crosshairX = candidateX;
this.domainAxisIndex = domainAxisIndex;
this.distance = d;
}
}
|
public void updateCrosshairY(double candidateY) {
updateCrosshairY(candidateY, 0);
} Deprecated! Use - #updateCrosshairY(double, int) . See bug report
1086307.
|
public void updateCrosshairY(double candidateY,
int rangeAxisIndex) {
double d = Math.abs(candidateY - this.anchorY);
if (d < this.distance) {
this.crosshairY = candidateY;
this.rangeAxisIndex = rangeAxisIndex;
this.distance = d;
}
}
|