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 classColorPreference.ColorEntryprivate static classColorPreference.ColorTableModelstatic classColorPreference.FactoryFactory used to create a newColorPreference.
-
Field Summary
Fields Modifier and Type Field Description private javax.swing.JButtoncolorEditprivate javax.swing.JTablecolorsprivate javax.swing.JButtondefaultSetprivate javax.swing.JButtonremoveprivate ColorPreference.ColorTableModeltableModel
-
Constructor Summary
Constructors Constructor Description ColorPreference()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddGui(PreferenceTabbedPane gui)Add the GUI elements to the dialog.private static voidfixColorPrefixes()Add all missing color entries.private static intgetCategoryPriority(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.StringgetHelpContext()Returns the help context for this preferences settings tab.booleanisExpert()Called to know if the preferences tab has only to be displayed in expert mode.private static booleanisRemoveColor(ColorPreference.ColorEntry ce)booleanok()Called when OK is pressed to save the setting in the preferences file.voidsetColors(java.util.Map<java.lang.String,ColorInfo> colorMap)Set the colors to be shown in the preference table.voidtableChanged(javax.swing.event.TableModelEvent e)private voidupdateEnabledState()voidvalueChanged(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 =ColorInfoinstance)
-
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:PreferenceSettingAdd the GUI elements to the dialog. The elements should be initialized after the current preferences.- Specified by:
addGuiin interfacePreferenceSetting- Overrides:
addGuiin 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:PreferenceSettingCalled when OK is pressed to save the setting in the preferences file. Return true when restart is required.- Specified by:
okin interfacePreferenceSetting- Returns:
trueif restart is required
-
isExpert
public boolean isExpert()
Description copied from interface:PreferenceSettingCalled to know if the preferences tab has only to be displayed in expert mode.- Specified by:
isExpertin interfacePreferenceSetting- Overrides:
isExpertin 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:
valueChangedin interfacejavax.swing.event.ListSelectionListener
-
tableChanged
public void tableChanged(javax.swing.event.TableModelEvent e)
- Specified by:
tableChangedin interfacejavax.swing.event.TableModelListener
-
updateEnabledState
private void updateEnabledState()
-
getHelpContext
public java.lang.String getHelpContext()
Description copied from interface:TabPreferenceSettingReturns the help context for this preferences settings tab.- Specified by:
getHelpContextin interfaceTabPreferenceSetting- Overrides:
getHelpContextin classDefaultTabPreferenceSetting- Returns:
- the help context for this preferences settings tab
-
-