Class XYPointerAnnotation

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Annotation, XYAnnotation, org.jfree.util.PublicCloneable

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

    The arrow 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 arrow starting at some point on the outer circle (the point is determined by the angle), with the arrow tip being drawn at a corresponding point on the inner circle.

    See Also:
    Serialized Form
    • Constructor Detail

      • XYPointerAnnotation

        public XYPointerAnnotation​(java.lang.String label,
                                   double x,
                                   double y,
                                   double angle)
        Creates a new label and arrow 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 arrow's line (in radians).
    • Method Detail

      • getAngle

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

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

        public void setLabelOffset​(double offset)
        Sets the label offset (from the arrow 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:
        getLabelOffset()
      • setArrowStroke

        public void setArrowStroke​(java.awt.Stroke stroke)
        Sets the stroke used to draw the arrow line and sends an AnnotationChangeEvent to all registered listeners.
        Parameters:
        stroke - the stroke (null not permitted).
        See Also:
        getArrowStroke()
      • setArrowPaint

        public void setArrowPaint​(java.awt.Paint paint)
        Sets the paint used for the arrow and sends an AnnotationChangeEvent to all registered listeners.
        Parameters:
        paint - the arrow paint (null not permitted).
        See Also:
        getArrowPaint()
      • draw

        public void draw​(java.awt.Graphics2D g2,
                         XYPlot plot,
                         java.awt.geom.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​(java.lang.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.
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Returns a clone of the annotation.
        Specified by:
        clone in interface org.jfree.util.PublicCloneable
        Overrides:
        clone in class XYTextAnnotation
        Returns:
        A clone.
        Throws:
        java.lang.CloneNotSupportedException - if the annotation can't be cloned.