com.orsoncharts.legend

## Class StandardLegendBuilder

- java.lang.Object
- - com.orsoncharts.legend.StandardLegendBuilder

- All Implemented Interfaces:
    LegendBuilder, java.io.Serializable

      public final class StandardLegendBuilder
      extends java.lang.Object
      implements LegendBuilder, java.io.Serializable

  The standard legend builder, which creates a simple legend with a flow layout and optional header and footer text.
  NOTE: This class is serializable, but the serialization format is subject to change in future releases and should not be relied upon for persisting instances of this class.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StandardLegendBuilder()` Creates a builder for a simple legend with no header and no footer.
    `StandardLegendBuilder(java.lang.String header, java.lang.String footer)` Creates a builder for a simple legend with the specified header and/or footer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `TableElement` | `createLegend(Plot3D plot, Anchor2D anchor, Orientation orientation, ChartStyle style)` Creates and returns a legend (instance of `TableElement`) that provides a visual key for the data series in the specified plot.
    `boolean` | `equals(java.lang.Object obj)` Tests this legend builder for equality with an arbitrary object.
    `VAlign` | `getColumnAlignment()` Returns the column alignment.
    `java.lang.String` | `getFooter()` Returns the footer text.
    `HAlign` | `getFooterAlignment()` Returns the footer alignment.
    `java.lang.String` | `getHeader()` Returns the header text.
    `HAlign` | `getHeaderAlignment()` Returns the header alignment.
    `HAlign` | `getRowAlignment()` Returns the row alignment.
    `void` | `setColumnAlignment(VAlign alignment)` Sets the column alignment (to override the default alignment that is derived from the legend anchor point).
    `void` | `setFooter(java.lang.String footer)` Sets the footer text.
    `void` | `setFooterAlignment(HAlign align)` Sets the footer alignment.
    `void` | `setHeader(java.lang.String header)` Sets the header text.
    `void` | `setHeaderAlignment(HAlign align)` Sets the header alignment.
    `void` | `setRowAlignment(HAlign alignment)` Sets the row alignment (to override the default alignment that is derived from the legend anchor point).

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

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

- - ### Constructor Detail

    - #### StandardLegendBuilder

          public StandardLegendBuilder()

      Creates a builder for a simple legend with no header and no footer.

    - #### StandardLegendBuilder

          public StandardLegendBuilder(java.lang.String header,
                                       java.lang.String footer)

      Creates a builder for a simple legend with the specified header and/or footer.
      Parameters:
        `header` - the legend header (`null` permitted).
        `footer` - the legend footer (`null` permitted).

  - ### Method Detail

    - #### getHeader

          public java.lang.String getHeader()

      Returns the header text.
      Returns:
        The header text (possibly `null`).

    - #### setHeader

          public void setHeader(java.lang.String header)

      Sets the header text.
      Parameters:
        `header` - the header (`null` permitted).

    - #### getHeaderAlignment

          public HAlign getHeaderAlignment()

      Returns the header alignment.
      Returns:
        The header alignment (never `null`).

    - #### setHeaderAlignment

          public void setHeaderAlignment(HAlign align)

      Sets the header alignment.
      Parameters:
        `align` - the header alignment (`null` not permitted).

    - #### getFooter

          public java.lang.String getFooter()

      Returns the footer text.
      Returns:
        The footer text (possibly `null`).

    - #### setFooter

          public void setFooter(java.lang.String footer)

      Sets the footer text.
      Parameters:
        `footer` - the footer (`null` permitted).

    - #### getFooterAlignment

          public HAlign getFooterAlignment()

      Returns the footer alignment.
      Returns:
        The footer alignment (never `null`).

    - #### setFooterAlignment

          public void setFooterAlignment(HAlign align)

      Sets the footer alignment.
      Parameters:
        `align` - the footer alignment (`null` not permitted).

    - #### getRowAlignment

          public HAlign getRowAlignment()

      Returns the row alignment. The default value is `null` which means that the row alignment is derived from the anchor point (left aligned for anchors on the left side, center alignment for anchors in the middle, and right aligned for anchors on the right side).
      Returns:
        The row alignment (possibly `null`).
      Since:
        1.1

    - #### setRowAlignment

          public void setRowAlignment(HAlign alignment)

      Sets the row alignment (to override the default alignment that is derived from the legend anchor point). In most circumstances you should be able to rely on the default behaviour, so leave this attribute set to `null`.
      Parameters:
        `alignment` - the row alignment (`null` permitted).
      Since:
        1.1

    - #### getColumnAlignment

          public VAlign getColumnAlignment()

      Returns the column alignment. The default value is `null` which means that the column alignment is derived from the anchor point (top aligned for anchors at the top, center alignment for anchors in the middle, and bottom aligned for anchors at the bottom).
      Returns:
        The column alignment (possibly `null`).
      Since:
        1.1

    - #### setColumnAlignment

          public void setColumnAlignment(VAlign alignment)

      Sets the column alignment (to override the default alignment that is derived from the legend anchor point). In most circumstances you should be able to rely on the default behaviour, so leave this attribute set to `null`.
      Parameters:
        `alignment` - the column alignment (`null` permitted).
      Since:
        1.1

    - #### createLegend

          public TableElement createLegend(Plot3D plot,
                                           Anchor2D anchor,
                                           Orientation orientation,
                                           ChartStyle style)

      Creates and returns a legend (instance of `TableElement`) that provides a visual key for the data series in the specified plot. The plot can be any of the built-in plot types: `PiePlot3D`, `CategoryPlot3D` or `XYZPlot`.
      Certain subelements will have the following properties set so that downstream code is able to identify which elements relate to particular data series: CLASS : 'LegendItem', SERIES_KEY : the series key.
      Specified by:
        `createLegend` in interface `LegendBuilder`
      Parameters:
        `plot` - the plot (`null` not permitted).
        `anchor` - the anchor (`null` not permitted).
        `orientation` - the orientation (`null` not permitted).
        `style` - the chart style (`null` not permitted).
      Returns:
        The legend.
      Since:
        1.2

    - #### equals

          public boolean equals(java.lang.Object obj)

      Tests this legend builder for equality with an arbitrary object.
      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `obj` - the object (`null` permitted).
      Returns:
        A boolean.