Statistics
| Revision:

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 @ 3039

History | View | Annotate | Download (7.71 KB)

1
/**
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
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.ArrayList;
30
import java.util.Collections;
31
import java.util.Iterator;
32
import java.util.List;
33

    
34
import javax.swing.ImageIcon;
35
import org.gvsig.tools.swing.api.SimpleImage;
36
import org.gvsig.tools.swing.api.ToolsSwingLocator;
37
import org.gvsig.tools.swing.api.ToolsSwingManager;
38

    
39
public interface IconTheme  {
40
        
41
        public static final String NO_ICON_NAME = "-no-icon-";
42

    
43
        interface Icon extends Comparable<Icon> {
44
                public String getName();
45
                public String getDescription() ;
46
                public String getGroup() ;
47
                public String getGroupDescription() ;
48
                public String getSubgroup() ;
49
                public String getSubgroupDescription() ;
50
                public ImageIcon getImageIcon();
51
                public Image getImage();
52
                public Object getResource() ;
53
                public URL getURL() ;
54
                public String getLabel();
55
                public String getProviderName();
56
                
57
                public void setDescription(String description);
58
                public void setSubgroup(String subgroup);
59
        }
60

    
61
        /**
62
         * Load all icons from the IconTheme
63
         */
64
        public void load(Object resource) throws IllegalArgumentException;
65
        
66

    
67
        public void setDefault(IconTheme def);
68

    
69
        public IconTheme getDefault();
70

    
71
        /**
72
         * Returns <code>true</code> if the icon theme contains a mapping for the
73
         * specified iconName.
74
         *
75
         * @param iconName The key to check if it has been registered in this
76
         * IconTheme
77
         *
78
         * @return <code>true</code> if this IconTheme contains
79
         * <code>iconName</code>, <code>false</code> otherwise.
80
         */
81
        public boolean exists(String name);
82

    
83
        /**
84
         * Gets the ImageIcon associated with the provided name, if the name
85
         * is present in the theme. If the icon not exists try to return
86
         * a icon with name "no-icon" or returns <code>null</code> if 
87
         * this not exists.
88
         *
89
         * @param name
90
         *                         The name whose associated icon is to be retrieved
91
         *
92
         * @return
93
         *                         The icon associated with the provided name
94
         */
95
        public ImageIcon get(String iconName);
96
        
97
        /**
98
         * Return the ThemeIcon associated with the name.
99
         *  
100
         * @param name of the icon
101
         * @return the IconTheme requiered
102
         */
103
        public Icon getThemeIcon(String name);
104

    
105
        public boolean isMyIcon(String name);
106
        
107
        /**
108
         * Gets the theme name of the theme
109
         * @return theme name
110
         */
111
        public String getName();
112

    
113
        /**
114
         * Sets the theme name of the theme
115
         *
116
         * @param themeName
117
         */
118
        public void setName(String themeName);
119

    
120
        public String getID();
121

    
122
        public void setID(String id);
123

    
124
        /**
125
         * Gets the theme description.
126
         *
127
         * @return The description of this theme.
128
         */
129
        public String getDescription();
130

    
131
        /**
132
         * Sets the theme description. It should be a short description
133
         * (around 20-30 words), including the highlights of the theme,
134
         * the author and maybe its email address or a link the the theme's
135
         * homepage.
136
         *
137
         * @param description
138
         */
139
        public void setDescription(String description);
140

    
141
        /**
142
         * Return an iterator over the names of the icons in the theme.
143
         * 
144
         * @return iterator of names of icons
145
         */
146
        public Iterator<String> iterator();
147

    
148
        /**
149
         * Return an iterator over the ThemIcon in the theme.
150
         *  
151
         * @return iterator of ThemeIcon
152
         */
153
        public Iterator<Icon> getThemeIcons();
154

    
155
        
156
        /**
157
         * Return the icon used as icon by default when the requested icon 
158
         * not exists.
159
         * 
160
         * @return the default icon to use.
161
         */
