View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2007 utgenome.org
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *--------------------------------------------------------------------------*/
16  //--------------------------------------
17  // GenomeBrowser Project
18  //
19  // Design.java
20  // Since: Jun 20, 2007
21  //
22  // $URL$ 
23  // $Author$
24  //--------------------------------------
25  package org.utgenome.gwt.utgb.client.track;
26  
27  import java.util.HashMap;
28  
29  import org.utgenome.gwt.utgb.client.ui.IconImage;
30  
31  import com.google.gwt.user.client.ui.Image;
32  
33  /**
34   * Design class gathers image file names
35   * 
36   * @author leo
37   * 
38   */
39  public class Design {
40  
41  	public static int ICON_UNKNOWN = 0;
42  	public static int ICON_CONFIG = 1;
43  	public static int ICON_PACK = 2;
44  	public static int ICON_UNPACK = 3;
45  	public static int ICON_HIDE = 4;
46  	public static int ICON_SHOW = 5;
47  	public static int ICON_CLOSE = 6;
48  	public static int TRACK_BORDER_V = 101;
49  	public static int TRACK_BORDER_H = 102;
50  
51  	public static String PREFIX = "theme/image/";
52  
53  	public static String IMAGE_NOT_AVAILABLE = PREFIX + "na.png";
54  	public static String IMAGE_RULER_TICK = PREFIX + "ruler-tick.gif";
55  	public static String IMAGE_TRANSPARENT = PREFIX + "transparent.gif";
56  	public static String IMAGE_DELETE_BUTTON = PREFIX + "tree_closed.gif";
57  	public static String IMAGE_NOW_LOADING = PREFIX + "nowloading.gif";
58  
59  	private static HashMap<Integer, IconImage> _iconTable = new HashMap<Integer, IconImage>();
60  
61  	static {
62  		// prefetch images
63  		Image.prefetch(IMAGE_NOT_AVAILABLE);
64  		Image.prefetch(IMAGE_RULER_TICK);
65  		Image.prefetch(IMAGE_TRANSPARENT);
66  		Image.prefetch(IMAGE_DELETE_BUTTON);
67  		Image.prefetch(IMAGE_NOW_LOADING);
68  
69  		// track frame icon
70  		addIcon(ICON_UNKNOWN, new IconImage(PREFIX + "transparent.gif", PREFIX + "transparent.gif"));
71  		addIcon(ICON_CONFIG, new IconImage(PREFIX + "track-config.gif", PREFIX + "track-config-w.gif"));
72  		addIcon(ICON_PACK, new IconImage(PREFIX + "track-pack.gif", PREFIX + "track-pack-w.gif"));
73  		addIcon(ICON_UNPACK, new IconImage(PREFIX + "track-unpack.gif", PREFIX + "track-unpack.gif"));
74  		addIcon(ICON_HIDE, new IconImage(PREFIX + "track-hide.gif", PREFIX + "track-hide-w.gif"));
75  		addIcon(ICON_SHOW, new IconImage(PREFIX + "track-open.gif", PREFIX + "track-open-w.gif"));
76  		addIcon(ICON_CLOSE, new IconImage(PREFIX + "track-close.gif", PREFIX + "track-close-w.gif"));
77  
78  		// track frame
79  		addIcon(TRACK_BORDER_V, new IconImage(PREFIX + "dragbar.png", PREFIX + "dragbar_active.png"));
80  		addIcon(TRACK_BORDER_H, new IconImage(PREFIX + "resizebar.png", PREFIX + "resizebar_active.png"));
81  	}
82  
83  	public static void addIcon(int iconType, IconImage icon) {
84  		_iconTable.put(new Integer(iconType), icon);
85  	}
86  
87  	/**
88  	 * Get the icon image URL
89  	 * 
90  	 * @param iconType
91  	 * @return the {@link IconImage} class
92  	 */
93  	public static IconImage getIconImage(int iconType) {
94  		Integer key = new Integer(iconType);
95  		if (_iconTable.containsKey(key))
96  			return _iconTable.get(key);
97  		else
98  			return _iconTable.get(new Integer(ICON_UNKNOWN));
99  
100 	}
101 
102 	/**
103 	 * Non constructable
104 	 */
105 	private Design() {
106 	}
107 }