Package org.jfree.chart.annotations
Class XYNoteAnnotation
java.lang.Object
org.jfree.chart.annotations.AbstractAnnotation
org.jfree.chart.annotations.AbstractXYAnnotation
org.jfree.chart.annotations.XYTextAnnotation
org.jfree.chart.annotations.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 Summary
Modifier and TypeFieldDescriptionstatic final Paint
The default line stroke.static final double
The default base radius (in Java2D units).static final double
The default label offset (in Java2D units).static final Stroke
The default line stroke.static final Paint
The default line stroke.static final double
The default tip radius (in Java2D units).Fields inherited from class org.jfree.chart.annotations.XYTextAnnotation
DEFAULT_FONT, DEFAULT_PAINT, DEFAULT_ROTATION_ANCHOR, DEFAULT_ROTATION_ANGLE, DEFAULT_TEXT_ANCHOR
-
Constructor Summary
ConstructorDescriptionXYNoteAnnotation
(String label, double x, double y, double angle) Creates a new label and line annotation. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a clone of the annotation.void
draw
(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) Draws the annotation.boolean
Tests this annotation for equality with an arbitrary object.double
getAngle()
Returns the angle of the line.double
Returns the base radius.double
Returns the label offset.Returns the paint used for the line.Returns the stroke used to draw the line line.double
Returns the tip radius.int
hashCode()
Returns a hash code for this instance.void
setAngle
(double angle) Sets the angle of the line and sends anAnnotationChangeEvent
to all registered listeners.void
setBaseRadius
(double radius) Sets the base radius and sends anAnnotationChangeEvent
to all registered listeners.void
setLabelOffset
(double offset) Sets the label offset (from the line base, continuing in a straight line, in Java2D units) and sends anAnnotationChangeEvent
to all registered listeners.void
setLinePaint
(Paint paint) Sets the paint used for the line and sends anAnnotationChangeEvent
to all registered listeners.void
setLineStroke
(Stroke stroke) Sets the stroke used to draw the line line and sends anAnnotationChangeEvent
to all registered listeners.void
setTipRadius
(double radius) Sets the tip radius and sends anAnnotationChangeEvent
to all registered listeners.Methods inherited from class org.jfree.chart.annotations.XYTextAnnotation
canEqual, getBackgroundPaint, getFont, getOutlinePaint, getOutlineStroke, getPaint, getRotationAnchor, getRotationAngle, getText, getTextAnchor, getX, getY, isOutlineVisible, setBackgroundPaint, setFont, setOutlinePaint, setOutlineStroke, setOutlineVisible, setPaint, setRotationAnchor, setRotationAngle, setText, setTextAnchor, setX, setY
Methods inherited from class org.jfree.chart.annotations.AbstractXYAnnotation
addEntity, getToolTipText, getURL, setToolTipText, setURL
Methods inherited from class org.jfree.chart.annotations.AbstractAnnotation
addChangeListener, fireAnnotationChanged, getNotify, hasListener, notifyListeners, removeChangeListener, setNotify
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jfree.chart.annotations.Annotation
addChangeListener, removeChangeListener
-
Field Details
-
DEFAULT_TIP_RADIUS
The default tip radius (in Java2D units).- See Also:
-
DEFAULT_BASE_RADIUS
The default base radius (in Java2D units).- See Also:
-
DEFAULT_LABEL_OFFSET
The default label offset (in Java2D units).- See Also:
-
DEFAULT_LINE_STROKE
The default line stroke. -
DEFAULT_BACKGROUND_PAINT
The default line stroke. -
DEFAULT_OUTLINE_PAINT
The default line stroke.
-
-
Constructor Details
-
XYNoteAnnotation
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
Returns the angle of the line.- Returns:
- The angle (in radians).
- See Also:
-
setAngle
Sets the angle of the line and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
angle
- the angle (in radians).- See Also:
-
getTipRadius
Returns the tip radius.- Returns:
- The tip radius (in Java2D units).
- See Also:
-
setTipRadius
Sets the tip radius and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
radius
- the radius (in Java2D units).- See Also:
-
getBaseRadius
Returns the base radius.- Returns:
- The base radius (in Java2D units).
- See Also:
-
setBaseRadius
Sets the base radius and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
radius
- the radius (in Java2D units).- See Also:
-
getLabelOffset
Returns the label offset.- Returns:
- The label offset (in Java2D units).
- See Also:
-
setLabelOffset
Sets the label offset (from the line base, continuing in a straight line, in Java2D units) and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
offset
- the offset (in Java2D units).- See Also:
-
getLineStroke
Returns the stroke used to draw the line line.- Returns:
- The line stroke (never
null
). - See Also:
-
setLineStroke
Sets the stroke used to draw the line line and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
stroke
- the stroke (null
not permitted).- See Also:
-
getLinePaint
Returns the paint used for the line.- Returns:
- The line paint (never
null
). - See Also:
-
setLinePaint
Sets the paint used for the line and sends anAnnotationChangeEvent
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 interfaceXYAnnotation
- Overrides:
draw
in classXYTextAnnotation
- 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
Tests this annotation for equality with an arbitrary object.- Overrides:
equals
in classXYTextAnnotation
- Parameters:
obj
- the object (null
permitted).- Returns:
true
orfalse
.
-
hashCode
Returns a hash code for this instance.- Overrides:
hashCode
in classXYTextAnnotation
- Returns:
- A hash code.
-
clone
Returns a clone of the annotation.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classXYTextAnnotation
- Returns:
- A clone.
- Throws:
CloneNotSupportedException
- if the annotation can't be cloned.
-