org.jfree.chart.editor

Class PaletteSample

Implemented Interfaces:
ListCellRenderer

public class PaletteSample
extends JComponent
implements ListCellRenderer

A panel that displays a palette sample.

Constructor Summary

PaletteSample(ColorPalette palette)
Creates a new sample.

Method Summary

Component
getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
Returns a list cell renderer for the stroke, so the sample can be displayed in a list or combo.
ColorPalette
getPalette()
Returns the current palette object being displayed.
Dimension
getPreferredSize()
Returns the preferred size of the component.
void
paintComponent(Graphics g)
Draws the sample.
void
setPalette(ColorPalette palette)
Sets the palette object being displayed.

Constructor Details

PaletteSample

public PaletteSample(ColorPalette palette)
Creates a new sample.
Parameters:
palette - the palette.

Method Details

getListCellRendererComponent

public Component getListCellRendererComponent(JList list,
                                              Object value,
                                              int index,
                                              boolean isSelected,
                                              boolean cellHasFocus)
Returns a list cell renderer for the stroke, so the sample can be displayed in a list or combo.
Parameters:
list - the list component.
value - the value.
index - the index.
isSelected - a flag that indicates whether or not the item is selected.
cellHasFocus - a flag that indicates whether or not the cell has the focus.
Returns:
The renderer.

getPalette

public ColorPalette getPalette()
Returns the current palette object being displayed.
Returns:
The palette.

getPreferredSize

public Dimension getPreferredSize()
Returns the preferred size of the component.
Returns:
The preferred size.

paintComponent

public void paintComponent(Graphics g)
Draws the sample.
Parameters:
g - the graphics device.

setPalette

public void setPalette(ColorPalette palette)
Sets the palette object being displayed.
Parameters:
palette - the palette.