Class MapPaintStyles
- java.lang.Object
-
- org.openstreetmap.josm.gui.mappaint.MapPaintStyles
-
public final class MapPaintStyles extends java.lang.Object
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 Classes Modifier and Type Class Description static classMapPaintStyles.IconReferenceIconReference is used to remember the associated style source for each icon URL.private static classMapPaintStyles.MapPaintStylesPreferenceListenerstatic interfaceMapPaintStyles.MapPaintStylesUpdateListenerMapPaintStylesUpdateListener & related code (get informed when the list of MapPaint StyleSources changes)static classMapPaintStyles.TagKeyReferenceValue holder for a reference to a tag name.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Collection<java.lang.String>DEPRECATED_IMAGE_NAMESprivate static ListenerList<MapPaintStyles.MapPaintStylesUpdateListener>listenersprivate static ElemStylesstyles
-
Constructor Summary
Constructors Modifier Constructor Description privateMapPaintStyles()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddMapPaintStylesUpdateListener(MapPaintStyles.MapPaintStylesUpdateListener listener)Add 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 voidfireMapPaintStylesUpdated()Notifies all listeners that there was any update to the map paint stylesprivate static StyleSourcefromSourceEntry(SourceEntry entry)static javax.swing.ImageIcongetIcon(MapPaintStyles.IconReference ref, int width, int height)Return scaled icon.static ImageProvidergetIconProvider(MapPaintStyles.IconReference ref, boolean test)Image provider for icon.static java.util.List<java.lang.String>getIconSourceDirs(StyleSource source)Gets the directories that should be searched for iconsstatic javax.swing.ImageIcongetNoIconIcon(StyleSource source)No icon with the given name was found, show a dummy icon insteadstatic ElemStylesgetStyles()Returns theElemStylessingleton instance.private static voidloadStyleForFirstTime(StyleSource source)static voidmoveStyles(int[] sel, int delta)Move position of entries in the current list of StyleSourcesstatic voidreadFromPreferences()Reloads all styles from the preferences.private static voidrefreshStyles()static voidremoveMapPaintStylesUpdateListener(MapPaintStyles.MapPaintStylesUpdateListener listener)Removes 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 Detail
-
DEPRECATED_IMAGE_NAMES
private static final java.util.Collection<java.lang.String> DEPRECATED_IMAGE_NAMES
-
listeners
private static final ListenerList<MapPaintStyles.MapPaintStylesUpdateListener> listeners
-
styles
private static final ElemStyles styles
-
-
Constructor Detail
-
MapPaintStyles
private MapPaintStyles()
-
-
Method Detail
-
getStyles
public static ElemStyles 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
public static ImageProvider getIconProvider(MapPaintStyles.IconReference ref, boolean test)
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(IconReference, int,int)
-
getIcon
public static javax.swing.ImageIcon getIcon(MapPaintStyles.IconReference ref, int width, int height)
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:
getIconProvider(IconReference, boolean)
-
getNoIconIcon
public static javax.swing.ImageIcon getNoIconIcon(StyleSource source)
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
public static java.util.List<java.lang.String> getIconSourceDirs(StyleSource source)
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
public static void readFromPreferences()
Reloads all styles from the preferences.
-
loadStyleForFirstTime
private static void loadStyleForFirstTime(StyleSource source)
-
fromSourceEntry
private static StyleSource fromSourceEntry(SourceEntry entry)
-
moveStyles
public static void moveStyles(int[] sel, int delta)
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
public static boolean canMoveStyles(int[] sel, int i)
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
public static void toggleStyleActive(int... sel)
Toggles the active state of several styles- Parameters:
sel- The style indexes
-
addStyle
public static StyleSource addStyle(SourceEntry entry)
Add a new map paint style.- Parameters:
entry- map paint style- Returns:
- loaded style source
-
removeStyle
public static void removeStyle(SourceEntry entry)
Remove a map paint style.- Parameters:
entry- map paint style- Since:
- 11493
-
refreshStyles
private static void 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
public static void fireMapPaintStylesUpdated()
Notifies all listeners that there was any update to the map paint styles
-
fireMapPaintStyleEntryUpdated
public static void fireMapPaintStyleEntryUpdated(int index)
Notifies all listeners that there was an update to a specific map paint style- Parameters:
index- The style index
-
-