Class ColorPreference
- java.lang.Object
-
- org.openstreetmap.josm.gui.preferences.DefaultPreferenceSetting
-
- org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting
-
- org.openstreetmap.josm.gui.preferences.ExtensibleTabPreferenceSetting
-
- org.openstreetmap.josm.gui.preferences.display.ColorPreference
-
- All Implemented Interfaces:
java.util.EventListener
,javax.swing.event.ListSelectionListener
,javax.swing.event.TableModelListener
,PreferenceSetting
,TabPreferenceSetting
public class ColorPreference extends ExtensibleTabPreferenceSetting implements javax.swing.event.ListSelectionListener, javax.swing.event.TableModelListener
Color preferences. GUI preference to let the user customize named colors.- See Also:
NamedColorProperty
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ColorPreference.ColorEntry
private static class
ColorPreference.ColorTableModel
static class
ColorPreference.Factory
Factory used to create a newColorPreference
.
-
Field Summary
Fields Modifier and Type Field Description private javax.swing.JButton
colorEdit
private javax.swing.JTable
colors
private javax.swing.JButton
defaultSet
private javax.swing.JButton
remove
private ColorPreference.ColorTableModel
tableModel
-
Constructor Summary
Constructors Constructor Description ColorPreference()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addGui(PreferenceTabbedPane gui)
Add the GUI elements to the dialog.private static void
fixColorPrefixes()
Add all missing color entries.private static int
getCategoryPriority(java.lang.String category)
java.util.Map<java.lang.String,ColorInfo>
getColors()
Returns a map with the colors in the table (key = preference key, value = color info).java.lang.String
getHelpContext()
Returns the help context for this preferences settings tab.boolean
isExpert()
Called to know if the preferences tab has only to be displayed in expert mode.private static boolean
isRemoveColor(ColorPreference.ColorEntry ce)
boolean
ok()
Called when OK is pressed to save the setting in the preferences file.void
setColors(java.util.Map<java.lang.String,ColorInfo> colorMap)
Set the colors to be shown in the preference table.void
tableChanged(javax.swing.event.TableModelEvent e)
private void
updateEnabledState()
void
valueChanged(javax.swing.event.ListSelectionEvent e)
-
Methods inherited from class org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting
addSubTab, addSubTab, canBeHidden, createPreferenceTabWithScrollPane, getDescription, getIconName, getSelectedSubTab, getSubTab, getTabPane, getTitle, getTooltip, registerSubTab, selectSubTab
-
Methods inherited from class org.openstreetmap.josm.gui.preferences.DefaultPreferenceSetting
saveBoolean, saveDouble, saveInt
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.gui.preferences.TabPreferenceSetting
getIcon
-
-
-
-
Field Detail
-
tableModel
private ColorPreference.ColorTableModel tableModel
-
colors
private javax.swing.JTable colors
-
colorEdit
private javax.swing.JButton colorEdit
-
defaultSet
private javax.swing.JButton defaultSet
-
remove
private javax.swing.JButton remove
-
-
Constructor Detail
-
ColorPreference
ColorPreference()
-
-
Method Detail
-
setColors
public void setColors(java.util.Map<java.lang.String,ColorInfo> colorMap)
Set the colors to be shown in the preference table. This method creates a table model if none exists and overwrites all existing values.- Parameters:
colorMap
- the map holding the colors (key = preference key, value =ColorInfo
instance)
-
getCategoryPriority
private static int getCategoryPriority(java.lang.String category)
-
getColors
public java.util.Map<java.lang.String,ColorInfo> getColors()
Returns a map with the colors in the table (key = preference key, value = color info).- Returns:
- a map holding the colors.
-
addGui
public void addGui(PreferenceTabbedPane gui)
Description copied from interface:PreferenceSetting
Add the GUI elements to the dialog. The elements should be initialized after the current preferences.- Specified by:
addGui
in interfacePreferenceSetting
- Overrides:
addGui
in classExtensibleTabPreferenceSetting
- Parameters:
gui
- the preferences tab pane
-
isRemoveColor
private static boolean isRemoveColor(ColorPreference.ColorEntry ce)
-
fixColorPrefixes
private static void fixColorPrefixes()
Add all missing color entries.
-
ok
public boolean ok()
Description copied from interface:PreferenceSetting
Called when OK is pressed to save the setting in the preferences file. Return true when restart is required.- Specified by:
ok
in interfacePreferenceSetting
- Returns:
true
if restart is required
-
isExpert
public boolean isExpert()
Description copied from interface:PreferenceSetting
Called to know if the preferences tab has only to be displayed in expert mode.- Specified by:
isExpert
in interfacePreferenceSetting
- Overrides:
isExpert
in classDefaultPreferenceSetting
- Returns:
- true if the tab has only to be displayed in expert mode, false otherwise.
-
valueChanged
public void valueChanged(javax.swing.event.ListSelectionEvent e)
- Specified by:
valueChanged
in interfacejavax.swing.event.ListSelectionListener
-
tableChanged
public void tableChanged(javax.swing.event.TableModelEvent e)
- Specified by:
tableChanged
in interfacejavax.swing.event.TableModelListener
-
updateEnabledState
private void updateEnabledState()
-
getHelpContext
public java.lang.String getHelpContext()
Description copied from interface:TabPreferenceSetting
Returns the help context for this preferences settings tab.- Specified by:
getHelpContext
in interfaceTabPreferenceSetting
- Overrides:
getHelpContext
in classDefaultTabPreferenceSetting
- Returns:
- the help context for this preferences settings tab
-
-