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 and Description
    --- | ---
    `(package private) static long` | `serialVersionUID` For serialization.

  - ### Constructor Summary

    Constructors
    Constructor and 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 and Description
    --- | ---
    `Size2D` | `arrange(java.awt.Graphics2D g2, RectangleConstraint constraint)` Arranges the contents of the block, within the given constraints, and returns the block size.
    `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.
    `java.lang.Object` | `clone()` Returns a clone of this `LegendGraphic` instance.
    `void` | `draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)` Draws the graphic item within the specified area.
    `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 `LegendGraphic` instance for equality with an arbitrary object.
    `java.awt.Paint` | `getFillPaint()` Returns the paint used to fill the shape.
    `GradientPaintTransformer` | `getFillPaintTransformer()` Returns the transformer used when the fill paint is an instance of `GradientPaint`.
    `java.awt.Shape` | `getLine()` Returns the line centered about (0, 0).
    `java.awt.Paint` | `getLinePaint()` Returns the line paint.
    `java.awt.Stroke` | `getLineStroke()` Returns the line stroke.
    `java.awt.Paint` | `getOutlinePaint()` Returns the outline paint.
    `java.awt.Stroke` | `getOutlineStroke()` Returns the outline stroke.
    `java.awt.Shape` | `getShape()` Returns the shape.
    `RectangleAnchor` | `getShapeAnchor()` Returns the shape anchor.
    `RectangleAnchor` | `getShapeLocation()` Returns the shape location.
    `int` | `hashCode()` Returns a hash code for this instance.
    `boolean` | `isLineVisible()` Returns the flag that controls whether or not the line is visible.
    `boolean` | `isShapeFilled()` Returns a flag that controls whether or not the shapes are filled.
    `boolean` | `isShapeOutlineVisible()` Returns a flag that controls whether the shape outline is visible.
    `boolean` | `isShapeVisible()` Returns a flag that controls whether or not the shape is visible.
    `void` | `setFillPaint(java.awt.Paint paint)` Sets the paint used to fill the shape.
    `void` | `setFillPaintTransformer(GradientPaintTransformer transformer)` Sets the transformer used when the fill paint is an instance of `GradientPaint`.
    `void` | `setLine(java.awt.Shape line)` Sets the line.
    `void` | `setLinePaint(java.awt.Paint paint)` Sets the line paint.
    `void` | `setLineStroke(java.awt.Stroke stroke)` Sets the line stroke.
    `void` | `setLineVisible(boolean visible)` Sets the flag that controls whether or not the line is visible.
    `void` | `setOutlinePaint(java.awt.Paint paint)` Sets the outline paint.
    `void` | `setOutlineStroke(java.awt.Stroke stroke)` Sets the outline stroke.
    `void` | `setShape(java.awt.Shape shape)` Sets the shape.
    `void` | `setShapeAnchor(RectangleAnchor anchor)` Sets the shape anchor.
    `void` | `setShapeFilled(boolean filled)` Sets a flag that controls whether or not the shape is filled.
    `void` | `setShapeLocation(RectangleAnchor location)` Sets the shape location.
    `void` | `setShapeOutlineVisible(boolean visible)` Sets a flag that controls whether or not the shape outline is visible.
    `void` | `setShapeVisible(boolean visible)` Sets a flag that controls whether or not the shape is visible.

    - ### Methods inherited from class org.jfree.chart.block.AbstractBlock

      `arrange, 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, trimToContentWidth`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.jfree.chart.block.Block

      `arrange, getBounds, getID, setBounds, setID`

- - ### Field Detail

    - #### serialVersionUID

          static final long serialVersionUID

      For serialization.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### LegendGraphic

          public LegendGraphic(java.awt.Shape shape,
                               java.awt.Paint fillPaint)

      Creates a new legend graphic.
      Parameters:
        `shape` - the shape (`null` not permitted).
        `fillPaint` - the fill paint (`null` not permitted).

  - ### 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 of `GradientPaint`.
      Returns:
        The transformer (never `null`).
      Since:
        1.0.4.
      See Also:
        `setFillPaintTransformer(GradientPaintTransformer)`

    - #### setFillPaintTransformer

          public void setFillPaintTransformer(GradientPaintTransformer transformer)

      Sets the transformer used when the fill paint is an instance of `GradientPaint`.
      Parameters:
        `transformer` - the transformer (`null` not permitted).
      Since:
        1.0.4
      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 (`null` not 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 (`null` not 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:
        `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`).

    - #### 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.
      Specified by:
        `draw` in interface `Drawable`
      Parameters:
        `g2` - the graphics device.
        `area` - the 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.
      Specified by:
        `draw` in interface `Block`
      Parameters:
        `g2` - the graphics device.
        `area` - the area.
        `params` - ignored (`null` permitted).
      Returns:
        Always `null`.

    - #### equals

          public boolean equals(java.lang.Object obj)

      Tests this `LegendGraphic` instance for equality with an arbitrary object.
      Overrides:
        `equals` in class `AbstractBlock`
      Parameters:
        `obj` - the object (`null` permitted).
      Returns:
        A boolean.

    - #### hashCode

          public int hashCode()

      Returns a hash code for this instance.
      Overrides:
        `hashCode` in class `java.lang.Object`
      Returns:
        A hash code.

    - #### clone

          public java.lang.Object clone()
                                 throws java.lang.CloneNotSupportedException

      Returns a clone of this `LegendGraphic` instance.
      Specified by:
        `clone` in interface `PublicCloneable`
      Overrides:
        `clone` in class `AbstractBlock`
      Returns:
        A clone of this `LegendGraphic` instance.
      Throws:
        `java.lang.CloneNotSupportedException` - if there is a problem cloning.