Package org.jfree.chart.annotations
Class CategoryLineAnnotation
- java.lang.Object
-
- org.jfree.chart.annotations.AbstractAnnotation
-
- org.jfree.chart.annotations.CategoryLineAnnotation
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,Annotation,CategoryAnnotation,PublicCloneable
public class CategoryLineAnnotation extends AbstractAnnotation implements CategoryAnnotation, java.lang.Cloneable, PublicCloneable, java.io.Serializable
A line annotation that can be placed on aCategoryPlot.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Comparablecategory1The category for the start of the line.private java.lang.Comparablecategory2The category for the end of the line.private java.awt.PaintpaintThe line color.(package private) static longserialVersionUIDFor serialization.private java.awt.StrokestrokeThe line stroke.private doublevalue1The value for the start of the line.private doublevalue2The value for the end of the line.
-
Constructor Summary
Constructors Constructor Description CategoryLineAnnotation(java.lang.Comparable category1, double value1, java.lang.Comparable category2, double value2, java.awt.Paint paint, java.awt.Stroke stroke)Creates a new annotation that draws a line between (category1, value1) and (category2, value2).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanEqual(java.lang.Object other)Ensures symmetry between super/subclass implementations of equals.java.lang.Objectclone()Returns a clone of the annotation.voiddraw(java.awt.Graphics2D g2, CategoryPlot plot, java.awt.geom.Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis)Draws the annotation.booleanequals(java.lang.Object obj)Tests this object for equality with another.java.lang.ComparablegetCategory1()Returns the category for the start of the line.java.lang.ComparablegetCategory2()Returns the category for the end of the line.java.awt.PaintgetPaint()Returns the paint used to draw the connecting line.java.awt.StrokegetStroke()Returns the stroke used to draw the connecting line.doublegetValue1()Returns the y-value for the start of the line.doublegetValue2()Returns the y-value for the end of the line.inthashCode()Returns a hash code for this instance.private voidreadObject(java.io.ObjectInputStream stream)Provides serialization support.voidsetCategory1(java.lang.Comparable category)Sets the category for the start of the line and sends anAnnotationChangeEventto all registered listeners.voidsetCategory2(java.lang.Comparable category)Sets the category for the end of the line and sends anAnnotationChangeEventto all registered listeners.voidsetPaint(java.awt.Paint paint)Sets the paint used to draw the connecting line and sends anAnnotationChangeEventto all registered listeners.voidsetStroke(java.awt.Stroke stroke)Sets the stroke used to draw the connecting line and sends anAnnotationChangeEventto all registered listeners.voidsetValue1(double value)Sets the y-value for the start of the line and sends anAnnotationChangeEventto all registered listeners.voidsetValue2(double value)Sets the y-value for the end of the line and sends anAnnotationChangeEventto all registered listeners.private voidwriteObject(java.io.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 Detail
-
serialVersionUID
static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
category1
private java.lang.Comparable category1
The category for the start of the line.
-
value1
private double value1
The value for the start of the line.
-
category2
private java.lang.Comparable category2
The category for the end of the line.
-
value2
private double value2
The value for the end of the line.
-
paint
private transient java.awt.Paint paint
The line color.
-
stroke
private transient java.awt.Stroke stroke
The line stroke.
-
-
Constructor Detail
-
CategoryLineAnnotation
public CategoryLineAnnotation(java.lang.Comparable category1, double value1, java.lang.Comparable category2, double value2, java.awt.Paint paint, java.awt.Stroke stroke)Creates a new annotation that draws a line between (category1, value1) and (category2, value2).- Parameters:
category1- the category (nullnot permitted).value1- the value (must be finite).category2- the category (nullnot permitted).value2- the value (must be finite).paint- the line color (nullnot permitted).stroke- the line stroke (nullnot permitted).
-
-
Method Detail
-
getCategory1
public java.lang.Comparable getCategory1()
Returns the category for the start of the line.- Returns:
- The category for the start of the line (never
null). - See Also:
setCategory1(Comparable)
-
setCategory1
public void setCategory1(java.lang.Comparable category)
Sets the category for the start of the line and sends anAnnotationChangeEventto all registered listeners.- Parameters:
category- the category (nullnot permitted).- See Also:
getCategory1()
-
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(double)
-
setValue1
public void setValue1(double value)
Sets the y-value for the start of the line and sends anAnnotationChangeEventto all registered listeners.- Parameters:
value- the value (must be finite).- See Also:
getValue1()
-
getCategory2
public java.lang.Comparable getCategory2()
Returns the category for the end of the line.- Returns:
- The category for the end of the line (never
null). - See Also:
setCategory2(Comparable)
-
setCategory2
public void setCategory2(java.lang.Comparable category)
Sets the category for the end of the line and sends anAnnotationChangeEventto all registered listeners.- Parameters:
category- the category (nullnot permitted).- See Also:
getCategory2()
-
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(double)
-
setValue2
public void setValue2(double value)
Sets the y-value for the end of the line and sends anAnnotationChangeEventto all registered listeners.- Parameters:
value- the value (must be finite).- See Also:
getValue2()
-
getPaint
public java.awt.Paint getPaint()
Returns the paint used to draw the connecting line.- Returns:
- The paint (never
null). - See Also:
setPaint(Paint)
-
setPaint
public void setPaint(java.awt.Paint paint)
Sets the paint used to draw the connecting line and sends anAnnotationChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
getPaint()
-
getStroke
public java.awt.Stroke getStroke()
Returns the stroke used to draw the connecting line.- Returns:
- The stroke (never
null). - See Also:
setStroke(Stroke)
-
setStroke
public void setStroke(java.awt.Stroke stroke)
Sets the stroke used to draw the connecting line and sends anAnnotationChangeEventto all registered listeners.- Parameters:
stroke- the stroke (nullnot permitted).- See Also:
getStroke()
-
draw
public void draw(java.awt.Graphics2D g2, CategoryPlot plot, java.awt.geom.Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis)Draws the annotation.- Specified by:
drawin interfaceCategoryAnnotation- Parameters:
g2- the graphics device (nullnot permitted).plot- the plot (nullnot permitted).dataArea- the data area (nullnot permitted).domainAxis- the domain axis (nullnot permitted).rangeAxis- the range axis (nullnot permitted).
-
equals
public boolean equals(java.lang.Object obj)
Tests this object for equality with another.- Overrides:
equalsin classAbstractAnnotation- Parameters:
obj- the object (nullpermitted).- Returns:
trueorfalse.
-
canEqual
public boolean canEqual(java.lang.Object other)
Ensures symmetry between super/subclass implementations of equals. For more detail, see http://jqno.nl/equalsverifier/manual/inheritance.- Overrides:
canEqualin 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:
hashCodein classAbstractAnnotation- 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 classAbstractAnnotation- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException- this class will not throw this exception, but subclasses (if any) might.
-
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.
-
-