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:
java.io.Serializable,java.lang.Cloneable,Annotation,XYAnnotation,PublicCloneable
public class XYNoteAnnotation extends XYTextAnnotation implements java.lang.Cloneable, PublicCloneable, java.io.Serializable
An line and label that can be placed on anXYPlot. 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private doubleangleThe angle of the line's line (in radians).private doublebaseRadiusThe radius from the (x, y) point to the start of the line line (in Java2D units).static java.awt.PaintDEFAULT_BACKGROUND_PAINTThe default line stroke.static doubleDEFAULT_BASE_RADIUSThe default base radius (in Java2D units).static doubleDEFAULT_LABEL_OFFSETThe default label offset (in Java2D units).static java.awt.StrokeDEFAULT_LINE_STROKEThe default line stroke.static java.awt.PaintDEFAULT_OUTLINE_PAINTThe default line stroke.static doubleDEFAULT_TIP_RADIUSThe default tip radius (in Java2D units).private doublelabelOffsetThe radius from the base point to the anchor point for the label.private java.awt.PaintlinePaintThe line paint.private java.awt.StrokelineStrokeThe line stroke.private static longserialVersionUIDFor serialization.private doubletipRadiusThe radius from the (x, y) point to the tip of the line (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
Constructors Constructor Description XYNoteAnnotation(java.lang.String label, double x, double y, double angle)Creates a new label and line annotation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()Returns a clone of the annotation.voiddraw(java.awt.Graphics2D g2, XYPlot plot, java.awt.geom.Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info)Draws the annotation.booleanequals(java.lang.Object obj)Tests this annotation for equality with an arbitrary object.doublegetAngle()Returns the angle of the line.doublegetBaseRadius()Returns the base radius.doublegetLabelOffset()Returns the label offset.java.awt.PaintgetLinePaint()Returns the paint used for the line.java.awt.StrokegetLineStroke()Returns the stroke used to draw the line line.doublegetTipRadius()Returns the tip radius.inthashCode()Returns a hash code for this instance.private voidreadObject(java.io.ObjectInputStream stream)Provides serialization support.voidsetAngle(double angle)Sets the angle of the line and sends anAnnotationChangeEventto all registered listeners.voidsetBaseRadius(double radius)Sets the base radius and sends anAnnotationChangeEventto all registered listeners.voidsetLabelOffset(double offset)Sets the label offset (from the line base, continuing in a straight line, in Java2D units) and sends anAnnotationChangeEventto all registered listeners.voidsetLinePaint(java.awt.Paint paint)Sets the paint used for the line and sends anAnnotationChangeEventto all registered listeners.voidsetLineStroke(java.awt.Stroke stroke)Sets the stroke used to draw the line line and sends anAnnotationChangeEventto all registered listeners.voidsetTipRadius(double radius)Sets the tip radius and sends anAnnotationChangeEventto all registered listeners.private voidwriteObject(java.io.ObjectOutputStream stream)Provides serialization support.-
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 Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
DEFAULT_TIP_RADIUS
public static final double DEFAULT_TIP_RADIUS
The default tip radius (in Java2D units).- See Also:
- Constant Field Values
-
DEFAULT_BASE_RADIUS
public static final double DEFAULT_BASE_RADIUS
The default base radius (in Java2D units).- See Also:
- Constant Field Values
-
DEFAULT_LABEL_OFFSET
public static final double DEFAULT_LABEL_OFFSET
The default label offset (in Java2D units).- See Also:
- Constant Field Values
-
DEFAULT_LINE_STROKE
public static final java.awt.Stroke DEFAULT_LINE_STROKE
The default line stroke.
-
DEFAULT_BACKGROUND_PAINT
public static final java.awt.Paint DEFAULT_BACKGROUND_PAINT
The default line stroke.
-
DEFAULT_OUTLINE_PAINT
public static final java.awt.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 java.awt.Stroke lineStroke
The line stroke.
-
linePaint
private transient java.awt.Paint linePaint
The line paint.
-
labelOffset
private double labelOffset
The radius from the base point to the anchor point for the label.
-
-
Constructor Detail
-
XYNoteAnnotation
public XYNoteAnnotation(java.lang.String label, double x, double y, double angle)Creates a new label and line annotation.- Parameters:
label- the label (nullpermitted).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 Detail
-
getAngle
public double getAngle()
Returns the angle of the line.- Returns:
- The angle (in radians).
- See Also:
setAngle(double)
-
setAngle
public void setAngle(double angle)
Sets the angle of the line and sends anAnnotationChangeEventto all registered listeners.- Parameters:
angle- the angle (in radians).- See Also:
getAngle()
-
getTipRadius
public double getTipRadius()
Returns the tip radius.- Returns:
- The tip radius (in Java2D units).
- See Also:
setTipRadius(double)
-
setTipRadius
public void setTipRadius(double radius)
Sets the tip radius and sends anAnnotationChangeEventto all registered listeners.- Parameters:
radius- the radius (in Java2D units).- See Also:
getTipRadius()
-
getBaseRadius
public double getBaseRadius()
Returns the base radius.- Returns:
- The base radius (in Java2D units).
- See Also:
setBaseRadius(double)
-
setBaseRadius
public void setBaseRadius(double radius)
Sets the base radius and sends anAnnotationChangeEventto all registered listeners.- Parameters:
radius- the radius (in Java2D units).- See Also:
getBaseRadius()
-
getLabelOffset
public double getLabelOffset()
Returns the label offset.- Returns:
- The label offset (in Java2D units).
- See Also:
setLabelOffset(double)
-
setLabelOffset
public void setLabelOffset(double offset)
Sets the label offset (from the line base, continuing in a straight line, in Java2D units) and sends anAnnotationChangeEventto all registered listeners.- Parameters:
offset- the offset (in Java2D units).- See Also:
getLabelOffset()
-
getLineStroke
public java.awt.Stroke getLineStroke()
Returns the stroke used to draw the line line.- Returns:
- The line stroke (never
null). - See Also:
setLineStroke(Stroke)
-
setLineStroke
public void setLineStroke(java.awt.Stroke stroke)
Sets the stroke used to draw the line line and sends anAnnotationChangeEventto all registered listeners.- Parameters:
stroke- the stroke (nullnot permitted).- See Also:
getLineStroke()
-
getLinePaint
public java.awt.Paint getLinePaint()
Returns the paint used for the line.- Returns:
- The line paint (never
null). - See Also:
setLinePaint(Paint)
-
setLinePaint
public void setLinePaint(java.awt.Paint paint)
Sets the paint used for the line and sends anAnnotationChangeEventto all registered listeners.- Parameters:
paint- the line paint (nullnot permitted).- See Also:
getLinePaint()
-
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:
drawin interfaceXYAnnotation- Overrides:
drawin 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
public boolean equals(java.lang.Object obj)
Tests this annotation for equality with an arbitrary object.- Overrides:
equalsin classXYTextAnnotation- Parameters:
obj- the object (nullpermitted).- Returns:
trueorfalse.
-
hashCode
public int hashCode()
Returns a hash code for this instance.- Overrides:
hashCodein classXYTextAnnotation- Returns:
- A hash code.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionReturns a clone of the annotation.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classXYTextAnnotation- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException- if the annotation can't be cloned.
-
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.
-
-