Class MapPaintStyles
java.lang.Object
org.openstreetmap.josm.gui.mappaint.MapPaintStyles
This class manages the list of available map paint styles and gives access to
the ElemStyles singleton.
On change,
MapPaintStyles.MapPaintStylesUpdateListener.mapPaintStylesUpdated() is fired
for all listeners.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classIconReference is used to remember the associated style source for each icon URL.private static final classstatic interfaceMapPaintStylesUpdateListener & related code (get informed when the list of MapPaint StyleSources changes)static classValue holder for a reference to a tag name. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Collection<String>private static final ListenerList<MapPaintStyles.MapPaintStylesUpdateListener>private static final ElemStyles -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdd a listener that listens to global style changes.static StyleSourceaddStyle(SourceEntry entry) Add a new map paint style.static booleancanMoveStyles(int[] sel, int i) Check if the styles can be movedstatic voidfireMapPaintStyleEntryUpdated(int index) Notifies all listeners that there was an update to a specific map paint stylestatic voidNotifies all listeners that there was any update to the map paint stylesprivate static StyleSourcefromSourceEntry(SourceEntry entry) static ImageIcongetIcon(MapPaintStyles.IconReference ref, int width, int height) Return scaled icon.static ImageProvidergetIconProvider(MapPaintStyles.IconReference ref, boolean test) Image provider for icon.getIconSourceDirs(StyleSource source) Gets the directories that should be searched for iconsstatic ImageIcongetNoIconIcon(StyleSource source) No icon with the given name was found, show a dummy icon insteadstatic ElemStylesReturns theElemStylessingleton instance.private static voidloadStyleForFirstTime(StyleSource source) static voidmoveStyles(int[] sel, int delta) Move position of entries in the current list of StyleSourcesstatic voidReloads all styles from the preferences.private static voidstatic voidRemoves a listener that listens to global style changes.static voidremoveStyle(SourceEntry entry) Remove a map paint style.static voidtoggleStyleActive(int... sel) Toggles the active state of several styles
-
Field Details
-
DEPRECATED_IMAGE_NAMES
-
listeners
-
styles
-
-
Constructor Details
-
MapPaintStyles
private MapPaintStyles()
-
-
Method Details
-
getStyles
Returns theElemStylessingleton instance. The returned object is read only, any manipulation happens via one of the other wrapper methods in this class. (readFromPreferences(),moveStyles(int[], int), ...)- Returns:
- the
ElemStylessingleton instance
-
getIconProvider
Image provider for icon. Note that this is a provider only. AImageProvider.get()call may still fail!- Parameters:
ref- reference to the requested icontest- iftruethan the icon is request is tested- Returns:
- image provider for icon (can be
nullwhentestistrue). - Since:
- 8097
- See Also:
-
getIcon
Return scaled icon.- Parameters:
ref- reference to the requested iconwidth- icon width or -1 for autoscaleheight- icon height or -1 for autoscale- Returns:
- image icon or
null. - See Also:
-
getNoIconIcon
No icon with the given name was found, show a dummy icon instead- Parameters:
source- style source- Returns:
- the icon misc/no_icon.png, in descending priority: - relative to source file - from user icon paths - josm's default icon can be null if the defaults are turned off by user
-
getIconSourceDirs
Gets the directories that should be searched for icons- Parameters:
source- The style source the icon is from- Returns:
- A list of directory names
-
readFromPreferences
Reloads all styles from the preferences. -
loadStyleForFirstTime
-
fromSourceEntry
-
moveStyles
Move position of entries in the current list of StyleSources- Parameters:
sel- The indices of styles to be moved.delta- The number of lines it should move. positive int moves down and negative moves up.
-
canMoveStyles
Check if the styles can be moved- Parameters:
sel- The indexes of the selected stylesi- The number of places to move the styles- Returns:
trueif that movement is possible
-
toggleStyleActive
Toggles the active state of several styles- Parameters:
sel- The style indexes
-
addStyle
Add a new map paint style.- Parameters:
entry- map paint style- Returns:
- loaded style source
-
removeStyle
Remove a map paint style.- Parameters:
entry- map paint style- Since:
- 11493
-
refreshStyles
-
addMapPaintStylesUpdateListener
public static void addMapPaintStylesUpdateListener(MapPaintStyles.MapPaintStylesUpdateListener listener) Add a listener that listens to global style changes.- Parameters:
listener- The listener
-
removeMapPaintStylesUpdateListener
public static void removeMapPaintStylesUpdateListener(MapPaintStyles.MapPaintStylesUpdateListener listener) Removes a listener that listens to global style changes.- Parameters:
listener- The listener
-
fireMapPaintStylesUpdated
Notifies all listeners that there was any update to the map paint styles -
fireMapPaintStyleEntryUpdated
Notifies all listeners that there was an update to a specific map paint style- Parameters:
index- The style index
-