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

History | View | Annotate | Download (5.21 KB)

1
package org.gvsig.tools.swing.icontheme;
2

    
3
import java.awt.Image;
4
import java.io.File;
5
import java.net.URL;
6
import java.util.Iterator;
7

    
8
import javax.swing.ImageIcon;
9

    
10
public interface IconTheme {
11
        
12
        public static final String NO_ICON_NAME = "-no-icon-";
13

    
14
        interface Icon extends Comparable<Icon> {
15
                public String getName();
16
                public String getGroup() ;
17
                public ImageIcon getImageIcon();
18
                public Image getImage();
19
                public Object getResource() ;
20
                public URL getURL() ;
21
                public String getLabel();
22
                public String getProviderName();
23
        }
24

    
25
        /**
26
         * Load all icons from the IconTheme
27
         */
28
        public void load(Object resource) throws IllegalArgumentException;
29
        
30

    
31
        public void setDefault(IconTheme def);
32

    
33
        public IconTheme getDefault();
34

    
35
        /**
36
         * Returns <code>true</code> if the icon theme contains a mapping for the
37
         * specified iconName.
38
         *
39
         * @param iconName The key to check if it has been registered in this
40
         * IconTheme
41
         *
42
         * @return <code>true</code> if this IconTheme contains
43
         * <code>iconName</code>, <code>false</code> otherwise.
44
         */
45
        public boolean exists(String name);
46

    
47
        /**
48
         * Gets the ImageIcon associated with the provided name, if the name
49
         * is present in the theme. If the icon not exists try to return
50
         * a icon with name "no-icon" or returns <code>null</code> if 
51
         * this not exists.
52
         *
53
         * @param name
54
         *                         The name whose associated icon is to be retrieved
55
         *
56
         * @return
57
         *                         The icon associated with the provided name
58
         */
59
        public ImageIcon get(String iconName);
60
        
61
        /**
62
         * Return the ThemeIcon associated with the name.
63
         *  
64
         * @param name of the icon
65
         * @return the IconTheme requiered
66
         */
67
        public Icon getThemeIcon(String name);
68

    
69
        /**
70
         * Gets the theme name of the theme
71
         * @return theme name
72
         */
73
        public String getName();
74

    
75
        /**
76
         * Sets the theme name of the theme
77
         *
78
         * @param themeName
79
         */
80
        public void setName(String themeName);
81

    
82
        public String getID();
83

    
84
        public void setID(String id);
85

    
86
        /**
87
         * Gets the theme description.
88
         *
89
         * @return The description of this theme.
90
         */
91
        public String getDescription();
92

    
93
        /**
94
         * Sets the theme description. It should be a short description
95
         * (around 20-30 words), including the highlights of the theme,
96
         * the author and maybe its email address or a link the the theme's
97
         * homepage.
98
         *
99
         * @param description
100
         */
101
        public void setDescription(String description);
102

    
103
        /**
104
         * Return an iterator over the names of the icons in the theme.
105
         * 
106
         * @return iterator of names of icons
107
         */
108
        public Iterator<String> iterator();
109

    
110
        /**
111
         * Return an iterator over the ThemIcon in the theme.
112
         *  
113
         * @return iterator of ThemeIcon
114
         */
115
        public Iterator<Icon> getThemeIcons();
116

    
117
        
118
        /**
119
         * Return the icon used as icon by default when the requested icon 
120
         * not exists.
121
         * 
122
         * @return the default icon to use.
123
         */
124
        public ImageIcon getDefaultIcon();
125
        
126
        /**
127
         * Set the default icon to use when the requestd icon not exists.
128
         * 
129
         * @param icon
130
         */
131
        public void setDefaultIcon(ImageIcon icon);
132

    
133
        public void setDefaultIcon(URL resource);
134

    
135
        public void setDefaultIcon(String name);
136

    
137
        /**
138
         * Register a icon in the theme.
139
         * The parameter icon can be null if the resource is specified.
140
         * The parameter resource can be null if the icon is specified. 
141
         * 
142
         * Plugin and group can be null.
143
         *  
144
         * @param provider name of the icon
145
         * @param group name for the icon.
146
         * @param name of icon
147
         * @param icon, can be nulll if the resource is specified. 
148
         * @param resource, resource of the icon, usualy and url to the icon.
149
         * 
150
         * @throws IllegalArgumentException if name is null/empty or icon/resource are null
151
         */
152
        public void registerDefault(String provider, String group, String name, ImageIcon icon, URL resource) throws IllegalArgumentException;
153

    
154
        /**
155
         * Register a icon in the theme.
156
         * The parameter icon can be null if the resource is specified.
157
         * The parameter resource can be null if the icon is specified. 
158
         * 
159
         * Plugin and group can be null.
160
         * 
161
         * @param provider name of the icon
162
         * @param group name for the icon.
163
         * @param name of icon
164
         * @param icon, can be nulll if the resource is specified. 
165
         * @param resource, resource of the icon, usualy and url to the icon.
166
         * 
167
         * @throws IllegalArgumentException if name is null/empty or icon/resource are null
168
         */
169
        public void register(String provider, String group, String name, ImageIcon icon, URL resource) throws IllegalArgumentException;
170

    
171
        public void export(File folder);
172
        
173
        /**
174
         * @deprecated use {@link #getDefaultIcon()} 
175
         * @return
176
         */
177
        public ImageIcon getNoIcon();
178
        
179
        /**
180
         * @deprecated use {@link #get(String)} instead
181
         */
182
        public ImageIcon get(String iconName, ClassLoader loader);
183

    
184
        /**
185
         * @deprecated use {@link #registerDefault(PluginServices, String, String, ImageIcon, Object)}
186
         */
187
        public void registerDefault(String iconName, ImageIcon image);
188

    
189
        /**
190
         * @deprecated use {@link #registerDefault(PluginServices, String, String, ImageIcon, Object)}
191
         */
192
        public void registerDefault(String iconName, Object resource);
193

    
194
        /**
195
         * @deprecated use {@link #register(PluginServices, String, String, ImageIcon, Object)}
196
         */
197
        public void register(String iconName, ImageIcon image);
198

    
199
        /**
200
         * @deprecated use {@link #register(PluginServices, String, String, ImageIcon, Object)}
201
         */
202
        public void register(String iconName, Object resource);
203
}