Changeset 18070 in josm


Ignore:
Timestamp:
2021-07-18T23:40:47+02:00 (3 years ago)
Author:
Don-vip
Message:

fix #16868 - use DevCharly's version of svgSalamander from Maven Central

Location:
trunk
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/README

    r18054 r18070  
    170170    -> http://commons.apache.org/proper/commons-validator
    171171* SVG Salamander: Support for SVG image format
    172     src/com/kitfox/svg
    173172    -> https://github.com/blackears/svgSalamander
    174173* Metadata Extractor: Read EXIF Metadata of photos
  • trunk/ivy.xml

    r17969 r18070  
    3030        <dependency conf="api->default" org="com.adobe.xmp" name="xmpcore" rev="6.1.11"/>
    3131        <dependency conf="api->default" org="com.drewnoakes" name="metadata-extractor" rev="2.16.0" transitive="false"/>
     32        <dependency conf="api->default" org="com.formdev" name="svgSalamander" rev="1.1.2.4"/>
    3233        <dependency conf="api->default" org="ch.poole" name="OpeningHoursParser" rev="0.23.4"/>
    3334        <dependency conf="api->default" org="oauth.signpost" name="signpost-core" rev="2.1.1"/>
     
    4344        <dependency conf="sources->sources" org="com.adobe.xmp" name="xmpcore" rev="6.1.11"/>
    4445        <dependency conf="sources->sources" org="com.drewnoakes" name="metadata-extractor" rev="2.16.0" transitive="false"/>
     46        <dependency conf="sources->default" org="com.formdev" name="svgSalamander" rev="1.1.2.4"/>
    4547        <dependency conf="sources->sources" org="ch.poole" name="OpeningHoursParser" rev="0.23.4"/>
    4648        <dependency conf="sources->sources" org="oauth.signpost" name="signpost-core" rev="2.1.1"/>
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r18014 r18070  
    1616import java.io.InputStream;
    1717import java.io.UnsupportedEncodingException;
     18import java.lang.reflect.Method;
    1819import java.net.MalformedURLException;
    1920import java.net.URI;
     
    6970import org.openstreetmap.josm.spi.preferences.Config;
    7071
    71 import com.kitfox.svg.xml.XMLParseUtil;
    72 
    7372/**
    7473 * Basic utils, that can be useful in different parts of the program.
     
    9897    private static final double TO_DEGREES = 180.0 / Math.PI;
    9998    private static final double TO_RADIANS = Math.PI / 180.0;
     99
     100    /**
     101     * A reference to {@code Map.ofEntries()} available since Java 9
     102     */
     103    static final Method mapOfEntries = mapOfEntriesMethod();
     104
     105    private static Method mapOfEntriesMethod() {
     106        try {
     107            return Map.class.getMethod("ofEntries", Map.Entry[].class);
     108        } catch (NoSuchMethodException e) {
     109            return null;
     110        }
     111    }
    100112
    101113    private Utils() {
     
    659671     */
    660672    public static <K, V> Map<K, V> toUnmodifiableMap(Map<K, V> map) {
    661         return XMLParseUtil.toUnmodifiableMap(map);
     673        if (map == null || map.isEmpty()) {
     674            return Collections.emptyMap();
     675        } else if (map.size() == 1) {
     676            final Map.Entry<K, V> entry = map.entrySet().iterator().next();
     677            return Collections.singletonMap(entry.getKey(), entry.getValue());
     678        } else if (mapOfEntries != null) {
     679            try {
     680                // Java 9: use Map.ofEntries(...)
     681                return (Map<K, V>) mapOfEntries.invoke(null, new Object[]{map.entrySet().toArray(new Map.Entry[0])});
     682            } catch (Exception ignore) {
     683                Logging.trace(ignore);
     684            }
     685        }
     686        return Collections.unmodifiableMap(map);
    662687    }
    663688
Note: See TracChangeset for help on using the changeset viewer.