2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.bin;
\r
27 * Stores and retrieves Jalview Application Properties
\r
28 * <br><br>Current properties include:
\r
29 * <br>logs.Axis.Level - one of the stringified Levels for log4j controlling the logging level for axis (used for web services)
\r
30 * <br>logs.Castor.Level - one of the stringified Levels for log4j controlling the logging level for castor (used for serialization)
\r
31 * <br>jalview.browser - used in the jalview.utils.browserLauncher class if it doesn't know what else to do.
\r
32 * <br>SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_Y=285,SCREEN_X=371,SHOW_FULLSCREEN
\r
33 * FONT_NAME,FONT_SIZE,FONT_STYLE,GAP_SYMBOL,LAST_DIRECTORY,USER_DEFINED_COLOUR
\r
34 * SHOW_FULL_ID,SHOW_IDENTITY,SHOW_QUALITY,SHOW_ANNOTATIONS,SHOW_CONSERVATION,
\r
35 * DEFAULT_COLOUR,DEFAULT_FILE_FORMAT,STARTUP_FILE,SHOW_STARTUP_FILE
\r
38 * @version $Revision$
\r
42 /** Current release tag */
\r
43 public static String VERSION = "AW Test";
\r
45 /** Date Jalview was last packaged, else compilation date of Cache.class */
\r
46 public static String BUILD_DATE = "";
\r
48 /** Jalview Properties */
\r
49 public static Properties applicationProperties;
\r
51 /** Default file is ~/.jalview_properties */
\r
52 static String propertiesFile;
\r
54 /** Called when Jalview is started */
\r
55 public static void loadProperties(String propsFile)
\r
57 propertiesFile = propsFile;
\r
58 if (propsFile == null)
\r
60 propertiesFile = System.getProperty("user.home") + "/.jalview_properties";
\r
64 // get last build time.
\r
69 String localFile = Cache.class.getProtectionDomain().getCodeSource()
\r
70 .getLocation().toString();
\r
71 localFile = localFile.concat("!/");
\r
73 String tmpString = "jar:";
\r
74 String localJarFileString = tmpString.concat(localFile);
\r
75 java.net.URL localJarFileURL = new java.net.URL(localJarFileString);
\r
76 java.net.JarURLConnection localJarFile = (java.net.JarURLConnection) localJarFileURL.openConnection();
\r
77 date = localJarFile.getLastModified();
\r
79 catch (Exception ex)
\r
81 ex.printStackTrace();
\r
86 // this is called for unpackaged class files, ie not in a Jar file
\r
87 // InstallAnywhere version will find build date this way
\r
88 // not entirely accurate as it only tells you when Cache.class was last compiled
\r
89 java.io.File f = new java.io.File(System.getProperty("user.dir") +
\r
90 "/jalview/bin/Cache.class");
\r
91 date = f.lastModified();
\r
96 BUILD_DATE = new Date(date).toString();
\r
99 applicationProperties = new Properties();
\r
103 FileInputStream in = new FileInputStream(propertiesFile);
\r
104 applicationProperties = new Properties();
\r
105 applicationProperties.load(in);
\r
108 catch (Exception ex)
\r
114 * Gets Jalview application property of given key. Returns null
\r
117 * @param key Name of property
\r
119 * @return Property value
\r
121 public static String getProperty(String key)
\r
123 return applicationProperties.getProperty(key);
\r
127 * Stores property in the file "HOME_DIR/.jalview_properties"
\r
129 * @param key Name of object
\r
130 * @param obj String value of property
\r
132 * @return String value of property
\r
134 public static String setProperty(String key, String obj)
\r
138 FileOutputStream out = new FileOutputStream(propertiesFile);
\r
140 applicationProperties.setProperty(key, obj);
\r
142 applicationProperties.store(out, "---JalviewX Properties File---");
\r
145 catch (Exception ex)
\r