Package org.jfree.chart.title
Class LegendGraphic
- java.lang.Object
-
- org.jfree.chart.block.AbstractBlock
-
- org.jfree.chart.title.LegendGraphic
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,Block,Drawable,PublicCloneable
public class LegendGraphic extends AbstractBlock implements Block, PublicCloneable
The graphical item within a legend item.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.PaintfillPaintThe fill paint for the shape.private GradientPaintTransformerfillPaintTransformerThe fill paint transformer (used if the fillPaint is an instance of GradientPaint).private java.awt.ShapelineThe line.private java.awt.PaintlinePaintThe line paint.private java.awt.StrokelineStrokeThe line stroke.private booleanlineVisibleA flag that controls whether or not the line is visible - see also shapeVisible.private java.awt.PaintoutlinePaintThe outline paint for the shape.private java.awt.StrokeoutlineStrokeThe outline stroke for the shape.(package private) static longserialVersionUIDFor serialization.private java.awt.ShapeshapeThe shape to display.private RectangleAnchorshapeAnchorDefines the point on the shape's bounding rectangle that will be aligned to the drawing location when the shape is rendered.private booleanshapeFilledA flag that controls whether or not the shape is filled.private RectangleAnchorshapeLocationDefines the location within the block to which the shape will be aligned.private booleanshapeOutlineVisibleA flag that controls whether or not the shape outline is visible.private booleanshapeVisibleA flag that controls whether or not the shape is visible - see also lineVisible.
-
Constructor Summary
Constructors Constructor Description LegendGraphic(java.awt.Shape shape, java.awt.Paint fillPaint)Creates a new legend graphic.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Size2Darrange(java.awt.Graphics2D g2, RectangleConstraint constraint)Arranges the contents of the block, within the given constraints, and returns the block size.protected Size2DarrangeNN(java.awt.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.booleancanEqual(java.lang.Object other)Ensures symmetry between super/subclass implementations of equals.java.lang.Objectclone()Returns a clone of thisLegendGraphicinstance.voiddraw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)Draws the graphic item within the specified area.java.lang.Objectdraw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.lang.Object params)Draws the block within the specified area.booleanequals(java.lang.Object obj)Tests thisLegendGraphicinstance for equality with an arbitrary object.java.awt.PaintgetFillPaint()Returns the paint used to fill the shape.GradientPaintTransformergetFillPaintTransformer()Returns the transformer used when the fill paint is an instance ofGradientPaint.java.awt.ShapegetLine()Returns the line centered about (0, 0).java.awt.PaintgetLinePaint()Returns the line paint.java.awt.StrokegetLineStroke()Returns the line stroke.java.awt.PaintgetOutlinePaint()Returns the outline paint.java.awt.StrokegetOutlineStroke()Returns the outline stroke.java.awt.ShapegetShape()Returns the shape.RectangleAnchorgetShapeAnchor()Returns the shape anchor.RectangleAnchorgetShapeLocation()Returns the shape location.inthashCode()Returns a hash code for this instance.booleanisLineVisible()Returns the flag that controls whether or not the line is visible.booleanisShapeFilled()Returns a flag that controls whether or not the shapes are filled.booleanisShapeOutlineVisible()Returns a flag that controls whether the shape outline is visible.booleanisShapeVisible()Returns a flag that controls whether or not the shape is visible.private voidreadObject(java.io.ObjectInputStream stream)Provides serialization support.voidsetFillPaint(java.awt.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.voidsetLine(java.awt.Shape line)Sets the line.voidsetLinePaint(java.awt.Paint paint)Sets the line paint.voidsetLineStroke(java.awt.Stroke stroke)Sets the line stroke.voidsetLineVisible(boolean visible)Sets the flag that controls whether or not the line is visible.voidsetOutlinePaint(java.awt.Paint paint)Sets the outline paint.voidsetOutlineStroke(java.awt.Stroke stroke)Sets the outline stroke.voidsetShape(java.awt.Shape shape)Sets 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(java.io.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 Detail
-
serialVersionUID
static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
shapeVisible
private boolean shapeVisible
A flag that controls whether or not the shape is visible - see also lineVisible.
-
shape
private transient java.awt.Shape shape
The shape to display. To allow for accurate positioning, the center of the shape should be at (0, 0).
-
shapeLocation
private RectangleAnchor shapeLocation
Defines the location within the block to which the shape will be aligned.
-
shapeAnchor
private RectangleAnchor 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 shapeFilled
A flag that controls whether or not the shape is filled.
-
fillPaint
private transient java.awt.Paint fillPaint
The fill paint for the shape.
-
fillPaintTransformer
private GradientPaintTransformer fillPaintTransformer
The fill paint transformer (used if the fillPaint is an instance of GradientPaint).
-
shapeOutlineVisible
private boolean shapeOutlineVisible
A flag that controls whether or not the shape outline is visible.
-
outlinePaint
private transient java.awt.Paint outlinePaint
The outline paint for the shape.
-
outlineStroke
private transient java.awt.Stroke outlineStroke
The outline stroke for the shape.
-
lineVisible
private boolean lineVisible
A flag that controls whether or not the line is visible - see also shapeVisible.
-
line
private transient java.awt.Shape line
The line.
-
lineStroke
private transient java.awt.Stroke lineStroke
The line stroke.
-
linePaint
private transient java.awt.Paint linePaint
The line paint.
-
-
Method Detail
-
isShapeVisible
public boolean isShapeVisible()
Returns a flag that controls whether or not the shape is visible.- Returns:
- A boolean.
- See Also:
setShapeVisible(boolean)
-
setShapeVisible
public void setShapeVisible(boolean visible)
Sets a flag that controls whether or not the shape is visible.- Parameters:
visible- the flag.- See Also:
isShapeVisible()
-
getShape
public java.awt.Shape getShape()
Returns the shape.- Returns:
- The shape.
- See Also:
setShape(Shape)
-
setShape
public void setShape(java.awt.Shape shape)
Sets the shape.- Parameters:
shape- the shape.- See Also:
getShape()
-
isShapeFilled
public boolean isShapeFilled()
Returns a flag that controls whether or not the shapes are filled.- Returns:
- A boolean.
- See Also:
setShapeFilled(boolean)
-
setShapeFilled
public void setShapeFilled(boolean filled)
Sets a flag that controls whether or not the shape is filled.- Parameters:
filled- the flag.- See Also:
isShapeFilled()
-
getFillPaint
public java.awt.Paint getFillPaint()
Returns the paint used to fill the shape.- Returns:
- The fill paint.
- See Also:
setFillPaint(Paint)
-
setFillPaint
public void setFillPaint(java.awt.Paint paint)
Sets the paint used to fill the shape.- Parameters:
paint- the paint.- See Also:
getFillPaint()
-
getFillPaintTransformer
public GradientPaintTransformer getFillPaintTransformer()
Returns the transformer used when the fill paint is an instance ofGradientPaint.- Returns:
- The transformer (never
null). - See Also:
setFillPaintTransformer(GradientPaintTransformer)
-
setFillPaintTransformer
public void setFillPaintTransformer(GradientPaintTransformer transformer)
Sets the transformer used when the fill paint is an instance ofGradientPaint.- Parameters:
transformer- the transformer (nullnot permitted).- See Also:
getFillPaintTransformer()
-
isShapeOutlineVisible
public boolean isShapeOutlineVisible()
Returns a flag that controls whether the shape outline is visible.- Returns:
- A boolean.
- See Also:
setShapeOutlineVisible(boolean)
-
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:
isShapeOutlineVisible()
-
getOutlinePaint
public java.awt.Paint getOutlinePaint()
Returns the outline paint.- Returns:
- The paint.
- See Also:
setOutlinePaint(Paint)
-
setOutlinePaint
public void setOutlinePaint(java.awt.Paint paint)
Sets the outline paint.- Parameters:
paint- the paint.- See Also:
getOutlinePaint()
-
getOutlineStroke
public java.awt.Stroke getOutlineStroke()
Returns the outline stroke.- Returns:
- The stroke.
- See Also:
setOutlineStroke(Stroke)
-
setOutlineStroke
public void setOutlineStroke(java.awt.Stroke stroke)
Sets the outline stroke.- Parameters:
stroke- the stroke.- See Also:
getOutlineStroke()
-
getShapeAnchor
public RectangleAnchor getShapeAnchor()
Returns the shape anchor.- Returns:
- The shape anchor.
- See Also:
getShapeAnchor()
-
setShapeAnchor
public void setShapeAnchor(RectangleAnchor anchor)
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:
setShapeAnchor(RectangleAnchor)
-
getShapeLocation
public RectangleAnchor getShapeLocation()
Returns the shape location.- Returns:
- The shape location.
- See Also:
setShapeLocation(RectangleAnchor)
-
setShapeLocation
public void setShapeLocation(RectangleAnchor location)
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:
getShapeLocation()
-
isLineVisible
public boolean isLineVisible()
Returns the flag that controls whether or not the line is visible.- Returns:
- A boolean.
- See Also:
setLineVisible(boolean)
-
setLineVisible
public void setLineVisible(boolean visible)
Sets the flag that controls whether or not the line is visible.- Parameters:
visible- the flag.- See Also:
isLineVisible()
-
getLine
public java.awt.Shape getLine()
Returns the line centered about (0, 0).- Returns:
- The line.
- See Also:
setLine(Shape)
-
setLine
public void setLine(java.awt.Shape line)
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:
getLine()
-
getLinePaint
public java.awt.Paint getLinePaint()
Returns the line paint.- Returns:
- The paint.
- See Also:
setLinePaint(Paint)
-
setLinePaint
public void setLinePaint(java.awt.Paint paint)
Sets the line paint.- Parameters:
paint- the paint.- See Also:
getLinePaint()
-
getLineStroke
public java.awt.Stroke getLineStroke()
Returns the line stroke.- Returns:
- The stroke.
- See Also:
setLineStroke(Stroke)
-
setLineStroke
public void setLineStroke(java.awt.Stroke stroke)
Sets the line stroke.- Parameters:
stroke- the stroke.- See Also:
getLineStroke()
-
arrange
public Size2D arrange(java.awt.Graphics2D g2, RectangleConstraint constraint)
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
protected Size2D arrangeNN(java.awt.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.- Parameters:
g2- the graphics device.- Returns:
- The content size.
-
draw
public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)Draws the graphic item within the specified area.
-
draw
public java.lang.Object draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.lang.Object params)Draws the block within the specified area.
-
equals
public boolean equals(java.lang.Object obj)
Tests thisLegendGraphicinstance for equality with an arbitrary object.- Overrides:
equalsin classAbstractBlock- Parameters:
obj- the object (nullpermitted).- Returns:
- A boolean.
-
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 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
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionReturns a clone of thisLegendGraphicinstance.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classAbstractBlock- Returns:
- A clone of this
LegendGraphicinstance. - Throws:
java.lang.CloneNotSupportedException- if there is a problem cloning.
-
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.
-
-