Class PaletteChooser

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, TabComponent

public class PaletteChooser extends JPanel implements TabComponent

A palette chooser is a panel that allows the user to pick a colour palette from a selection of predefined palettes. A color palette is typically used in conjunction with a 2D data variable to map a set of data values to a set of colours.

The palette chooser signals a change in the selected palette by firing a PropertyChangeEvent whose property name is PaletterChooser.PALETTE_PROPERTY, and new value contains a palette name from the predefined palettes supplied by the Palette class.

Since:
3.1.6
Author:
Peter Hollemans
See Also:
  • Field Details

  • Constructor Details

    • PaletteChooser

      public PaletteChooser()
      Creates a new palette chooser panel. Initially no palette is selected.
  • Method Details

    • getPalette

      public Palette getPalette()
      Gets the currently selected palette.
      Returns:
      the selected palette, or if the selection is empty, the last valid selected palette, or null if no palette has ever been selected.
    • setPalette

      public void setPalette(Palette palette)
      Sets the selected palette. The palette must have been obtained using the PaletteFactory.create(String) method or be a value previously returned by getPalette().
    • setPalette

      public void setPalette(String name)
      Set the selected palette by name.
      Parameters:
      name - the palette name.
      See Also:
    • getIcon

      public Icon getIcon()
      Description copied from interface: TabComponent
      Gets the tab icon.
      Specified by:
      getIcon in interface TabComponent
      Returns:
      the icon to be used if the tab is to have an icon beside the title label, or null if no icon is required.
    • getToolTip

      public String getToolTip()
      Description copied from interface: TabComponent
      Gets the tab tooltip.
      Specified by:
      getToolTip in interface TabComponent
      Returns:
      the tooltip text if the tab is to have an appearing tooltip when the mouse hovers over the tab, or null if no tooltip is required.
    • getTitle

      public String getTitle()
      Description copied from interface: TabComponent
      Gets the tab title.
      Specified by:
      getTitle in interface TabComponent
      Returns:
      the title to be used if the tab is to have a text label as a title, or null if no title is required.