Revision 711
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/icontheme/BaseIconTheme.java | ||
---|---|---|
44 | 44 |
import java.awt.Image; |
45 | 45 |
import java.io.File; |
46 | 46 |
import java.io.IOException; |
47 |
import java.io.InputStream; |
|
47 | 48 |
import java.net.URL; |
48 | 49 |
import java.util.ArrayList; |
49 | 50 |
import java.util.Collections; |
... | ... | |
57 | 58 |
import javax.swing.ImageIcon; |
58 | 59 |
|
59 | 60 |
import org.apache.commons.io.FileUtils; |
60 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
|
61 | 61 |
import org.slf4j.Logger; |
62 | 62 |
import org.slf4j.LoggerFactory; |
63 | 63 |
|
64 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
|
64 | 65 |
|
66 |
|
|
65 | 67 |
/** |
66 | 68 |
* <p>This class represents an icon theme, which is basically a mapping of |
67 | 69 |
* symbolic icon names, and real icons (or icon paths). This is useful to |
... | ... | |
95 | 97 |
this.provider = provider; |
96 | 98 |
} |
97 | 99 |
|
100 |
public boolean existsIcon() { |
|
101 |
if (image != null) { |
|
102 |
return true; |
|
103 |
} |
|
104 |
|
|
105 |
InputStream ist = null; |
|
106 |
boolean resp = false; |
|
107 |
|
|
108 |
try { |
|
109 |
ist = resource.openStream(); |
|
110 |
resp = true; |
|
111 |
} catch (Exception ex) { |
|
112 |
resp = false; |
|
113 |
} |
|
114 |
try { |
|
115 |
ist.close(); |
|
116 |
} catch (Exception ex) { |
|
117 |
} |
|
118 |
return resp; |
|
119 |
} |
|
120 |
|
|
98 | 121 |
public ImageIcon getImageIcon() { |
99 | 122 |
if (this.image != null){ |
100 | 123 |
return this.image; |
... | ... | |
390 | 413 |
iconList.put(name, themeIcon); |
391 | 414 |
throw new IllegalArgumentException("icon and resource for '"+getIconIdentifier(provider,group, name)+"' are null"); |
392 | 415 |
} |
393 |
Icon themeIcon = new DefaultIcon(provider, group, name, icon, resource); |
|
416 |
DefaultIcon themeIcon = new DefaultIcon(provider, group, name, icon, resource); |
|
417 |
|
|
394 | 418 |
iconList.put(name, themeIcon); |
419 |
if (!themeIcon.existsIcon()) { |
|
420 |
throw new IllegalArgumentException("Resource not found for icon '"+getIconIdentifier(provider,group, name) + "'"); |
|
421 |
} |
|
395 | 422 |
} |
396 | 423 |
|
397 | 424 |
private String getIconIdentifier(String provider, String group, String name) { |
Also available in: Unified diff