Class ColorModelTab

All Implemented Interfaces:
Drawable

public class ColorModelTab extends Composite
A color-model tab of the SWT color chooser (CC-COLOR-CHOOSER-SWT-PANELS, 2026-10-10): HSV, HSL, RGB or CMYK. Per channel a label, a slider (Scale) and a Spinner; for HSV and HSL a two-dimensional diagram of saturation against value or lightness at the current hue and a vertical hue strip. A change of any control recomputes the color and hands it to the chooser, which updates the other tabs, the hex field and the preview; a change from elsewhere sets the channels from the color.

The channels are kept as floats (hue in degrees, the others in [0,1]) so that moving one slider never drifts the others through rounding; the hue is kept when the color turns gray through the slider that made it gray.

Author:
Christopher Mindus
  • Field Details

  • Constructor Details

    • ColorModelTab

      public ColorModelTab(Composite parent, int model, ColorChooserComposite chooser, Font font, int fontHeight, int argb, ChooserColors colors)
      Creates the tab.
      Parameters:
      parent - The parent.
      model - HSV, HSL, RGB or CMYK.
      chooser - The chooser.
      font - The dialog font, or null for the default.
      fontHeight - The height of the dialog font's metrics in points, for the diagram sizes.
      argb - The initial color.
      colors - The theme colors: this page's background, the marker pair of the diagrams.
  • Method Details

    • nameOf

      public static String nameOf(int model)
      Gets the tab name of a model.
    • getModel

      public int getModel()
      Gets the model.
    • getChannelCount

      public int getChannelCount()
      Gets the number of channels.
    • getLabel

      public Label getLabel(int channel)
      Gets the label of a channel.
    • getScale

      public Scale getScale(int channel)
      Gets the slider of a channel.
    • getSpinner

      public Spinner getSpinner(int channel)
      Gets the spinner of a channel.
    • getPlane

      public ColorDiagramCanvas getPlane()
      Gets the two-dimensional diagram, null for RGB and CMYK.
    • getHueStrip

      public ColorDiagramCanvas getHueStrip()
      Gets the hue strip, null for RGB and CMYK.
    • getChannel

      public float getChannel(int channel)
      Gets a channel: the hue in degrees, the others in [0,1].
    • update

      public void update(int argb)
      The chooser's color changed: the channels follow unless this tab produced the color.
      Parameters:
      argb - The color; the alpha byte is ignored.
    • commitPendingEdits

      public boolean commitPendingEdits()
      Commits a value typed in a spinner and not yet entered: the spinner's text is parsed and, when it differs from the spinner's value, applied as if entered.
      Returns:
      true if a value was committed.