162
        public ImageIcon getDefaultIcon();
163
        
164
        /**
165
         * Set the default icon to use when the requestd icon not exists.
166
         * 
167
         * @param icon
168
         */
169
        public void setDefaultIcon(ImageIcon icon);
170

    
171
        public void setDefaultIcon(URL resource);
172

    
173
        public void setDefaultIcon(String name);
174

    
175
        /**
176
         * Register a icon in the theme.
177
         * The parameter icon can be null if the resource is specified.
178
         * The parameter resource can be null if the icon is specified. 
179
         * 
180
         * Plugin and group can be null.
181
         *  
182
         * @param provider name of the icon
183
         * @param group name for the icon.
184
         * @param name of icon
185
         * @param icon, can be nulll if the resource is specified. 
186
         * @param resource, resource of the icon, usualy and url to the icon.
187
         * 
188
         * @throws IllegalArgumentException if name is null/empty or icon/resource are null
189
         */
190
        public void registerDefault(String provider, String group, String name, ImageIcon icon, URL resource) throws IllegalArgumentException;
191
        
192
        public IconTheme.Icon registerDefault(String provider, String group, String subgroup, String name, ImageIcon icon, URL resource) throws IllegalArgumentException;
193

    
194
        /**
195
         * Register a icon in the theme.
196
         * The parameter icon can be null if the resource is specified.
197
         * The parameter resource can be null if the icon is specified. 
198
         * 
199
         * Plugin and group can be null.
200
         * 
201
         * @param provider name of the icon
202
         * @param group name for the icon.
203
         * @param name of icon
204
         * @param icon, can be nulll if the resource is specified. 
205
         * @param resource, resource of the icon, usualy and url to the icon.
206
         * 
207
         * @throws IllegalArgumentException if name is null/empty or icon/resource are null
208
         */
209
        public void register(String provider, String group, String name, ImageIcon icon, URL resource) throws IllegalArgumentException;
210

    
211
        public IconTheme.Icon register(String provider, String group, String subgroup, String name, ImageIcon icon, URL resource) throws IllegalArgumentException;
212

    
213
        public void export(File folder);
214
        
215
        /**
216
         * @deprecated use {@link #getDefaultIcon()} 
217
         * @return
218
         */
219
        public ImageIcon getNoIcon();
220
        
221
        /**
222
         * @deprecated use {@link #get(String)} instead
223
         */
224
        public ImageIcon get(String iconName, ClassLoader loader);
225

    
226
        /**
227
         * @deprecated use {@link #registerDefault(PluginServices, String, String, ImageIcon, Object)}
228
         */
229
        public void registerDefault(String iconName, ImageIcon image);
230

    
231
        /**
232
         * @deprecated use {@link #registerDefault(PluginServices, String, String, ImageIcon, Object)}
233
         */
234
        public void registerDefault(String iconName, Object resource);
235

    
236
        /**
237
         * @deprecated use {@link #register(PluginServices, String, String, ImageIcon, Object)}
238
         */
239
        public void register(String iconName, ImageIcon image);
240

    
241
        /**
242
         * @deprecated use {@link #register(PluginServices, String, String, ImageIcon, Object)}
243
         */
244
        public void register(String iconName, Object resource);
245

    
246
        public String getGroupDescription(String group);
247
        public String getSubgroupDescription(String group, String subgroup);
248
        
249
        public void setGroupDescription(String group, String description);
250
        public void setSubgroupDescription(String group, String subgroup, String description);
251

    
252

    
253
        public void addGroupImage(String group, URL resource);
254
        
255
        public List<SimpleImage> getGroupImages(String group);
256
        
257
        public void addSubgroupImage(String group, String subgroup, URL resource);
258
        
259
        public List<SimpleImage> getSubgroupImages(String group, String subgroup);
260
        
261
        public boolean matchID(String id);
262

    
263
}