KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > planetamessenger > mos > engine > JResources


1 /*
2     =========================================================================
3     Package engine - Implements the engine package.
4
5     This module is developed and maintained by PlanetaMessenger.org.
6     Specs, New and updated versions can be found in
7     http://www.planetamessenger.org
8     If you want contact the Team please send a email to Project Manager
9     Leidson Campos Alves Ferreira at leidson@planetamessenger.org
10
11     Copyright (C) since 2001 by PlanetaMessenger.org
12
13     This program is free software; you can redistribute it and/or modify
14     it under the terms of the GNU General Public License as published by
15     the Free Software Foundation; either version 2 of the License, or
16     (at your option) any later version.
17
18     This program is distributed in the hope that it will be useful,
19     but WITHOUT ANY WARRANTY; without even the implied warranty of
20     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21     GNU General Public License for more details.
22
23     You should have received a copy of the GNU General Public License
24     along with this program; if not, write to the Free Software
25     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27     =========================================================================
28 */

29 /**
30  *
31  * $Id: JResources.java,v 1.31 2007/01/28 17:39:20 popolony2k Exp $
32  * $Author: popolony2k $
33  * $Name: $
34  * $Revision: 1.31 $
35  * $State: Exp $
36  *
37  */

38
39 package org.planetamessenger.mos.engine;
40
41 import java.util.*;
42 import java.util.jar.*;
43 import javax.swing.*;
44 import org.planetamessenger.ui.*;
45 import org.planetamessenger.plugin.*;
46
47
48 public class JResources {
49   
50   static public final int DEFAULT_BUTTON_WIDTH = 110;
51   static public final int DEFAULT_BUTTON_HEIGHT = 40;
52   static public final int BUTTON_WIDTH_16 = 16;
53   static public final int BUTTON_HEIGHT_16 = 16;
54   static public final int ICON_WIDTH_16 = 16;
55   static public final int ICON_HEIGHT_16 = 16;
56   static public final int ICON_WIDTH_32 = 32;
57   static public final int ICON_HEIGHT_32 = 32;
58
59   static public final int SPLASH_WINDOW_BACKGROUND = JPlugin.STATUS_LAST + 1;
60   static public final int LOADING_ICON = JPlugin.STATUS_LAST + 2;
61   static public final int MESSAGE_BLINK = JPlugin.STATUS_LAST + 3;
62   static public final int ADD_INVITE_ICON = JPlugin.STATUS_LAST + 4;
63   static public final int MY_MESSENGER_ICON = JPlugin.STATUS_LAST + 5;
64   static public final int EXIT_ICON = JPlugin.STATUS_LAST + 6;
65   static public final int REMOVE_ICON = JPlugin.STATUS_LAST + 7;
66   static public final int ABOUT_ICON = JPlugin.STATUS_LAST + 8;
67   static public final int SETTINGS_ICON = JPlugin.STATUS_LAST + 9;
68   static public final int MESSAGE_ICON = JPlugin.STATUS_LAST + 10;
69   static public final int ACCOUNTS_ICON = JPlugin.STATUS_LAST + 11;
70   static public final int CONTACTS_ICON = JPlugin.STATUS_LAST + 12;
71   static public final int PROFILE_ICON = JPlugin.STATUS_LAST + 13;
72   static public final int CONSOLE_ICON = JPlugin.STATUS_LAST + 14;
73   static public final int SEND_IM_ICON = JPlugin.STATUS_LAST + 15;
74   static public final int USER_DETAIL_ICON = JPlugin.STATUS_LAST + 16;
75   static public final int OK_BUTTON_ICON = JPlugin.STATUS_LAST + 17;
76   static public final int CLOSE_BUTTON_ICON = JPlugin.STATUS_LAST + 18;
77   static public final int UPDATE_NAME_ICON = JPlugin.STATUS_LAST + 19;
78   static public final int APPLICATION_ICON = JPlugin.STATUS_LAST + 20;
79   static public final int PROXY_SETTINGS_ICON = JPlugin.STATUS_LAST + 21;
80   static public final int NEW_ICON = JPlugin.STATUS_LAST + 22;
81   static public final int RENAME_ICON = JPlugin.STATUS_LAST + 23;
82   static public final int ADD_PLUGIN_ICON = JPlugin.STATUS_LAST + 24;
83   static public final int REMOVE_PLUGIN_ICON = JPlugin.STATUS_LAST + 25;
84   static public final int APPLY_BUTTON_ICON = JPlugin.STATUS_LAST + 26;
85   static public final int REMOVE_FILE_ICON = JPlugin.STATUS_LAST + 27;
86   static public final int PLUGIN_ICON = JPlugin.STATUS_LAST + 28;
87   static public final int LOOKNFEEL_ICON = JPlugin.STATUS_LAST + 29;
88   static public final int RELOAD_ICON = JPlugin.STATUS_LAST + 30;
89   static public final int LANGUAGE_ICON = JPlugin.STATUS_LAST + 31;
90   static public final int CLOSE_TAB_ICON = JPlugin.STATUS_LAST + 32;
91   static public final int LOADING_STARTUP_ICON = JPlugin.STATUS_LAST + 33;
92   static public final int INSTALL_PLUGIN_ICON = JPlugin.STATUS_LAST + 34;
93   static public final int UNINSTALL_PLUGIN_ICON = JPlugin.STATUS_LAST + 35;
94   static public final int LOADING_32_ICON = JPlugin.STATUS_LAST + 36;
95   static public final int BLOCK_16_ICON = JPlugin.STATUS_LAST + 37;
96   static public final int UNBLOCK_16_ICON = JPlugin.STATUS_LAST + 38;
97
98   String JavaDoc strResPath;
99   HashMap<Integer JavaDoc, Icon> hIconsList = null;
100   HashMap<Integer JavaDoc, Icon> hImagesList = null;
101
102   
103   /**
104    * Init the resources class.
105    * @param strResourcesPath The application resources
106    * path;
107    */

108   public JResources( String JavaDoc strResourcesPath ) {
109   
110     strResPath = strResourcesPath;
111     
112     loadIcons();
113     loadImages();
114   }
115
116   /**
117    * Get a specified icon.
118    * @param nIcon The icon that will be retrieved;
119    */

120   public javax.swing.ImageIcon JavaDoc getIcon( int nIcon ) {
121     
122     return ( javax.swing.ImageIcon JavaDoc ) hIconsList.get( new Integer JavaDoc( nIcon ) );
123   }
124
125   /**
126    * Get a specified image.
127    * @param nImage The image that will be retrieved;
128    */

129   public javax.swing.ImageIcon JavaDoc getImage( int nImage ) {
130     
131     return ( javax.swing.ImageIcon JavaDoc ) hImagesList.get( new Integer JavaDoc( nImage ) );
132   }
133   
134   /**
135    * Load all icons from icons jar file.
136    */

137   private void loadIcons() {
138     
139     String JavaDoc strJarFile = strResPath + "icons.jar";
140     
141     
142     hIconsList = new HashMap<Integer JavaDoc, Icon>();
143     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_OFFLINE ), JImage.loadIconFromJar( strJarFile, "icons/offline.gif" ) );
144     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_ONLINE ), JImage.loadIconFromJar( strJarFile, "icons/online.gif" ) );
145     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_CUSTOM ), JImage.loadIconFromJar( strJarFile, "icons/online.gif" ) );
146     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_FREE_CHAT ), JImage.loadIconFromJar( strJarFile, "icons/freeforchat.gif" ) );
147     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_INVISIBLE ), JImage.loadIconFromJar( strJarFile, "icons/invisible.gif" ) );
148     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_AWAY ), JImage.loadIconFromJar( strJarFile, "icons/away.gif" ) );
149     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_IDLE ), JImage.loadIconFromJar( strJarFile, "icons/away.gif" ) );
150     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_BUSY ), JImage.loadIconFromJar( strJarFile, "icons/busy.gif" ) );
151     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_DND ), JImage.loadIconFromJar( strJarFile, "icons/dnd.gif" ) );
152     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_ON_PHONE ), JImage.loadIconFromJar( strJarFile, "icons/onphone.gif" ) );
153     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_ON_LUNCH ), JImage.loadIconFromJar( strJarFile, "icons/onlunch.gif" ) );
154     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_NOT_AT_HOME ), JImage.loadIconFromJar( strJarFile, "icons/notathome.gif" ) );
155     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_NOT_IN_OFFICE ), JImage.loadIconFromJar( strJarFile, "icons/notinoffice.gif" ) );
156     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_NOT_AT_DESK ), JImage.loadIconFromJar( strJarFile, "icons/notatdesk.gif" ) );
157     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_ON_VACATION ), JImage.loadIconFromJar( strJarFile, "icons/onvacation.gif" ) );
158     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_MESSAGE ), JImage.loadIconFromJar( strJarFile, "icons/message.gif" ) );
159     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_URL ), JImage.loadIconFromJar( strJarFile, "icons/url.gif" ) );
160     hIconsList.put( new Integer JavaDoc( JPlugin.STATUS_NOT_IN_LIST ), JImage.loadIconFromJar( strJarFile, "icons/notinlist.gif" ) );
161     hIconsList.put( new Integer JavaDoc( LOADING_ICON ), JImage.loadIconFromJar( strJarFile, "icons/loading.gif" ) );
162     hIconsList.put( new Integer JavaDoc( MESSAGE_BLINK ), JImage.loadIconFromJar( strJarFile, "icons/message_blink.gif" ) );
163     hIconsList.put( new Integer JavaDoc( ADD_INVITE_ICON ), JImage.loadIconFromJar( strJarFile, "icons/add_invite_16.gif" ) );
164     hIconsList.put( new Integer JavaDoc( MY_MESSENGER_ICON ), JImage.loadIconFromJar( strJarFile, "icons/my_messenger_16.gif" ) );
165     hIconsList.put( new Integer JavaDoc( EXIT_ICON ), JImage.loadIconFromJar( strJarFile, "icons/exit_16.gif" ) );
166     hIconsList.put( new Integer JavaDoc( REMOVE_ICON ), JImage.loadIconFromJar( strJarFile, "icons/remove_16.gif" ) );
167     hIconsList.put( new Integer JavaDoc( ABOUT_ICON ), JImage.loadIconFromJar( strJarFile, "icons/about_16.gif" ) );
168     hIconsList.put( new Integer JavaDoc( SETTINGS_ICON ), JImage.loadIconFromJar( strJarFile, "icons/settings_16.gif" ) );
169     hIconsList.put( new Integer JavaDoc( MESSAGE_ICON ), JImage.loadIconFromJar( strJarFile, "icons/message_16.gif" ) );
170     hIconsList.put( new Integer JavaDoc( ACCOUNTS_ICON ), JImage.loadIconFromJar( strJarFile, "icons/accounts_16.gif" ) );
171     hIconsList.put( new Integer JavaDoc( CONTACTS_ICON ), JImage.loadIconFromJar( strJarFile, "icons/contacts_16.gif" ) );
172     hIconsList.put( new Integer JavaDoc( PROFILE_ICON ), JImage.loadIconFromJar( strJarFile, "icons/profile_16.gif" ) );
173     hIconsList.put( new Integer JavaDoc( CONSOLE_ICON ), JImage.loadIconFromJar( strJarFile, "icons/terminal_16.gif" ) );
174     hIconsList.put( new Integer JavaDoc( SEND_IM_ICON ), JImage.loadIconFromJar( strJarFile, "icons/sendmessage_24.gif" ) );
175     hIconsList.put( new Integer JavaDoc( USER_DETAIL_ICON ), JImage.loadIconFromJar( strJarFile, "icons/userdetail_16.gif" ) );
176     hIconsList.put( new Integer JavaDoc( OK_BUTTON_ICON ), JImage.loadIconFromJar( strJarFile, "icons/ok_24.gif" ) );
177     hIconsList.put( new Integer JavaDoc( CLOSE_BUTTON_ICON ), JImage.loadIconFromJar( strJarFile, "icons/close_24.gif" ) );
178     hIconsList.put( new Integer JavaDoc( UPDATE_NAME_ICON ), JImage.loadIconFromJar( strJarFile, "icons/refresh_16.gif" ) );
179     hIconsList.put( new Integer JavaDoc( APPLICATION_ICON ), JImage.loadIconFromJar( strJarFile, "icons/planet_24.gif" ) );
180     hIconsList.put( new Integer JavaDoc( PROXY_SETTINGS_ICON ), JImage.loadIconFromJar( strJarFile, "icons/proxy_settings_16.gif" ) );
181     hIconsList.put( new Integer JavaDoc( NEW_ICON ), JImage.loadIconFromJar( strJarFile, "icons/new_24.gif" ) );
182     hIconsList.put( new Integer JavaDoc( RENAME_ICON ), JImage.loadIconFromJar( strJarFile, "icons/rename_16.gif" ) );
183     hIconsList.put( new Integer JavaDoc( ADD_PLUGIN_ICON ), JImage.loadIconFromJar( strJarFile, "icons/add_plugin_24.gif" ) );
184     hIconsList.put( new Integer JavaDoc( REMOVE_PLUGIN_ICON ), JImage.loadIconFromJar( strJarFile, "icons/remove_plugin_24.gif" ) );
185     hIconsList.put( new Integer JavaDoc( APPLY_BUTTON_ICON ), JImage.loadIconFromJar( strJarFile, "icons/apply_24.gif" ) );
186     hIconsList.put( new Integer JavaDoc( REMOVE_FILE_ICON ), JImage.loadIconFromJar( strJarFile, "icons/remove_24.gif" ) );
187     hIconsList.put( new Integer JavaDoc( PLUGIN_ICON ), JImage.loadIconFromJar( strJarFile, "icons/plugin_16.gif" ) );
188     hIconsList.put( new Integer JavaDoc( LOOKNFEEL_ICON ), JImage.loadIconFromJar( strJarFile, "icons/looknfeel_16.gif" ) );
189     hIconsList.put( new Integer JavaDoc( RELOAD_ICON ), JImage.loadIconFromJar( strJarFile, "icons/reload_24.gif" ) );
190     // TODO: CHANGE THIS ICON
191
hIconsList.put( new Integer JavaDoc( LANGUAGE_ICON ), JImage.loadIconFromJar( strJarFile, "icons/looknfeel_16.gif" ) );
192     // END OF TODO
193
hIconsList.put( new Integer JavaDoc( CLOSE_TAB_ICON ), JImage.loadIconFromJar( strJarFile, "icons/close_tab_16.gif" ) );
194     hIconsList.put( new Integer JavaDoc( LOADING_STARTUP_ICON ), JImage.loadIconFromJar( strJarFile, "icons/loading_classic.gif" ) );
195     hIconsList.put( new Integer JavaDoc( INSTALL_PLUGIN_ICON ), JImage.loadIconFromJar( strJarFile, "icons/install_plugin_16.png" ) );
196     hIconsList.put( new Integer JavaDoc( UNINSTALL_PLUGIN_ICON ), JImage.loadIconFromJar( strJarFile, "icons/uninstall_plugin_16.png" ) );
197     hIconsList.put( new Integer JavaDoc( LOADING_32_ICON ), JImage.loadIconFromJar( strJarFile, "icons/loading_32.gif" ) );
198     hIconsList.put( new Integer JavaDoc( BLOCK_16_ICON ), JImage.loadIconFromJar( strJarFile, "icons/block_16.png" ) );
199     hIconsList.put( new Integer JavaDoc( UNBLOCK_16_ICON ), JImage.loadIconFromJar( strJarFile, "icons/unblock_16.png" ) );
200   }
201
202   /**
203    * Load all images from images jar file.
204    */

205   private void loadImages() {
206
207     String JavaDoc strJarFile = strResPath + "images.jar";
208
209     hImagesList = new HashMap<Integer JavaDoc, Icon>();
210     hImagesList.put( new Integer JavaDoc( SPLASH_WINDOW_BACKGROUND ), JImage.loadIconFromJar( strJarFile, "images/splash_window.gif" ) );
211   }
212 }
213
214 // JResources class
Popular Tags