KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > text > completion > IconStore


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.xml.text.completion;
20
21 import java.util.HashMap JavaDoc;
22
23 import javax.swing.ImageIcon JavaDoc;
24
25 /**
26  * @author Sandeep Singh Randhawa
27  * @version 0.1
28  */

29 final class IconStore extends Object JavaDoc {
30
31     public static final String JavaDoc EMPTY_TAG = "/org/netbeans/modules/xml/text/completion/resources/emptyTag";
32     public static final String JavaDoc END_TAG = "/org/netbeans/modules/xml/text/completion/resources/endTag";
33     public static final String JavaDoc CHILDREN = "/org/netbeans/modules/xml/text/completion/resources/typeChildren";
34     public static final String JavaDoc MIXED = "/org/netbeans/modules/xml/text/completion/resources/typeMixed";
35     public static final String JavaDoc PCDATA = "/org/netbeans/modules/xml/text/completion/resources/typePCDATA";
36     
37     public static final String JavaDoc TYPE_ENTITY = "/org/netbeans/modules/xml/text/completion/resources/attTypeENTITY";
38     public static final String JavaDoc TYPE_ENTITIES = "/org/netbeans/modules/xml/text/completion/resources/attTypeENTITIES";
39     public static final String JavaDoc TYPE_ENUMERATION = "/org/netbeans/modules/xml/text/completion/resources/attTypeEn";
40     public static final String JavaDoc TYPE_ID = "/org/netbeans/modules/xml/text/completion/resources/attTypeID";
41     public static final String JavaDoc TYPE_IDREF = "/org/netbeans/modules/xml/text/completion/resources/attTypeIDREF";
42     public static final String JavaDoc TYPE_IDREFS = "/org/netbeans/modules/xml/text/completion/resources/attTypeIDREFS";
43     public static final String JavaDoc TYPE_NMTOKEN = "/org/netbeans/modules/xml/text/completion/resources/attTypeNMTOKEN";
44     public static final String JavaDoc TYPE_NMTOKENS = "/org/netbeans/modules/xml/text/completion/resources/attTypeNMTOKENS";
45     public static final String JavaDoc TYPE_NOTATION = "/org/netbeans/modules/xml/text/completion/resources/attTypeNOTATION";
46     public static final String JavaDoc TYPE_CDATA = "/org/netbeans/modules/xml/text/completion/resources/typeCDATA";
47         
48     public static final String JavaDoc SPACER_16 = "/org/netbeans/modules/xml/text/completion/resources/spacer_16";
49     public static final String JavaDoc SPACER_8 = "/org/netbeans/modules/xml/text/completion/resources/spacer_8";
50     public static final String JavaDoc ICON_SUFFIX = ".gif";
51
52     /** HashMap{@link java.util.HashMap } that acts as a store for the icons.
53      */

54     private static HashMap JavaDoc iconsMap = new HashMap JavaDoc();
55     
56     /** Main method to retrieve the ImageIcon{@link javax.swing.ImageIcon}
57      * @param name Name of the icon to retrieve. In most instances would be one of the variables of
58      * this class.
59      * @return ImageIcon{@link javax.swing.ImageIcon}
60      */

61     
62     public static ImageIcon JavaDoc getImageIcon(String JavaDoc name){
63       if(name == null)
64         name = SPACER_16;
65       
66         if(iconsMap.containsKey(name))
67             return (ImageIcon JavaDoc)iconsMap.get(name);
68         else{
69             iconsMap.put(name, new ImageIcon JavaDoc(IconStore.class.getResource(name + ICON_SUFFIX)));
70             return (ImageIcon JavaDoc)iconsMap.get(name);
71         }
72     }
73 }
74
Popular Tags