## org.jfree.chart.title
Class LegendTitle

    java.lang.Object
      org.jfree.chart.block.AbstractBlock
          org.jfree.chart.title.Title
              org.jfree.chart.title.LegendTitle

All Implemented Interfaces:
  java.io.Serializable, java.lang.Cloneable, Block, org.jfree.ui.Drawable, org.jfree.util.PublicCloneable

    public class LegendTitle

extends Title
implements java.lang.Cloneable, org.jfree.util.PublicCloneable, java.io.Serializable

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

See Also:
  Serialized Form

Field Summary

Fields inherited from class org.jfree.chart.title.Title
`DEFAULT_HORIZONTAL_ALIGNMENT, DEFAULT_PADDING, DEFAULT_POSITION, DEFAULT_VERTICAL_ALIGNMENT`

Constructor Summary
`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.

Method Summary
`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).
`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.
`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.
`LegendItemSource[]` `getSources()` Returns the legend item sources.
`void` `setBackgroundPaint(java.awt.Paint paint)` Sets the background paint for the legend.
`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` `setSources(LegendItemSource[] sources)` Sets the legend item sources.
`void` `setWrapper(BlockContainer wrapper)` Sets the wrapper container for the legend.

Methods inherited from class org.jfree.chart.title.Title
`addChangeListener, clone, getHorizontalAlignment, getNotify, getPosition, getVerticalAlignment, hashCode, notifyListeners, removeChangeListener, setHorizontalAlignment, setNotify, setPosition, setVerticalAlignment`

Methods inherited from class org.jfree.chart.block.AbstractBlock
`arrange, calculateTotalHeight, calculateTotalWidth, drawBorder, getBorder, getBounds, getHeight, getID, getMargin, getPadding, getWidth, setBorder, setBounds, setHeight, setID, setMargin, setPadding, setWidth, toContentConstraint, trimBorder, trimMargin, trimPadding, trimToContentHeight, trimToContentWidth`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.jfree.util.PublicCloneable
`clone`

Methods inherited from interface org.jfree.chart.block.Block
`arrange, getBounds, getID, setBounds, setID`

Constructor Detail

### LegendTitle

    public LegendTitle(LegendItemSource source)

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

  Parameters:
    `source` - the source.

### LegendTitle

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

Method Detail

### getSources

    public LegendItemSource[] getSources()

  Returns the legend item sources.

  Returns:
    The sources.

### setSources

    public void setSources(LegendItemSource[] sources)

  Sets the legend item sources.

  Parameters:
    `sources` - the sources.

### getBackgroundPaint

    public java.awt.Paint getBackgroundPaint()

  Returns the background paint.

  Returns:
    The background paint (possibly `null`).

### setBackgroundPaint

    public void setBackgroundPaint(java.awt.Paint paint)

  Sets the background paint for the legend.

  Parameters:
    `paint` - the paint (`null` permitted).

### getLegendItemGraphicEdge

    public org.jfree.ui.RectangleEdge getLegendItemGraphicEdge()

  Returns the location of the shape within each legend item.

  Returns:
    The location (never `null`).

### setLegendItemGraphicEdge

    public void setLegendItemGraphicEdge(org.jfree.ui.RectangleEdge edge)

  Sets the location of the shape within each legend item.

  Parameters:
    `edge` - the edge (`null` not permitted).

### getLegendItemGraphicAnchor

    public org.jfree.ui.RectangleAnchor getLegendItemGraphicAnchor()

  Returns the legend item graphic anchor.

  Returns:
    The graphic anchor (never `null`).

### setLegendItemGraphicAnchor

    public void setLegendItemGraphicAnchor(org.jfree.ui.RectangleAnchor anchor)

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

  Parameters:
    `anchor` - the anchor point (`null` not permitted).

### getLegendItemGraphicLocation

    public org.jfree.ui.RectangleAnchor getLegendItemGraphicLocation()

  Returns the legend item graphic location.

  Returns:
    The location (never `null`).

### setLegendItemGraphicLocation

    public void setLegendItemGraphicLocation(org.jfree.ui.RectangleAnchor anchor)

  Sets the legend item graphic location.

  Parameters:
    `anchor` - the anchor (`null` not permitted).

### fetchLegendItems

    protected void fetchLegendItems()

  Fetches the latest legend items.

### createLegendItemBlock

    protected Block createLegendItemBlock(LegendItem item)

  Creates a legend item block.

  Parameters:
    `item` - the legend item.
  Returns:
    The block.

### getItemContainer

    public BlockContainer getItemContainer()

  Returns the container that holds the legend items.

  Returns:
    The container for the legend items.

### arrange

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

  Specified by:
    `arrange` in interface `Block`
  Overrides:
    `arrange` in class `AbstractBlock`
  Parameters:
    `g2` - the graphics device.
    `constraint` - the constraint (`null` not permitted).
  Returns:
    The block size (in Java2D units, never `null`).

### draw

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

  Specified by:
    `draw` in interface `org.jfree.ui.Drawable`
  Specified by:
    `draw` in class `Title`
  Parameters:
    `g2` - the graphics device.
    `area` - the available area for the title.

### setWrapper

    public void setWrapper(BlockContainer wrapper)

  Sets the wrapper container for the legend.

  Parameters:
    `wrapper` - the wrapper container.

### equals

    public boolean equals(java.lang.Object obj)

  Tests this title for equality with an arbitrary object.

  Overrides:
    `equals` in class `Title`
  Parameters:
    `obj` - the object (`null` permitted).
  Returns:
    A boolean.