Class Crosshair

java.lang.Object
org.jfree.chart.plot.Crosshair
All Implemented Interfaces:
Serializable, Cloneable, org.jfree.util.PublicCloneable

public class Crosshair extends Object implements Cloneable, org.jfree.util.PublicCloneable, Serializable
A crosshair for display on a plot.
Since:
1.0.13
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private org.jfree.ui.RectangleAnchor
    The label anchor.
    private Paint
    The label background paint.
    private Font
    The label font.
    A label generator.
    private Paint
    The label outline paint.
    private Stroke
    The label outline stroke.
    private boolean
    A flag that controls the visibility of the label outline.
    private Paint
    The label paint.
    private boolean
    A flag that controls whether or not the crosshair has a label visible.
    private double
    The x-offset in Java2D units.
    private double
    The y-offset in Java2D units.
    private Paint
    The paint for the crosshair line.
    Property change support.
    private Stroke
    The stroke for the crosshair line.
    private double
    The crosshair value.
    private boolean
    Flag controlling visibility.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new crosshair with value 0.0.
    Crosshair(double value)
    Creates a new crosshair with the specified value.
    Crosshair(double value, Paint paint, Stroke stroke)
    Creates a new crosshair value with the specified value and line style.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a property change listener.
    Returns an independent copy of this instance.
    boolean
    Tests this crosshair for equality with an arbitrary object.
    org.jfree.ui.RectangleAnchor
    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 paint.
    double
    Returns the x-offset for the label (in Java2D units).
    double
    Returns the y-offset for the label (in Java2D units).
    Returns the paint for the crosshair line.
    Returns the stroke for the crosshair line.
    double
    Returns the crosshair value.
    int
    Returns a hash code for this instance.
    boolean
    Returns the flag that controls the visibility of the label outline.
    boolean
    Returns the flag that controls whether or not a label is drawn for this crosshair.
    boolean
    Returns the flag that indicates whether or not the crosshair is currently visible.
    private void
    Provides serialization support.
    void
    Removes a property change listener.
    void
    setLabelAnchor(org.jfree.ui.RectangleAnchor anchor)
    Sets the label anchor point and sends a property change event (with the name 'labelAnchor') to all registered listeners.
    void
    Sets the label background paint and sends a property change event with the name 'labelBackgroundPaint') to all registered listeners.
    void
    Sets the label font and sends a property change event (with the name 'labelFont') to all registered listeners.
    void
    Sets the crosshair label generator and sends a property change event (with the name 'labelGenerator') to all registered listeners.
    void
    Sets the label outline paint and sends a property change event (with the name "labelOutlinePaint") to all registered listeners.
    void
    Sets the label outline stroke and sends a property change event (with the name 'labelOutlineStroke') to all registered listeners.
    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.
    void
    Sets the label paint and sends a property change event (with the name 'labelPaint') to all registered listeners.
    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.
    void
    setLabelXOffset(double offset)
    Sets the x-offset and sends a property change event (with the name 'labelXOffset') to all registered listeners.
    void
    setLabelYOffset(double offset)
    Sets the y-offset and sends a property change event (with the name 'labelYOffset') to all registered listeners.
    void
    setPaint(Paint paint)
    Sets the paint for the crosshair line and sends a property change event with the name "paint" to all registered listeners.
    void
    setStroke(Stroke stroke)
    Sets the stroke for the crosshair line and sends a property change event with the name "stroke" to all registered listeners.
    void
    setValue(double value)
    Sets the crosshair value and sends a property change event with the name 'value' to all registered listeners.
    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.
    private void
    Provides serialization support.

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • visible

      private boolean visible
      Flag controlling visibility.
    • value

      private double value
      The crosshair value.
    • paint

      private transient Paint paint
      The paint for the crosshair line.
    • stroke

      private transient 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 org.jfree.ui.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 Font labelFont
      The label font.
    • labelPaint

      private transient Paint labelPaint
      The label paint.
    • labelBackgroundPaint

      private transient Paint labelBackgroundPaint
      The label background paint.
    • labelOutlineVisible

      private boolean labelOutlineVisible
      A flag that controls the visibility of the label outline.
    • labelOutlineStroke

      private transient Stroke labelOutlineStroke
      The label outline stroke.
    • labelOutlinePaint

      private transient Paint labelOutlinePaint
      The label outline paint.
    • pcs

      private transient PropertyChangeSupport pcs
      Property change support.
  • Constructor Details

    • 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, Paint paint, Stroke stroke)
      Creates a new crosshair value with the specified value and line style.
      Parameters:
      value - the value.
      paint - the line paint (null not permitted).
      stroke - the line stroke (null not permitted).
  • Method Details

    • isVisible

      public boolean isVisible()
      Returns the flag that indicates whether or not the crosshair is currently visible.
      Returns:
      A boolean.
      See Also:
    • 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:
    • getValue

      public double getValue()
      Returns the crosshair value.
      Returns:
      The crosshair value.
      See Also:
    • 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:
    • getPaint

      public Paint getPaint()
      Returns the paint for the crosshair line.
      Returns:
      The paint (never null).
      See Also:
    • setPaint

      public void setPaint(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 (null not permitted).
      See Also:
    • getStroke

      public Stroke getStroke()
      Returns the stroke for the crosshair line.
      Returns:
      The stroke (never null).
      See Also:
    • setStroke

      public void setStroke(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 (null not permitted).
      See Also:
    • 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

      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:
    • getLabelGenerator

      public CrosshairLabelGenerator getLabelGenerator()
      Returns the crosshair label generator.
      Returns:
      The label crosshair generator (never null).
      See Also:
    • 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 (null not permitted).
      See Also:
    • getLabelAnchor

      public org.jfree.ui.RectangleAnchor getLabelAnchor()
      Returns the label anchor point.
      Returns:
      the label anchor point (never null.
      See Also:
    • setLabelAnchor

      public void setLabelAnchor(org.jfree.ui.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 (null not permitted).
      See Also:
    • getLabelXOffset

      public double getLabelXOffset()
      Returns the x-offset for the label (in Java2D units).
      Returns:
      The x-offset.
      See Also:
    • 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:
    • getLabelYOffset

      public double getLabelYOffset()
      Returns the y-offset for the label (in Java2D units).
      Returns:
      The y-offset.
      See Also:
    • 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:
    • getLabelFont

      public Font getLabelFont()
      Returns the label font.
      Returns:
      The label font (never null).
      See Also:
    • setLabelFont

      public void setLabelFont(Font font)
      Sets the label font and sends a property change event (with the name 'labelFont') to all registered listeners.
      Parameters:
      font - the font (null not permitted).
      See Also:
    • getLabelPaint

      public Paint getLabelPaint()
      Returns the label paint.
      Returns:
      The label paint (never null).
      See Also:
    • setLabelPaint

      public void setLabelPaint(Paint paint)
      Sets the label paint and sends a property change event (with the name 'labelPaint') to all registered listeners.
      Parameters:
      paint - the paint (null not permitted).
      See Also:
    • getLabelBackgroundPaint

      public Paint getLabelBackgroundPaint()
      Returns the label background paint.
      Returns:
      The label background paint (possibly null).
      See Also:
    • setLabelBackgroundPaint

      public void setLabelBackgroundPaint(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 (null permitted).
      See Also:
    • isLabelOutlineVisible

      public boolean isLabelOutlineVisible()
      Returns the flag that controls the visibility of the label outline.
      Returns:
      A boolean.
      See Also:
    • 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:
    • getLabelOutlinePaint

      public Paint getLabelOutlinePaint()
      Returns the label outline paint.
      Returns:
      The label outline paint (never null).
      See Also:
    • setLabelOutlinePaint

      public void setLabelOutlinePaint(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 (null not permitted).
      See Also:
    • getLabelOutlineStroke

      public Stroke getLabelOutlineStroke()
      Returns the label outline stroke.
      Returns:
      The label outline stroke (never null).
      See Also:
    • setLabelOutlineStroke

      public void setLabelOutlineStroke(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 (null not permitted).
      See Also:
    • equals

      public boolean equals(Object obj)
      Tests this crosshair for equality with an arbitrary object.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object (null permitted).
      Returns:
      A boolean.
    • hashCode

      public int hashCode()
      Returns a hash code for this instance.
      Overrides:
      hashCode in class Object
      Returns:
      A hash code.
    • clone

      public Object clone() throws CloneNotSupportedException
      Returns an independent copy of this instance.
      Specified by:
      clone in interface org.jfree.util.PublicCloneable
      Overrides:
      clone in class Object
      Returns:
      An independent copy of this instance.
      Throws:
      CloneNotSupportedException - if there is a problem with cloning.
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener l)
      Adds a property change listener.
      Parameters:
      l - the listener.
      See Also:
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener l)
      Removes a property change listener.
      Parameters:
      l - the listener.
      See Also:
    • writeObject

      private void writeObject(ObjectOutputStream stream) throws IOException
      Provides serialization support.
      Parameters:
      stream - the output stream.
      Throws:
      IOException - if there is an I/O error.
    • readObject

      private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException
      Provides serialization support.
      Parameters:
      stream - the input stream.
      Throws:
      IOException - if there is an I/O error.
      ClassNotFoundException - if there is a classpath problem.