gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.swing / org.gvsig.tools.swing.api / src / main / java / org / gvsig / tools / swing / icontheme / IconTheme.java @ 1825
History | View | Annotate | Download (6.15 KB)
1 | 802 | cordinyana | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | *
|
||
4 | * Copyright (C) 2007-2013 gvSIG Association.
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | * For any additional information, do not hesitate to contact us
|
||
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | */
|
||
24 | 698 | jjdelcerro | package org.gvsig.tools.swing.icontheme; |
25 | |||
26 | import java.awt.Image; |
||
27 | import java.io.File; |
||
28 | import java.net.URL; |
||
29 | import java.util.Iterator; |
||
30 | |||
31 | import javax.swing.ImageIcon; |
||
32 | |||
33 | 710 | jjdelcerro | public interface IconTheme { |
34 | 698 | jjdelcerro | |
35 | public static final String NO_ICON_NAME = "-no-icon-"; |
||
36 | |||
37 | interface Icon extends Comparable<Icon> { |
||
38 | public String getName(); |
||
39 | public String getGroup() ; |
||
40 | public ImageIcon getImageIcon(); |
||
41 | public Image getImage(); |
||
42 | public Object getResource() ; |
||
43 | public URL getURL() ; |
||
44 | public String getLabel(); |
||
45 | public String getProviderName(); |
||
46 | } |
||
47 | |||
48 | /**
|
||
49 | * Load all icons from the IconTheme
|
||
50 | */
|
||
51 | public void load(Object resource) throws IllegalArgumentException; |
||
52 | |||
53 | |||
54 | public void setDefault(IconTheme def); |
||
55 | |||
56 | public IconTheme getDefault();
|
||
57 | |||
58 | /**
|
||
59 | * Returns <code>true</code> if the icon theme contains a mapping for the
|
||
60 | * specified iconName.
|
||
61 | *
|
||
62 | * @param iconName The key to check if it has been registered in this
|
||
63 | * IconTheme
|
||
64 | *
|
||
65 | * @return <code>true</code> if this IconTheme contains
|
||
66 | * <code>iconName</code>, <code>false</code> otherwise.
|
||
67 | */
|
||
68 | public boolean exists(String name); |
||
69 | |||
70 | /**
|
||
71 | * Gets the ImageIcon associated with the provided name, if the name
|
||
72 | * is present in the theme. If the icon not exists try to return
|
||
73 | * a icon with name "no-icon" or returns <code>null</code> if
|
||
74 | * this not exists.
|
||
75 | *
|
||
76 | * @param name
|
||
77 | * The name whose associated icon is to be retrieved
|
||
78 | *
|
||
79 | * @return
|
||
80 | * The icon associated with the provided name
|
||
81 | */
|
||
82 | public ImageIcon get(String iconName); |
||
83 | |||
84 | /**
|
||
85 | * Return the ThemeIcon associated with the name.
|
||
86 | *
|
||
87 | * @param name of the icon
|
||
88 | * @return the IconTheme requiered
|
||
89 | */
|
||
90 | public Icon getThemeIcon(String name); |
||
91 | |||
92 | /**
|
||
93 | * Gets the theme name of the theme
|
||
94 | * @return theme name
|
||
95 | */
|
||
96 | public String getName(); |
||
97 | |||
98 | /**
|
||
99 | * Sets the theme name of the theme
|
||
100 | *
|
||
101 | * @param themeName
|
||
102 | */
|
||
103 | public void setName(String themeName); |
||
104 | |||
105 | public String getID(); |
||
106 | |||
107 | public void setID(String id); |
||
108 | |||
109 | /**
|
||
110 | * Gets the theme description.
|
||
111 | *
|
||
112 | * @return The description of this theme.
|
||
113 | */
|
||
114 | public String getDescription(); |
||
115 | |||
116 | /**
|
||
117 | * Sets the theme description. It should be a short description
|
||
118 | * (around 20-30 words), including the highlights of the theme,
|
||
119 | * the author and maybe its email address or a link the the theme's
|
||
120 | * homepage.
|
||
121 | *
|
||
122 | * @param description
|
||
123 | */
|
||
124 | public void setDescription(String description); |
||
125 | |||
126 | /**
|
||
127 | * Return an iterator over the names of the icons in the theme.
|
||
128 | *
|
||
129 | * @return iterator of names of icons
|
||
130 | */
|
||
131 | public Iterator<String> iterator(); |
||
132 | |||
133 | /**
|
||
134 | * Return an iterator over the ThemIcon in the theme.
|
||
135 | *
|
||
136 | * @return iterator of ThemeIcon
|
||
137 | */
|
||
138 | public Iterator<Icon> getThemeIcons(); |
||
139 | |||
140 | |||
141 | /**
|
||
142 | * Return the icon used as icon by default when the requested icon
|
||
143 | * not exists.
|
||
144 | *
|
||
145 | * @return the default icon to use.
|
||
146 | */
|
||
147 | public ImageIcon getDefaultIcon(); |
||
148 | |||
149 | /**
|
||
150 | * Set the default icon to use when the requestd icon not exists.
|
||
151 | *
|
||
152 | * @param icon
|
||
153 | */
|
||
154 | public void setDefaultIcon(ImageIcon icon); |
||
155 | |||
156 | public void setDefaultIcon(URL resource); |
||
157 | |||
158 | public void setDefaultIcon(String name); |
||
159 | |||
160 | /**
|
||
161 | * Register a icon in the theme.
|
||
162 | * The parameter icon can be null if the resource is specified.
|
||
163 | * The parameter resource can be null if the icon is specified.
|
||
164 | *
|
||
165 | * Plugin and group can be null.
|
||
166 | *
|
||
167 | * @param provider name of the icon
|
||
168 | * @param group name for the icon.
|
||
169 | * @param name of icon
|
||
170 | * @param icon, can be nulll if the resource is specified.
|
||
171 | * @param resource, resource of the icon, usualy and url to the icon.
|
||
172 | *
|
||
173 | * @throws IllegalArgumentException if name is null/empty or icon/resource are null
|
||
174 | */
|
||
175 | public void registerDefault(String provider, String group, String name, ImageIcon icon, URL resource) throws IllegalArgumentException; |
||
176 | |||
177 | /**
|
||
178 | * Register a icon in the theme.
|
||
179 | * The parameter icon can be null if the resource is specified.
|
||
180 | * The parameter resource can be null if the icon is specified.
|
||
181 | *
|
||
182 | * Plugin and group can be null.
|
||
183 | *
|
||
184 | * @param provider name of the icon
|
||
185 | * @param group name for the icon.
|
||
186 | * @param name of icon
|
||
187 | * @param icon, can be nulll if the resource is specified.
|
||
188 | * @param resource, resource of the icon, usualy and url to the icon.
|
||
189 | *
|
||
190 | * @throws IllegalArgumentException if name is null/empty or icon/resource are null
|
||
191 | */
|
||
192 | public void register(String provider, String group, String name, ImageIcon icon, URL resource) throws IllegalArgumentException; |
||
193 | |||
194 | public void export(File folder); |
||
195 | 701 | jjdelcerro | |
196 | /**
|
||
197 | * @deprecated use {@link #getDefaultIcon()}
|
||
198 | * @return
|
||
199 | */
|
||
200 | public ImageIcon getNoIcon(); |
||
201 | |||
202 | /**
|
||
203 | * @deprecated use {@link #get(String)} instead
|
||
204 | */
|
||
205 | public ImageIcon get(String iconName, ClassLoader loader); |
||
206 | |||
207 | /**
|
||
208 | * @deprecated use {@link #registerDefault(PluginServices, String, String, ImageIcon, Object)}
|
||
209 | */
|
||
210 | public void registerDefault(String iconName, ImageIcon image); |
||
211 | |||
212 | /**
|
||
213 | * @deprecated use {@link #registerDefault(PluginServices, String, String, ImageIcon, Object)}
|
||
214 | */
|
||
215 | public void registerDefault(String iconName, Object resource); |
||
216 | |||
217 | /**
|
||
218 | * @deprecated use {@link #register(PluginServices, String, String, ImageIcon, Object)}
|
||
219 | */
|
||
220 | public void register(String iconName, ImageIcon image); |
||
221 | |||
222 | /**
|
||
223 | * @deprecated use {@link #register(PluginServices, String, String, ImageIcon, Object)}
|
||
224 | */
|
||
225 | public void register(String iconName, Object resource); |
||
226 | 698 | jjdelcerro | } |