Parcourir la source

added getScaledIcon to IconManager

tags/0.6.3m1rc1
Gregory Holmes il y a 15 ans
Parent
révision
ede054ca4a
1 fichiers modifiés avec 21 ajouts et 2 suppressions
  1. 21
    2
      src/com/dmdirc/ui/IconManager.java

+ 21
- 2
src/com/dmdirc/ui/IconManager.java Voir le fichier

28
 
28
 
29
 import java.awt.Image;
29
 import java.awt.Image;
30
 import java.awt.Toolkit;
30
 import java.awt.Toolkit;
31
-import java.io.File;
32
-import java.io.IOException;
33
 import java.net.URL;
31
 import java.net.URL;
34
 import java.util.HashMap;
32
 import java.util.HashMap;
35
 import java.util.Map;
33
 import java.util.Map;
87
         }
85
         }
88
         return icons.get(type);
86
         return icons.get(type);
89
     }
87
     }
88
+
89
+    /**
90
+     * Retrieves the icon with the specified type. Returns null if the icon
91
+     * wasn't found.
92
+     *
93
+     * @param type The name of the icon type to retrieve
94
+     * @param width width of the image
95
+     * @param height height of the image
96
+     * 
97
+     * @return The icon that should be used for the specified type
98
+     *
99
+     * @since 0.6.3
100
+     */
101
+    public Icon getScaledIcon(final String type, final int width, final int height) {
102
+        if (!icons.containsKey(type)) {
103
+            icons.put(type, new ImageIcon(getScaledImage(
104
+                    new ImageIcon(getIconURL(type)).getImage(), width, height)));
105
+        }
106
+        return icons.get(type);
107
+    }
90
     
108
     
91
     /**
109
     /**
92
      * Retrieves the image with the specified type. Returns null if the icon
110
      * Retrieves the image with the specified type. Returns null if the icon
152
     }
170
     }
153
 
171
 
154
     /** {@inheritDoc} */
172
     /** {@inheritDoc} */
173
+    @Override
155
     public void configChanged(final String domain, final String key) {
174
     public void configChanged(final String domain, final String key) {
156
         if ("icon".equals(domain)) {
175
         if ("icon".equals(domain)) {
157
             if (images.containsKey(key)) {
176
             if (images.containsKey(key)) {

Chargement…
Annuler
Enregistrer