Revision 38078 branches/v2_0_0_prep/frameworks/_fwAndami/src/org/gvsig/andami/iconthemes/AbstractIconTheme.java
AbstractIconTheme.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
|
44 | 44 |
import java.net.URL; |
45 |
import java.util.ArrayList; |
|
46 |
import java.util.Collections; |
|
45 | 47 |
import java.util.HashMap; |
48 |
import java.util.HashSet; |
|
49 |
import java.util.Iterator; |
|
50 |
import java.util.Set; |
|
51 |
import java.util.List; |
|
46 | 52 |
|
47 | 53 |
import javax.swing.ImageIcon; |
48 | 54 |
|
... | ... | |
134 | 140 |
return false; |
135 | 141 |
} |
136 | 142 |
|
143 |
public Iterator<String> iterator() { |
|
144 |
Set<String> names = new HashSet<String>(); |
|
145 |
|
|
146 |
if( defaultTheme !=null ) { |
|
147 |
Iterator<String> it = defaultTheme.iterator(); |
|
148 |
while( it.hasNext() ) { |
|
149 |
names.add(it.next()); |
|
150 |
} |
|
151 |
} |
|
152 |
Iterator<String> it = iconList.keySet().iterator(); |
|
153 |
while( it.hasNext() ) { |
|
154 |
names.add(it.next()); |
|
155 |
} |
|
156 |
List<String> names2 = new ArrayList<String>(names); |
|
157 |
Collections.sort(names2); |
|
158 |
return names2.iterator(); |
|
159 |
} |
|
160 |
|
|
161 |
|
|
162 |
|
|
137 | 163 |
/* (non-Javadoc) |
138 | 164 |
* @see com.iver.andami.iconthemes.IIconTheme#get(java.lang.String) |
139 | 165 |
*/ |
... | ... | |
151 | 177 |
return toImageIcon(loader.getResource(iconName),iconName); |
152 | 178 |
} |
153 | 179 |
|
154 |
if (defaultTheme==null ){ |
|
155 |
Object object = iconList.get(iconName); |
|
156 |
if (object!=null) { |
|
157 |
return toImageIcon(object,iconName); |
|
158 |
} |
|
159 |
return getNoIcon(); |
|
160 |
} |
|
161 | 180 |
Object object = iconList.get(iconName); |
162 | 181 |
if (object!=null) { |
163 | 182 |
return toImageIcon(object,iconName); |
164 | 183 |
} |
165 |
if( defaultTheme.exists(iconName)) { |
|
184 |
if( defaultTheme!=null && defaultTheme.exists(iconName)) {
|
|
166 | 185 |
return defaultTheme.get(iconName, null); |
167 | 186 |
} |
168 | 187 |
return getNoIcon(); |
... | ... | |
203 | 222 |
* @see com.iver.andami.iconthemes.IIconTheme#registerDefault(java.lang.String, java.lang.Object) |
204 | 223 |
*/ |
205 | 224 |
public void registerDefault(String iconName, Object resource) { |
206 |
if (defaultTheme!=null)defaultTheme.register(iconName, resource); |
|
207 |
else register(iconName, resource); |
|
225 |
if (defaultTheme!=null) { |
|
226 |
defaultTheme.register(iconName, resource); |
|
227 |
} else { |
|
228 |
register(iconName, resource); |
|
229 |
} |
|
208 | 230 |
} |
209 | 231 |
|
210 | 232 |
/* (non-Javadoc) |
... | ... | |
294 | 316 |
return null; |
295 | 317 |
} |
296 | 318 |
|
319 |
public String getResourceID(String iconName) { |
|
320 |
Object icon = null; |
|
321 |
icon = iconList.get(iconName); |
|
322 |
if( icon != null ) { |
|
323 |
return icon.toString(); |
|
324 |
} |
|
325 |
icon = ((AbstractIconTheme)defaultTheme).iconList.get(iconName); |
|
326 |
if( icon != null ) { |
|
327 |
return icon.toString(); |
|
328 |
} |
|
329 |
return ""; |
|
330 |
} |
|
297 | 331 |
|
298 | 332 |
} |
Also available in: Unified diff