Changeset 5139 in josm


Ignore:
Timestamp:
Mar 31, 2012 11:30:04 AM (15 months ago)
Author:
simon04
Message:

see #6964 - load preset icons in a background thread in order to speedup startup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r5136 r5139  
    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 
Note: See TracChangeset for help on using the changeset viewer.