Package org.jfree.chart.annotations
Class CategoryLineAnnotation
java.lang.Object
org.jfree.chart.annotations.AbstractAnnotation
org.jfree.chart.annotations.CategoryLineAnnotation
- All Implemented Interfaces:
Serializable
,Cloneable
,Annotation
,CategoryAnnotation
,PublicCloneable
public class CategoryLineAnnotation
extends AbstractAnnotation
implements CategoryAnnotation, Cloneable, PublicCloneable, Serializable
A line annotation that can be placed on a
CategoryPlot
.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Comparable
The category for the start of the line.private Comparable
The category for the end of the line.private Paint
The line color.(package private) static final long
For serialization.private Stroke
The line stroke.private double
The value for the start of the line.private double
The value for the end of the line. -
Constructor Summary
ConstructorsConstructorDescriptionCategoryLineAnnotation
(Comparable category1, double value1, Comparable category2, double value2, Paint paint, Stroke stroke) Creates a new annotation that draws a line between (category1, value1) and (category2, value2). -
Method Summary
Modifier and TypeMethodDescriptionboolean
Ensures symmetry between super/subclass implementations of equals.clone()
Returns a clone of the annotation.void
draw
(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis) Draws the annotation.boolean
Tests this object for equality with another.Returns the category for the start of the line.Returns the category for the end of the line.getPaint()
Returns the paint used to draw the connecting line.Returns the stroke used to draw the connecting line.double
Returns the y-value for the start of the line.double
Returns the y-value for the end of the line.int
hashCode()
Returns a hash code for this instance.private void
readObject
(ObjectInputStream stream) Provides serialization support.void
setCategory1
(Comparable category) Sets the category for the start of the line and sends anAnnotationChangeEvent
to all registered listeners.void
setCategory2
(Comparable category) Sets the category for the end of the line and sends anAnnotationChangeEvent
to all registered listeners.void
Sets the paint used to draw the connecting line and sends anAnnotationChangeEvent
to all registered listeners.void
Sets the stroke used to draw the connecting line and sends anAnnotationChangeEvent
to all registered listeners.void
setValue1
(double value) Sets the y-value for the start of the line and sends anAnnotationChangeEvent
to all registered listeners.void
setValue2
(double value) Sets the y-value for the end of the line and sends anAnnotationChangeEvent
to all registered listeners.private void
writeObject
(ObjectOutputStream stream) Provides serialization support.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
-
serialVersionUID
static final long serialVersionUIDFor serialization.- See Also:
-
category1
The category for the start of the line. -
value1
private double value1The value for the start of the line. -
category2
The category for the end of the line. -
value2
private double value2The value for the end of the line. -
paint
The line color. -
stroke
The line stroke.
-
-
Constructor Details
-
CategoryLineAnnotation
public CategoryLineAnnotation(Comparable category1, double value1, Comparable category2, double value2, Paint paint, Stroke stroke) Creates a new annotation that draws a line between (category1, value1) and (category2, value2).- Parameters:
category1
- the category (null
not permitted).value1
- the value (must be finite).category2
- the category (null
not permitted).value2
- the value (must be finite).paint
- the line color (null
not permitted).stroke
- the line stroke (null
not permitted).
-
-
Method Details
-
getCategory1
Returns the category for the start of the line.- Returns:
- The category for the start of the line (never
null
). - See Also:
-
setCategory1
Sets the category for the start of the line and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
category
- the category (null
not permitted).- See Also:
-
getValue1
public double getValue1()Returns the y-value for the start of the line.- Returns:
- The y-value for the start of the line.
- See Also:
-
setValue1
public void setValue1(double value) Sets the y-value for the start of the line and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
value
- the value (must be finite).- See Also:
-
getCategory2
Returns the category for the end of the line.- Returns:
- The category for the end of the line (never
null
). - See Also:
-
setCategory2
Sets the category for the end of the line and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
category
- the category (null
not permitted).- See Also:
-
getValue2
public double getValue2()Returns the y-value for the end of the line.- Returns:
- The y-value for the end of the line.
- See Also:
-
setValue2
public void setValue2(double value) Sets the y-value for the end of the line and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
value
- the value (must be finite).- See Also:
-
getPaint
Returns the paint used to draw the connecting line.- Returns:
- The paint (never
null
). - See Also:
-
setPaint
Sets the paint used to draw the connecting line and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
not permitted).- See Also:
-
getStroke
Returns the stroke used to draw the connecting line.- Returns:
- The stroke (never
null
). - See Also:
-
setStroke
Sets the stroke used to draw the connecting line and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
stroke
- the stroke (null
not permitted).- See Also:
-
draw
public void draw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis) Draws the annotation.- Specified by:
draw
in interfaceCategoryAnnotation
- Parameters:
g2
- the graphics device (null
not permitted).plot
- the plot (null
not permitted).dataArea
- the data area (null
not permitted).domainAxis
- the domain axis (null
not permitted).rangeAxis
- the range axis (null
not permitted).
-
equals
Tests this object for equality with another.- Overrides:
equals
in classAbstractAnnotation
- Parameters:
obj
- the object (null
permitted).- Returns:
true
orfalse
.
-
canEqual
Ensures symmetry between super/subclass implementations of equals. For more detail, see http://jqno.nl/equalsverifier/manual/inheritance.- Overrides:
canEqual
in classAbstractAnnotation
- Parameters:
other
- Object- Returns:
- true ONLY if the parameter is THIS class type
-
hashCode
public int hashCode()Returns a hash code for this instance.- Overrides:
hashCode
in classAbstractAnnotation
- Returns:
- A hash code.
-
clone
Returns a clone of the annotation.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classAbstractAnnotation
- Returns:
- A clone.
- Throws:
CloneNotSupportedException
- this class will not throw this exception, but subclasses (if any) might.
-
writeObject
Provides serialization support.- Parameters:
stream
- the output stream.- Throws:
IOException
- if there is an I/O error.
-
readObject
Provides serialization support.- Parameters:
stream
- the input stream.- Throws:
IOException
- if there is an I/O error.ClassNotFoundException
- if there is a classpath problem.
-