Package org.jfree.chart
Class StandardLegend
java.lang.Object
org.jfree.chart.Legend
org.jfree.chart.StandardLegend
- All Implemented Interfaces:
Serializable,Cloneable
- Direct Known Subclasses:
MeterLegend
public class StandardLegend extends Legend implements Serializable
A chart legend shows the names and visual representations of the series that
are plotted in a chart.
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static PaintDEFAULT_BACKGROUND_PAINTThe default background paint.static org.jfree.ui.SpacerDEFAULT_INNER_GAPThe default inner gap.static FontDEFAULT_ITEM_FONTThe default item font.static org.jfree.ui.SpacerDEFAULT_OUTER_GAPThe default outer gap.static PaintDEFAULT_OUTLINE_PAINTThe default outline paint.static StrokeDEFAULT_OUTLINE_STROKEThe default outline stroke.static FontDEFAULT_TITLE_FONTThe default title font.static doubleNO_PREFERRED_WIDTHUsed withsetPreferredWidth(double)to indicate that no preferred width is desired and defaults are to be used.Fields inherited from class org.jfree.chart.Legend
EAST, EAST_NORTHEAST, EAST_SOUTHEAST, NORTH, NORTH_NORTHEAST, NORTH_NORTHWEST, SOUTH, SOUTH_SOUTHEAST, SOUTH_SOUTHWEST, WEST, WEST_NORTHWEST, WEST_SOUTHWEST -
Constructor Summary
Constructors Constructor Description StandardLegend()Constructs a new legend with default settings.StandardLegend(JFreeChart chart)Deprecated.use the default constructor instead and let JFreeChart manage the chart reference -
Method Summary
Modifier and Type Method Description Rectangle2Ddraw(Graphics2D g2, Rectangle2D available, ChartRenderingInfo info)Draws the legend on a Java 2D graphics device (such as the screen or a printer).booleanequals(Object obj)Tests an object for equality with this legend.PaintgetBackgroundPaint()Returns the background paint for the legend.intgetBoundingBoxArcHeight()Returns the height of the arc used to round off the corners of the bounding box.intgetBoundingBoxArcWidth()Returns the width of the arc used to round off the corners of the bounding box.booleangetDisplaySeriesLines()Returns a flag that controls whether or not the legend displays the series line stroke.booleangetDisplaySeriesShapes()Returns a flag that controls whether or not the legend displays the series shapes.org.jfree.ui.SpacergetInnerGap()Returns the inner gap for the legend.FontgetItemFont()Returns the series label font.PaintgetItemPaint()Returns the series label paint.org.jfree.ui.SpacergetOuterGap()Returns the outer gap for the legend.PaintgetOutlinePaint()Returns the outline paint.booleangetOutlineShapes()Returns the flag that indicates whether or not outlines are drawn around shapes.StrokegetOutlineStroke()Returns the outline stroke.doublegetPreferredWidth()Returns the preferred width of the legend bounding box if such width has been defined; otherwise returnsNO_PREFERRED_WIDTH.LegendRenderingOrdergetRenderingOrder()Returns the legend rendering order.PaintgetShapeOutlinePaint()Returns the paint used to outline shapes.StrokegetShapeOutlineStroke()Returns the stroke used to outline shapes.doublegetShapeScaleX()Returns the x scale factor for shapes displayed in the legend.doublegetShapeScaleY()Returns the y scale factor for shapes displayed in the legend.StringgetTitle()Gets the title for the legend.FontgetTitleFont()Returns the title font.voidsetBackgroundPaint(Paint paint)Sets the background paint for the legend and sends aLegendChangeEventto all registered listeners.voidsetBoundingBoxArcHeight(int arcHeight)Sets the height of the arc used to round off the corners of the bounding box.voidsetBoundingBoxArcWidth(int arcWidth)Sets the width of the arc used to round off the corners of the bounding box.voidsetDisplaySeriesLines(boolean flag)Sets a flag that controls whether or not the legend displays the series line stroke.voidsetDisplaySeriesShapes(boolean flag)Sets a flag that controls whether or not the legend displays the series shapes.voidsetInnerGap(org.jfree.ui.Spacer innerGap)Sets the inner gap for the legend and sends aLegendChangeEventto all registered listeners.voidsetItemFont(Font font)Sets the series label font and sends aLegendChangeEventto all registered listeners.voidsetItemPaint(Paint paint)Sets the series label paint and sends aLegendChangeEventto all registered listeners.voidsetOuterGap(org.jfree.ui.Spacer outerGap)Sets the outer gap for the legend and sends aLegendChangeEventto all registered listeners.voidsetOutlinePaint(Paint paint)Sets the outline paint and sends aLegendChangeEventto all registered listeners.voidsetOutlineShapes(boolean flag)Sets the flag that controls whether or not outlines are drawn around shapes, and sends aLegendChangeEventto all registered listeners.voidsetOutlineStroke(Stroke stroke)Sets the outline stroke and sends aLegendChangeEventto all registered listeners.voidsetPreferredWidth(double width)Sets the preferred width of the legend bounding box.voidsetRenderingOrder(LegendRenderingOrder order)Sets the legend rendering order and sends aLegendChangeEventto all registered listeners.voidsetShapeOutlinePaint(Paint paint)Sets the paint used to outline shapes.voidsetShapeOutlineStroke(Stroke stroke)Sets the stroke used to outline shapes and sends aLegendChangeEventto all registered listeners.voidsetShapeScaleX(double factor)Sets the x scale factor for shapes displayed in the legend and sends aLegendChangeEventto all registered listeners.voidsetShapeScaleY(double factor)Sets the y scale factor for shapes displayed in the legend and sends aLegendChangeEventto all registered listeners.voidsetTitle(String title)Sets the title of the legend and sends aLegendChangeEventto all registered listeners.voidsetTitleFont(Font font)Sets the title font and sends aLegendChangeEventto all registered listeners.Methods inherited from class org.jfree.chart.Legend
addChangeListener, createInstance, getAnchor, getChart, removeChangeListener, setAnchor
-
Field Details
-
DEFAULT_OUTER_GAP
public static final org.jfree.ui.Spacer DEFAULT_OUTER_GAPThe default outer gap. -
DEFAULT_INNER_GAP
public static final org.jfree.ui.Spacer DEFAULT_INNER_GAPThe default inner gap. -
DEFAULT_OUTLINE_STROKE
The default outline stroke. -
DEFAULT_OUTLINE_PAINT
The default outline paint. -
DEFAULT_BACKGROUND_PAINT
The default background paint. -
DEFAULT_TITLE_FONT
The default title font. -
DEFAULT_ITEM_FONT
The default item font. -
NO_PREFERRED_WIDTH
public static final double NO_PREFERRED_WIDTHUsed withsetPreferredWidth(double)to indicate that no preferred width is desired and defaults are to be used.- See Also:
- Constant Field Values
-
-
Constructor Details
-
StandardLegend
public StandardLegend()Constructs a new legend with default settings. -
StandardLegend
Deprecated.use the default constructor instead and let JFreeChart manage the chart referenceCreates a new legend.- Parameters:
chart- the chart that the legend belongs to.
-
-
Method Details
-
getOuterGap
public org.jfree.ui.Spacer getOuterGap()Returns the outer gap for the legend. This is the amount of blank space around the outside of the legend.- Returns:
- The gap (never
null).
-
setOuterGap
public void setOuterGap(org.jfree.ui.Spacer outerGap)Sets the outer gap for the legend and sends aLegendChangeEventto all registered listeners.- Parameters:
outerGap- the outer gap (nullnot permitted).
-
getInnerGap
public org.jfree.ui.Spacer getInnerGap()Returns the inner gap for the legend. This is the amount of blank space around the inside of the legend.- Returns:
- The gap (never
null).
-
setInnerGap
public void setInnerGap(org.jfree.ui.Spacer innerGap)Sets the inner gap for the legend and sends aLegendChangeEventto all registered listeners.- Parameters:
innerGap- the inner gap (nullnot permitted).
-
getBackgroundPaint
Returns the background paint for the legend.- Returns:
- The background paint (never
null).
-
setBackgroundPaint
Sets the background paint for the legend and sends aLegendChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).
-
getOutlineStroke
Returns the outline stroke.- Returns:
- The outline stroke (never
null).
-
setOutlineStroke
Sets the outline stroke and sends aLegendChangeEventto all registered listeners.- Parameters:
stroke- the stroke (nullnot permitted).
-
getOutlinePaint
Returns the outline paint.- Returns:
- The outline paint (never
null).
-
setOutlinePaint
Sets the outline paint and sends aLegendChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).
-
getTitle
Gets the title for the legend.- Returns:
- The title (possibly
null).
-
setTitle
Sets the title of the legend and sends aLegendChangeEventto all registered listeners.- Parameters:
title- the title (nullpermitted).
-
getTitleFont
Returns the title font.- Returns:
- The font (never
null).
-
setTitleFont
Sets the title font and sends aLegendChangeEventto all registered listeners.- Parameters:
font- the font (nullnot permitted).
-
getItemFont
Returns the series label font.- Returns:
- The font (never
null).
-
setItemFont
Sets the series label font and sends aLegendChangeEventto all registered listeners.- Parameters:
font- the font (nullnot permitted).
-
getItemPaint
Returns the series label paint.- Returns:
- The paint (never
null).
-
setItemPaint
Sets the series label paint and sends aLegendChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).
-
getOutlineShapes
public boolean getOutlineShapes()Returns the flag that indicates whether or not outlines are drawn around shapes.- Returns:
- The flag.
-
setOutlineShapes
public void setOutlineShapes(boolean flag)Sets the flag that controls whether or not outlines are drawn around shapes, and sends aLegendChangeEventto all registered listeners.- Parameters:
flag- the flag.
-
getShapeOutlineStroke
Returns the stroke used to outline shapes.- Returns:
- The stroke (never
null).
-
setShapeOutlineStroke
Sets the stroke used to outline shapes and sends aLegendChangeEventto all registered listeners.- Parameters:
stroke- the stroke (nullnot permitted).
-
getShapeOutlinePaint
Returns the paint used to outline shapes.- Returns:
- The paint.
-
setShapeOutlinePaint
Sets the paint used to outline shapes. ALegendChangeEventis sent to all registered listeners.- Parameters:
paint- the paint.
-
setDisplaySeriesShapes
public void setDisplaySeriesShapes(boolean flag)Sets a flag that controls whether or not the legend displays the series shapes.- Parameters:
flag- the new value of the flag.
-
getDisplaySeriesShapes
public boolean getDisplaySeriesShapes()Returns a flag that controls whether or not the legend displays the series shapes.- Returns:
trueif the series shapes should be displayed,falseotherwise.
-
getShapeScaleX
public double getShapeScaleX()Returns the x scale factor for shapes displayed in the legend.- Returns:
- the x scale factor.
-
setShapeScaleX
public void setShapeScaleX(double factor)Sets the x scale factor for shapes displayed in the legend and sends aLegendChangeEventto all registered listeners.- Parameters:
factor- the factor.
-
getShapeScaleY
public double getShapeScaleY()Returns the y scale factor for shapes displayed in the legend.- Returns:
- the y scale factor.
-
setShapeScaleY
public void setShapeScaleY(double factor)Sets the y scale factor for shapes displayed in the legend and sends aLegendChangeEventto all registered listeners.- Parameters:
factor- the factor.
-
setDisplaySeriesLines
public void setDisplaySeriesLines(boolean flag)Sets a flag that controls whether or not the legend displays the series line stroke.- Parameters:
flag- the new value of the flag.
-
getDisplaySeriesLines
public boolean getDisplaySeriesLines()Returns a flag that controls whether or not the legend displays the series line stroke.- Returns:
trueif the series lines should be displayed,falseotherwise.
-
getRenderingOrder
Returns the legend rendering order.- Returns:
- The order (never
null).
-
setRenderingOrder
Sets the legend rendering order and sends aLegendChangeEventto all registered listeners.- Parameters:
order- the order (nullnot permitted).
-
getBoundingBoxArcWidth
public int getBoundingBoxArcWidth()Returns the width of the arc used to round off the corners of the bounding box.- Returns:
- the width of the arc used to round off the corners of the bounding box.
-
setBoundingBoxArcWidth
public void setBoundingBoxArcWidth(int arcWidth)Sets the width of the arc used to round off the corners of the bounding box. ALegendChangeEventis sent to all registered listeners.- Parameters:
arcWidth- the new arc width.
-
getBoundingBoxArcHeight
public int getBoundingBoxArcHeight()Returns the height of the arc used to round off the corners of the bounding box.- Returns:
- the height of the arc used to round off the corners of the bounding box.
-
setBoundingBoxArcHeight
public void setBoundingBoxArcHeight(int arcHeight)Sets the height of the arc used to round off the corners of the bounding box. ALegendChangeEventis sent to all registered listeners.- Parameters:
arcHeight- the new arc height.
-
getPreferredWidth
public double getPreferredWidth()Returns the preferred width of the legend bounding box if such width has been defined; otherwise returnsNO_PREFERRED_WIDTH.- Returns:
- the preferred width of the legend bounding box if such width has been
defined; otherwise returns
NO_PREFERRED_WIDTH.
-
setPreferredWidth
public void setPreferredWidth(double width)Sets the preferred width of the legend bounding box. If a preferred width is set, the legend text is word-wrapped in an attempt to fulfill the preferred width. If the preferred width cannot be fulfilled, the legend would be wider to the extent necessary.The preferred width takes effect only when the legend's anchor is set to one of the three EAST anchors or to one of the three WEST anchors.
A
LegendChangeEventis sent to all registered listeners.- Parameters:
width- the new width.
-
draw
Draws the legend on a Java 2D graphics device (such as the screen or a printer). -
equals
Tests an object for equality with this legend.
-