Class XYNoteAnnotation

All Implemented Interfaces:
Serializable, Cloneable, Annotation, XYAnnotation, PublicCloneable

public class XYNoteAnnotation extends XYTextAnnotation implements Cloneable, PublicCloneable, Serializable
An line and label that can be placed on an XYPlot. The line is drawn at a user-definable angle so that it points towards the (x, y) location for the annotation.

The line length (and its offset from the (x, y) location) is controlled by the tip radius and the base radius attributes. Imagine two circles around the (x, y) coordinate: the inner circle defined by the tip radius, and the outer circle defined by the base radius. Now, draw the line starting at some point on the outer circle (the point is determined by the angle), with the line tip being drawn at a corresponding point on the inner circle.

See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For serialization.
      See Also:
    • DEFAULT_TIP_RADIUS

      public static final double DEFAULT_TIP_RADIUS
      The default tip radius (in Java2D units).
      See Also:
    • DEFAULT_BASE_RADIUS

      public static final double DEFAULT_BASE_RADIUS
      The default base radius (in Java2D units).
      See Also:
    • DEFAULT_LABEL_OFFSET

      public static final double DEFAULT_LABEL_OFFSET
      The default label offset (in Java2D units).
      See Also:
    • DEFAULT_LINE_STROKE

      public static final Stroke DEFAULT_LINE_STROKE
      The default line stroke.
    • DEFAULT_BACKGROUND_PAINT

      public static final Paint DEFAULT_BACKGROUND_PAINT
      The default line stroke.
    • DEFAULT_OUTLINE_PAINT

      public static final Paint DEFAULT_OUTLINE_PAINT
      The default line stroke.
    • angle

      private double angle
      The angle of the line's line (in radians).
    • tipRadius

      private double tipRadius
      The radius from the (x, y) point to the tip of the line (in Java2D units).
    • baseRadius

      private double baseRadius
      The radius from the (x, y) point to the start of the line line (in Java2D units).
    • lineStroke

      private transient Stroke lineStroke
      The line stroke.
    • linePaint

      private transient Paint linePaint
      The line paint.
    • labelOffset

      private double labelOffset
      The radius from the base point to the anchor point for the label.
  • Constructor Details

    • XYNoteAnnotation

      public XYNoteAnnotation(String label, double x, double y, double angle)
      Creates a new label and line annotation.
      Parameters:
      label - the label (null permitted).
      x - the x-coordinate (measured against the chart's domain axis).
      y - the y-coordinate (measured against the chart's range axis).
      angle - the angle of the line's line (in radians).
  • Method Details

    • getAngle

      public double getAngle()
      Returns the angle of the line.
      Returns:
      The angle (in radians).
      See Also:
    • setAngle

      public void setAngle(double angle)
      Sets the angle of the line and sends an AnnotationChangeEvent to all registered listeners.
      Parameters:
      angle - the angle (in radians).
      See Also:
    • getTipRadius

      public double getTipRadius()
      Returns the tip radius.
      Returns:
      The tip radius (in Java2D units).
      See Also:
    • setTipRadius

      public void setTipRadius(double radius)
      Sets the tip radius and sends an AnnotationChangeEvent to all registered listeners.
      Parameters:
      radius - the radius (in Java2D units).
      See Also:
    • getBaseRadius

      public double getBaseRadius()
      Returns the base radius.
      Returns:
      The base radius (in Java2D units).
      See Also:
    • setBaseRadius

      public void setBaseRadius(double radius)
      Sets the base radius and sends an AnnotationChangeEvent to all registered listeners.
      Parameters:
      radius - the radius (in Java2D units).
      See Also:
    • getLabelOffset

      public double getLabelOffset()
      Returns the label offset.
      Returns:
      The label offset (in Java2D units).
      See Also:
    • setLabelOffset

      public void setLabelOffset(double offset)
      Sets the label offset (from the line base, continuing in a straight line, in Java2D units) and sends an AnnotationChangeEvent to all registered listeners.
      Parameters:
      offset - the offset (in Java2D units).
      See Also:
    • getLineStroke

      public Stroke getLineStroke()
      Returns the stroke used to draw the line line.
      Returns:
      The line stroke (never null).
      See Also:
    • setLineStroke

      public void setLineStroke(Stroke stroke)
      Sets the stroke used to draw the line line and sends an AnnotationChangeEvent to all registered listeners.
      Parameters:
      stroke - the stroke (null not permitted).
      See Also:
    • getLinePaint

      public Paint getLinePaint()
      Returns the paint used for the line.
      Returns:
      The line paint (never null).
      See Also:
    • setLinePaint

      public void setLinePaint(Paint paint)
      Sets the paint used for the line and sends an AnnotationChangeEvent to all registered listeners.
      Parameters:
      paint - the line paint (null not permitted).
      See Also:
    • draw

      public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info)
      Draws the annotation.
      Specified by:
      draw in interface XYAnnotation
      Overrides:
      draw in class XYTextAnnotation
      Parameters:
      g2 - the graphics device.
      plot - the plot.
      dataArea - the data area.
      domainAxis - the domain axis.
      rangeAxis - the range axis.
      rendererIndex - the renderer index.
      info - the plot rendering info.
    • equals

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

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

      public Object clone() throws CloneNotSupportedException
      Returns a clone of the annotation.
      Specified by:
      clone in interface PublicCloneable
      Overrides:
      clone in class XYTextAnnotation
      Returns:
      A clone.
      Throws:
      CloneNotSupportedException - if the annotation can't be cloned.
    • 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.