Package org.jfree.chart.plot
Class Crosshair
- java.lang.Object
-
- org.jfree.chart.plot.Crosshair
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,PublicCloneable
public class Crosshair extends java.lang.Object implements java.lang.Cloneable, PublicCloneable, java.io.Serializable
A crosshair for display on a plot.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private RectangleAnchorlabelAnchorThe label anchor.private java.awt.PaintlabelBackgroundPaintThe label background paint.private java.awt.FontlabelFontThe label font.private CrosshairLabelGeneratorlabelGeneratorA label generator.private java.awt.PaintlabelOutlinePaintThe label outline paint.private java.awt.StrokelabelOutlineStrokeThe label outline stroke.private booleanlabelOutlineVisibleA flag that controls the visibility of the label outline.private java.awt.PaintlabelPaintThe label paint.private booleanlabelVisibleA flag that controls whether or not the crosshair has a label visible.private doublelabelXOffsetThe x-offset in Java2D units.private doublelabelYOffsetThe y-offset in Java2D units.private java.awt.PaintpaintThe paint for the crosshair line.private java.beans.PropertyChangeSupportpcsProperty change support.private java.awt.StrokestrokeThe stroke for the crosshair line.private doublevalueThe crosshair value.private booleanvisibleFlag controlling visibility.
-
Constructor Summary
Constructors Constructor Description Crosshair()Creates a new crosshair with value 0.0.Crosshair(double value)Creates a new crosshair with the specified value.Crosshair(double value, java.awt.Paint paint, java.awt.Stroke stroke)Creates a new crosshair value with the specified value and line style.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPropertyChangeListener(java.beans.PropertyChangeListener l)Adds a property change listener.java.lang.Objectclone()Returns an independent copy of this instance.booleanequals(java.lang.Object obj)Tests this crosshair for equality with an arbitrary object.RectangleAnchorgetLabelAnchor()Returns the label anchor point.java.awt.PaintgetLabelBackgroundPaint()Returns the label background paint.java.awt.FontgetLabelFont()Returns the label font.CrosshairLabelGeneratorgetLabelGenerator()Returns the crosshair label generator.java.awt.PaintgetLabelOutlinePaint()Returns the label outline paint.java.awt.StrokegetLabelOutlineStroke()Returns the label outline stroke.java.awt.PaintgetLabelPaint()Returns the label paint.doublegetLabelXOffset()Returns the x-offset for the label (in Java2D units).doublegetLabelYOffset()Returns the y-offset for the label (in Java2D units).java.awt.PaintgetPaint()Returns the paint for the crosshair line.java.awt.StrokegetStroke()Returns the stroke for the crosshair line.doublegetValue()Returns the crosshair value.inthashCode()Returns a hash code for this instance.booleanisLabelOutlineVisible()Returns the flag that controls the visibility of the label outline.booleanisLabelVisible()Returns the flag that controls whether or not a label is drawn for this crosshair.booleanisVisible()Returns the flag that indicates whether or not the crosshair is currently visible.private voidreadObject(java.io.ObjectInputStream stream)Provides serialization support.voidremovePropertyChangeListener(java.beans.PropertyChangeListener l)Removes 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(java.awt.Paint paint)Sets the label background paint and sends a property change event with the name 'labelBackgroundPaint') to all registered listeners.voidsetLabelFont(java.awt.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(java.awt.Paint paint)Sets the label outline paint and sends a property change event (with the name "labelOutlinePaint") to all registered listeners.voidsetLabelOutlineStroke(java.awt.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.voidsetLabelPaint(java.awt.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 or not 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.voidsetPaint(java.awt.Paint paint)Sets the paint for the crosshair line and sends a property change event with the name "paint" to all registered listeners.voidsetStroke(java.awt.Stroke stroke)Sets 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.private voidwriteObject(java.io.ObjectOutputStream stream)Provides serialization support.
-
-
-
Field Detail
-
visible
private boolean visible
Flag controlling visibility.
-
value
private double value
The crosshair value.
-
paint
private transient java.awt.Paint paint
The paint for the crosshair line.
-
stroke
private transient java.awt.Stroke stroke
The stroke for the crosshair line.
-
labelVisible
private boolean labelVisible
A flag that controls whether or not the crosshair has a label visible.
-
labelAnchor
private RectangleAnchor labelAnchor
The label anchor.
-
labelGenerator
private CrosshairLabelGenerator labelGenerator
A label generator.
-
labelXOffset
private double labelXOffset
The x-offset in Java2D units.
-
labelYOffset
private double labelYOffset
The y-offset in Java2D units.
-
labelFont
private java.awt.Font labelFont
The label font.
-
labelPaint
private transient java.awt.Paint labelPaint
The label paint.
-
labelBackgroundPaint
private transient java.awt.Paint labelBackgroundPaint
The label background paint.
-
labelOutlineVisible
private boolean labelOutlineVisible
A flag that controls the visibility of the label outline.
-
labelOutlineStroke
private transient java.awt.Stroke labelOutlineStroke
The label outline stroke.
-
labelOutlinePaint
private transient java.awt.Paint labelOutlinePaint
The label outline paint.
-
pcs
private transient java.beans.PropertyChangeSupport pcs
Property change support.
-
-
Constructor Detail
-
Crosshair
public Crosshair()
Creates a new crosshair with value 0.0.
-
Crosshair
public Crosshair(double value)
Creates a new crosshair with the specified value.- Parameters:
value- the value.
-
Crosshair
public Crosshair(double value, java.awt.Paint paint, java.awt.Stroke stroke)Creates a new crosshair value with the specified value and line style.- Parameters:
value- the value.paint- the line paint (nullnot permitted).stroke- the line stroke (nullnot permitted).
-
-
Method Detail
-
isVisible
public boolean isVisible()
Returns the flag that indicates whether or not the crosshair is currently visible.- Returns:
- A boolean.
- See Also:
setVisible(boolean)
-
setVisible
public void setVisible(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.- Parameters:
visible- the new flag value.- See Also:
isVisible()
-
getValue
public double getValue()
Returns the crosshair value.- Returns:
- The crosshair value.
- See Also:
setValue(double)
-
setValue
public void setValue(double value)
Sets the crosshair value and sends a property change event with the name 'value' to all registered listeners.- Parameters:
value- the value.- See Also:
getValue()
-
getPaint
public java.awt.Paint getPaint()
Returns the paint for the crosshair line.- Returns:
- The paint (never
null). - See Also:
setPaint(java.awt.Paint)
-
setPaint
public void setPaint(java.awt.Paint paint)
Sets the paint for the crosshair line and sends a property change event with the name "paint" to all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
getPaint()
-
getStroke
public java.awt.Stroke getStroke()
Returns the stroke for the crosshair line.- Returns:
- The stroke (never
null). - See Also:
setStroke(java.awt.Stroke)
-
setStroke
public void setStroke(java.awt.Stroke stroke)
Sets the stroke for the crosshair line and sends a property change event with the name "stroke" to all registered listeners.- Parameters:
stroke- the stroke (nullnot permitted).- See Also:
getStroke()
-
isLabelVisible
public boolean isLabelVisible()
Returns the flag that controls whether or not a label is drawn for this crosshair.- Returns:
- A boolean.
- See Also:
setLabelVisible(boolean)
-
setLabelVisible
public void setLabelVisible(boolean visible)
Sets the flag that controls whether or not 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:
isLabelVisible()
-
getLabelGenerator
public CrosshairLabelGenerator getLabelGenerator()
Returns the crosshair label generator.- Returns:
- The label crosshair generator (never
null). - See Also:
setLabelGenerator(org.jfree.chart.labels.CrosshairLabelGenerator)
-
setLabelGenerator
public void setLabelGenerator(CrosshairLabelGenerator generator)
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:
getLabelGenerator()
-
getLabelAnchor
public RectangleAnchor getLabelAnchor()
Returns the label anchor point.- Returns:
- the label anchor point (never
null. - See Also:
setLabelAnchor(org.jfree.chart.ui.RectangleAnchor)
-
setLabelAnchor
public void setLabelAnchor(RectangleAnchor anchor)
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:
getLabelAnchor()
-
getLabelXOffset
public double getLabelXOffset()
Returns the x-offset for the label (in Java2D units).- Returns:
- The x-offset.
- See Also:
setLabelXOffset(double)
-
setLabelXOffset
public void setLabelXOffset(double offset)
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:
getLabelXOffset()
-
getLabelYOffset
public double getLabelYOffset()
Returns the y-offset for the label (in Java2D units).- Returns:
- The y-offset.
- See Also:
setLabelYOffset(double)
-
setLabelYOffset
public void setLabelYOffset(double offset)
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:
getLabelYOffset()
-
getLabelFont
public java.awt.Font getLabelFont()
Returns the label font.- Returns:
- The label font (never
null). - See Also:
setLabelFont(java.awt.Font)
-
setLabelFont
public void setLabelFont(java.awt.Font font)
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:
getLabelFont()
-
getLabelPaint
public java.awt.Paint getLabelPaint()
Returns the label paint. The default value isColor.BLACK.- Returns:
- The label paint (never
null). - See Also:
setLabelPaint(java.awt.Paint)
-
setLabelPaint
public void setLabelPaint(java.awt.Paint paint)
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:
getLabelPaint()
-
getLabelBackgroundPaint
public java.awt.Paint getLabelBackgroundPaint()
Returns the label background paint.- Returns:
- The label background paint (possibly
null). - See Also:
setLabelBackgroundPaint(java.awt.Paint)
-
setLabelBackgroundPaint
public void setLabelBackgroundPaint(java.awt.Paint paint)
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:
getLabelBackgroundPaint()
-
isLabelOutlineVisible
public boolean isLabelOutlineVisible()
Returns the flag that controls the visibility of the label outline. The default value istrue.- Returns:
- A boolean.
- See Also:
setLabelOutlineVisible(boolean)
-
setLabelOutlineVisible
public void setLabelOutlineVisible(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.- Parameters:
visible- the new flag value.- See Also:
isLabelOutlineVisible()
-
getLabelOutlinePaint
public java.awt.Paint getLabelOutlinePaint()
Returns the label outline paint.- Returns:
- The label outline paint (never
null). - See Also:
setLabelOutlinePaint(java.awt.Paint)
-
setLabelOutlinePaint
public void setLabelOutlinePaint(java.awt.Paint paint)
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:
getLabelOutlinePaint()
-
getLabelOutlineStroke
public java.awt.Stroke getLabelOutlineStroke()
Returns the label outline stroke. The default value isBasicStroke(0.5).- Returns:
- The label outline stroke (never
null). - See Also:
setLabelOutlineStroke(java.awt.Stroke)
-
setLabelOutlineStroke
public void setLabelOutlineStroke(java.awt.Stroke stroke)
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:
getLabelOutlineStroke()
-
equals
public boolean equals(java.lang.Object obj)
Tests this crosshair for equality with an arbitrary object.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the object (nullpermitted).- Returns:
- A boolean.
-
hashCode
public int hashCode()
Returns a hash code for this instance.- Overrides:
hashCodein classjava.lang.Object- Returns:
- A hash code.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionReturns an independent copy of this instance.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classjava.lang.Object- Returns:
- An independent copy of this instance.
- Throws:
java.lang.CloneNotSupportedException- if there is a problem with cloning.
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a property change listener.- Parameters:
l- the listener.- See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener)
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a property change listener.- Parameters:
l- the listener.- See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener)
-
writeObject
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOExceptionProvides serialization support.- Parameters:
stream- the output stream.- Throws:
java.io.IOException- if there is an I/O error.
-
readObject
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundExceptionProvides serialization support.- Parameters:
stream- the input stream.- Throws:
java.io.IOException- if there is an I/O error.java.lang.ClassNotFoundException- if there is a classpath problem.
-
-