Package net.sf.jaxodraw.gui.panel
Class JaxoColorChooser
- java.lang.Object
-
- net.sf.jaxodraw.gui.panel.JaxoColorChooser
-
- All Implemented Interfaces:
JaxoLocalized
public class JaxoColorChooser extends java.lang.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 Summary
Constructors Constructor Description JaxoColorChooser(java.awt.Component parentc)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChangeListener(javax.swing.event.ChangeListener l)
ChangeEvents will be fired everytime the selected color is changed when the color chooser is on the screen.protected void
createComponents()
Sets up all components of this color chooser.void
dispose()
Dispose existing cached components.protected void
fireStateChanged()
Notifies all listeners of a state change.java.awt.Color
getColor()
The currently selected color (or null) - updated while the chooser is shown.java.lang.String
getDialogTitle()
Dialog title - if null (default), a default title will be chosen.int
getMode()
The colors that can be chosen.boolean
hasChanged()
Determines if the color was changed the last time it was shown.boolean
isAdjusting()
Determines if the color change is temporary.boolean
isCancelled()
Determines if the chooser was cancelled the last time it was shown.boolean
isOptional()
Current optional property.boolean
isPermanent()
Whether the chooser stays alive after showing for further requests.void
removeChangeListener(javax.swing.event.ChangeListener l)
Removes a change listener.void
setColor(java.awt.Color value)
Set color to be displayed.void
setDialogTitle(java.lang.String value)
Sets the dialog title.void
setMode(int value)
Sets the current mode.void
setOptional(boolean value)
Sets the optional property.void
setOptionalColor(java.awt.Color value)
Sets the optional and color properties.void
setPermanent(boolean value)
Whether the chooser stays alive after showing for further requests.void
show()
See the variant that takes a Location argument, which here is taken to be JaxoUtils.RelativeTo('parent').void
show(Location l)
Brings up a color chooser menu to select the color of the specified JaxoObject.void
updateLanguage()
Updates the component with the current language as set in the preferences (JaxoPrefs.PREF_LANGUAGE
).
-
-
-
Method Detail
-
dispose
public void dispose()
Dispose existing cached components. Also close the dialog if it is current visible.- See Also:
isPermanent()
-
addChangeListener
public void addChangeListener(javax.swing.event.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(javax.swing.event.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(java.awt.Color value)
Set color to be displayed.- Parameters:
value
- color to set.
-
getColor
public java.awt.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(java.awt.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 isJaxoColor.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 interfaceJaxoLocalized
-
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:
dispose()
-
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 java.lang.String getDialogTitle()
Dialog title - if null (default), a default title will be chosen.- Returns:
- The dialog title.
-
setDialogTitle
public void setDialogTitle(java.lang.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.
-
-