Ticket #6964: 6964_icon_in_background.patch

File 6964_icon_in_background.patch, 2.5 KB (added by simon04, 14 years ago)
  • src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    diff --git a/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java b/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
    index 6f410d8..46bb24c 100644
    a b public class TaggingPreset extends AbstractAction implements MapView.LayerChange  
    10491049    public String getRawName() {
    10501050        return group != null ? group.getRawName() + "/" + name : name;
    10511051    }
    1052     /**
    1053      * Called from the XML parser to set the icon
     1052
     1053    /*
     1054     * Called from the XML parser to set the icon.
     1055     * This task is performed in the background in order to speedup startup.
    10541056     *
    10551057     * FIXME for Java 1.6 - use 24x24 icons for LARGE_ICON_KEY (button bar)
    10561058     * and the 16x16 icons for SMALL_ICON.
    10571059     */
    1058     public void setIcon(String iconName) {
    1059         Collection<String> s = Main.pref.getCollection("taggingpreset.icon.sources", null);
    1060         ImageIcon icon = new ImageProvider(iconName).setDirs(s).setId("presets").setArchive(zipIcons).setOptional(true).get();
    1061         if (icon == null)
    1062         {
    1063             System.out.println("Could not get presets icon " + iconName);
    1064             icon = new ImageIcon(iconName);
    1065         }
    1066         if (Math.max(icon.getIconHeight(), icon.getIconWidth()) != 16) {
    1067             icon = new ImageIcon(icon.getImage().getScaledInstance(16, 16, Image.SCALE_SMOOTH));
    1068         }
    1069         putValue(Action.SMALL_ICON, icon);
     1060    public void setIcon(final String iconName) {
     1061        Main.worker.submit(new Runnable() {
     1062
     1063            @Override
     1064            public void run() {
     1065                final Collection<String> s = Main.pref.getCollection("taggingpreset.icon.sources", null);
     1066                ImageIcon icon = new ImageProvider(iconName).setDirs(s).setId("presets").setArchive(zipIcons).setOptional(true).get();
     1067                if (icon == null) {
     1068                    System.out.println("Could not get presets icon " + iconName);
     1069                    icon = new ImageIcon(iconName);
     1070                }
     1071                if (Math.max(icon.getIconHeight(), icon.getIconWidth()) != 16) {
     1072                    icon = new ImageIcon(icon.getImage().getScaledInstance(16, 16, Image.SCALE_SMOOTH));
     1073                }
     1074                putValue(Action.SMALL_ICON, icon);
     1075            }
     1076        });
    10701077    }
    10711078
    10721079    // cache the parsing of types using a LRU cache (http://java-planet.blogspot.com/2005/08/how-to-set-up-simple-lru-cache-using.html)