2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.datamodel.DBRefSource;
24 import jalview.structure.StructureImportSettings;
25 import jalview.ws.dbsources.das.api.DasSourceRegistryI;
26 import jalview.ws.dbsources.das.datamodel.DasSourceRegistry;
27 import jalview.ws.sifts.SiftsSettings;
29 import java.awt.Color;
30 import java.io.BufferedReader;
32 import java.io.FileInputStream;
33 import java.io.FileOutputStream;
34 import java.io.InputStream;
35 import java.io.InputStreamReader;
36 import java.text.DateFormat;
37 import java.text.SimpleDateFormat;
38 import java.util.Collections;
39 import java.util.Date;
40 import java.util.Enumeration;
41 import java.util.Properties;
42 import java.util.TreeSet;
44 import org.apache.log4j.ConsoleAppender;
45 import org.apache.log4j.Level;
46 import org.apache.log4j.Logger;
47 import org.apache.log4j.SimpleLayout;
50 * Stores and retrieves Jalview Application Properties Lists and fields within
51 * list entries are separated by '|' symbols unless otherwise stated (|) clauses
52 * are alternative values for a tag. <br>
54 * Current properties include:
57 * logs.Axis.Level - one of the stringified Levels for log4j controlling the
58 * logging level for axis (used for web services) <br>
60 * <li>logs.Castor.Level - one of the stringified Levels for log4j controlling
61 * the logging level for castor (used for serialization) <br>
63 * <li>logs.Jalview.Level - Cache.log stringified level. <br>
65 * <li>SCREEN_WIDTH</li>
66 * <li>SCREEN_HEIGHT</li>
67 * <li>SCREEN_Y=285</li>
68 * <li>SCREEN_X=371</li>
69 * <li>SHOW_FULLSCREEN boolean</li>
70 * <li>FONT_NAME java font name for alignment text display</li>
71 * <li>FONT_SIZE size of displayed alignment text</li>
72 * <li>FONT_STYLE style of font displayed (sequence labels are always italic)</li>
73 * <li>GAP_SYMBOL character to treat as gap symbol (usually -,.,' ')</li>
74 * <li>LAST_DIRECTORY last directory for browsing alignment</li>
75 * <li>USER_DEFINED_COLOURS list of user defined colour scheme files</li>
76 * <li>SHOW_FULL_ID show id with '/start-end' numbers appended</li>
77 * <li>SHOW_IDENTITY show percentage identity annotation</li>
78 * <li>SHOW_QUALITY show alignment quality annotation</li>
79 * <li>SHOW_ANNOTATIONS show alignment annotation rows</li>
80 * <li>SHOW_CONSERVATION show alignment conservation annotation</li>
81 * <li>SORT_ANNOTATIONS currently either SEQUENCE_AND_LABEL or
82 * LABEL_AND_SEQUENCE</li>
83 * <li>SHOW_AUTOCALC_ABOVE true to show autocalculated annotations above
84 * sequence annotations</li>
85 * <li>CENTRE_COLUMN_LABELS centre the labels at each column in a displayed
87 * <li>DEFAULT_COLOUR default colour scheme to apply for a new alignment</li>
88 * <li>DEFAULT_FILE_FORMAT file format used to save</li>
89 * <li>STARTUP_FILE file loaded on startup (may be a fully qualified url)</li>
90 * <li>SHOW_STARTUP_FILE flag to control loading of startup file</li>
91 * <li>VERSION the version of the jalview build</li>
92 * <li>BUILD_DATE date of this build</li>
93 * <li>LATEST_VERSION the latest jalview version advertised on the
94 * www.jalview.org</li>
95 * <li>PIR_MODELLER boolean indicating if PIR files are written with MODELLER
97 * <li>(FASTA,MSF,PILEUP,CLUSTAL,BLC,PIR,PFAM)_JVSUFFIX boolean for adding jv
99 * <li>RECENT_URL list of recently retrieved URLs</li>
100 * <li>RECENT_FILE list of recently opened files</li>
101 * <li>USE_PROXY flag for whether a http proxy is to be used</li>
102 * <li>PROXY_SERVER the proxy</li>
103 * <li>PROXY_PORT</li>
104 * <li>NOQUESTIONNAIRES true to prevent jalview from checking the questionnaire
106 * <li>QUESTIONNAIRE last questionnaire:responder id string from questionnaire
108 * <li>USAGESTATS (false - user prompted) Enable google analytics tracker for
109 * collecting usage statistics</li>
110 * <li>DAS_LOCAL_SOURCE list of local das sources</li>
111 * <li>SHOW_OVERVIEW boolean for overview window display</li>
112 * <li>ANTI_ALIAS boolean for smooth fonts</li>
113 * <li>RIGHT_ALIGN_IDS boolean</li>
114 * <li>AUTO_CALC_CONSENSUS boolean for automatic recalculation of consensus</li>
115 * <li>PAD_GAPS boolean</li>
116 * <li>ID_ITALICS boolean</li>
117 * <li>SHOW_JV_SUFFIX</li>
118 * <li>WRAP_ALIGNMENT</li>
119 * <li>EPS_RENDERING (Prompt each time|Lineart|Text) default for EPS rendering
121 * <li>SORT_ALIGNMENT (No sort|Id|Pairwise Identity)</li>
122 * <li>SEQUENCE_LINKS list of name|URL pairs for opening a url with
124 * <li>GROUP_LINKS list of name|URL[|<separator>] tuples - see
125 * jalview.utils.GroupURLLink for more info</li>
126 * <li>DAS_REGISTRY_URL the registry to query</li>
127 * <li>DEFAULT_BROWSER for unix</li>
128 * <li>DAS_ACTIVE_SOURCE list of active sources</li>
129 * <li>SHOW_MEMUSAGE boolean show memory usage and warning indicator on desktop
131 * <li>VERSION_CHECK (true) check for the latest release version from
132 * www.jalview.org (or the alias given by the www.jalview.org property)</li>
133 * <li>SHOW_NPFEATS_TOOLTIP (true) show non-positional features in the Sequence
135 * <li>SHOW_DBREFS_TOOLTIP (true) show Database Cross References in the Sequence
137 * <li>SHOW_UNCONSERVED (false) only render unconserved residues - conserved
138 * displayed as '.'</li>
139 * <li>SORT_BY_TREE (false) sort the current alignment view according to the
140 * order of a newly displayed tree</li>
141 * <li>DBFETCH_USEPICR (false) use PICR to recover valid DB references from
142 * sequence ID strings before attempting retrieval from any datasource</li>
143 * <li>SHOW_GROUP_CONSENSUS (false) Show consensus annotation for groups in the
145 * <li>SHOW_GROUP_CONSERVATION (false) Show conservation annotation for groups
146 * in the alignment.</li>
147 * <li>SHOW_CONSENSUS_HISTOGRAM (false) Show consensus annotation row's
149 * <li>SHOW_CONSENSUS_LOGO (false) Show consensus annotation row's sequence
151 * <li>NORMALISE_CONSENSUS_LOGO (false) Show consensus annotation row's sequence
152 * logo normalised to row height rather than histogram height.</li>
153 * <li>FOLLOW_SELECTIONS (true) Controls whether a new alignment view should
154 * respond to selections made in other alignments containing the same sequences.
156 * <li>JWS2HOSTURLS comma-separated list of URLs to try for JABAWS services</li>
157 * <li>SHOW_WSDISCOVERY_ERRORS (true) Controls if the web service URL discovery
158 * warning dialog box is displayed.</li>
159 * <li>ANNOTATIONCOLOUR_MIN (orange) Shade used for minimum value of annotation
160 * when shading by annotation</li>
161 * <li>ANNOTATIONCOLOUR_MAX (red) Shade used for maximum value of annotation
162 * when shading by annotation</li>
163 * <li>www.jalview.org (http://www.jalview.org) a property enabling all HTTP
164 * requests to be redirected to a mirror of http://www.jalview.org</li>
165 * <li>FIGURE_AUTOIDWIDTH (false) Expand the left hand column of an exported
166 * alignment figure to accommodate even the longest sequence ID or annotation
168 * <li>FIGURE_FIXEDIDWIDTH Specifies the width to use for the left-hand column
169 * when exporting an alignment as a figure (setting FIGURE_AUTOIDWIDTH to true
170 * will override this).</li>
171 * <li>STRUCT_FROM_PDB (false) derive secondary structure annotation from PDB
173 * <li>USE_RNAVIEW (false) use RNAViewer to derive secondary structure</li>
174 * <li>ADD_SS_ANN (false) add secondary structure annotation to alignment
176 * <li>ADD_TEMPFACT_ANN (false) add Temperature Factor annotation to alignment
178 * <li>STRUCTURE_DISPLAY choose from JMOL (default) or CHIMERA for 3D structure
180 * <li>CHIMERA_PATH specify full path to Chimera program (if non-standard)</li>
183 * Deprecated settings:
186 * <li>DISCOVERY_START - Boolean - controls if discovery services are queried on
187 * startup (JWS1 services only)</li>
188 * <li>DISCOVERY_URLS - comma separated list of Discovery Service endpoints.
189 * (JWS1 services only)</li>
190 * <li>SHOW_JWS1_SERVICES (true) enable or disable the original Jalview 2
191 * services in the desktop GUI</li>
192 * <li>ENABLE_RSBS_EDITOR (false for 2.7 release) enable or disable RSBS editing
193 * panel in web service preferences</li>
197 * @version $Revision$
202 * property giving log4j level for CASTOR loggers
204 public static final String CASTORLOGLEVEL = "logs.Castor.level";
207 * property giving log4j level for AXIS loggers
209 public static final String AXISLOGLEVEL = "logs.Axis.level";
212 * property giving log4j level for Jalview Log
214 public static final String JALVIEWLOGLEVEL = "logs.Jalview.level";
216 public static final String DAS_LOCAL_SOURCE = "DAS_LOCAL_SOURCE";
218 public static final String DAS_REGISTRY_URL = "DAS_REGISTRY_URL";
220 public static final String DAS_ACTIVE_SOURCE = "DAS_ACTIVE_SOURCE";
222 public static final String DEFAULT_SIFTS_DOWNLOAD_DIR = System
223 .getProperty("user.home")
225 + ".sifts_downloads" + File.separatorChar;
227 private final static String DEFAULT_CACHE_THRESHOLD_IN_DAYS = "2";
229 private final static String DEFAULT_FAIL_SAFE_PID_THRESHOLD = "30";
231 private final static String DEFAULT_STRUCTURE_FORMAT = DBRefSource.PDB;
234 * Initialises the Jalview Application Log
236 public static Logger log;
238 /** Jalview Properties */
239 public static Properties applicationProperties = new Properties()
241 // override results in properties output in alphabetical order
243 public synchronized Enumeration<Object> keys()
245 return Collections.enumeration(new TreeSet<Object>(super.keySet()));
249 /** Default file is ~/.jalview_properties */
250 static String propertiesFile;
252 private static boolean propsAreReadOnly = false;
254 public static void initLogger()
262 // TODO: redirect stdout and stderr here in order to grab the output of
265 ConsoleAppender ap = new ConsoleAppender(new SimpleLayout(),
267 ap.setName("JalviewLogger");
268 org.apache.log4j.Logger.getRootLogger().addAppender(ap); // catch all for
270 Logger laxis = Logger.getLogger("org.apache.axis");
271 Logger lcastor = Logger.getLogger("org.exolab.castor");
272 jalview.bin.Cache.log = Logger.getLogger("jalview.bin.Jalview");
274 laxis.setLevel(Level.toLevel(Cache.getDefault("logs.Axis.Level",
275 Level.INFO.toString())));
276 lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level",
277 Level.INFO.toString())));
278 lcastor = Logger.getLogger("org.exolab.castor.xml");
279 lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level",
280 Level.INFO.toString())));
281 // lcastor = Logger.getLogger("org.exolab.castor.xml.Marshaller");
282 // lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level",
283 // Level.INFO.toString())));
284 jalview.bin.Cache.log.setLevel(Level.toLevel(Cache.getDefault(
285 "logs.Jalview.level", Level.INFO.toString())));
286 // laxis.addAppender(ap);
287 // lcastor.addAppender(ap);
288 // jalview.bin.Cache.log.addAppender(ap);
289 // Tell the user that debug is enabled
290 jalview.bin.Cache.log.debug("Jalview Debugging Output Follows.");
291 } catch (Exception ex)
293 System.err.println("Problems initializing the log4j system\n");
294 ex.printStackTrace(System.err);
298 /** Called when Jalview is started */
299 public static void loadProperties(String propsFile)
301 propertiesFile = propsFile;
302 if (propsFile == null)
304 propertiesFile = System.getProperty("user.home") + File.separatorChar
305 + ".jalview_properties";
309 // don't corrupt the file we've been given.
310 propsAreReadOnly = true;
318 fis = new java.net.URL(propertiesFile).openStream();
319 System.out.println("Loading jalview properties from : "
322 .println("Disabling Jalview writing to user's local properties file.");
323 propsAreReadOnly = true;
325 } catch (Exception ex)
331 fis = new FileInputStream(propertiesFile);
333 applicationProperties.load(fis);
335 // remove any old build properties
337 deleteBuildProperties();
339 } catch (Exception ex)
341 System.out.println("Error reading properties file: " + ex);
344 if (getDefault("USE_PROXY", false))
346 String proxyServer = getDefault("PROXY_SERVER", ""), proxyPort = getDefault(
347 "PROXY_PORT", "8080");
349 System.out.println("Using proxyServer: " + proxyServer
350 + " proxyPort: " + proxyPort);
352 System.setProperty("http.proxyHost", proxyServer);
353 System.setProperty("http.proxyPort", proxyPort);
356 // LOAD THE AUTHORS FROM THE authors.props file
359 String authorDetails = "jar:".concat(Cache.class
360 .getProtectionDomain().getCodeSource().getLocation()
361 .toString().concat("!/authors.props"));
363 java.net.URL localJarFileURL = new java.net.URL(authorDetails);
365 InputStream in = localJarFileURL.openStream();
366 applicationProperties.load(in);
368 } catch (Exception ex)
370 System.out.println("Error reading author details: " + ex);
371 applicationProperties.remove("AUTHORS");
372 applicationProperties.remove("AUTHORFNAMES");
373 applicationProperties.remove("YEAR");
376 // FIND THE VERSION NUMBER AND BUILD DATE FROM jalview.jar
377 // MUST FOLLOW READING OF LOCAL PROPERTIES FILE AS THE
378 // VERSION MAY HAVE CHANGED SINCE LAST USING JALVIEW
381 String buildDetails = "jar:".concat(Cache.class.getProtectionDomain()
382 .getCodeSource().getLocation().toString()
383 .concat("!/.build_properties"));
385 java.net.URL localJarFileURL = new java.net.URL(buildDetails);
387 InputStream in = localJarFileURL.openStream();
388 applicationProperties.load(in);
390 } catch (Exception ex)
392 System.out.println("Error reading build details: " + ex);
393 applicationProperties.remove("VERSION");
396 String jnlpVersion = System.getProperty("jalview.version");
397 String codeVersion = getProperty("VERSION");
398 String codeInstallation = getProperty("INSTALLATION");
399 if (codeVersion == null)
401 // THIS SHOULD ONLY BE THE CASE WHEN TESTING!!
402 codeVersion = "Test";
403 jnlpVersion = "Test";
404 codeInstallation = "";
408 codeInstallation = " (" + codeInstallation + ")";
410 new BuildDetails(codeVersion, null, codeInstallation);
413 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
415 SiftsSettings.setSiftDownloadDirectory(jalview.bin.Cache.getDefault(
416 "sifts_download_dir", DEFAULT_SIFTS_DOWNLOAD_DIR));
418 SiftsSettings.setFailSafePIDThreshold(jalview.bin.Cache.getDefault(
419 "sifts_fail_safe_pid_threshold",
420 DEFAULT_FAIL_SAFE_PID_THRESHOLD));
422 SiftsSettings.setCacheThresholdInDays(jalview.bin.Cache.getDefault(
423 "sifts_cache_threshold_in_days",
424 DEFAULT_CACHE_THRESHOLD_IN_DAYS));
427 .println("Jalview Version: " + codeVersion + codeInstallation);
429 StructureImportSettings.setCurrentDefaultFormat(jalview.bin.Cache
431 "DEFAULT_STRUCTURE_FORMAT", DEFAULT_STRUCTURE_FORMAT));
433 StructureImportSettings.setProcessHETATMs(jalview.bin.Cache.getDefault(
434 "PROCESS_HETATM", false));
435 // jnlpVersion will be null if we're using InstallAnywhere
436 // Dont do this check if running in headless mode
437 if (jnlpVersion == null
438 && getDefault("VERSION_CHECK", true)
439 && (System.getProperty("java.awt.headless") == null || System
440 .getProperty("java.awt.headless").equals("false")))
443 class VersionChecker extends Thread
448 String orgtimeout = System
449 .getProperty("sun.net.client.defaultConnectTimeout");
450 if (orgtimeout == null)
453 System.out.println("# INFO: Setting default net timeout to "
454 + orgtimeout + " seconds.");
456 String remoteVersion = null;
459 System.setProperty("sun.net.client.defaultConnectTimeout",
461 java.net.URL url = new java.net.URL(Cache.getDefault(
462 "www.jalview.org", "http://www.jalview.org")
463 + "/webstart/jalview.jnlp");
464 BufferedReader in = new BufferedReader(new InputStreamReader(
467 while ((line = in.readLine()) != null)
469 if (line.indexOf("jalview.version") == -1)
474 line = line.substring(line.indexOf("value=") + 7);
475 line = line.substring(0, line.lastIndexOf("\""));
476 remoteVersion = line;
479 } catch (Exception ex)
482 .println("Non-fatal exception when checking version at www.jalview.org :");
483 System.out.println(ex);
484 remoteVersion = getProperty("VERSION");
486 System.setProperty("sun.net.client.defaultConnectTimeout",
489 setProperty("LATEST_VERSION", remoteVersion);
493 VersionChecker vc = new VersionChecker();
498 if (jnlpVersion != null)
500 setProperty("LATEST_VERSION", jnlpVersion);
504 applicationProperties.remove("LATEST_VERSION");
508 setProperty("VERSION", codeVersion);
510 // LOAD USERDEFINED COLOURS
511 jalview.gui.UserDefinedColours
512 .initUserColourSchemes(getProperty("USER_DEFINED_COLOURS"));
513 jalview.io.PIRFile.useModellerOutput = Cache.getDefault("PIR_MODELLER",
517 private static void deleteBuildProperties()
519 applicationProperties.remove("LATEST_VERSION");
520 applicationProperties.remove("VERSION");
521 applicationProperties.remove("AUTHORS");
522 applicationProperties.remove("AUTHORFNAMES");
523 applicationProperties.remove("YEAR");
524 applicationProperties.remove("BUILD_DATE");
525 applicationProperties.remove("INSTALLATION");
529 * Gets Jalview application property of given key. Returns null if key not
535 * @return Property value
537 public static String getProperty(String key)
539 return applicationProperties.getProperty(key);
543 * These methods are used when checking if the saved preference is different
544 * to the default setting
547 public static boolean getDefault(String property, boolean def)
549 String string = getProperty(property);
552 def = Boolean.valueOf(string).booleanValue();
559 * These methods are used when checking if the saved preference is different
560 * to the default setting
562 public static String getDefault(String property, String def)
564 String string = getProperty(property);
574 * Stores property in the file "HOME_DIR/.jalview_properties"
579 * String value of property
581 * @return String value of property
583 public static String setProperty(String key, String obj)
588 applicationProperties.setProperty(key, obj);
589 if (!propsAreReadOnly)
591 FileOutputStream out = new FileOutputStream(propertiesFile);
592 applicationProperties.store(out, "---JalviewX Properties File---");
595 } catch (Exception ex)
597 System.out.println("Error setting property: " + key + " " + obj
604 * remove the specified property from the jalview properties file
608 public static void removeProperty(String string)
610 applicationProperties.remove(string);
615 * save the properties to the jalview properties path
617 public static void saveProperties()
619 if (!propsAreReadOnly)
623 FileOutputStream out = new FileOutputStream(propertiesFile);
624 applicationProperties.store(out, "---JalviewX Properties File---");
626 } catch (Exception ex)
628 System.out.println("Error saving properties: " + ex);
634 * internal vamsas class discovery state
636 private static int vamsasJarsArePresent = -1;
639 * Searches for vamsas client classes on class path.
641 * @return true if vamsas client is present on classpath
643 public static boolean vamsasJarsPresent()
645 if (vamsasJarsArePresent == -1)
649 if (jalview.jbgui.GDesktop.class.getClassLoader().loadClass(
650 "uk.ac.vamsas.client.VorbaId") != null)
652 jalview.bin.Cache.log
653 .debug("Found Vamsas Classes (uk.ac..vamsas.client.VorbaId can be loaded)");
654 vamsasJarsArePresent = 1;
655 Logger lvclient = Logger.getLogger("uk.ac.vamsas");
656 lvclient.setLevel(Level.toLevel(Cache.getDefault(
657 "logs.Vamsas.Level", Level.INFO.toString())));
659 lvclient.addAppender(log.getAppender("JalviewLogger"));
660 // Tell the user that debug is enabled
661 lvclient.debug("Jalview Vamsas Client Debugging Output Follows.");
663 } catch (Exception e)
665 vamsasJarsArePresent = 0;
666 jalview.bin.Cache.log.debug("Vamsas Classes are not present");
669 return (vamsasJarsArePresent > 0);
673 * internal vamsas class discovery state
675 private static int groovyJarsArePresent = -1;
678 * Searches for vamsas client classes on class path.
680 * @return true if vamsas client is present on classpath
682 public static boolean groovyJarsPresent()
684 if (groovyJarsArePresent == -1)
688 if (Cache.class.getClassLoader().loadClass(
689 "groovy.lang.GroovyObject") != null)
691 jalview.bin.Cache.log
692 .debug("Found Groovy (groovy.lang.GroovyObject can be loaded)");
693 groovyJarsArePresent = 1;
694 Logger lgclient = Logger.getLogger("groovy");
695 lgclient.setLevel(Level.toLevel(Cache.getDefault(
696 "logs.Groovy.Level", Level.INFO.toString())));
698 lgclient.addAppender(log.getAppender("JalviewLogger"));
699 // Tell the user that debug is enabled
700 lgclient.debug("Jalview Groovy Client Debugging Output Follows.");
704 groovyJarsArePresent = 0;
705 jalview.bin.Cache.log.debug("Groovy Classes are not present", e);
706 } catch (Exception e)
708 groovyJarsArePresent = 0;
709 jalview.bin.Cache.log.debug("Groovy Classes are not present");
712 return (groovyJarsArePresent > 0);
716 * GA tracker object - actually JGoogleAnalyticsTracker null if tracking not
719 protected static Object tracker = null;
721 protected static Class trackerfocus = null;
723 protected static Class jgoogleanalyticstracker = null;
726 * Initialise the google tracker if it is not done already.
728 public static void initGoogleTracker()
732 if (jgoogleanalyticstracker == null)
734 // try to get the tracker class
737 jgoogleanalyticstracker = Cache.class
740 "com.boxysystems.jgoogleanalytics.JGoogleAnalyticsTracker");
741 trackerfocus = Cache.class.getClassLoader().loadClass(
742 "com.boxysystems.jgoogleanalytics.FocusPoint");
743 } catch (Exception e)
745 log.debug("com.boxysystems.jgoogleanalytics package is not present - tracking not enabled.");
747 jgoogleanalyticstracker = null;
752 // now initialise tracker
753 Exception re = null, ex = null;
755 String vrs = "No Version Accessible";
758 // Google analytics tracking code for Library Finder
759 tracker = jgoogleanalyticstracker.getConstructor(
760 new Class[] { String.class, String.class, String.class })
764 (vrs = jalview.bin.Cache.getProperty("VERSION")
766 + jalview.bin.Cache.getDefault(
767 "BUILD_DATE", "unknown")),
769 jgoogleanalyticstracker.getMethod("trackAsynchronously",
770 new Class[] { trackerfocus }).invoke(
772 new Object[] { trackerfocus.getConstructor(
773 new Class[] { String.class }).newInstance(
774 new Object[] { "Application Started." }) });
775 } catch (RuntimeException e)
778 } catch (Exception e)
785 if (re != null || ex != null || err != null)
791 log.debug("Caught runtime exception in googletracker init:", re);
796 "Failed to initialise GoogleTracker for Jalview Desktop with version "
802 "Whilst initing GoogleTracker for Jalview Desktop version "
811 .println("Debug: Caught runtime exception in googletracker init:"
813 re.printStackTrace();
818 .println("Warning: Failed to initialise GoogleTracker for Jalview Desktop with version "
820 ex.printStackTrace();
826 .println("ERROR: Whilst initing GoogleTracker for Jalview Desktop version "
828 err.printStackTrace();
834 log.debug("Successfully initialised tracker.");
840 * get the user's default colour if available
846 public static Color getDefaultColour(String property, Color defcolour)
848 String colprop = getProperty(property);
853 Color col = jalview.schemes.ColourSchemeProperty
854 .getAWTColorFromName(colprop);
859 col = new jalview.schemes.UserColourScheme(colprop).findColour('A');
860 } catch (Exception ex)
862 log.warn("Couldn't parse '" + colprop + "' as a colour for "
867 return (col == null) ? defcolour : col;
871 * store a colour as a Jalview user default property
876 public static void setColourProperty(String property, Color colour)
878 setProperty(property, jalview.util.Format.getHexString(colour));
881 public static final DateFormat date_format = SimpleDateFormat
882 .getDateTimeInstance();
885 * store a date in a jalview property
890 public static void setDateProperty(String property, Date time)
892 setProperty(property, date_format.format(time));
896 * read a date stored in a jalview property
899 * @return valid date as stored by setDateProperty, or null
902 public static Date getDateProperty(String property)
904 String val = getProperty(property);
909 return date_format.parse(val);
910 } catch (Exception ex)
912 System.err.println("Invalid or corrupt date in property '"
913 + property + "' : value was '" + val + "'");
920 * get and parse a property as an integer. send any parsing problems to
924 * @return null or Integer
926 public static Integer getIntegerProperty(String property)
928 String val = getProperty(property);
929 if (val != null && (val = val.trim()).length() > 0)
933 return Integer.valueOf(val);
934 } catch (NumberFormatException x)
936 System.err.println("Invalid integer in property '" + property
937 + "' (value was '" + val + "')");
943 private static DasSourceRegistryI sourceRegistry = null;
948 * @return instance of the das source registry
950 public static DasSourceRegistryI getDasSourceRegistry()
952 if (sourceRegistry == null)
954 sourceRegistry = new DasSourceRegistry();
956 return sourceRegistry;
960 * Set the specified value, or remove it if null or empty. Does not save the
966 public static void setOrRemove(String propName, String value)
968 if (propName == null)
972 if (value == null || value.trim().length() < 1)
974 Cache.applicationProperties.remove(propName);
978 Cache.applicationProperties.setProperty(propName, value);