Ticket #19551: 19551.patch
File 19551.patch, 3.8 KB (added by , 4 years ago) |
---|
-
src/org/openstreetmap/josm/tools/ImageProvider.java
1600 1600 if (primitive.isTagged() && (!options.contains(GetPaddedOptions.NO_WAY_PRESETS) || OsmPrimitiveType.WAY != primitive.getType())) { 1601 1601 final Optional<ImageIcon> icon = TaggingPresets.getMatchingPresets(primitive).stream() 1602 1602 .sorted(Comparator.comparing(p -> 1603 p.iconName .contains("multipolygon") || p.types == null || p.types.isEmpty() ? Integer.MAX_VALUE : p.types.size()))1603 p.iconName != null && p.iconName.contains("multipolygon") || p.types == null || p.types.isEmpty() ? Integer.MAX_VALUE : p.types.size())) 1604 1604 .map(TaggingPreset::getImageResource) 1605 1605 .filter(Objects::nonNull) 1606 1606 .map(resource -> resource.getPaddedIcon(iconSize)) -
test/unit/org/openstreetmap/josm/tools/ImageProviderTest.java
6 6 import static org.junit.Assert.assertFalse; 7 7 import static org.junit.Assert.assertNotNull; 8 8 import static org.junit.Assert.assertTrue; 9 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 9 10 10 11 import java.awt.Color; 11 12 import java.awt.Dimension; 13 import java.awt.Graphics; 12 14 import java.awt.GraphicsEnvironment; 13 15 import java.awt.GridLayout; 14 import java.awt.Graphics;15 16 import java.awt.Image; 16 17 import java.awt.Point; 17 18 import java.awt.Toolkit; … … 21 22 import java.awt.image.BufferedImage; 22 23 import java.io.File; 23 24 import java.io.IOException; 25 import java.util.Arrays; 26 import java.util.Collections; 24 27 import java.util.List; 25 28 import java.util.logging.Handler; 26 29 import java.util.logging.LogRecord; … … 37 40 import org.junit.Test; 38 41 import org.openstreetmap.josm.JOSMFixture; 39 42 import org.openstreetmap.josm.TestUtils; 43 import org.openstreetmap.josm.data.coor.LatLon; 44 import org.openstreetmap.josm.data.osm.Node; 45 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 46 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 47 import org.openstreetmap.josm.gui.tagging.presets.items.Key; 40 48 import org.openstreetmap.josm.testutils.JOSMTestRules; 49 import org.xml.sax.SAXException; 41 50 42 51 import com.kitfox.svg.SVGConst; 43 52 … … 47 56 * Unit tests of {@link ImageProvider} class. 48 57 */ 49 58 public class ImageProviderTest { 50 59 51 60 /** 52 61 * Setup test. 53 62 */ … … 128 137 } 129 138 130 139 /** 140 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/19551">#19551</a> 141 * @throws SAXException If the type cannot be set (shouldn't throw) 142 */ 143 @Test 144 public void testTicket19551() throws SAXException { 145 TaggingPreset badPreset = new TaggingPreset(); 146 badPreset.setType("node,way,relation,closedway"); 147 Key key = new Key(); 148 key.key = "amenity"; 149 key.value = "fuel"; 150 badPreset.data.add(key); 151 TaggingPreset goodPreset = new TaggingPreset(); 152 goodPreset.setType("node,way,relation,closedway"); 153 goodPreset.data.add(key); 154 goodPreset.iconName = "stop"; 155 TaggingPresets.addTaggingPresets(Arrays.asList(goodPreset, badPreset)); 156 Node node = new Node(LatLon.ZERO); 157 node.put("amenity", "fuel"); 158 assertDoesNotThrow(() -> ImageProvider.getPadded(node, ImageProvider.ImageSizes.MAP.getImageDimension(), Collections.emptyList())); 159 } 160 161 /** 131 162 * Test fetching an image using {@code wiki://} protocol. 132 163 */ 133 164 @Test