Package org.jfree.chart.panel
Class CrosshairOverlay
java.lang.Object
org.jfree.chart.panel.AbstractOverlay
org.jfree.chart.panel.CrosshairOverlay
- All Implemented Interfaces:
PropertyChangeListener,Serializable,Cloneable,EventListener,Overlay,PublicCloneable
public class CrosshairOverlay
extends AbstractOverlay
implements Overlay, PropertyChangeListener, PublicCloneable, Cloneable, Serializable
An overlay for a
ChartPanel that draws crosshairs on a chart. If
you are using the JavaFX extensions for JFreeChart, then you should use
the CrosshairOverlayFX class.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new overlay that initially contains no crosshairs. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDomainCrosshair(Crosshair crosshair) Adds a crosshair against the domain axis (x-axis) and sends anOverlayChangeEventto all registered listeners.voidaddRangeCrosshair(Crosshair crosshair) Adds a crosshair against the range axis and sends anOverlayChangeEventto all registered listeners.voidClears all the domain crosshairs from the overlay and sends anOverlayChangeEventto all registered listeners (unless there were no crosshairs to begin with).voidClears all the range crosshairs from the overlay and sends anOverlayChangeEventto all registered listeners (unless there were no crosshairs to begin with).clone()Returns a clone of this instance.protected voiddrawHorizontalCrosshair(Graphics2D g2, Rectangle2D dataArea, double y, Crosshair crosshair) Draws a crosshair horizontally across the plot.protected voiddrawVerticalCrosshair(Graphics2D g2, Rectangle2D dataArea, double x, Crosshair crosshair) Draws a crosshair vertically on the plot.booleanTests this overlay for equality with an arbitrary object.Returns a new list containing the domain crosshairs for this overlay.Returns a new list containing the range crosshairs for this overlay.voidpaintOverlay(Graphics2D g2, ChartPanel chartPanel) Renders the crosshairs in the overlay on top of the chart that has just been rendered in the specifiedchartPanel.voidReceives a property change event (typically a change in one of the crosshairs).voidremoveDomainCrosshair(Crosshair crosshair) Removes a domain axis crosshair and sends anOverlayChangeEventto all registered listeners.voidremoveRangeCrosshair(Crosshair crosshair) Removes a range axis crosshair and sends anOverlayChangeEventto all registered listeners.Methods inherited from class org.jfree.chart.panel.AbstractOverlay
addChangeListener, fireOverlayChanged, notifyListeners, removeChangeListenerMethods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jfree.chart.panel.Overlay
addChangeListener, removeChangeListener
-
Constructor Details
-
CrosshairOverlay
public CrosshairOverlay()Creates a new overlay that initially contains no crosshairs.
-
-
Method Details
-
addDomainCrosshair
Adds a crosshair against the domain axis (x-axis) and sends anOverlayChangeEventto all registered listeners.- Parameters:
crosshair- the crosshair (nullnot permitted).- See Also:
-
removeDomainCrosshair
Removes a domain axis crosshair and sends anOverlayChangeEventto all registered listeners.- Parameters:
crosshair- the crosshair (nullnot permitted).- See Also:
-
clearDomainCrosshairs
Clears all the domain crosshairs from the overlay and sends anOverlayChangeEventto all registered listeners (unless there were no crosshairs to begin with). -
getDomainCrosshairs
Returns a new list containing the domain crosshairs for this overlay.- Returns:
- A list of crosshairs.
-
addRangeCrosshair
Adds a crosshair against the range axis and sends anOverlayChangeEventto all registered listeners.- Parameters:
crosshair- the crosshair (nullnot permitted).
-
removeRangeCrosshair
Removes a range axis crosshair and sends anOverlayChangeEventto all registered listeners.- Parameters:
crosshair- the crosshair (nullnot permitted).- See Also:
-
clearRangeCrosshairs
Clears all the range crosshairs from the overlay and sends anOverlayChangeEventto all registered listeners (unless there were no crosshairs to begin with). -
getRangeCrosshairs
Returns a new list containing the range crosshairs for this overlay.- Returns:
- A list of crosshairs.
-
propertyChange
Receives a property change event (typically a change in one of the crosshairs).- Specified by:
propertyChangein interfacePropertyChangeListener- Parameters:
e- the event.
-
paintOverlay
Renders the crosshairs in the overlay on top of the chart that has just been rendered in the specifiedchartPanel. This method is called by the JFreeChart framework, you won't normally call it from user code.- Specified by:
paintOverlayin interfaceOverlay- Parameters:
g2- the graphics target.chartPanel- the chart panel.
-
drawHorizontalCrosshair
protected void drawHorizontalCrosshair(Graphics2D g2, Rectangle2D dataArea, double y, Crosshair crosshair) Draws a crosshair horizontally across the plot.- Parameters:
g2- the graphics target.dataArea- the data area.y- the y-value in Java2D space.crosshair- the crosshair.
-
drawVerticalCrosshair
protected void drawVerticalCrosshair(Graphics2D g2, Rectangle2D dataArea, double x, Crosshair crosshair) Draws a crosshair vertically on the plot.- Parameters:
g2- the graphics target.dataArea- the data area.x- the x-value in Java2D space.crosshair- the crosshair.
-
equals
Tests this overlay for equality with an arbitrary object. -
clone
Returns a clone of this instance.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classObject- Returns:
- A clone of this instance.
- Throws:
CloneNotSupportedException- if there is some problem with the cloning.
-