Module org.jfree.chart3d
Package org.jfree.chart3d.legend

# Class ColorScaleElement

java.lang.Object
org.jfree.chart3d.table.AbstractTableElement
org.jfree.chart3d.legend.ColorScaleElement

All Implemented Interfaces:
  `Serializable`, `TableElement`

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 org.jfree.chart3d.table.TableElement

`CLASS`

## Constructor Summary

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

## Method Summary

Modifier and Type
Method
Description
`void`
`draw(Graphics2D g2, Rectangle2D bounds)`
Draws the element within the specified bounds.
`void`
`draw(Graphics2D g2, Rectangle2D bounds, TableElementOnDraw onDrawHandler)`
Draws the element within the specified bounds.
`boolean`
`equals(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.
`Font`
`getFont()`
Returns the font used to display the labels on the color scale.
`Orientation`
`getOrientation()`
Returns the orientation.
`Color`
`getTextColor()`
Returns the text color.
`List<Rectangle2D>`
`layoutElements(Graphics2D g2, Rectangle2D bounds, Map<String,Object> constraints)`
Performs a layout of this table element, returning a list of bounding rectangles for the element and its subelements.
`Dimension2D`
`preferredSize(Graphics2D g2, Rectangle2D bounds)`
Returns the preferred size for this element.
`Dimension2D`
`preferredSize(Graphics2D g2, Rectangle2D bounds, Map<String,Object> constraints)`
Returns the preferred size for this element.
`void`
`receive(TableElementVisitor visitor)`
Receives a visitor.

### Methods inherited from class org.jfree.chart3d.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 org.jfree.chart3d.table.TableElement

`getProperty, getRefPoint, setProperty`

## Constructor Details

### ColorScaleElement

public ColorScaleElement(ColorScale scale, Orientation orientation, double barWidth, double barLength, Font font, 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 Details

### 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 Font getFont()
Returns the font used to display the labels on the color scale.

Returns:
  The font (never `null`).

### getTextColor

public 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 Dimension2D preferredSize(Graphics2D g2, 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 Dimension2D preferredSize(Graphics2D g2, Rectangle2D bounds, Map<String,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 List<Rectangle2D> layoutElements(Graphics2D g2, Rectangle2D bounds, Map<String,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(Graphics2D g2, 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(Graphics2D g2, 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(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.