Package org.jfree.chart
Class LegendItem
java.lang.Object
org.jfree.chart.LegendItem
- All Implemented Interfaces:
Serializable
,Cloneable
A temporary storage object for recording the properties of a legend item,
without any consideration for layout issues.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AttributedString
The attributed label (if null, fall back to the regular label).private Dataset
The dataset.private int
The dataset index.private String
The description (not currently used - could be displayed as a tool tip).private Paint
The paint.private GradientPaintTransformer
A gradient paint transformer.private String
The label.private Font
The label font (null
is permitted).private Paint
The label paint (null
is permitted).private Shape
The line.private Paint
The line paint.private Stroke
The stroke.private boolean
A flag that controls whether or not the line is visible.private Paint
The outline paint.private Stroke
The outline stroke.private static final long
For serialization.private int
The series index.private Comparable
The series key.private Shape
The shape.private boolean
A flag that controls whether or not the shape is filled.private boolean
A flag that controls whether or not the shape outline is visible.private boolean
A flag that controls whether or not the shape is visible.private String
The tool tip text.private static final Shape
The shape must be non-null for a LegendItem - if no shape is required, use this.private static final Stroke
The stroke must be non-null for a LegendItem - if no stroke is required, use this.private String
The url text. -
Constructor Summary
ConstructorsConstructorDescriptionLegendItem
(String label) Creates a legend item with the specified label.LegendItem
(String label, Paint paint) Creates a legend item with the specified label and fill paint.LegendItem
(String label, String description, String toolTipText, String urlText, boolean shapeVisible, Shape shape, boolean shapeFilled, Paint fillPaint, boolean shapeOutlineVisible, Paint outlinePaint, Stroke outlineStroke, boolean lineVisible, Shape line, Stroke lineStroke, Paint linePaint) Creates a new legend item.LegendItem
(String label, String description, String toolTipText, String urlText, Shape shape, Paint fillPaint) Creates a legend item with a filled shape.LegendItem
(String label, String description, String toolTipText, String urlText, Shape shape, Paint fillPaint, Stroke outlineStroke, Paint outlinePaint) Creates a legend item with a filled and outlined shape.LegendItem
(String label, String description, String toolTipText, String urlText, Shape line, Stroke lineStroke, Paint linePaint) Creates a legend item using a line.LegendItem
(AttributedString label, String description, String toolTipText, String urlText, boolean shapeVisible, Shape shape, boolean shapeFilled, Paint fillPaint, boolean shapeOutlineVisible, Paint outlinePaint, Stroke outlineStroke, boolean lineVisible, Shape line, Stroke lineStroke, Paint linePaint) Creates a new legend item.LegendItem
(AttributedString label, String description, String toolTipText, String urlText, Shape shape, Paint fillPaint) Creates a legend item with a filled shape.LegendItem
(AttributedString label, String description, String toolTipText, String urlText, Shape shape, Paint fillPaint, Stroke outlineStroke, Paint outlinePaint) Creates a legend item with a filled and outlined shape.LegendItem
(AttributedString label, String description, String toolTipText, String urlText, Shape line, Stroke lineStroke, Paint linePaint) Creates a legend item using a line. -
Method Summary
Modifier and TypeMethodDescriptionprivate String
characterIteratorToString
(CharacterIterator iterator) Returns a string containing the characters from the given iterator.clone()
Returns an independent copy of this object (except that the clone will still reference the same dataset as the originalLegendItem
).boolean
Tests this item for equality with an arbitrary object.Returns the attributed label.Returns the dataset.int
Returns the dataset index for this legend item.Returns the description for the legend item.Returns the fill paint.Returns the transformer used when the fill paint is an instance ofGradientPaint
.getLabel()
Returns the label.Returns the label font.Returns the paint used to draw the label.getLine()
Returns the line.Returns the paint used for lines.Returns the line stroke for the series.Returns the outline paint.Returns the outline stroke.int
Returns the series index for this legend item.Returns the series key.getShape()
Returns the shape used to label the series represented by this legend item.Returns the tool tip text.Returns the URL text.int
hashCode()
boolean
Returns a flag that indicates whether or not the line is visible.boolean
Returns a flag that controls whether or not the shape is filled.boolean
Returns the flag that controls whether or not the shape outline is visible.boolean
Returns a flag that indicates whether or not the shape is visible.private void
readObject
(ObjectInputStream stream) Provides serialization support.void
setDataset
(Dataset dataset) Sets the dataset.void
setDatasetIndex
(int index) Sets the dataset index for this legend item.void
setDescription
(String text) Sets the description for this legend item.void
setFillPaint
(Paint paint) Sets the fill paint.void
setFillPaintTransformer
(GradientPaintTransformer transformer) Sets the transformer used when the fill paint is an instance ofGradientPaint
.void
setLabelFont
(Font font) Sets the label font.void
setLabelPaint
(Paint paint) Sets the paint used to draw the label.void
Sets the line.void
setLinePaint
(Paint paint) Sets the line paint.void
setLineStroke
(Stroke stroke) Sets the line stroke.void
setLineVisible
(boolean visible) Sets the flag that controls whether or not the line shape is visible for this legend item.void
setOutlinePaint
(Paint paint) Sets the outline paint.void
setOutlineStroke
(Stroke stroke) Sets the outline stroke.void
setSeriesIndex
(int index) Sets the series index for this legend item.void
setSeriesKey
(Comparable key) Sets the series key.void
Sets the shape for the legend item.void
setShapeVisible
(boolean visible) Sets the flag that controls whether or not the shape is visible.void
setToolTipText
(String text) Sets the tool tip text for this legend item.void
setURLText
(String text) Sets the URL text.private void
writeObject
(ObjectOutputStream stream) Provides serialization support.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor serialization.- See Also:
-
dataset
The dataset. -
seriesKey
The series key. -
datasetIndex
private int datasetIndexThe dataset index. -
series
private int seriesThe series index. -
label
The label. -
labelFont
The label font (null
is permitted). -
labelPaint
The label paint (null
is permitted). -
attributedLabel
The attributed label (if null, fall back to the regular label). -
description
The description (not currently used - could be displayed as a tool tip). -
toolTipText
The tool tip text. -
urlText
The url text. -
shapeVisible
private boolean shapeVisibleA flag that controls whether or not the shape is visible. -
shape
The shape. -
shapeFilled
private boolean shapeFilledA flag that controls whether or not the shape is filled. -
fillPaint
The paint. -
fillPaintTransformer
A gradient paint transformer. -
shapeOutlineVisible
private boolean shapeOutlineVisibleA flag that controls whether or not the shape outline is visible. -
outlinePaint
The outline paint. -
outlineStroke
The outline stroke. -
lineVisible
private boolean lineVisibleA flag that controls whether or not the line is visible. -
line
The line. -
lineStroke
The stroke. -
linePaint
The line paint. -
UNUSED_SHAPE
The shape must be non-null for a LegendItem - if no shape is required, use this. -
UNUSED_STROKE
The stroke must be non-null for a LegendItem - if no stroke is required, use this.
-
-
Constructor Details
-
LegendItem
Creates a legend item with the specified label. The remaining attributes take default values.- Parameters:
label
- the label (null
not permitted).
-
LegendItem
Creates a legend item with the specified label and fill paint. The remaining attributes take default values.- Parameters:
label
- the label (null
not permitted).paint
- the paint (null
not permitted).
-
LegendItem
public LegendItem(String label, String description, String toolTipText, String urlText, Shape shape, Paint fillPaint) Creates a legend item with a filled shape. The shape is not outlined, and no line is visible.- Parameters:
label
- the label (null
not permitted).description
- the description (null
permitted).toolTipText
- the tool tip text (null
permitted).urlText
- the URL text (null
permitted).shape
- the shape (null
not permitted).fillPaint
- the paint used to fill the shape (null
not permitted).
-
LegendItem
public LegendItem(String label, String description, String toolTipText, String urlText, Shape shape, Paint fillPaint, Stroke outlineStroke, Paint outlinePaint) Creates a legend item with a filled and outlined shape.- Parameters:
label
- the label (null
not permitted).description
- the description (null
permitted).toolTipText
- the tool tip text (null
permitted).urlText
- the URL text (null
permitted).shape
- the shape (null
not permitted).fillPaint
- the paint used to fill the shape (null
not permitted).outlineStroke
- the outline stroke (null
not permitted).outlinePaint
- the outline paint (null
not permitted).
-
LegendItem
public LegendItem(String label, String description, String toolTipText, String urlText, Shape line, Stroke lineStroke, Paint linePaint) Creates a legend item using a line.- Parameters:
label
- the label (null
not permitted).description
- the description (null
permitted).toolTipText
- the tool tip text (null
permitted).urlText
- the URL text (null
permitted).line
- the line (null
not permitted).lineStroke
- the line stroke (null
not permitted).linePaint
- the line paint (null
not permitted).
-
LegendItem
public LegendItem(String label, String description, String toolTipText, String urlText, boolean shapeVisible, Shape shape, boolean shapeFilled, Paint fillPaint, boolean shapeOutlineVisible, Paint outlinePaint, Stroke outlineStroke, boolean lineVisible, Shape line, Stroke lineStroke, Paint linePaint) Creates a new legend item.- Parameters:
label
- the label (null
not permitted).description
- the description (not currently used,null
permitted).toolTipText
- the tool tip text (null
permitted).urlText
- the URL text (null
permitted).shapeVisible
- a flag that controls whether or not the shape is displayed.shape
- the shape (null
permitted).shapeFilled
- a flag that controls whether or not the shape is filled.fillPaint
- the fill paint (null
not permitted).shapeOutlineVisible
- a flag that controls whether or not the shape is outlined.outlinePaint
- the outline paint (null
not permitted).outlineStroke
- the outline stroke (null
not permitted).lineVisible
- a flag that controls whether or not the line is visible.line
- the line.lineStroke
- the stroke (null
not permitted).linePaint
- the line paint (null
not permitted).
-
LegendItem
public LegendItem(AttributedString label, String description, String toolTipText, String urlText, Shape shape, Paint fillPaint) Creates a legend item with a filled shape. The shape is not outlined, and no line is visible.- Parameters:
label
- the label (null
not permitted).description
- the description (null
permitted).toolTipText
- the tool tip text (null
permitted).urlText
- the URL text (null
permitted).shape
- the shape (null
not permitted).fillPaint
- the paint used to fill the shape (null
not permitted).
-
LegendItem
public LegendItem(AttributedString label, String description, String toolTipText, String urlText, Shape shape, Paint fillPaint, Stroke outlineStroke, Paint outlinePaint) Creates a legend item with a filled and outlined shape.- Parameters:
label
- the label (null
not permitted).description
- the description (null
permitted).toolTipText
- the tool tip text (null
permitted).urlText
- the URL text (null
permitted).shape
- the shape (null
not permitted).fillPaint
- the paint used to fill the shape (null
not permitted).outlineStroke
- the outline stroke (null
not permitted).outlinePaint
- the outline paint (null
not permitted).
-
LegendItem
public LegendItem(AttributedString label, String description, String toolTipText, String urlText, Shape line, Stroke lineStroke, Paint linePaint) Creates a legend item using a line.- Parameters:
label
- the label (null
not permitted).description
- the description (null
permitted).toolTipText
- the tool tip text (null
permitted).urlText
- the URL text (null
permitted).line
- the line (null
not permitted).lineStroke
- the line stroke (null
not permitted).linePaint
- the line paint (null
not permitted).
-
LegendItem
public LegendItem(AttributedString label, String description, String toolTipText, String urlText, boolean shapeVisible, Shape shape, boolean shapeFilled, Paint fillPaint, boolean shapeOutlineVisible, Paint outlinePaint, Stroke outlineStroke, boolean lineVisible, Shape line, Stroke lineStroke, Paint linePaint) Creates a new legend item.- Parameters:
label
- the label (null
not permitted).description
- the description (not currently used,null
permitted).toolTipText
- the tool tip text (null
permitted).urlText
- the URL text (null
permitted).shapeVisible
- a flag that controls whether or not the shape is displayed.shape
- the shape (null
permitted).shapeFilled
- a flag that controls whether or not the shape is filled.fillPaint
- the fill paint (null
not permitted).shapeOutlineVisible
- a flag that controls whether or not the shape is outlined.outlinePaint
- the outline paint (null
not permitted).outlineStroke
- the outline stroke (null
not permitted).lineVisible
- a flag that controls whether or not the line is visible.line
- the line (null
not permitted).lineStroke
- the stroke (null
not permitted).linePaint
- the line paint (null
not permitted).
-
-
Method Details
-
characterIteratorToString
Returns a string containing the characters from the given iterator.- Parameters:
iterator
- the iterator (null
not permitted).- Returns:
- A string.
-
getDataset
Returns the dataset.- Returns:
- The dataset.
- See Also:
-
setDataset
Sets the dataset.- Parameters:
dataset
- the dataset.
-
getDatasetIndex
public int getDatasetIndex()Returns the dataset index for this legend item.- Returns:
- The dataset index.
- See Also:
-
setDatasetIndex
public void setDatasetIndex(int index) Sets the dataset index for this legend item.- Parameters:
index
- the index.- See Also:
-
getSeriesKey
Returns the series key.- Returns:
- The series key.
- See Also:
-
setSeriesKey
Sets the series key.- Parameters:
key
- the series key.
-
getSeriesIndex
public int getSeriesIndex()Returns the series index for this legend item.- Returns:
- The series index.
-
setSeriesIndex
public void setSeriesIndex(int index) Sets the series index for this legend item.- Parameters:
index
- the index.
-
getLabel
Returns the label.- Returns:
- The label (never
null
).
-
getLabelFont
Returns the label font.- Returns:
- The label font (possibly
null
).
-
setLabelFont
Sets the label font.- Parameters:
font
- the font (null
permitted).
-
getLabelPaint
Returns the paint used to draw the label.- Returns:
- The paint (possibly
null
).
-
setLabelPaint
Sets the paint used to draw the label.- Parameters:
paint
- the paint (null
permitted).
-
getAttributedLabel
Returns the attributed label.- Returns:
- The attributed label (possibly
null
).
-
getDescription
Returns the description for the legend item.- Returns:
- The description (possibly
null
). - See Also:
-
setDescription
Sets the description for this legend item.- Parameters:
text
- the description (null
permitted).- See Also:
-
getToolTipText
Returns the tool tip text.- Returns:
- The tool tip text (possibly
null
). - See Also:
-
setToolTipText
Sets the tool tip text for this legend item.- Parameters:
text
- the text (null
permitted).- See Also:
-
getURLText
Returns the URL text.- Returns:
- The URL text (possibly
null
). - See Also:
-
setURLText
Sets the URL text.- Parameters:
text
- the text (null
permitted).- See Also:
-
isShapeVisible
public boolean isShapeVisible()Returns a flag that indicates whether or not the shape is visible.- Returns:
- A boolean.
- See Also:
-
setShapeVisible
public void setShapeVisible(boolean visible) Sets the flag that controls whether or not the shape is visible.- Parameters:
visible
- the new flag value.- See Also:
-
getShape
Returns the shape used to label the series represented by this legend item.- Returns:
- The shape (never
null
). - See Also:
-
setShape
Sets the shape for the legend item.- Parameters:
shape
- the shape (null
not permitted).- See Also:
-
isShapeFilled
public boolean isShapeFilled()Returns a flag that controls whether or not the shape is filled.- Returns:
- A boolean.
-
getFillPaint
Returns the fill paint.- Returns:
- The fill paint (never
null
).
-
setFillPaint
Sets the fill paint.- Parameters:
paint
- the paint (null
not permitted).
-
isShapeOutlineVisible
public boolean isShapeOutlineVisible()Returns the flag that controls whether or not the shape outline is visible.- Returns:
- A boolean.
-
getLineStroke
Returns the line stroke for the series.- Returns:
- The stroke (never
null
).
-
setLineStroke
Sets the line stroke.- Parameters:
stroke
- the stroke (null
not permitted).
-
getLinePaint
Returns the paint used for lines.- Returns:
- The paint (never
null
).
-
setLinePaint
Sets the line paint.- Parameters:
paint
- the paint (null
not permitted).
-
getOutlinePaint
Returns the outline paint.- Returns:
- The outline paint (never
null
).
-
setOutlinePaint
Sets the outline paint.- Parameters:
paint
- the paint (null
not permitted).
-
getOutlineStroke
Returns the outline stroke.- Returns:
- The outline stroke (never
null
). - See Also:
-
setOutlineStroke
Sets the outline stroke.- Parameters:
stroke
- the stroke (null
not permitted).- See Also:
-
isLineVisible
public boolean isLineVisible()Returns a flag that indicates whether or not the line is visible.- Returns:
- A boolean.
- See Also:
-
setLineVisible
public void setLineVisible(boolean visible) Sets the flag that controls whether or not the line shape is visible for this legend item.- Parameters:
visible
- the new flag value.- See Also:
-
getLine
Returns the line.- Returns:
- The line (never
null
). - See Also:
-
setLine
Sets the line.- Parameters:
line
- the line (null
not permitted).- See Also:
-
getFillPaintTransformer
Returns the transformer used when the fill paint is an instance ofGradientPaint
.- Returns:
- The transformer (never
null
). - See Also:
-
setFillPaintTransformer
Sets the transformer used when the fill paint is an instance ofGradientPaint
.- Parameters:
transformer
- the transformer (null
not permitted).- See Also:
-
equals
Tests this item for equality with an arbitrary object. -
hashCode
public int hashCode() -
clone
Returns an independent copy of this object (except that the clone will still reference the same dataset as the originalLegendItem
).- Overrides:
clone
in classObject
- Returns:
- A clone.
- Throws:
CloneNotSupportedException
- if the legend item cannot be cloned.
-
writeObject
Provides serialization support.- Parameters:
stream
- the output stream (null
not permitted).- Throws:
IOException
- if there is an I/O error.
-
readObject
Provides serialization support.- Parameters:
stream
- the input stream (null
not permitted).- Throws:
IOException
- if there is an I/O error.ClassNotFoundException
- if there is a classpath problem.
-