public class LegendTitle extends Title implements java.lang.Cloneable, org.jfree.util.PublicCloneable, java.io.Serializable
The title can be populated with legend items manually, or you can assign a reference to the plot, in which case the legend items will be automatically created to match the dataset(s).
| Modifier and Type | Field and Description |
|---|---|
private java.awt.Paint |
backgroundPaint
The background paint (possibly
null). |
static java.awt.Font |
DEFAULT_ITEM_FONT
The default item font.
|
static java.awt.Paint |
DEFAULT_ITEM_PAINT
The default item paint.
|
private Arrangement |
hLayout
The layout for the legend when it is positioned at the top or bottom
of the chart.
|
private java.awt.Font |
itemFont
The item font.
|
private org.jfree.ui.RectangleInsets |
itemLabelPadding
The padding for the item labels.
|
private java.awt.Paint |
itemPaint
The item paint.
|
private BlockContainer |
items
A container that holds and displays the legend items.
|
private org.jfree.ui.RectangleAnchor |
legendItemGraphicAnchor
The anchor point for the legend item graphic.
|
private org.jfree.ui.RectangleEdge |
legendItemGraphicEdge
The edge for the legend item graphic relative to the text.
|
private org.jfree.ui.RectangleAnchor |
legendItemGraphicLocation
The legend item graphic location.
|
private org.jfree.ui.RectangleInsets |
legendItemGraphicPadding
The padding for the legend item graphic.
|
private static long |
serialVersionUID
For serialization.
|
private org.jfree.util.SortOrder |
sortOrder
Whether to render legend items in ascending or descending order.
|
private LegendItemSource[] |
sources
The sources for legend items.
|
private Arrangement |
vLayout
The layout for the legend when it is positioned at the left or right
of the chart.
|
private BlockContainer |
wrapper
An optional container for wrapping the legend items (allows for adding
a title or other text to the legend).
|
DEFAULT_HORIZONTAL_ALIGNMENT, DEFAULT_PADDING, DEFAULT_POSITION, DEFAULT_VERTICAL_ALIGNMENT, visible| Constructor and Description |
|---|
LegendTitle(LegendItemSource source)
Constructs a new (empty) legend for the specified source.
|
LegendTitle(LegendItemSource source,
Arrangement hLayout,
Arrangement vLayout)
Creates a new legend title with the specified arrangement.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
addItemBlock(LegendItem item) |
org.jfree.ui.Size2D |
arrange(java.awt.Graphics2D g2,
RectangleConstraint constraint)
Arranges the contents of the block, within the given constraints, and
returns the block size.
|
protected Block |
createLegendItemBlock(LegendItem item)
Creates a legend item block.
|
void |
draw(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area)
Draws the title on a Java 2D graphics device (such as the screen or a
printer).
|
java.lang.Object |
draw(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area,
java.lang.Object params)
Draws the block within the specified area.
|
boolean |
equals(java.lang.Object obj)
Tests this title for equality with an arbitrary object.
|
protected void |
fetchLegendItems()
Fetches the latest legend items.
|
java.awt.Paint |
getBackgroundPaint()
Returns the background paint.
|
BlockContainer |
getItemContainer()
Returns the container that holds the legend items.
|
java.awt.Font |
getItemFont()
Returns the item font.
|
org.jfree.ui.RectangleInsets |
getItemLabelPadding()
Returns the padding used for the items labels.
|
java.awt.Paint |
getItemPaint()
Returns the item paint.
|
org.jfree.ui.RectangleAnchor |
getLegendItemGraphicAnchor()
Returns the legend item graphic anchor.
|
org.jfree.ui.RectangleEdge |
getLegendItemGraphicEdge()
Returns the location of the shape within each legend item.
|
org.jfree.ui.RectangleAnchor |
getLegendItemGraphicLocation()
Returns the legend item graphic location.
|
org.jfree.ui.RectangleInsets |
getLegendItemGraphicPadding()
Returns the padding that will be applied to each item graphic.
|
org.jfree.util.SortOrder |
getSortOrder()
Gets the order used to display legend items.
|
LegendItemSource[] |
getSources()
Returns the legend item sources.
|
BlockContainer |
getWrapper()
Returns the wrapper container, if any.
|
private void |
readObject(java.io.ObjectInputStream stream)
Provides serialization support.
|
void |
setBackgroundPaint(java.awt.Paint paint)
Sets the background paint for the legend and sends a
TitleChangeEvent to all registered listeners. |
void |
setItemFont(java.awt.Font font)
Sets the item font and sends a
TitleChangeEvent to
all registered listeners. |
void |
setItemLabelPadding(org.jfree.ui.RectangleInsets padding)
Sets the padding used for the item labels in the legend.
|
void |
setItemPaint(java.awt.Paint paint)
Sets the item paint.
|
void |
setLegendItemGraphicAnchor(org.jfree.ui.RectangleAnchor anchor)
Sets the anchor point used for the graphic in each legend item.
|
void |
setLegendItemGraphicEdge(org.jfree.ui.RectangleEdge edge)
Sets the location of the shape within each legend item.
|
void |
setLegendItemGraphicLocation(org.jfree.ui.RectangleAnchor anchor)
Sets the legend item graphic location.
|
void |
setLegendItemGraphicPadding(org.jfree.ui.RectangleInsets padding)
Sets the padding that will be applied to each item graphic in the
legend and sends a
TitleChangeEvent to all registered listeners. |
void |
setSortOrder(org.jfree.util.SortOrder order)
Sets the order used to display legend items.
|
void |
setSources(LegendItemSource[] sources)
Sets the legend item sources and sends a
TitleChangeEvent to
all registered listeners. |
void |
setWrapper(BlockContainer wrapper)
Sets the wrapper container for the legend.
|
private void |
writeObject(java.io.ObjectOutputStream stream)
Provides serialization support.
|
addChangeListener, clone, getHorizontalAlignment, getNotify, getPosition, getVerticalAlignment, hashCode, isVisible, notifyListeners, removeChangeListener, setHorizontalAlignment, setNotify, setPosition, setVerticalAlignment, setVisiblearrange, calculateTotalHeight, calculateTotalWidth, drawBorder, getBorder, getBounds, getContentXOffset, getContentYOffset, getFrame, getHeight, getID, getMargin, getPadding, getWidth, setBorder, setBorder, setBounds, setFrame, setHeight, setID, setMargin, setMargin, setPadding, setPadding, setWidth, toContentConstraint, trimBorder, trimMargin, trimPadding, trimToContentHeight, trimToContentWidthprivate static final long serialVersionUID
public static final java.awt.Font DEFAULT_ITEM_FONT
public static final java.awt.Paint DEFAULT_ITEM_PAINT
private LegendItemSource[] sources
private transient java.awt.Paint backgroundPaint
null).private org.jfree.ui.RectangleEdge legendItemGraphicEdge
private org.jfree.ui.RectangleAnchor legendItemGraphicAnchor
private org.jfree.ui.RectangleAnchor legendItemGraphicLocation
private org.jfree.ui.RectangleInsets legendItemGraphicPadding
private java.awt.Font itemFont
private transient java.awt.Paint itemPaint
private org.jfree.ui.RectangleInsets itemLabelPadding
private BlockContainer items
private Arrangement hLayout
private Arrangement vLayout
private BlockContainer wrapper
private org.jfree.util.SortOrder sortOrder
public LegendTitle(LegendItemSource source)
source - the source.public LegendTitle(LegendItemSource source, Arrangement hLayout, Arrangement vLayout)
source - the source.hLayout - the horizontal item arrangement (null not
permitted).vLayout - the vertical item arrangement (null not
permitted).public LegendItemSource[] getSources()
public void setSources(LegendItemSource[] sources)
TitleChangeEvent to
all registered listeners.sources - the sources (null not permitted).public java.awt.Paint getBackgroundPaint()
null).public void setBackgroundPaint(java.awt.Paint paint)
TitleChangeEvent to all registered listeners.paint - the paint (null permitted).public org.jfree.ui.RectangleEdge getLegendItemGraphicEdge()
null).public void setLegendItemGraphicEdge(org.jfree.ui.RectangleEdge edge)
edge - the edge (null not permitted).public org.jfree.ui.RectangleAnchor getLegendItemGraphicAnchor()
null).public void setLegendItemGraphicAnchor(org.jfree.ui.RectangleAnchor anchor)
anchor - the anchor point (null not permitted).public org.jfree.ui.RectangleAnchor getLegendItemGraphicLocation()
null).public void setLegendItemGraphicLocation(org.jfree.ui.RectangleAnchor anchor)
anchor - the anchor (null not permitted).public org.jfree.ui.RectangleInsets getLegendItemGraphicPadding()
null).public void setLegendItemGraphicPadding(org.jfree.ui.RectangleInsets padding)
TitleChangeEvent to all registered listeners.padding - the padding (null not permitted).public java.awt.Font getItemFont()
null).public void setItemFont(java.awt.Font font)
TitleChangeEvent to
all registered listeners.font - the font (null not permitted).public java.awt.Paint getItemPaint()
null).public void setItemPaint(java.awt.Paint paint)
paint - the paint (null not permitted).public org.jfree.ui.RectangleInsets getItemLabelPadding()
null).public void setItemLabelPadding(org.jfree.ui.RectangleInsets padding)
padding - the padding (null not permitted).public org.jfree.util.SortOrder getSortOrder()
null).public void setSortOrder(org.jfree.util.SortOrder order)
order - Specifies ascending or descending order (null
not permitted).protected void fetchLegendItems()
private void addItemBlock(LegendItem item)
protected Block createLegendItemBlock(LegendItem item)
item - the legend item.public BlockContainer getItemContainer()
public org.jfree.ui.Size2D arrange(java.awt.Graphics2D g2,
RectangleConstraint constraint)
arrange in interface Blockarrange in class AbstractBlockg2 - the graphics device.constraint - the constraint (null not permitted).null).public void draw(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area)
public java.lang.Object draw(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area,
java.lang.Object params)
draw in interface Blockg2 - the graphics device.area - the area.params - ignored (null permitted).EntityBlockResult or
null.public BlockContainer getWrapper()
null).public void setWrapper(BlockContainer wrapper)
wrapper - the wrapper container.public boolean equals(java.lang.Object obj)
private void writeObject(java.io.ObjectOutputStream stream)
throws java.io.IOException
stream - the output stream.java.io.IOException - if there is an I/O error.private void readObject(java.io.ObjectInputStream stream)
throws java.io.IOException,
java.lang.ClassNotFoundException
stream - the input stream.java.io.IOException - if there is an I/O error.java.lang.ClassNotFoundException - if there is a classpath problem.