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 class
MapPaintStyles.IconReference
IconReference is used to remember the associated style source for each icon URL.private static class
MapPaintStyles.MapPaintStylesPreferenceListener
static interface
MapPaintStyles.MapPaintStylesUpdateListener
MapPaintStylesUpdateListener & related code (get informed when the list of MapPaint StyleSources changes)static class
MapPaintStyles.TagKeyReference
Value 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_NAMES
private static ListenerList<MapPaintStyles.MapPaintStylesUpdateListener>
listeners
private static ElemStyles
styles
-
Constructor Summary
Constructors Modifier Constructor Description private
MapPaintStyles()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
addMapPaintStylesUpdateListener(MapPaintStyles.MapPaintStylesUpdateListener listener)
Add a listener that listens to global style changes.static StyleSource
addStyle(SourceEntry entry)
Add a new map paint style.static boolean
canMoveStyles(int[] sel, int i)
Check if the styles can be movedstatic void
fireMapPaintStyleEntryUpdated(int index)
Notifies all listeners that there was an update to a specific map paint stylestatic void
fireMapPaintStylesUpdated()
Notifies all listeners that there was any update to the map paint stylesprivate static StyleSource
fromSourceEntry(SourceEntry entry)
static javax.swing.ImageIcon
getIcon(MapPaintStyles.IconReference ref, int width, int height)
Return scaled icon.static ImageProvider
getIconProvider(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.ImageIcon
getNodeIcon(Tag tag)
static javax.swing.ImageIcon
getNoIconIcon(StyleSource source)
No icon with the given name was found, show a dummy icon insteadstatic ElemStyles
getStyles()
Returns theElemStyles
singleton instance.private static void
loadStyleForFirstTime(StyleSource source)
static void
moveStyles(int[] sel, int delta)
Move position of entries in the current list of StyleSourcesstatic void
readFromPreferences()
Reloads all styles from the preferences.private static void
refreshStyles()
static void
removeMapPaintStylesUpdateListener(MapPaintStyles.MapPaintStylesUpdateListener listener)
Removes a listener that listens to global style changes.static void
removeStyle(SourceEntry entry)
Remove a map paint style.static void
toggleStyleActive(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 theElemStyles
singleton 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
ElemStyles
singleton 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
- iftrue
than the icon is request is tested- Returns:
- image provider for icon (can be
null
whentest
istrue
). - 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
-
getNodeIcon
@Deprecated public static javax.swing.ImageIcon getNodeIcon(Tag tag)
Returns the node icon that would be displayed for the given tag.- Parameters:
tag
- The tag to look an icon for- Returns:
null
if no icon found
-
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:
true
if 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
-
-