Package org.jfree.chart.title
Class LegendGraphic
java.lang.Object
org.jfree.chart.block.AbstractBlock
org.jfree.chart.title.LegendGraphic
- All Implemented Interfaces:
Serializable,Cloneable,Block,Drawable,PublicCloneable
The graphical item within a legend item.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate PaintThe fill paint for the shape.private GradientPaintTransformerThe fill paint transformer (used if the fillPaint is an instance of GradientPaint).private ShapeThe line.private PaintThe line paint.private StrokeThe line stroke.private booleanA flag that controls whether or not the line is visible - see also shapeVisible.private PaintThe outline paint for the shape.private StrokeThe outline stroke for the shape.(package private) static final longFor serialization.private ShapeThe shape to display.private RectangleAnchorDefines the point on the shape's bounding rectangle that will be aligned to the drawing location when the shape is rendered.private booleanA flag that controls whether or not the shape is filled.private RectangleAnchorDefines the location within the block to which the shape will be aligned.private booleanA flag that controls whether or not the shape outline is visible.private booleanA flag that controls whether or not the shape is visible - see also lineVisible. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionarrange(Graphics2D g2, RectangleConstraint constraint) Arranges the contents of the block, within the given constraints, and returns the block size.protected Size2DarrangeNN(Graphics2D g2) Performs the layout with no constraint, so the content size is determined by the bounds of the shape and/or line drawn to represent the series.booleanEnsures symmetry between super/subclass implementations of equals.clone()Returns a clone of thisLegendGraphicinstance.voiddraw(Graphics2D g2, Rectangle2D area) Draws the graphic item within the specified area.draw(Graphics2D g2, Rectangle2D area, Object params) Draws the block within the specified area.booleanTests thisLegendGraphicinstance for equality with an arbitrary object.Returns the paint used to fill the shape.Returns the transformer used when the fill paint is an instance ofGradientPaint.getLine()Returns the line centered about (0, 0).Returns the line paint.Returns the line stroke.Returns the outline paint.Returns the outline stroke.getShape()Returns the shape.Returns the shape anchor.Returns the shape location.inthashCode()Returns a hash code for this instance.booleanReturns the flag that controls whether or not the line is visible.booleanReturns a flag that controls whether or not the shapes are filled.booleanReturns a flag that controls whether the shape outline is visible.booleanReturns a flag that controls whether or not the shape is visible.private voidreadObject(ObjectInputStream stream) Provides serialization support.voidsetFillPaint(Paint paint) Sets the paint used to fill the shape.voidsetFillPaintTransformer(GradientPaintTransformer transformer) Sets the transformer used when the fill paint is an instance ofGradientPaint.voidSets the line.voidsetLinePaint(Paint paint) Sets the line paint.voidsetLineStroke(Stroke stroke) Sets the line stroke.voidsetLineVisible(boolean visible) Sets the flag that controls whether or not the line is visible.voidsetOutlinePaint(Paint paint) Sets the outline paint.voidsetOutlineStroke(Stroke stroke) Sets the outline stroke.voidSets the shape.voidsetShapeAnchor(RectangleAnchor anchor) Sets the shape anchor.voidsetShapeFilled(boolean filled) Sets a flag that controls whether or not the shape is filled.voidsetShapeLocation(RectangleAnchor location) Sets the shape location.voidsetShapeOutlineVisible(boolean visible) Sets a flag that controls whether or not the shape outline is visible.voidsetShapeVisible(boolean visible) Sets a flag that controls whether or not the shape is visible.private voidwriteObject(ObjectOutputStream stream) Provides serialization support.Methods inherited from class org.jfree.chart.block.AbstractBlock
arrange, calculateTotalHeight, calculateTotalWidth, drawBorder, getBounds, getContentXOffset, getContentYOffset, getFrame, getHeight, getID, getMargin, getPadding, getWidth, setBorder, setBounds, setFrame, setHeight, setID, setMargin, setMargin, setPadding, setPadding, setWidth, toContentConstraint, trimBorder, trimMargin, trimPadding, trimToContentHeight, trimToContentWidth
-
Field Details
-
serialVersionUID
static final long serialVersionUIDFor serialization.- See Also:
-
shapeVisible
private boolean shapeVisibleA flag that controls whether or not the shape is visible - see also lineVisible. -
shape
The shape to display. To allow for accurate positioning, the center of the shape should be at (0, 0). -
shapeLocation
Defines the location within the block to which the shape will be aligned. -
shapeAnchor
Defines the point on the shape's bounding rectangle that will be aligned to the drawing location when the shape is rendered. -
shapeFilled
private boolean shapeFilledA flag that controls whether or not the shape is filled. -
fillPaint
The fill paint for the shape. -
fillPaintTransformer
The fill paint transformer (used if the fillPaint is an instance of GradientPaint). -
shapeOutlineVisible
private boolean shapeOutlineVisibleA flag that controls whether or not the shape outline is visible. -
outlinePaint
The outline paint for the shape. -
outlineStroke
The outline stroke for the shape. -
lineVisible
private boolean lineVisibleA flag that controls whether or not the line is visible - see also shapeVisible. -
line
The line. -
lineStroke
The line stroke. -
linePaint
The line paint.
-
-
Constructor Details
-
LegendGraphic
Creates a new legend graphic.- Parameters:
shape- the shape (nullnot permitted).fillPaint- the fill paint (nullnot permitted).
-
-
Method Details
-
isShapeVisible
public boolean isShapeVisible()Returns a flag that controls whether or not the shape is visible.- Returns:
- A boolean.
- See Also:
-
setShapeVisible
public void setShapeVisible(boolean visible) Sets a flag that controls whether or not the shape is visible.- Parameters:
visible- the flag.- See Also:
-
getShape
Returns the shape.- Returns:
- The shape.
- See Also:
-
setShape
Sets the shape.- Parameters:
shape- the shape.- See Also:
-
isShapeFilled
public boolean isShapeFilled()Returns a flag that controls whether or not the shapes are filled.- Returns:
- A boolean.
- See Also:
-
setShapeFilled
public void setShapeFilled(boolean filled) Sets a flag that controls whether or not the shape is filled.- Parameters:
filled- the flag.- See Also:
-
getFillPaint
Returns the paint used to fill the shape.- Returns:
- The fill paint.
- See Also:
-
setFillPaint
Sets the paint used to fill the shape.- Parameters:
paint- the paint.- 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 (nullnot permitted).- See Also:
-
isShapeOutlineVisible
public boolean isShapeOutlineVisible()Returns a flag that controls whether the shape outline is visible.- Returns:
- A boolean.
- See Also:
-
setShapeOutlineVisible
public void setShapeOutlineVisible(boolean visible) Sets a flag that controls whether or not the shape outline is visible.- Parameters:
visible- the flag.- See Also:
-
getOutlinePaint
Returns the outline paint.- Returns:
- The paint.
- See Also:
-
setOutlinePaint
Sets the outline paint.- Parameters:
paint- the paint.- See Also:
-
getOutlineStroke
Returns the outline stroke.- Returns:
- The stroke.
- See Also:
-
setOutlineStroke
Sets the outline stroke.- Parameters:
stroke- the stroke.- See Also:
-
getShapeAnchor
Returns the shape anchor.- Returns:
- The shape anchor.
- See Also:
-
setShapeAnchor
Sets the shape anchor. This defines a point on the shapes bounding rectangle that will be used to align the shape to a location.- Parameters:
anchor- the anchor (nullnot permitted).- See Also:
-
getShapeLocation
Returns the shape location.- Returns:
- The shape location.
- See Also:
-
setShapeLocation
Sets the shape location. This defines a point within the drawing area that will be used to align the shape to.- Parameters:
location- the location (nullnot permitted).- See Also:
-
isLineVisible
public boolean isLineVisible()Returns the flag that controls 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 is visible.- Parameters:
visible- the flag.- See Also:
-
getLine
Returns the line centered about (0, 0).- Returns:
- The line.
- See Also:
-
setLine
Sets the line. A Shape is used here, because then you can use Line2D, GeneralPath or any other Shape to represent the line.- Parameters:
line- the line.- See Also:
-
getLinePaint
Returns the line paint.- Returns:
- The paint.
- See Also:
-
setLinePaint
Sets the line paint.- Parameters:
paint- the paint.- See Also:
-
getLineStroke
Returns the line stroke.- Returns:
- The stroke.
- See Also:
-
setLineStroke
Sets the line stroke.- Parameters:
stroke- the stroke.- See Also:
-
arrange
Arranges the contents of the block, within the given constraints, and returns the block size.- Specified by:
arrangein interfaceBlock- Overrides:
arrangein classAbstractBlock- Parameters:
g2- the graphics device.constraint- the constraint (nullnot permitted).- Returns:
- The block size (in Java2D units, never
null).
-
arrangeNN
Performs the layout with no constraint, so the content size is determined by the bounds of the shape and/or line drawn to represent the series.- Parameters:
g2- the graphics device.- Returns:
- The content size.
-
draw
Draws the graphic item within the specified area. -
draw
Draws the block within the specified area. -
equals
Tests thisLegendGraphicinstance for equality with an arbitrary object.- Overrides:
equalsin classAbstractBlock- Parameters:
obj- the object (nullpermitted).- Returns:
- A boolean.
-
canEqual
Ensures symmetry between super/subclass implementations of equals. For more detail, see http://jqno.nl/equalsverifier/manual/inheritance.- Overrides:
canEqualin classAbstractBlock- 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 classAbstractBlock- Returns:
- A hash code.
-
clone
Returns a clone of thisLegendGraphicinstance.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classAbstractBlock- Returns:
- A clone of this
LegendGraphicinstance. - Throws:
CloneNotSupportedException- if there is a problem cloning.
-
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.
-