01: /*
02: * uDig - User Friendly Desktop Internet GIS client
03: * http://udig.refractions.net
04: * (C) 2004, Refractions Research Inc.
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library 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 GNU
14: * Lesser General Public License for more details.
15: *
16: */
17: package net.refractions.udig.internal.ui;
18:
19: import org.eclipse.jface.resource.ImageDescriptor;
20: import org.eclipse.jface.resource.ImageRegistry;
21: import org.eclipse.swt.graphics.Image;
22:
23: /**
24: * The image descriptors for the plugin
25: */
26: public class Images {
27:
28: static ImageRegistry registry() {
29: return UiPlugin.getDefault().getImageRegistry();
30: }
31:
32: /**
33: * Returns the image descriptor for ID, or null if not found.
34: * <p>
35: * Images are from RegistryUIPlugin.getDefault().getImages()
36: * </p>
37: * @return ImageDescriptor, or null if there is no such image.
38: */
39: public static ImageDescriptor getDescriptor(String id) {
40: ImageDescriptor found = registry().getDescriptor(id);
41: if (found != null) {
42: return found;
43: }
44: return UiPlugin.getDefault().create(id);
45: }
46:
47: /**
48: * Returns the image associated with the given key,
49: * or <code>null</code> if none.
50: *
51: * @param key the key
52: * @return the image, or <code>null</code> if none
53: */
54: public static Image get(String id) {
55: Image found = registry().get(id);
56: if (found == null) {
57: UiPlugin.getDefault().create(id);
58: }
59: return registry().get(id);
60: }
61:
62: }
|