Ignore:
Timestamp:
2020-02-21T21:19:34+01:00 (4 years ago)
Author:
simon04
Message:

fix #14088 - Add tags dialog: use padded preset/style icons for okay button

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r15755 r15889  
    77import java.util.Arrays;
    88import java.util.Collection;
     9import java.util.EnumSet;
    910import java.util.LinkedList;
    1011import java.util.List;
     
    2021import org.openstreetmap.josm.data.preferences.sources.SourceEntry;
    2122import 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;
    2523import org.openstreetmap.josm.io.CachedFile;
    2624import org.openstreetmap.josm.io.FileWatcher;
     
    215213     * @param tag The tag to look an icon for
    216214     * @return {@code null} if no icon found
    217      */
     215     * @deprecated use {@link ImageProvider#getPadded}
     216     */
     217    @Deprecated
    218218    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 for
    225      * @param includeDeprecatedIcon if {@code true}, the special deprecated icon will be returned if applicable
    226      * @return {@code null} if no icon found, or if the icon is deprecated and not wanted
    227      */
    228     public static ImageIcon getNodeIcon(Tag tag, boolean includeDeprecatedIcon) {
    229219        if (tag != null) {
    230220            DataSet ds = new DataSet();
    231221            Node virtualNode = new Node(LatLon.ZERO);
    232222            virtualNode.put(tag.getKey(), tag.getValue());
    233             StyleElementList styleList;
    234223            MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().lock();
    235224            try {
    236225                // Add primitive to dataset to avoid DataIntegrityProblemException when evaluating selectors
    237226                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 {
    239230                ds.removePrimitive(virtualNode);
    240             } finally {
    241231                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 wanted
    252                             }
    253                         }
    254                     }
    255                 }
    256232            }
    257233        }
Note: See TracChangeset for help on using the changeset viewer.