public class

LegendTitle

extends Title
implements Serializable Cloneable
java.lang.Object
   ↳ org.jfree.chart.block.AbstractBlock
     ↳ org.jfree.chart.title.Title
       ↳ org.jfree.chart.title.LegendTitle

Class Overview

A chart title that displays a legend for the data in the chart.

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).

Summary

Fields
public static final Font DEFAULT_ITEM_FONT The default item font.
public static final Paint DEFAULT_ITEM_PAINT The default item paint.
[Expand]
Inherited Fields
From class org.jfree.chart.title.Title
Public Constructors
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.
Public Methods
Size2D arrange(Graphics2D g2, RectangleConstraint constraint)
Arranges the contents of the block, within the given constraints, and returns the block size.
void draw(Graphics2D g2, Rectangle2D area)
Draws the title on a Java 2D graphics device (such as the screen or a printer).
Object draw(Graphics2D g2, Rectangle2D area, Object params)
Draws the block within the specified area.
boolean equals(Object obj)
Tests this title for equality with an arbitrary object.
Paint getBackgroundPaint()
Returns the background paint.
BlockContainer getItemContainer()
Returns the container that holds the legend items.
Font getItemFont()
Returns the item font.
RectangleInsets getItemLabelPadding()
Returns the padding used for the items labels.
Paint getItemPaint()
Returns the item paint.
RectangleAnchor getLegendItemGraphicAnchor()
Returns the legend item graphic anchor.
RectangleEdge getLegendItemGraphicEdge()
Returns the location of the shape within each legend item.
RectangleAnchor getLegendItemGraphicLocation()
Returns the legend item graphic location.
RectangleInsets getLegendItemGraphicPadding()
Returns the padding that will be applied to each item graphic.
LegendItemSource[] getSources()
Returns the legend item sources.
BlockContainer getWrapper()
Returns the wrapper container, if any.
void setBackgroundPaint(Paint paint)
Sets the background paint for the legend and sends a TitleChangeEvent to all registered listeners.
void setItemFont(Font font)
Sets the item font and sends a TitleChangeEvent to all registered listeners.
void setItemLabelPadding(RectangleInsets padding)
Sets the padding used for the item labels in the legend.
void setItemPaint(Paint paint)
Sets the item paint.
void setLegendItemGraphicAnchor(RectangleAnchor anchor)
Sets the anchor point used for the graphic in each legend item.
void setLegendItemGraphicEdge(RectangleEdge edge)
Sets the location of the shape within each legend item.
void setLegendItemGraphicLocation(RectangleAnchor anchor)
Sets the legend item graphic location.
void setLegendItemGraphicPadding(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 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.
Protected Methods
Block createLegendItemBlock(LegendItem item)
Creates a legend item block.
void fetchLegendItems()
Fetches the latest legend items.
[Expand]
Inherited Methods
From class org.jfree.chart.title.Title
From class org.jfree.chart.block.AbstractBlock
From class java.lang.Object
From interface org.jfree.chart.block.Block

Fields

public static final Font DEFAULT_ITEM_FONT

The default item font.

public static final Paint DEFAULT_ITEM_PAINT

The default item paint.

Public Constructors

public LegendTitle (LegendItemSource source)

Constructs a new (empty) legend for the specified source.

Parameters
source the source.

public LegendTitle (LegendItemSource source, Arrangement hLayout, Arrangement vLayout)

Creates a new legend title with the specified arrangement.

Parameters
source the source.
hLayout the horizontal item arrangement (null not permitted).
vLayout the vertical item arrangement (null not permitted).

Public Methods

public Size2D arrange (Graphics2D g2, RectangleConstraint constraint)

Arranges the contents of the block, within the given constraints, and returns the block size.

Parameters
g2 the graphics device.
constraint the constraint (null not permitted).
Returns
  • The block size (in Java2D units, never null).

public void draw (Graphics2D g2, Rectangle2D area)

Draws the title on a Java 2D graphics device (such as the screen or a printer).

Parameters
g2 the graphics device.
area the available area for the title.

public Object draw (Graphics2D g2, Rectangle2D area, Object params)

Draws the block within the specified area.

Parameters
g2 the graphics device.
area the area.
params ignored (null permitted).
Returns

public boolean equals (Object obj)

Tests this title for equality with an arbitrary object.

Parameters
obj the object (null permitted).
Returns
  • A boolean.

public Paint getBackgroundPaint ()

Returns the background paint.

Returns
  • The background paint (possibly null).

public BlockContainer getItemContainer ()

Returns the container that holds the legend items.

Returns
  • The container for the legend items.

public Font getItemFont ()

Returns the item font.

Returns
  • The font (never null).

public RectangleInsets getItemLabelPadding ()

Returns the padding used for the items labels.

Returns
  • The padding (never null).

public Paint getItemPaint ()

Returns the item paint.

Returns
  • The paint (never null).

public RectangleAnchor getLegendItemGraphicAnchor ()

Returns the legend item graphic anchor.

Returns
  • The graphic anchor (never null).

public RectangleEdge getLegendItemGraphicEdge ()

Returns the location of the shape within each legend item.

Returns
  • The location (never null).

public RectangleAnchor getLegendItemGraphicLocation ()

Returns the legend item graphic location.

Returns
  • The location (never null).

public RectangleInsets getLegendItemGraphicPadding ()

Returns the padding that will be applied to each item graphic.

Returns
  • The padding (never null).

public LegendItemSource[] getSources ()

Returns the legend item sources.

Returns
  • The sources.

public BlockContainer getWrapper ()

Returns the wrapper container, if any.

Returns
  • The wrapper container (possibly null).

public void setBackgroundPaint (Paint paint)

Sets the background paint for the legend and sends a TitleChangeEvent to all registered listeners.

Parameters
paint the paint (null permitted).

public void setItemFont (Font font)

Sets the item font and sends a TitleChangeEvent to all registered listeners.

Parameters
font the font (null not permitted).

public void setItemLabelPadding (RectangleInsets padding)

Sets the padding used for the item labels in the legend.

Parameters
padding the padding (null not permitted).

public void setItemPaint (Paint paint)

Sets the item paint.

Parameters
paint the paint (null not permitted).

public void setLegendItemGraphicAnchor (RectangleAnchor anchor)

Sets the anchor point used for the graphic in each legend item.

Parameters
anchor the anchor point (null not permitted).

public void setLegendItemGraphicEdge (RectangleEdge edge)

Sets the location of the shape within each legend item.

Parameters
edge the edge (null not permitted).

public void setLegendItemGraphicLocation (RectangleAnchor anchor)

Sets the legend item graphic location.

Parameters
anchor the anchor (null not permitted).

public void setLegendItemGraphicPadding (RectangleInsets padding)

Sets the padding that will be applied to each item graphic in the legend and sends a TitleChangeEvent to all registered listeners.

Parameters
padding the padding (null not permitted).

public void setSources (LegendItemSource[] sources)

Sets the legend item sources and sends a TitleChangeEvent to all registered listeners.

Parameters
sources the sources (null not permitted).

public void setWrapper (BlockContainer wrapper)

Sets the wrapper container for the legend.

Parameters
wrapper the wrapper container.

Protected Methods

protected Block createLegendItemBlock (LegendItem item)

Creates a legend item block.

Parameters
item the legend item.
Returns
  • The block.

protected void fetchLegendItems ()

Fetches the latest legend items.