com.orsoncharts.legend

## Class ColorScaleElement

- java.lang.Object
- - com.orsoncharts.table.AbstractTableElement
  - - com.orsoncharts.legend.ColorScaleElement

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

      public class ColorScaleElement
      extends AbstractTableElement
      implements TableElement

  A `TableElement` that displays a `ColorScale`.
  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.
  Since:
    1.1
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from interface com.orsoncharts.table.TableElement

      `CLASS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ColorScaleElement(ColorScale scale, Orientation orientation, double barWidth, double barLength, java.awt.Font font, java.awt.Color textColor)` Creates a new `ColorScaleElement` with the specified attributes.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D bounds)` Draws the element within the specified bounds.
    `void` | `draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D bounds, TableElementOnDraw onDrawHandler)` Draws the element within the specified bounds.
    `boolean` | `equals(java.lang.Object obj)` Tests this instance for equality with an arbitrary object.
    `double` | `getBarLength()` Returns the bar length.
    `double` | `getBarWidth()` Returns the bar width.
    `ColorScale` | `getColorScale()` Returns the color scale.
    `java.awt.Font` | `getFont()` Returns the font used to display the labels on the color scale.
    `Orientation` | `getOrientation()` Returns the orientation.
    `java.awt.Color` | `getTextColor()` Returns the text color.
    `java.util.List<java.awt.geom.Rectangle2D>` | `layoutElements(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D bounds, java.util.Map<java.lang.String,java.lang.Object> constraints)` Performs a layout of this table element, returning a list of bounding rectangles for the element and its subelements.
    `java.awt.geom.Dimension2D` | `preferredSize(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D bounds)` Returns the preferred size for this element.
    `java.awt.geom.Dimension2D` | `preferredSize(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D bounds, java.util.Map<java.lang.String,java.lang.Object> constraints)` Returns the preferred size for this element.
    `void` | `receive(TableElementVisitor visitor)` Receives a visitor.

    - ### Methods inherited from class com.orsoncharts.table.AbstractTableElement

      `getBackground, getInsets, getProperty, getRefPoint, getTag, setBackground, setBackgroundColor, setInsets, setProperty, setRefPoint, setTag`

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

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

    - ### Methods inherited from interface com.orsoncharts.table.TableElement

      `getProperty, getRefPoint, setProperty`

- - ### Constructor Detail

    - #### ColorScaleElement

          public ColorScaleElement(ColorScale scale,
                                   Orientation orientation,
                                   double barWidth,
                                   double barLength,
                                   java.awt.Font font,
                                   java.awt.Color textColor)

      Creates a new `ColorScaleElement` with the specified attributes.
      Parameters:
        `scale` - the color scale (`null` not permitted).
        `orientation` - the orientation (`null` not permitted).
        `barWidth` - the bar width (in Java2D units).
        `barLength` - the bar length (in Java2D units).
        `font` - the font (`null` not permitted).
        `textColor` - the text color (`null` not permitted).
      Since:
        1.2

  - ### Method Detail

    - #### getColorScale

          public ColorScale getColorScale()

      Returns the color scale.
      Returns:
        The color scale (never `null`).

    - #### getOrientation

          public Orientation getOrientation()

      Returns the orientation.
      Returns:
        The orientation (never `null`).

    - #### getBarWidth

          public double getBarWidth()

      Returns the bar width.
      Returns:
        The bar width.

    - #### getBarLength

          public double getBarLength()

      Returns the bar length.
      Returns:
        The bar length.

    - #### getFont

          public java.awt.Font getFont()

      Returns the font used to display the labels on the color scale.
      Returns:
        The font (never `null`).

    - #### getTextColor

          public java.awt.Color getTextColor()

      Returns the text color.
      Returns:
        The text color (never `null`).

    - #### receive

          public void receive(TableElementVisitor visitor)

      Receives a visitor. This is part of a general mechanism to perform operations on an arbitrary hierarchy of table elements. You will not normally call this method directly.
      Specified by:
        `receive` in interface `TableElement`
      Parameters:
        `visitor` - the visitor (`null` not permitted).
      Since:
        1.2

    - #### preferredSize

          public java.awt.geom.Dimension2D preferredSize(java.awt.Graphics2D g2,
                                                         java.awt.geom.Rectangle2D bounds)

      Returns the preferred size for this element.
      Specified by:
        `preferredSize` in interface `TableElement`
      Overrides:
        `preferredSize` in class `AbstractTableElement`
      Parameters:
        `g2` - the graphics target.
        `bounds` - the available drawing space.
      Returns:
        The preferred size (never `null`).

    - #### preferredSize

          public java.awt.geom.Dimension2D preferredSize(java.awt.Graphics2D g2,
                                                         java.awt.geom.Rectangle2D bounds,
                                                         java.util.Map<java.lang.String,java.lang.Object> constraints)

      Returns the preferred size for this element.
      Specified by:
        `preferredSize` in interface `TableElement`
      Specified by:
        `preferredSize` in class `AbstractTableElement`
      Parameters:
        `g2` - the graphics target.
        `bounds` - the available drawing space.
        `constraints` - layout constraints (ignored here).
      Returns:
        The preferred size (never `null`).

    - #### layoutElements

          public java.util.List<java.awt.geom.Rectangle2D> layoutElements(java.awt.Graphics2D g2,
                                                                          java.awt.geom.Rectangle2D bounds,
                                                                          java.util.Map<java.lang.String,java.lang.Object> constraints)

      Description copied from interface: `TableElement`
      Performs a layout of this table element, returning a list of bounding rectangles for the element and its subelements. This method is typically called by the `TableElement.draw(java.awt.Graphics2D, java.awt.geom.Rectangle2D)` method.
      Specified by:
        `layoutElements` in interface `TableElement`
      Parameters:
        `g2` - the graphics target (`null` not permitted).
        `bounds` - the bounds (`null` not permitted).
        `constraints` - the constraints (if any).
      Returns:
        A list of bounding rectangles.

    - #### draw

          public void draw(java.awt.Graphics2D g2,
                           java.awt.geom.Rectangle2D bounds)

      Draws the element within the specified bounds.
      Specified by:
        `draw` in interface `TableElement`
      Parameters:
        `g2` - the graphics target (`null` not permitted).
        `bounds` - the bounds (`null` not permitted).

    - #### draw

          public void draw(java.awt.Graphics2D g2,
                           java.awt.geom.Rectangle2D bounds,
                           TableElementOnDraw onDrawHandler)

      Draws the element within the specified bounds.
      Specified by:
        `draw` in interface `TableElement`
      Parameters:
        `g2` - the graphics target (`null` not permitted).
        `bounds` - the bounds (`null` not permitted).
        `onDrawHandler` - receives notification before and after the element is drawn (`null` permitted);
      Since:
        1.3

    - #### equals

          public boolean equals(java.lang.Object obj)

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