Changeset 255 in josm for src


Ignore:
Timestamp:
2007-06-13T22:30:51+02:00 (18 years ago)
Author:
imi
Message:
  • fixed AnnotationPreset image loading to load from .jar-ressources as well
Location:
src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/gui/annotation/AnnotationPreset.java

    r212 r255  
    3535import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3636import org.openstreetmap.josm.tools.GBC;
     37import org.openstreetmap.josm.tools.ImageProvider;
    3738import org.openstreetmap.josm.tools.XmlObjectParser;
    3839import org.xml.sax.SAXException;
     
    5455                boolean requestFocusInWindow() {return false;}
    5556        }
    56        
     57
    5758        public static class Text extends Item {
    5859                public String key;
     
    8182                public String text;
    8283                public boolean default_ = false;
    83                
     84
    8485                private JCheckBox check = new JCheckBox();
    8586
     
    143144
    144145        /**
    145     * The types as preparsed collection.
    146     */
    147     public Collection<Class<?>> types;
     146        * The types as preparsed collection.
     147        */
     148        public Collection<Class<?>> types;
    148149        private List<Item> data = new LinkedList<Item>();
    149150
     
    166167         * Called from the XML parser to set the icon
    167168         */
    168         public void setIcon(String icon) {
    169                 putValue(Action.SMALL_ICON, new ImageIcon(new ImageIcon(icon).getImage().getScaledInstance(24, 24, Image.SCALE_SMOOTH)));
    170         }
    171        
     169        public void setIcon(String iconName) {
     170                ImageIcon icon = ImageProvider.getIfAvailable(null, iconName);
     171                if (icon == null)
     172                        icon = new ImageIcon(iconName);
     173                if (Math.max(icon.getIconHeight(), icon.getIconWidth()) != 24)
     174                        icon = new ImageIcon(icon.getImage().getScaledInstance(24, 24, Image.SCALE_SMOOTH));
     175                putValue(Action.SMALL_ICON, icon);
     176        }
     177
    172178        /**
    173179         * Called from the XML parser to set the types, this preset affects
     
    186192                }
    187193        }
    188        
     194
    189195        public static List<AnnotationPreset> readAll(InputStream inStream) throws SAXException {
    190196                BufferedReader in = null;
  • src/org/openstreetmap/josm/tools/ImageProvider.java

    r243 r255  
    6969                if (name == null)
    7070                        return null;
    71                 if (subdir == null || subdir != "")
     71                if (subdir == null)
     72                        subdir = "";
     73                else
    7274                        subdir += "/";
    7375                String ext = name.indexOf('.') != -1 ? "" : ".png";
Note: See TracChangeset for help on using the changeset viewer.