Class JaxoColorChooser

java.lang.Object
net.sf.jaxodraw.gui.panel.JaxoColorChooser
All Implemented Interfaces:
JaxoLocalized

public class JaxoColorChooser extends Object implements JaxoLocalized
Color chooser dialog, a wrapper around JColorChooser. Besides allowing to choose an arbitrary color, there are also modes where the colors presented are those available in the colrdvi LaTex package, plus a set of gray scales.
Since:
2.0
  • Constructor Details

    • JaxoColorChooser

      public JaxoColorChooser(Component parentc)
      Constructor.
      Parameters:
      parentc - Component to take as context for the dialog.
  • Method Details

    • dispose

      public void dispose()
      Dispose existing cached components. Also close the dialog if it is current visible.
      See Also:
    • addChangeListener

      public void addChangeListener(ChangeListener l)
      ChangeEvents will be fired everytime the selected color is changed when the color chooser is on the screen. Use @link{#isAdjusting} to see whether the change is final.
      Parameters:
      l - The listener to add.
    • removeChangeListener

      public void removeChangeListener(ChangeListener l)
      Removes a change listener.
      Parameters:
      l - The listener to remove.
    • fireStateChanged

      protected void fireStateChanged()
      Notifies all listeners of a state change.
    • setColor

      public void setColor(Color value)
      Set color to be displayed.
      Parameters:
      value - color to set.
    • getColor

      public Color getColor()
      The currently selected color (or null) - updated while the chooser is shown.
      Returns:
      The selected color.
    • isOptional

      public final boolean isOptional()
      Current optional property.
      Returns:
      The current optional value.
    • setOptional

      public void setOptional(boolean value)
      Sets the optional property. When set, the user may also choose 'no color'.
      Parameters:
      value - The value to set.
    • setOptionalColor

      public void setOptionalColor(Color value)
      Sets the optional and color properties. 'Optional' is set to true iff the color is 'null'.
      Parameters:
      value - The color to set.
    • isAdjusting

      public final boolean isAdjusting()
      Determines if the color change is temporary. At the end of a color choosing process, this will become true.
      Returns:
      True if still adjusting.
    • isCancelled

      public boolean isCancelled()
      Determines if the chooser was cancelled the last time it was shown.
      Returns:
      True if the chooser was cancelled.
    • hasChanged

      public boolean hasChanged()
      Determines if the color was changed the last time it was shown.
      Returns:
      True if the color was changed.
    • getMode

      public final int getMode()
      The colors that can be chosen. This is any of the mode constants, the default is JaxoColor.JAXO_COLORS_MODE.
      Returns:
      The current mode.
    • setMode

      public void setMode(int value)
      Sets the current mode.
      Parameters:
      value - The mode to set.
    • updateLanguage

      public void updateLanguage()
      Updates the component with the current language as set in the preferences (JaxoPrefs.PREF_LANGUAGE).
      Specified by:
      updateLanguage in interface JaxoLocalized
    • isPermanent

      public final boolean isPermanent()
      Whether the chooser stays alive after showing for further requests. If this is true, the chooser must be disposed if not needed anymore. (This will happen automatically if the owner window (via 'parent') is disposed). The default is false.
      Returns:
      True if the window is permanent.
      See Also:
    • setPermanent

      public void setPermanent(boolean value)
      Whether the chooser stays alive after showing for further requests.
      Parameters:
      value - True if the chooser is permanent.
    • getDialogTitle

      public final String getDialogTitle()
      Dialog title - if null (default), a default title will be chosen.
      Returns:
      The dialog title.
    • setDialogTitle

      public void setDialogTitle(String value)
      Sets the dialog title.
      Parameters:
      value - The dialog title to set.
    • createComponents

      protected void createComponents()
      Sets up all components of this color chooser.
    • show

      public void show()
      See the variant that takes a Location argument, which here is taken to be JaxoUtils.RelativeTo('parent').
    • show

      public void show(Location l)
      Brings up a color chooser menu to select the color of the specified JaxoObject.
      Parameters:
      l - The location of the dialog.