Class Crosshair
java.lang.Object
org.jfree.chart.plot.Crosshair
- All Implemented Interfaces:
Serializable,Cloneable,PublicCloneable
A
Crosshairs support a property change mechanism which is used by JFreeChart to automatically repaint the overlay whenever a crosshair attribute is updated.
Crosshair represents a value on a chart and is usually displayed
as a line perpendicular to the x or y-axis (and sometimes including a label
that shows the crosshair value as text). Instances of this class are used
to store the cross hair value plus the visual characteristics of the line
that will be rendered once the instance is added to a
CrosshairOverlay (or CrosshairOverlaydFX if you are using
the JavaFX extensions for JFreeChart).
Crosshairs support a property change mechanism which is used by JFreeChart to automatically repaint the overlay whenever a crosshair attribute is updated.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a property change listener.clone()Returns an independent copy of this instance.booleanTests this crosshair for equality with an arbitrary object.Returns the label anchor point.Returns the label background paint.Returns the label font.Returns the crosshair label generator.Returns the label outline paint.Returns the label outline stroke.Returns the label padding.Returns the label paint.doubleReturns the x-offset for the label (in Java2D units).doubleReturns the y-offset for the label (in Java2D units).getPaint()Returns the paint for the crosshair line.Returns the stroke for the crosshair line.doublegetValue()Returns the crosshair value.inthashCode()Returns a hash code for this instance.booleanReturns the flag that controls the visibility of the label outline.booleanReturns the flag that controls whether a label is drawn for this crosshair.booleanReturns the flag that indicates whether the crosshair is currently visible.voidRemoves a property change listener.voidsetLabelAnchor(RectangleAnchor anchor) Sets the label anchor point and sends a property change event (with the name 'labelAnchor') to all registered listeners.voidsetLabelBackgroundPaint(Paint paint) Sets the label background paint and sends a property change event with the name 'labelBackgroundPaint') to all registered listeners.voidsetLabelFont(Font font) Sets the label font and sends a property change event (with the name 'labelFont') to all registered listeners.voidsetLabelGenerator(CrosshairLabelGenerator generator) Sets the crosshair label generator and sends a property change event (with the name 'labelGenerator') to all registered listeners.voidsetLabelOutlinePaint(Paint paint) Sets the label outline paint and sends a property change event (with the name "labelOutlinePaint") to all registered listeners.voidsetLabelOutlineStroke(Stroke stroke) Sets the label outline stroke and sends a property change event (with the name 'labelOutlineStroke') to all registered listeners.voidsetLabelOutlineVisible(boolean visible) Sets the flag that controls the visibility of the label outlines and sends a property change event (with the name "labelOutlineVisible") to all registered listeners.voidsetLabelPadding(RectangleInsets padding) Sets the label padding and sends a property change event (with the name 'labelPadding') to all registered listeners.voidsetLabelPaint(Paint paint) Sets the label paint and sends a property change event (with the name 'labelPaint') to all registered listeners.voidsetLabelVisible(boolean visible) Sets the flag that controls whether a label is drawn for the crosshair and sends a property change event (with the name 'labelVisible') to all registered listeners.voidsetLabelXOffset(double offset) Sets the x-offset and sends a property change event (with the name 'labelXOffset') to all registered listeners.voidsetLabelYOffset(double offset) Sets the y-offset and sends a property change event (with the name 'labelYOffset') to all registered listeners.voidSets the paint for the crosshair line and sends a property change event with the name "paint" to all registered listeners.voidSets the stroke for the crosshair line and sends a property change event with the name "stroke" to all registered listeners.voidsetValue(double value) Sets the crosshair value and sends a property change event with the name 'value' to all registered listeners.voidsetVisible(boolean visible) Sets the flag that controls the visibility of the crosshair and sends a proerty change event (with the name 'visible') to all registered listeners.
-
Constructor Details
-
Crosshair
public Crosshair()Creates a new crosshair with value 0.0. -
Crosshair
Creates a new crosshair with the specified value.- Parameters:
value- the value.
-
Crosshair
-
-
Method Details
-
isVisible
Returns the flag that indicates whether the crosshair is currently visible.- Returns:
- A boolean.
- See Also:
-
setVisible
Sets the flag that controls the visibility of the crosshair and sends a proerty change event (with the name 'visible') to all registered listeners.- Parameters:
visible- the new flag value.- See Also:
-
getValue
-
setValue
Sets the crosshair value and sends a property change event with the name 'value' to all registered listeners.- Parameters:
value- the value.- See Also:
-
getPaint
-
setPaint
-
getStroke
-
setStroke
-
isLabelVisible
Returns the flag that controls whether a label is drawn for this crosshair.- Returns:
- A boolean.
- See Also:
-
setLabelVisible
Sets the flag that controls whether a label is drawn for the crosshair and sends a property change event (with the name 'labelVisible') to all registered listeners.- Parameters:
visible- the new flag value.- See Also:
-
getLabelGenerator
Returns the crosshair label generator.- Returns:
- The label crosshair generator (never
null). - See Also:
-
setLabelGenerator
Sets the crosshair label generator and sends a property change event (with the name 'labelGenerator') to all registered listeners.- Parameters:
generator- the new generator (nullnot permitted).- See Also:
-
getLabelAnchor
Returns the label anchor point.- Returns:
- the label anchor point (never
null). - See Also:
-
setLabelAnchor
Sets the label anchor point and sends a property change event (with the name 'labelAnchor') to all registered listeners.- Parameters:
anchor- the anchor (nullnot permitted).- See Also:
-
getLabelXOffset
Returns the x-offset for the label (in Java2D units).- Returns:
- The x-offset.
- See Also:
-
setLabelXOffset
Sets the x-offset and sends a property change event (with the name 'labelXOffset') to all registered listeners.- Parameters:
offset- the new offset.- See Also:
-
getLabelYOffset
Returns the y-offset for the label (in Java2D units).- Returns:
- The y-offset.
- See Also:
-
setLabelYOffset
Sets the y-offset and sends a property change event (with the name 'labelYOffset') to all registered listeners.- Parameters:
offset- the new offset.- See Also:
-
getLabelPadding
Returns the label padding.- Returns:
- The label padding (never
null). - Since:
- 1.5.6
-
setLabelPadding
Sets the label padding and sends a property change event (with the name 'labelPadding') to all registered listeners.- Parameters:
padding- the padding (nullnot permitted).- Since:
- 1.5.6
-
getLabelFont
-
setLabelFont
Sets the label font and sends a property change event (with the name 'labelFont') to all registered listeners.- Parameters:
font- the font (nullnot permitted).- See Also:
-
getLabelPaint
Returns the label paint. The default value isColor.BLACK.- Returns:
- The label paint (never
null). - See Also:
-
setLabelPaint
Sets the label paint and sends a property change event (with the name 'labelPaint') to all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
-
getLabelBackgroundPaint
Returns the label background paint.- Returns:
- The label background paint (possibly
null). - See Also:
-
setLabelBackgroundPaint
Sets the label background paint and sends a property change event with the name 'labelBackgroundPaint') to all registered listeners.- Parameters:
paint- the paint (nullpermitted).- See Also:
-
isLabelOutlineVisible
Returns the flag that controls the visibility of the label outline. The default value istrue.- Returns:
- A boolean.
- See Also:
-
setLabelOutlineVisible
Sets the flag that controls the visibility of the label outlines and sends a property change event (with the name "labelOutlineVisible") to all registered listeners.- Parameters:
visible- the new flag value.- See Also:
-
getLabelOutlinePaint
Returns the label outline paint.- Returns:
- The label outline paint (never
null). - See Also:
-
setLabelOutlinePaint
Sets the label outline paint and sends a property change event (with the name "labelOutlinePaint") to all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
-
getLabelOutlineStroke
Returns the label outline stroke. The default value isBasicStroke(0.5).- Returns:
- The label outline stroke (never
null). - See Also:
-
setLabelOutlineStroke
Sets the label outline stroke and sends a property change event (with the name 'labelOutlineStroke') to all registered listeners.- Parameters:
stroke- the stroke (nullnot permitted).- See Also:
-
equals
-
hashCode
-
clone
Returns an independent copy of this instance.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classObject- Returns:
- An independent copy of this instance.
- Throws:
CloneNotSupportedException- if there is a problem with cloning.
-
addPropertyChangeListener
Adds a property change listener.- Parameters:
l- the listener.- See Also:
-
removePropertyChangeListener
Removes a property change listener.- Parameters:
l- the listener.- See Also:
-