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

History | View | Annotate | Download (6.2 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.Iterator;
30

    
31
import javax.swing.ImageIcon;
32

    
33
public interface IconTheme  {
34
        
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
        public boolean isMyIcon(String name);
93
        
94
        /**
95
         * Gets the theme name of the theme
96
         * @return theme name
97
         */
98
        public String getName();
99

    
100
        /**
101
         * Sets the theme name of the theme
102
         *
103
         * @param themeName
104
         */
105
        public void setName(String themeName);
106

    
107
        public String getID();
108

    
109
        public void setID(String id);
110

    
111
        /**
112
         * Gets the theme description.
113
         *
114
         * @return The description of this theme.
115
         */
116
        public String getDescription();
117

    
118
        /**
119
         * Sets the theme description. It should be a short description
120
         * (around 20-30 words), including the highlights of the theme,
121
         * the author and maybe its email address or a link the the theme's
122
         * homepage.
123
         *
124
         * @param description
125
         */
126
        public void setDescription(String description);
127

    
128
        /**
129
         * Return an iterator over the names of the icons in the theme.
130
         * 
131
         * @return iterator of names of icons
132
         */
133
        public Iterator<String> iterator();
134

    
135
        /**
136
         * Return an iterator over the ThemIcon in the theme.
137
         *  
138
         * @return iterator of ThemeIcon
139
         */
140
        public Iterator<Icon> getThemeIcons();
141

    
142
        
143
        /**
144
         * Return the icon used as icon by default when the requested icon 
145
         * not exists.
146
         * 
147
         * @return the default icon to use.
148
         */
149
        public ImageIcon getDefaultIcon();
150
        
151
        /**
152
         * Set the default icon to use when the requestd icon not exists.
153
         * 
154
         * @param icon
155
         */
156
        public void setDefaultIcon(ImageIcon icon);
157

    
158
        public void setDefaultIcon(URL resource);
159

    
160
        public void setDefaultIcon(String name);
161

    
162
        /**
163
         * Register a icon in the theme.
164
         * The parameter icon can be null if the resource is specified.
165
         * The parameter resource can be null if the icon is specified. 
166
         * 
167
         * Plugin and group can be null.
168
         *  
169
         * @param provider name of the icon
170
         * @param group name for the icon.
171
         * @param name of icon
172
         * @param icon, can be nulll if the resource is specified. 
173
         * @param resource, resource of the icon, usualy and url to the icon.
174
         * 
175
         * @throws IllegalArgumentException if name is null/empty or icon/resource are null
176
         */
177
        public void registerDefault(String provider, String group, String name, ImageIcon icon, URL resource) throws IllegalArgumentException;
178

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

    
196
        public void export(File folder);
197
        
198
        /**
199
         * @deprecated use {@link #getDefaultIcon()} 
200
         * @return
201
         */
202
        public ImageIcon getNoIcon();
203
        
204
        /**
205
         * @deprecated use {@link #get(String)} instead
206
         */
207
        public ImageIcon get(String iconName, ClassLoader loader);
208

    
209
        /**
210
         * @deprecated use {@link #registerDefault(PluginServices, String, String, ImageIcon, Object)}
211
         */
212
        public void registerDefault(String iconName, ImageIcon image);
213

    
214
        /**
215
         * @deprecated use {@link #registerDefault(PluginServices, String, String, ImageIcon, Object)}
216
         */
217
        public void registerDefault(String iconName, Object resource);
218

    
219
        /**
220
         * @deprecated use {@link #register(PluginServices, String, String, ImageIcon, Object)}
221
         */
222
        public void register(String iconName, ImageIcon image);
223

    
224
        /**
225
         * @deprecated use {@link #register(PluginServices, String, String, ImageIcon, Object)}
226
         */
227
        public void register(String iconName, Object resource);
228
}