Changeset 15889 in josm for trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
- Timestamp:
- 2020-02-21T21:19:34+01:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r15755 r15889 7 7 import java.util.Arrays; 8 8 import java.util.Collection; 9 import java.util.EnumSet; 9 10 import java.util.LinkedList; 10 11 import java.util.List; … … 20 21 import org.openstreetmap.josm.data.preferences.sources.SourceEntry; 21 22 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; 22 import org.openstreetmap.josm.gui.mappaint.styleelement.MapImage;23 import org.openstreetmap.josm.gui.mappaint.styleelement.NodeElement;24 import org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement;25 23 import org.openstreetmap.josm.io.CachedFile; 26 24 import org.openstreetmap.josm.io.FileWatcher; … … 215 213 * @param tag The tag to look an icon for 216 214 * @return {@code null} if no icon found 217 */ 215 * @deprecated use {@link ImageProvider#getPadded} 216 */ 217 @Deprecated 218 218 public static ImageIcon getNodeIcon(Tag tag) { 219 return getNodeIcon(tag, true);220 }221 222 /**223 * Returns the node icon that would be displayed for the given tag.224 * @param tag The tag to look an icon for225 * @param includeDeprecatedIcon if {@code true}, the special deprecated icon will be returned if applicable226 * @return {@code null} if no icon found, or if the icon is deprecated and not wanted227 */228 public static ImageIcon getNodeIcon(Tag tag, boolean includeDeprecatedIcon) {229 219 if (tag != null) { 230 220 DataSet ds = new DataSet(); 231 221 Node virtualNode = new Node(LatLon.ZERO); 232 222 virtualNode.put(tag.getKey(), tag.getValue()); 233 StyleElementList styleList;234 223 MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().lock(); 235 224 try { 236 225 // Add primitive to dataset to avoid DataIntegrityProblemException when evaluating selectors 237 226 ds.addPrimitive(virtualNode); 238 styleList = getStyles().generateStyles(virtualNode, 0.5, false).a; 227 return ImageProvider.getPadded(virtualNode, ImageProvider.ImageSizes.SMALLICON.getImageDimension(), 228 EnumSet.of(ImageProvider.GetPaddedOptions.NO_PRESETS, ImageProvider.GetPaddedOptions.NO_DEFAULT)); 229 } finally { 239 230 ds.removePrimitive(virtualNode); 240 } finally {241 231 MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().unlock(); 242 }243 if (styleList != null) {244 for (StyleElement style : styleList) {245 if (style instanceof NodeElement) {246 MapImage mapImage = ((NodeElement) style).mapImage;247 if (mapImage != null) {248 if (includeDeprecatedIcon || mapImage.name == null || !DEPRECATED_IMAGE_NAMES.contains(mapImage.name)) {249 return new ImageIcon(mapImage.getImage(false));250 } else {251 return null; // Deprecated icon found but not wanted252 }253 }254 }255 }256 232 } 257 233 }
Note:
See TracChangeset
for help on using the changeset viewer.