View Javadoc

1   /*
2    *                Doelan development code
3    *
4    * This code may be freely distributed and modified under the
5    * terms of the GNU General Public Licence.  This should
6    * be distributed with the code. If you do not have a copy,
7    * see:
8    *
9    *      http://www.gnu.org/copyleft/gpl.txt
10   *
11   * Copyright (c) 2004-2005 ENS Microarray Platform
12   * Copyright for this code is held jointly by the individual
13   * authors.  These should be listed in @author doc comments.
14   *
15   * For more information on the Doelan project and its aims,
16   * or to join the Doelan mailing list, visit the home page
17   * at:
18   *
19   *      http://www.transcriptome.ens.fr/doelan
20   */
21  
22  package fr.ens.transcriptome.doelan;
23  
24  import java.io.File;
25  import java.net.URL;
26  import java.text.DateFormat;
27  import java.text.ParseException;
28  import java.text.SimpleDateFormat;
29  import java.util.Date;
30  import java.util.Locale;
31  
32  import fr.ens.transcriptome.nividic.platform.Registery;
33  import fr.ens.transcriptome.nividic.platform.PlatformRegistery;
34  import fr.ens.transcriptome.nividic.util.WebBrowser;
35  
36  /***
37   * Globals setting for the application
38   * @author Laurent Jourdren
39   */
40  public final class DoelanRegistery {
41  
42    /***
43     * Initialize default values.
44     */
45    public static void init() {
46  
47      URL url = DoelanRegistery.class.getResource(Defaults.CONFIG_FILE);
48      Registery.loadRegistery(url);
49      Registery.getRegistery().setProperty("debug", "" + Defaults.DEBUG);
50    }
51  
52    /***
53     * Get the absolute path of the test suite list file.
54     * @return The path of this file
55     */
56    public static String getTestSuiteListFilename() {
57      return Registery.getRegistery().getProperty(
58          "doelan.suiteslist.file",
59          PlatformRegistery.getConfDirectory() + File.separator
60              + Defaults.TEST_SUITE_LIST_FILE);
61    }
62  
63    /***
64     * Get the absolute path of the directory for plugins.
65     * @return The path of the directory for plugins
66     */
67    public static String getDoelanDataDirectory() {
68  
69      return Registery.getRegistery().getProperty(
70          "doelan.data.dir",
71          PlatformRegistery.getBaseDirectory() + File.separator
72              + Defaults.SUBDIR_DATA);
73    }
74  
75    /***
76     * Get the absolute path of the directory for plugins.
77     * @return The path of the directory for plugins
78     */
79    public static String getDoelanReportDirectory() {
80  
81      return Registery.getRegistery().getProperty(
82          "doelan.report.dir",
83          PlatformRegistery.getBaseDirectory() + File.separator
84              + Defaults.SUBDIR_REPORT);
85    }
86  
87    /***
88     * Get the name of the application.
89     * @return The name of the application
90     */
91    public static String getAppName() {
92      return Registery.getRegistery().getProperty("project.name",
93          Defaults.APP_NAME);
94    }
95  
96    /***
97     * Get the version of the application.
98     * @return the name of the application
99     */
100   public static String getAppVersion() {
101     return Registery.getRegistery().getProperty("project.version",
102         Defaults.VERSION);
103   }
104 
105   /***
106    * Get the description of the application.
107    * @return the description of the application
108    */
109   public static String getAppDescription() {
110     return Registery.getRegistery().getProperty("project.description",
111         Defaults.APP_DESCRITPION);
112   }
113 
114   /***
115    * Get the date of the compilation.
116    * @return The date of the compilation
117    */
118   public static Date getAppCompileDate() {
119 
120     String d = Registery.getRegistery().getProperty("project.compile.date");
121 
122     if (d == null)
123       return null;
124 
125     DateFormat df = new SimpleDateFormat("dd-MM-yy-H:mm:ss");
126     try {
127       return df.parse(d);
128     } catch (ParseException e) {
129       return null;
130     }
131 
132   }
133 
134   /***
135    * Get the URL of the project.
136    * @return Get the URL of the project
137    */
138   public static String getAppURL() {
139     return Registery.getRegistery()
140         .getProperty("project.url", Defaults.WEBSITE);
141   }
142 
143   /***
144    * Get the name of the organization of the project.
145    * @return The name of the organization of the project
146    */
147   public static String getOrganizationName() {
148     return Registery.getRegistery().getProperty("project.organization.name",
149         Defaults.MANUFACTURER);
150   }
151 
152   /***
153    * Get the url of the organization
154    * @return The url of the organization of the project
155    */
156   public static String getOrganizationURL() {
157     return Registery.getRegistery().getProperty("project.organization.url",
158         Defaults.MANUFACTURER_WEBSITE);
159   }
160 
161   /***
162    * Get the date of the copyright.
163    * @return The date of the copyright
164    */
165   public static String getCopyrightDate() {
166     return Registery.getRegistery().getProperty("project.copyright.date",
167         Defaults.COPYRIGHT_DATE);
168   }
169 
170   /***
171    * Get the copyright.
172    * @return The copyright of the appplication.
173    */
174   public static String getAppCopyright() {
175     return "Copyright " + getCopyrightDate() + " " + getOrganizationName();
176   }
177 
178   /***
179    * Get information about the project.
180    * @return a String with information about the project
181    */
182   public static String about() {
183     StringBuffer sb = new StringBuffer();
184 
185     sb.append("\n");
186     sb.append(DoelanRegistery.getAppName() + " version "
187         + DoelanRegistery.getAppVersion() + ": "
188         + DoelanRegistery.getAppDescription() + "\n");
189     sb.append("Compiled on ");
190 
191     DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL,
192         DateFormat.MEDIUM, Locale.UK);
193 
194     Date compileDate = DoelanRegistery.getAppCompileDate();
195 
196     if (compileDate != null)
197       sb.append(df.format(compileDate));
198     sb.append("\n\n");
199     sb.append(DoelanRegistery.getAppCopyright() + "\n");
200     sb.append("This software is published under the " + Defaults.LICENCE
201         + ".\n\n");
202 
203     sb.append("Website: " + DoelanRegistery.getAppURL() + "\n");
204 
205     return sb.toString();
206   }
207 
208   /***
209    * Get information about the project.
210    * @return a String with information about the project
211    */
212   public static String licence() {
213     StringBuffer sb = new StringBuffer();
214 
215     sb.append(DoelanRegistery.getAppCopyright() + "\n");
216     sb.append("This software is published under the " + Defaults.LICENCE
217         + ".\n\n");
218 
219     sb.append("Website: " + DoelanRegistery.getAppURL() + "\n");
220 
221     return sb.toString();
222   }
223 
224   /***
225    * Get the path of the alterantive web browser.
226    * @return The path of the alternative path
227    */
228   public static String getAlternativeBrowserPath() {
229 
230     return Registery.getRegistery().getProperty(
231         "doelan.alternative.browser.path");
232   }
233 
234   /***
235    * Get the browser path.
236    * @return The browser path
237    */
238   public static String getBrowserPath() {
239 
240     return WebBrowser.getBrowserPath(getAlternativeBrowserPath());
241   }
242 
243   /***
244    * Test if applet mode is set.
245    * @return true if applet mode is set
246    */
247   public static boolean isAppletMode() {
248     return "true".equals(Registery.getRegistery().getProperty(
249         "doelan.applet.mode"));
250   }
251 
252   /***
253    * Set the applet mode.
254    * @param appletMode The applet mode
255    */
256   public static void setAppletMode(final boolean appletMode) {
257     Registery.getRegistery().setProperty("doelan.applet.mode", "" + appletMode);
258   }
259 
260   /***
261    * Get the width of the doelan charts.
262    * @return The width in pixel of doelan charts
263    */
264   public static int getDoelanChartWidth() {
265     return Integer.parseInt(Registery.getRegistery().getProperty(
266         "doelan.chart.witdh", "" + Defaults.DOLEAN_CHART_WIDTH));
267   }
268 
269   /***
270    * Get the height of the doelan charts.
271    * @return The width in pixel of doelan charts
272    */
273   public static int getDoelanChartHeigth() {
274     return Integer.parseInt(Registery.getRegistery().getProperty(
275         "doelan.chart.height", "" + Defaults.DOELAN_CHART_HEIGHT));
276   }
277 
278   //
279   // Constructor
280   //
281 
282   /***
283    * Private constructor.
284    */
285   private DoelanRegistery() {
286   }
287 
288 }