7 |
24 Aug 07 |
jari |
// $Id$ |
7 |
24 Aug 07 |
jari |
2 |
|
2 |
26 Feb 07 |
jari |
3 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2005, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
6 |
*/ |
2 |
26 Feb 07 |
jari |
7 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: TMEV.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.18 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/08/22 17:50:47 $ |
2 |
26 Feb 07 |
jari |
* $Author: eleanorahowe $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
13 |
*/ |
2 |
26 Feb 07 |
jari |
14 |
|
2 |
26 Feb 07 |
jari |
15 |
package org.tigr.microarray.mev; |
2 |
26 Feb 07 |
jari |
16 |
|
2 |
26 Feb 07 |
jari |
17 |
import java.io.BufferedReader; |
2 |
26 Feb 07 |
jari |
18 |
import java.io.BufferedWriter; |
2 |
26 Feb 07 |
jari |
19 |
import java.io.File; |
2 |
26 Feb 07 |
jari |
20 |
import java.io.FileInputStream; |
2 |
26 Feb 07 |
jari |
21 |
import java.io.FileNotFoundException; |
2 |
26 Feb 07 |
jari |
22 |
import java.io.FileReader; |
2 |
26 Feb 07 |
jari |
23 |
import java.io.FileWriter; |
2 |
26 Feb 07 |
jari |
24 |
import java.io.IOException; |
2 |
26 Feb 07 |
jari |
25 |
import java.io.InputStream; |
7 |
24 Aug 07 |
jari |
26 |
import java.io.InputStreamReader; |
2 |
26 Feb 07 |
jari |
27 |
import java.net.URL; |
2 |
26 Feb 07 |
jari |
28 |
import java.sql.Connection; |
2 |
26 Feb 07 |
jari |
29 |
import java.sql.DriverManager; |
2 |
26 Feb 07 |
jari |
30 |
import java.util.Enumeration; |
2 |
26 Feb 07 |
jari |
31 |
import java.util.Hashtable; |
2 |
26 Feb 07 |
jari |
32 |
import java.util.Properties; |
2 |
26 Feb 07 |
jari |
33 |
import java.util.StringTokenizer; |
2 |
26 Feb 07 |
jari |
34 |
|
2 |
26 Feb 07 |
jari |
35 |
import javax.swing.UIManager; |
2 |
26 Feb 07 |
jari |
36 |
|
2 |
26 Feb 07 |
jari |
37 |
import org.tigr.microarray.mev.cluster.algorithm.AlgorithmFactory; |
2 |
26 Feb 07 |
jari |
38 |
import org.tigr.microarray.mev.cluster.gui.IGUIFactory; |
2 |
26 Feb 07 |
jari |
39 |
import org.tigr.util.ConfMap; |
2 |
26 Feb 07 |
jari |
40 |
import org.tigr.util.awt.ImageScreen; |
2 |
26 Feb 07 |
jari |
41 |
|
2 |
26 Feb 07 |
jari |
42 |
public class TMEV { |
2 |
26 Feb 07 |
jari |
43 |
public final static String VERSION = "4.0.01"; |
2 |
26 Feb 07 |
jari |
44 |
|
2 |
26 Feb 07 |
jari |
45 |
public final static int SYSTEM = 1000; |
2 |
26 Feb 07 |
jari |
46 |
public final static int DB_AVAILABLE = 1001; |
2 |
26 Feb 07 |
jari |
47 |
public final static int DB_LOGIN = 1002; |
2 |
26 Feb 07 |
jari |
48 |
public final static int DATA_AVAILABLE = 1003; |
2 |
26 Feb 07 |
jari |
49 |
public final static int SPOTFIRE_AVAILABLE = 1004; |
2 |
26 Feb 07 |
jari |
50 |
public final static int DATA_TYPE_TWO_DYE = 1; |
2 |
26 Feb 07 |
jari |
51 |
public final static int DATA_TYPE_AFFY = 2; |
2 |
26 Feb 07 |
jari |
52 |
|
2 |
26 Feb 07 |
jari |
53 |
public final static int ANALYSIS_LOADED = 101; |
2 |
26 Feb 07 |
jari |
54 |
|
2 |
26 Feb 07 |
jari |
//public final static String TMP_FOLDER_NAME = "mev_saved_state_tmp"; |
2 |
26 Feb 07 |
jari |
56 |
|
2 |
26 Feb 07 |
jari |
57 |
private static Connection connection; |
2 |
26 Feb 07 |
jari |
58 |
private static Hashtable properties; |
2 |
26 Feb 07 |
jari |
59 |
private static AlgorithmFactory algorithmFactory; |
2 |
26 Feb 07 |
jari |
60 |
private static IGUIFactory guiFactory; |
2 |
26 Feb 07 |
jari |
61 |
private static int coordinatePairCount; |
2 |
26 Feb 07 |
jari |
62 |
private static int intensityCount; |
2 |
26 Feb 07 |
jari |
63 |
private static int headerRowCount; |
2 |
26 Feb 07 |
jari |
64 |
private static int headerColumnCount; |
2 |
26 Feb 07 |
jari |
65 |
private static int uniqueIDIndex; |
2 |
26 Feb 07 |
jari |
66 |
private static int nameIndex; |
2 |
26 Feb 07 |
jari |
//FL |
2 |
26 Feb 07 |
jari |
68 |
private static boolean indicesAdjusted = false; |
2 |
26 Feb 07 |
jari |
// private static String[] fieldNames; |
2 |
26 Feb 07 |
jari |
70 |
private static String[] databases; |
2 |
26 Feb 07 |
jari |
71 |
private static int[] customerAnalysis=null; |
2 |
26 Feb 07 |
jari |
72 |
|
2 |
26 Feb 07 |
jari |
//Prompt user to save analysis on close |
2 |
26 Feb 07 |
jari |
74 |
public static boolean permitSavePrompt = true; |
2 |
26 Feb 07 |
jari |
75 |
|
2 |
26 Feb 07 |
jari |
//Initial data path |
2 |
26 Feb 07 |
jari |
77 |
private static String dataPath; |
2 |
26 Feb 07 |
jari |
78 |
private static int flag=0; |
2 |
26 Feb 07 |
jari |
// pcahan jcb:constant |
2 |
26 Feb 07 |
jari |
80 |
private static int dataType = DATA_TYPE_TWO_DYE; |
2 |
26 Feb 07 |
jari |
81 |
|
2 |
26 Feb 07 |
jari |
//OS string |
2 |
26 Feb 07 |
jari |
83 |
private static String os = ""; |
2 |
26 Feb 07 |
jari |
84 |
|
2 |
26 Feb 07 |
jari |
//signals active save in progress |
2 |
26 Feb 07 |
jari |
86 |
public static boolean activeSave = false; |
2 |
26 Feb 07 |
jari |
87 |
|
2 |
26 Feb 07 |
jari |
//added for Rama (vu 2005.08.24) |
2 |
26 Feb 07 |
jari |
89 |
public static String rPath = "127.0.0.1:6311"; |
2 |
26 Feb 07 |
jari |
90 |
|
2 |
26 Feb 07 |
jari |
91 |
/** |
2 |
26 Feb 07 |
jari |
* Raktim |
2 |
26 Feb 07 |
jari |
* Nov 07, 2005 |
2 |
26 Feb 07 |
jari |
* CGH default Values |
2 |
26 Feb 07 |
jari |
95 |
*/ |
2 |
26 Feb 07 |
jari |
96 |
public static boolean cloneDistributionsLogState = true; |
2 |
26 Feb 07 |
jari |
97 |
public static int browserDefaultDyeSwapValue = 1; |
2 |
26 Feb 07 |
jari |
98 |
public static int browserDefaultNoDyeSwapValue = 5; |
2 |
26 Feb 07 |
jari |
99 |
public static int defaultCloneValue = 1; |
2 |
26 Feb 07 |
jari |
100 |
public static int defaultFlankingRegionValue = 0; |
2 |
26 Feb 07 |
jari |
101 |
public static final int CGH_SPECIES_HS = 0; |
2 |
26 Feb 07 |
jari |
102 |
public static final int CGH_SPECIES_MM = 1; |
2 |
26 Feb 07 |
jari |
103 |
public static final int CGH_SPECIES_Undef = -100; |
2 |
26 Feb 07 |
jari |
104 |
|
7 |
24 Aug 07 |
jari |
105 |
public static int BASE_column; |
7 |
24 Aug 07 |
jari |
106 |
public static String BASE_download_url; |
7 |
24 Aug 07 |
jari |
107 |
public static int BASE_row; |
7 |
24 Aug 07 |
jari |
108 |
|
2 |
26 Feb 07 |
jari |
109 |
public static void main(String[] args) { |
2 |
26 Feb 07 |
jari |
110 |
try { |
2 |
26 Feb 07 |
jari |
111 |
System.out.println("MultiExperimentViewer - version "+TMEV.VERSION+" - " + System.getProperty("os.name")); |
2 |
26 Feb 07 |
jari |
112 |
String Java3DTitle, Java3DVendor, Java3DVersion; |
2 |
26 Feb 07 |
jari |
113 |
try { |
2 |
26 Feb 07 |
jari |
114 |
InformationPanel info = new InformationPanel(); |
2 |
26 Feb 07 |
jari |
115 |
Java3DTitle = info.getJava3DRunTimeEnvironment(); |
2 |
26 Feb 07 |
jari |
116 |
Java3DVendor = info.getJava3DVendor(); |
2 |
26 Feb 07 |
jari |
117 |
Java3DVersion = info.getJava3DVersion(); |
2 |
26 Feb 07 |
jari |
118 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
119 |
Java3DTitle="not installed"; |
2 |
26 Feb 07 |
jari |
120 |
Java3DVendor="not available"; |
2 |
26 Feb 07 |
jari |
121 |
Java3DVersion="not available"; |
2 |
26 Feb 07 |
jari |
122 |
} |
2 |
26 Feb 07 |
jari |
123 |
|
2 |
26 Feb 07 |
jari |
124 |
os = System.getProperty("os.name"); |
2 |
26 Feb 07 |
jari |
125 |
|
2 |
26 Feb 07 |
jari |
//System.out.println(System.currentTimeMillis()); |
7 |
24 Aug 07 |
jari |
127 |
|
7 |
24 Aug 07 |
jari |
// This should be more robust ... error checking |
7 |
24 Aug 07 |
jari |
129 |
for (int i=0; i<args.length; ++i) { |
7 |
24 Aug 07 |
jari |
130 |
String[] bits=args[i].split("\\s",2); |
7 |
24 Aug 07 |
jari |
131 |
if (bits[0].equals("-download_url")) { |
7 |
24 Aug 07 |
jari |
132 |
BASE_download_url=bits[1]; |
7 |
24 Aug 07 |
jari |
133 |
} |
7 |
24 Aug 07 |
jari |
134 |
else if (bits[0].equals("-row")) { |
7 |
24 Aug 07 |
jari |
135 |
BASE_row=Integer.parseInt(bits[1]); |
7 |
24 Aug 07 |
jari |
136 |
} |
7 |
24 Aug 07 |
jari |
137 |
else if (bits[0].equals("-column")) { |
7 |
24 Aug 07 |
jari |
138 |
BASE_column=Integer.parseInt(bits[1]); |
7 |
24 Aug 07 |
jari |
139 |
} |
7 |
24 Aug 07 |
jari |
140 |
} |
7 |
24 Aug 07 |
jari |
141 |
|
2 |
26 Feb 07 |
jari |
142 |
System.out.println("Java Runtime Environment version: "+System.getProperty("java.version")); |
2 |
26 Feb 07 |
jari |
143 |
System.out.println("Java Runtime Environment vendor: "+System.getProperty("java.vendor")); |
2 |
26 Feb 07 |
jari |
144 |
System.out.println("Java Virtual Machine name: "+System.getProperty("java.vm.name")); |
2 |
26 Feb 07 |
jari |
145 |
System.out.println("Java Virtual Machine version: "+System.getProperty("java.vm.version")); |
2 |
26 Feb 07 |
jari |
146 |
System.out.println("Java Virtual Machine vendor: "+System.getProperty("java.vm.vendor")); |
2 |
26 Feb 07 |
jari |
147 |
System.out.println("Java 3D Runtime Environment: "+Java3DTitle); |
2 |
26 Feb 07 |
jari |
148 |
System.out.println("Java 3D Runtime Environment vendor: "+Java3DVendor); |
2 |
26 Feb 07 |
jari |
149 |
System.out.println("Java 3D Runtime Environment version:"+Java3DVersion); |
2 |
26 Feb 07 |
jari |
150 |
System.out.println("Operating System name: "+os); |
2 |
26 Feb 07 |
jari |
151 |
System.out.println("Operating System version: "+System.getProperty("os.version")); |
2 |
26 Feb 07 |
jari |
152 |
System.out.println("Operating System architecture: "+System.getProperty("os.arch")); |
2 |
26 Feb 07 |
jari |
153 |
|
2 |
26 Feb 07 |
jari |
154 |
configure(); |
2 |
26 Feb 07 |
jari |
155 |
ImageScreen is = new ImageScreen(); |
2 |
26 Feb 07 |
jari |
156 |
is.showImageScreen(1500); |
2 |
26 Feb 07 |
jari |
157 |
|
2 |
26 Feb 07 |
jari |
158 |
Manager manager = new Manager(); |
2 |
26 Feb 07 |
jari |
159 |
|
2 |
26 Feb 07 |
jari |
//default Mac Aqua L+F is not serializable, therefore use Java Metal L+F for Mac OS |
2 |
26 Feb 07 |
jari |
161 |
if (os.indexOf("Apple") != -1 || os.indexOf("Mac") != -1 ) { |
2 |
26 Feb 07 |
jari |
162 |
manager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); |
2 |
26 Feb 07 |
jari |
163 |
} |
2 |
26 Feb 07 |
jari |
164 |
|
2 |
26 Feb 07 |
jari |
165 |
Manager.createNewMultipleArrayViewer(); |
2 |
26 Feb 07 |
jari |
166 |
|
2 |
26 Feb 07 |
jari |
167 |
} |
2 |
26 Feb 07 |
jari |
168 |
catch (Exception e) { |
2 |
26 Feb 07 |
jari |
169 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
170 |
} |
2 |
26 Feb 07 |
jari |
171 |
} |
2 |
26 Feb 07 |
jari |
172 |
|
2 |
26 Feb 07 |
jari |
173 |
public static boolean readPreferencesFile(File inputFile) { |
2 |
26 Feb 07 |
jari |
174 |
BufferedReader reader = null; |
2 |
26 Feb 07 |
jari |
175 |
boolean returnValue = true; |
2 |
26 Feb 07 |
jari |
176 |
|
2 |
26 Feb 07 |
jari |
177 |
try { |
2 |
26 Feb 07 |
jari |
178 |
reader = new BufferedReader(new FileReader(inputFile)); |
2 |
26 Feb 07 |
jari |
179 |
} catch (IOException ioe) { |
2 |
26 Feb 07 |
jari |
180 |
ioe.printStackTrace(); |
2 |
26 Feb 07 |
jari |
181 |
returnValue = false; |
2 |
26 Feb 07 |
jari |
182 |
} |
2 |
26 Feb 07 |
jari |
183 |
StringTokenizer ss; |
2 |
26 Feb 07 |
jari |
184 |
try { |
2 |
26 Feb 07 |
jari |
185 |
String currentLine, key; |
2 |
26 Feb 07 |
jari |
186 |
TMEV.properties = new Hashtable(); |
2 |
26 Feb 07 |
jari |
187 |
|
2 |
26 Feb 07 |
jari |
//FL |
2 |
26 Feb 07 |
jari |
189 |
indicesAdjusted = false; |
2 |
26 Feb 07 |
jari |
190 |
|
2 |
26 Feb 07 |
jari |
191 |
while ((currentLine = reader.readLine()) != null) { |
2 |
26 Feb 07 |
jari |
192 |
currentLine.trim(); |
2 |
26 Feb 07 |
jari |
193 |
if (!(currentLine.startsWith("//") || (currentLine.length() == 0))) { |
2 |
26 Feb 07 |
jari |
194 |
ss = new StringTokenizer(currentLine, "\t"); |
2 |
26 Feb 07 |
jari |
195 |
key = ss.nextToken(); |
2 |
26 Feb 07 |
jari |
196 |
if (ss.hasMoreTokens()) properties.put(key, ss.nextToken()); |
2 |
26 Feb 07 |
jari |
197 |
else properties.put(key, new String("")); |
2 |
26 Feb 07 |
jari |
198 |
} |
2 |
26 Feb 07 |
jari |
199 |
} |
2 |
26 Feb 07 |
jari |
200 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
201 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
202 |
} |
2 |
26 Feb 07 |
jari |
203 |
try { |
2 |
26 Feb 07 |
jari |
204 |
String elementInfo = TMEV.getSettingForOption("Element Info"); |
2 |
26 Feb 07 |
jari |
205 |
ss = new StringTokenizer(elementInfo, ":"); |
2 |
26 Feb 07 |
jari |
206 |
coordinatePairCount = Integer.parseInt(ss.nextToken()); |
2 |
26 Feb 07 |
jari |
207 |
intensityCount = Integer.parseInt(ss.nextToken()); |
2 |
26 Feb 07 |
jari |
208 |
|
2 |
26 Feb 07 |
jari |
209 |
String headerInfo = TMEV.getSettingForOption("Headers"); |
2 |
26 Feb 07 |
jari |
210 |
ss = new StringTokenizer(headerInfo, ":"); |
2 |
26 Feb 07 |
jari |
211 |
headerRowCount = Integer.parseInt(ss.nextToken()); |
2 |
26 Feb 07 |
jari |
212 |
headerColumnCount = Integer.parseInt(ss.nextToken()); |
2 |
26 Feb 07 |
jari |
213 |
|
2 |
26 Feb 07 |
jari |
214 |
String uniqueIDString = TMEV.getSettingForOption("Unique ID"); |
2 |
26 Feb 07 |
jari |
215 |
uniqueIDIndex = Integer.parseInt(uniqueIDString); |
2 |
26 Feb 07 |
jari |
216 |
|
2 |
26 Feb 07 |
jari |
217 |
String nameString = TMEV.getSettingForOption("Spot Name"); |
2 |
26 Feb 07 |
jari |
218 |
nameIndex = Integer.parseInt(nameString); |
2 |
26 Feb 07 |
jari |
219 |
|
2 |
26 Feb 07 |
jari |
220 |
String dbs = TMEV.getSettingForOption("Database Names"); |
2 |
26 Feb 07 |
jari |
221 |
ss = new StringTokenizer(dbs, ":"); |
2 |
26 Feb 07 |
jari |
222 |
TMEV.databases = new String[ss.countTokens()]; |
2 |
26 Feb 07 |
jari |
223 |
for (int i = 0; ss.hasMoreTokens(); i++) { |
2 |
26 Feb 07 |
jari |
224 |
TMEV.databases[i] = ss.nextToken(); |
2 |
26 Feb 07 |
jari |
225 |
} |
2 |
26 Feb 07 |
jari |
/* EH removed fieldnames from TMEV because they belong in SlideData |
2 |
26 Feb 07 |
jari |
String additionalFields = TMEV.getSettingForOption("Additional Fields"); |
2 |
26 Feb 07 |
jari |
ss = new StringTokenizer(additionalFields, ":"); |
2 |
26 Feb 07 |
jari |
if (ss.countTokens() > 0) { |
2 |
26 Feb 07 |
jari |
TMEV.fieldNames = new String[ss.countTokens()]; |
2 |
26 Feb 07 |
jari |
for (int i = 0; ss.hasMoreTokens(); i++) { |
2 |
26 Feb 07 |
jari |
TMEV.fieldNames[i] = ss.nextToken(); |
2 |
26 Feb 07 |
jari |
233 |
} |
2 |
26 Feb 07 |
jari |
} else TMEV.fieldNames = null; |
2 |
26 Feb 07 |
jari |
235 |
*/ |
2 |
26 Feb 07 |
jari |
236 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
237 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
238 |
returnValue = false; |
2 |
26 Feb 07 |
jari |
239 |
} |
2 |
26 Feb 07 |
jari |
240 |
return returnValue; |
2 |
26 Feb 07 |
jari |
241 |
} |
2 |
26 Feb 07 |
jari |
242 |
|
2 |
26 Feb 07 |
jari |
243 |
public static String getSettingForOption(String option) { |
2 |
26 Feb 07 |
jari |
244 |
String setting = ""; |
2 |
26 Feb 07 |
jari |
245 |
try { |
2 |
26 Feb 07 |
jari |
246 |
setting = (String) properties.get(option); |
2 |
26 Feb 07 |
jari |
247 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
248 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
249 |
} |
2 |
26 Feb 07 |
jari |
250 |
return setting; |
2 |
26 Feb 07 |
jari |
251 |
} |
2 |
26 Feb 07 |
jari |
252 |
|
2 |
26 Feb 07 |
jari |
253 |
/* |
2 |
26 Feb 07 |
jari |
public static boolean connect(String username, String password) { |
2 |
26 Feb 07 |
jari |
try { |
2 |
26 Feb 07 |
jari |
Class.forName("com.sybase.jdbc2.jdbc.SybDriver"); |
2 |
26 Feb 07 |
jari |
String server = new String(getSettingForOption("Database Server Name")); |
2 |
26 Feb 07 |
jari |
Properties connectionProperties = new Properties(); |
2 |
26 Feb 07 |
jari |
259 |
|
2 |
26 Feb 07 |
jari |
connectionProperties.put("user", username); |
2 |
26 Feb 07 |
jari |
connectionProperties.put("password", password); |
2 |
26 Feb 07 |
jari |
connectionProperties.put("APPLICATIONNAME", "TIGR MultiExperimentViewer"); |
2 |
26 Feb 07 |
jari |
263 |
|
2 |
26 Feb 07 |
jari |
DriverManager.setLoginTimeout(2200); |
2 |
26 Feb 07 |
jari |
TMEV.connection = DriverManager.getConnection(server, connectionProperties); |
2 |
26 Feb 07 |
jari |
return true; |
2 |
26 Feb 07 |
jari |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
System.out.println("Exception (TMEV.connect()): " + e); |
2 |
26 Feb 07 |
jari |
return false; |
2 |
26 Feb 07 |
jari |
270 |
} |
2 |
26 Feb 07 |
jari |
271 |
} |
2 |
26 Feb 07 |
jari |
272 |
*/ |
2 |
26 Feb 07 |
jari |
273 |
|
2 |
26 Feb 07 |
jari |
274 |
/* |
2 |
26 Feb 07 |
jari |
* This code was modified by Jim Johnson with other changes to enable |
2 |
26 Feb 07 |
jari |
* Java Web Start |
2 |
26 Feb 07 |
jari |
277 |
*/ |
2 |
26 Feb 07 |
jari |
278 |
public static boolean connect(String username, String password) { |
2 |
26 Feb 07 |
jari |
279 |
try { |
2 |
26 Feb 07 |
jari |
280 |
System.err.println("jdbc.drivers " + System.getProperty("jdbc.drivers")); |
2 |
26 Feb 07 |
jari |
281 |
for (Enumeration en = DriverManager.getDrivers();en.hasMoreElements();) { |
2 |
26 Feb 07 |
jari |
282 |
System.err.println("jdbc.driver " + en.nextElement()); |
2 |
26 Feb 07 |
jari |
283 |
} |
2 |
26 Feb 07 |
jari |
284 |
String drivers = System.getProperty("jdbc.drivers"); |
2 |
26 Feb 07 |
jari |
285 |
if (drivers != null) { |
2 |
26 Feb 07 |
jari |
286 |
for (StringTokenizer st = new StringTokenizer(drivers,":"); st.hasMoreTokens();) { |
2 |
26 Feb 07 |
jari |
287 |
try { |
2 |
26 Feb 07 |
jari |
288 |
Class.forName(st.nextToken()); |
2 |
26 Feb 07 |
jari |
289 |
} catch (Exception ex) { |
2 |
26 Feb 07 |
jari |
290 |
} |
2 |
26 Feb 07 |
jari |
291 |
} |
2 |
26 Feb 07 |
jari |
292 |
} |
2 |
26 Feb 07 |
jari |
//Class.forName("com.sybase.jdbc2.jdbc.SybDriver"); |
2 |
26 Feb 07 |
jari |
294 |
String server = new String(getSettingForOption("Database Server Name")); |
2 |
26 Feb 07 |
jari |
295 |
Properties connectionProperties = new Properties(); |
2 |
26 Feb 07 |
jari |
296 |
|
2 |
26 Feb 07 |
jari |
297 |
connectionProperties.put("user", username); |
2 |
26 Feb 07 |
jari |
298 |
connectionProperties.put("password", password); |
2 |
26 Feb 07 |
jari |
299 |
connectionProperties.put("APPLICATIONNAME", "TIGR MultiExperimentViewer"); |
2 |
26 Feb 07 |
jari |
300 |
|
2 |
26 Feb 07 |
jari |
301 |
DriverManager.setLoginTimeout(2200); |
2 |
26 Feb 07 |
jari |
302 |
TMEV.connection = DriverManager.getConnection(server, connectionProperties); |
2 |
26 Feb 07 |
jari |
303 |
return true; |
2 |
26 Feb 07 |
jari |
304 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
305 |
System.out.println("Exception (TMEV.connect()): " + e); |
2 |
26 Feb 07 |
jari |
306 |
return false; |
2 |
26 Feb 07 |
jari |
307 |
} |
2 |
26 Feb 07 |
jari |
308 |
} |
2 |
26 Feb 07 |
jari |
309 |
|
2 |
26 Feb 07 |
jari |
310 |
|
2 |
26 Feb 07 |
jari |
311 |
public static int getCoordinatePairCount() {return TMEV.coordinatePairCount;} |
2 |
26 Feb 07 |
jari |
312 |
public static int getIntensityCount() {return TMEV.intensityCount;} |
2 |
26 Feb 07 |
jari |
313 |
public static int getHeaderRowCount() {return TMEV.headerRowCount;} |
2 |
26 Feb 07 |
jari |
314 |
public static int getHeaderColumnCount() {return TMEV.headerColumnCount;} |
2 |
26 Feb 07 |
jari |
/* EH removed fieldNames from TMEV because they belong in SlideData |
2 |
26 Feb 07 |
jari |
public static String[] getFieldNames() { |
2 |
26 Feb 07 |
jari |
if(TMEV.fieldNames == null) |
2 |
26 Feb 07 |
jari |
return new String[0]; |
2 |
26 Feb 07 |
jari |
return TMEV.fieldNames; |
2 |
26 Feb 07 |
jari |
320 |
} |
2 |
26 Feb 07 |
jari |
321 |
*/ |
2 |
26 Feb 07 |
jari |
//wwang for customer icon |
2 |
26 Feb 07 |
jari |
//get initial algorithm list from file tmev.cfg |
2 |
26 Feb 07 |
jari |
324 |
public static int[] getCustomerAnalysis() { |
2 |
26 Feb 07 |
jari |
325 |
String text = new String(""); |
2 |
26 Feb 07 |
jari |
326 |
boolean haveCustomTag = false; |
2 |
26 Feb 07 |
jari |
327 |
String lineSep = System.getProperty("line.separator"); |
2 |
26 Feb 07 |
jari |
328 |
try { |
7 |
24 Aug 07 |
jari |
329 |
BufferedReader br = new java.io.BufferedReader(new InputStreamReader(TMEV.getConfigInputStream())); |
2 |
26 Feb 07 |
jari |
330 |
String line; |
2 |
26 Feb 07 |
jari |
331 |
while((line = br.readLine()) != null) { |
2 |
26 Feb 07 |
jari |
332 |
if(line.indexOf("algorithm-list") != -1) { |
2 |
26 Feb 07 |
jari |
333 |
haveCustomTag=true; |
2 |
26 Feb 07 |
jari |
334 |
line = line.substring(15); |
2 |
26 Feb 07 |
jari |
335 |
if(TMEV.customerAnalysis==null) |
2 |
26 Feb 07 |
jari |
336 |
TMEV.initCustomerAnalysis(line.length()); |
2 |
26 Feb 07 |
jari |
337 |
for(int i=0;i<line.length();i++){ |
2 |
26 Feb 07 |
jari |
338 |
int m=(new Integer(line.substring(i,i+1))).intValue(); |
2 |
26 Feb 07 |
jari |
339 |
TMEV.customerAnalysis[i]=m; |
2 |
26 Feb 07 |
jari |
340 |
} |
2 |
26 Feb 07 |
jari |
341 |
|
2 |
26 Feb 07 |
jari |
342 |
} |
2 |
26 Feb 07 |
jari |
343 |
text += line+lineSep; |
2 |
26 Feb 07 |
jari |
344 |
} |
2 |
26 Feb 07 |
jari |
345 |
br.close(); |
2 |
26 Feb 07 |
jari |
346 |
if(!haveCustomTag){ |
2 |
26 Feb 07 |
jari |
347 |
text +="algorithm-list 1"; |
2 |
26 Feb 07 |
jari |
348 |
BufferedWriter bw = new java.io.BufferedWriter(new FileWriter(TMEV.getFile("config/tmev.cfg"))); |
2 |
26 Feb 07 |
jari |
349 |
bw.write(text); |
2 |
26 Feb 07 |
jari |
350 |
bw.flush(); |
2 |
26 Feb 07 |
jari |
351 |
bw.close(); |
2 |
26 Feb 07 |
jari |
352 |
if(TMEV.customerAnalysis==null) |
2 |
26 Feb 07 |
jari |
353 |
TMEV.initCustomerAnalysis(1); |
2 |
26 Feb 07 |
jari |
354 |
TMEV.customerAnalysis[0]=1; |
2 |
26 Feb 07 |
jari |
355 |
} |
2 |
26 Feb 07 |
jari |
356 |
} catch (IOException ioe) { |
2 |
26 Feb 07 |
jari |
357 |
System.out.print("File tmev.cfg not found"); |
2 |
26 Feb 07 |
jari |
358 |
} |
2 |
26 Feb 07 |
jari |
359 |
return TMEV.customerAnalysis; |
2 |
26 Feb 07 |
jari |
360 |
} |
2 |
26 Feb 07 |
jari |
361 |
|
2 |
26 Feb 07 |
jari |
362 |
public static String getCustomerAnalysisList() { |
2 |
26 Feb 07 |
jari |
363 |
String list=""; |
2 |
26 Feb 07 |
jari |
364 |
for(int i=0;i<TMEV.customerAnalysis.length;i++) |
2 |
26 Feb 07 |
jari |
365 |
list=list+TMEV.customerAnalysis[i]; |
2 |
26 Feb 07 |
jari |
366 |
return list; |
2 |
26 Feb 07 |
jari |
367 |
} |
2 |
26 Feb 07 |
jari |
368 |
|
2 |
26 Feb 07 |
jari |
369 |
public static boolean validCustomerAnalysis() { |
2 |
26 Feb 07 |
jari |
370 |
int count=TMEV.customerAnalysis.length; |
2 |
26 Feb 07 |
jari |
371 |
for(int i=0;i<count;i++){ |
2 |
26 Feb 07 |
jari |
372 |
if(TMEV.customerAnalysis[i]==1) |
2 |
26 Feb 07 |
jari |
373 |
return true; |
2 |
26 Feb 07 |
jari |
374 |
} |
2 |
26 Feb 07 |
jari |
375 |
return false; |
2 |
26 Feb 07 |
jari |
376 |
} |
2 |
26 Feb 07 |
jari |
377 |
|
2 |
26 Feb 07 |
jari |
378 |
public static void initCustomerAnalysis(int total){ |
2 |
26 Feb 07 |
jari |
379 |
TMEV.customerAnalysis=new int[total]; |
2 |
26 Feb 07 |
jari |
380 |
for(int i=0;i<total;i++) |
2 |
26 Feb 07 |
jari |
381 |
TMEV.customerAnalysis[i]=1; |
2 |
26 Feb 07 |
jari |
382 |
} |
2 |
26 Feb 07 |
jari |
383 |
|
2 |
26 Feb 07 |
jari |
384 |
|
2 |
26 Feb 07 |
jari |
385 |
|
2 |
26 Feb 07 |
jari |
386 |
public static void setCustomerAnalysis(int total,int index,int tag) { |
2 |
26 Feb 07 |
jari |
387 |
TMEV.customerAnalysis[index]=tag; |
2 |
26 Feb 07 |
jari |
388 |
} |
2 |
26 Feb 07 |
jari |
389 |
|
2 |
26 Feb 07 |
jari |
390 |
public static void setCustomerStatSave(){ |
2 |
26 Feb 07 |
jari |
391 |
String lineSep = System.getProperty("line.separator"); |
2 |
26 Feb 07 |
jari |
392 |
if(lineSep == null) |
2 |
26 Feb 07 |
jari |
393 |
lineSep = "\n"; |
2 |
26 Feb 07 |
jari |
394 |
String text = new String(""); |
2 |
26 Feb 07 |
jari |
395 |
try { |
7 |
24 Aug 07 |
jari |
396 |
BufferedReader br = new java.io.BufferedReader(new InputStreamReader(TMEV.getConfigInputStream())); |
2 |
26 Feb 07 |
jari |
397 |
String line; |
2 |
26 Feb 07 |
jari |
398 |
while((line = br.readLine()) != null) { |
2 |
26 Feb 07 |
jari |
399 |
if(line.indexOf("algorithm-list") != -1) { |
2 |
26 Feb 07 |
jari |
400 |
line = line.substring(0, line.lastIndexOf(" ")); |
2 |
26 Feb 07 |
jari |
401 |
line += " "+TMEV.getCustomerAnalysisList(); |
2 |
26 Feb 07 |
jari |
402 |
} |
2 |
26 Feb 07 |
jari |
403 |
text += line+lineSep; |
2 |
26 Feb 07 |
jari |
404 |
} |
2 |
26 Feb 07 |
jari |
405 |
|
2 |
26 Feb 07 |
jari |
406 |
br.close(); |
2 |
26 Feb 07 |
jari |
407 |
|
7 |
24 Aug 07 |
jari |
408 |
BufferedWriter bw = new java.io.BufferedWriter(new FileWriter(TMEV.getFile("config/tmev.cfg"))); |
2 |
26 Feb 07 |
jari |
409 |
bw.write(text); |
2 |
26 Feb 07 |
jari |
410 |
bw.flush(); |
2 |
26 Feb 07 |
jari |
411 |
bw.close(); |
2 |
26 Feb 07 |
jari |
412 |
} catch (IOException ioe) { |
2 |
26 Feb 07 |
jari |
413 |
System.out.print("File tmev.cfg not found"); |
2 |
26 Feb 07 |
jari |
414 |
} |
2 |
26 Feb 07 |
jari |
415 |
} |
2 |
26 Feb 07 |
jari |
416 |
|
2 |
26 Feb 07 |
jari |
417 |
public static String[] getDatabases() {return TMEV.databases;} |
2 |
26 Feb 07 |
jari |
418 |
public static int getUniqueIDIndex() {return TMEV.uniqueIDIndex;} |
2 |
26 Feb 07 |
jari |
419 |
public static int getNameIndex() {return TMEV.nameIndex;} |
2 |
26 Feb 07 |
jari |
420 |
public static Connection getConnection() {return TMEV.connection;} |
2 |
26 Feb 07 |
jari |
//pcahan |
2 |
26 Feb 07 |
jari |
422 |
public static int getDataType() {return TMEV.dataType; } |
2 |
26 Feb 07 |
jari |
//set method for use with SuperLoader |
2 |
26 Feb 07 |
jari |
424 |
public static void setDataType(int dataType){ TMEV.dataType = dataType; } |
2 |
26 Feb 07 |
jari |
425 |
public static void setIndicesAdjusted(boolean state) {TMEV.indicesAdjusted = state;} |
2 |
26 Feb 07 |
jari |
426 |
public static boolean indicesAdjusted() {return TMEV.indicesAdjusted;} |
2 |
26 Feb 07 |
jari |
427 |
public static void setUniqueIDIndex(int index) { |
2 |
26 Feb 07 |
jari |
428 |
TMEV.uniqueIDIndex = (index < 0) ? 0 : index; |
2 |
26 Feb 07 |
jari |
429 |
} |
2 |
26 Feb 07 |
jari |
430 |
|
2 |
26 Feb 07 |
jari |
//TODO maybe this should be moved to IData? |
2 |
26 Feb 07 |
jari |
432 |
public static void setNameIndex(int index) { |
2 |
26 Feb 07 |
jari |
433 |
TMEV.nameIndex = (index < 0) ? 0 : index; |
2 |
26 Feb 07 |
jari |
434 |
} |
2 |
26 Feb 07 |
jari |
/* EH removed fieldNames from TMEV because they belong in SlideData |
2 |
26 Feb 07 |
jari |
public static void setFieldNames(String [] fieldNames){ |
2 |
26 Feb 07 |
jari |
TMEV.fieldNames = fieldNames; |
2 |
26 Feb 07 |
jari |
438 |
} |
2 |
26 Feb 07 |
jari |
439 |
|
2 |
26 Feb 07 |
jari |
public static void appendFieldNames(String [] fieldNames){ |
2 |
26 Feb 07 |
jari |
if(TMEV.fieldNames == null || fieldNames == null) //trying to set to null or initial set |
2 |
26 Feb 07 |
jari |
TMEV.fieldNames = fieldNames; |
2 |
26 Feb 07 |
jari |
else { //names exist and new names exist, APPEND (ie. mev format, extra ann load) |
2 |
26 Feb 07 |
jari |
String [] newNames = new String[TMEV.fieldNames.length+fieldNames.length]; |
2 |
26 Feb 07 |
jari |
System.arraycopy(TMEV.fieldNames, 0, newNames, 0, TMEV.fieldNames.length); |
2 |
26 Feb 07 |
jari |
System.arraycopy(fieldNames, 0, newNames, TMEV.fieldNames.length, fieldNames.length); |
2 |
26 Feb 07 |
jari |
TMEV.fieldNames = newNames; |
2 |
26 Feb 07 |
jari |
448 |
} |
2 |
26 Feb 07 |
jari |
449 |
} |
2 |
26 Feb 07 |
jari |
450 |
|
2 |
26 Feb 07 |
jari |
public static void clearFieldNames(){ |
2 |
26 Feb 07 |
jari |
TMEV.fieldNames = null; |
2 |
26 Feb 07 |
jari |
453 |
} |
2 |
26 Feb 07 |
jari |
454 |
*/ |
2 |
26 Feb 07 |
jari |
455 |
public static void setPermitPrompt(boolean permitPrompt) { |
2 |
26 Feb 07 |
jari |
456 |
boolean havePromptTag = false; |
2 |
26 Feb 07 |
jari |
457 |
|
2 |
26 Feb 07 |
jari |
458 |
if(TMEV.permitSavePrompt != permitPrompt) { |
2 |
26 Feb 07 |
jari |
459 |
String value = String.valueOf(permitPrompt); |
2 |
26 Feb 07 |
jari |
460 |
String lineSep = System.getProperty("line.separator"); |
2 |
26 Feb 07 |
jari |
461 |
if(lineSep == null) |
2 |
26 Feb 07 |
jari |
462 |
lineSep = "\n"; |
2 |
26 Feb 07 |
jari |
463 |
String fileName = "tmev.cfg"; |
2 |
26 Feb 07 |
jari |
464 |
String text = new String(""); |
2 |
26 Feb 07 |
jari |
465 |
|
2 |
26 Feb 07 |
jari |
466 |
try { |
7 |
24 Aug 07 |
jari |
467 |
BufferedReader br = new java.io.BufferedReader(new InputStreamReader(TMEV.getConfigInputStream())); |
2 |
26 Feb 07 |
jari |
468 |
String line; |
2 |
26 Feb 07 |
jari |
469 |
while((line = br.readLine()) != null) { |
2 |
26 Feb 07 |
jari |
470 |
if(line.indexOf("prompt-for-save") != -1) { |
2 |
26 Feb 07 |
jari |
471 |
havePromptTag = true; |
2 |
26 Feb 07 |
jari |
472 |
line = line.substring(0, line.lastIndexOf(" ")); |
2 |
26 Feb 07 |
jari |
473 |
line += " "+value; |
2 |
26 Feb 07 |
jari |
474 |
} |
2 |
26 Feb 07 |
jari |
475 |
text += line+lineSep; |
2 |
26 Feb 07 |
jari |
476 |
} |
2 |
26 Feb 07 |
jari |
477 |
|
2 |
26 Feb 07 |
jari |
478 |
if(!havePromptTag){ |
2 |
26 Feb 07 |
jari |
479 |
text += lineSep+"# Prompt save state"+lineSep+"prompt-for-save "+String.valueOf(permitPrompt); |
2 |
26 Feb 07 |
jari |
480 |
} |
2 |
26 Feb 07 |
jari |
481 |
|
2 |
26 Feb 07 |
jari |
482 |
br.close(); |
2 |
26 Feb 07 |
jari |
483 |
|
2 |
26 Feb 07 |
jari |
484 |
BufferedWriter bw = new java.io.BufferedWriter(new FileWriter(fileName)); |
2 |
26 Feb 07 |
jari |
485 |
bw.write(text); |
2 |
26 Feb 07 |
jari |
486 |
bw.flush(); |
2 |
26 Feb 07 |
jari |
487 |
bw.close(); |
2 |
26 Feb 07 |
jari |
488 |
} catch (IOException ioe) { |
2 |
26 Feb 07 |
jari |
//no update to config file |
2 |
26 Feb 07 |
jari |
490 |
} |
2 |
26 Feb 07 |
jari |
491 |
TMEV.permitSavePrompt = permitPrompt; |
2 |
26 Feb 07 |
jari |
492 |
} |
2 |
26 Feb 07 |
jari |
493 |
} |
2 |
26 Feb 07 |
jari |
494 |
|
2 |
26 Feb 07 |
jari |
/* public static void configure() { |
2 |
26 Feb 07 |
jari |
String filename = "tmev.cfg"; |
2 |
26 Feb 07 |
jari |
ConfMap cfg = new ConfMap(); |
2 |
26 Feb 07 |
jari |
try { |
2 |
26 Feb 07 |
jari |
cfg.load( new FileInputStream(filename)); |
2 |
26 Feb 07 |
jari |
500 |
|
2 |
26 Feb 07 |
jari |
String guiFactoryClassName = cfg.getString("gui.factory.class"); |
2 |
26 Feb 07 |
jari |
if (guiFactoryClassName != null && !guiFactoryClassName.equals("null")) { |
2 |
26 Feb 07 |
jari |
Class clazz = Class.forName(guiFactoryClassName); |
2 |
26 Feb 07 |
jari |
guiFactory = (IGUIFactory)clazz.newInstance(); |
2 |
26 Feb 07 |
jari |
} else { |
2 |
26 Feb 07 |
jari |
throw new Exception("GUI factory class name not found, check the 'gui.factory.class' key in "+filename+" file."); |
2 |
26 Feb 07 |
jari |
507 |
} |
2 |
26 Feb 07 |
jari |
algorithmFactory = new TMEVAlgorithmFactory(cfg); |
2 |
26 Feb 07 |
jari |
} catch (IOException ioe) { |
2 |
26 Feb 07 |
jari |
System.out.println("Error to load configuration file."); |
2 |
26 Feb 07 |
jari |
ioe.printStackTrace(); |
2 |
26 Feb 07 |
jari |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
514 |
} |
2 |
26 Feb 07 |
jari |
515 |
} |
2 |
26 Feb 07 |
jari |
516 |
*/ |
2 |
26 Feb 07 |
jari |
517 |
/* |
2 |
26 Feb 07 |
jari |
* This code was modified by Jim Johnson with other changes to enable |
2 |
26 Feb 07 |
jari |
* Java Web Start |
2 |
26 Feb 07 |
jari |
520 |
*/ |
2 |
26 Feb 07 |
jari |
521 |
public static void configure() { |
7 |
24 Aug 07 |
jari |
522 |
String filename = "org/tigr/config/tmev.cfg"; |
2 |
26 Feb 07 |
jari |
523 |
ConfMap cfg = new ConfMap(); |
2 |
26 Feb 07 |
jari |
524 |
try { |
2 |
26 Feb 07 |
jari |
// Try reading configuration from resource |
2 |
26 Feb 07 |
jari |
526 |
try { |
2 |
26 Feb 07 |
jari |
527 |
InputStream is = TMEV.class.getClassLoader().getResourceAsStream(filename); |
2 |
26 Feb 07 |
jari |
528 |
|
2 |
26 Feb 07 |
jari |
529 |
if (is != null) { |
2 |
26 Feb 07 |
jari |
530 |
cfg.load(is); |
2 |
26 Feb 07 |
jari |
531 |
} |
2 |
26 Feb 07 |
jari |
532 |
} catch (SecurityException se) { |
2 |
26 Feb 07 |
jari |
533 |
System.out.println("resource configuration file " + se); |
2 |
26 Feb 07 |
jari |
534 |
} catch (IOException ioe) { |
2 |
26 Feb 07 |
jari |
535 |
System.out.println("Error to load configuration file."); |
2 |
26 Feb 07 |
jari |
536 |
ioe.printStackTrace(); |
2 |
26 Feb 07 |
jari |
537 |
} |
2 |
26 Feb 07 |
jari |
// Try reading configuration from local file |
2 |
26 Feb 07 |
jari |
539 |
try { |
2 |
26 Feb 07 |
jari |
540 |
cfg.load( new FileInputStream(filename) ); |
2 |
26 Feb 07 |
jari |
541 |
} catch (FileNotFoundException fnfe) { |
2 |
26 Feb 07 |
jari |
542 |
System.out.println("local configuration file " + fnfe); |
2 |
26 Feb 07 |
jari |
543 |
} catch (IOException ioe) { |
2 |
26 Feb 07 |
jari |
544 |
System.out.println("Error to load configuration file."); |
2 |
26 Feb 07 |
jari |
545 |
ioe.printStackTrace(); |
2 |
26 Feb 07 |
jari |
546 |
} |
2 |
26 Feb 07 |
jari |
547 |
|
2 |
26 Feb 07 |
jari |
548 |
// |
2 |
26 Feb 07 |
jari |
549 |
String guiFactoryClassName = cfg.getString("gui.factory.class"); |
2 |
26 Feb 07 |
jari |
550 |
|
2 |
26 Feb 07 |
jari |
551 |
if (guiFactoryClassName != null && !guiFactoryClassName.equals("null")) { |
2 |
26 Feb 07 |
jari |
552 |
Class clazz = Class.forName(guiFactoryClassName); |
2 |
26 Feb 07 |
jari |
553 |
guiFactory = (IGUIFactory)clazz.newInstance(); |
2 |
26 Feb 07 |
jari |
554 |
} else { |
2 |
26 Feb 07 |
jari |
555 |
throw new Exception("GUI factory class name not found, check the 'gui.factory.class' key in "+filename+" file."); |
2 |
26 Feb 07 |
jari |
556 |
} |
2 |
26 Feb 07 |
jari |
557 |
algorithmFactory = new TMEVAlgorithmFactory(cfg); |
2 |
26 Feb 07 |
jari |
558 |
|
2 |
26 Feb 07 |
jari |
559 |
TMEV.permitSavePrompt = cfg.getBoolean("prompt-for-save", true); |
2 |
26 Feb 07 |
jari |
560 |
String path = cfg.getProperty("current-data-path"); |
2 |
26 Feb 07 |
jari |
561 |
|
2 |
26 Feb 07 |
jari |
562 |
if(path != null) { |
2 |
26 Feb 07 |
jari |
563 |
String sep = System.getProperty("file.separator"); |
2 |
26 Feb 07 |
jari |
564 |
StringTokenizer stok = new StringTokenizer(path, "/"); |
2 |
26 Feb 07 |
jari |
565 |
path = new String(); |
2 |
26 Feb 07 |
jari |
566 |
while(stok.hasMoreTokens()) |
2 |
26 Feb 07 |
jari |
567 |
path += stok.nextToken()+sep; |
2 |
26 Feb 07 |
jari |
568 |
TMEV.dataPath = path; |
2 |
26 Feb 07 |
jari |
569 |
|
2 |
26 Feb 07 |
jari |
//Mac/Linux needs to start with a / vu4.8.05 |
2 |
26 Feb 07 |
jari |
571 |
if(System.getProperty("os.name").startsWith("Mac")) { |
2 |
26 Feb 07 |
jari |
//TMEV.dataPath = sep + path; |
2 |
26 Feb 07 |
jari |
573 |
} |
2 |
26 Feb 07 |
jari |
574 |
} |
2 |
26 Feb 07 |
jari |
575 |
|
2 |
26 Feb 07 |
jari |
//read the Rserve connection path |
2 |
26 Feb 07 |
jari |
577 |
String sPath = cfg.getString( "rserve-path" ); |
2 |
26 Feb 07 |
jari |
578 |
if( sPath != null && ! sPath.equals("") ) { |
2 |
26 Feb 07 |
jari |
579 |
TMEV.rPath = sPath; |
2 |
26 Feb 07 |
jari |
580 |
} else { |
2 |
26 Feb 07 |
jari |
581 |
TMEV.rPath = "localhost:6311"; |
2 |
26 Feb 07 |
jari |
582 |
} |
2 |
26 Feb 07 |
jari |
583 |
|
7 |
24 Aug 07 |
jari |
584 |
} catch (SecurityException e) { |
7 |
24 Aug 07 |
jari |
585 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
586 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
587 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
588 |
} |
2 |
26 Feb 07 |
jari |
589 |
} |
2 |
26 Feb 07 |
jari |
590 |
|
2 |
26 Feb 07 |
jari |
591 |
public static String getRPath() { |
2 |
26 Feb 07 |
jari |
592 |
return rPath; |
2 |
26 Feb 07 |
jari |
593 |
} |
2 |
26 Feb 07 |
jari |
594 |
|
2 |
26 Feb 07 |
jari |
595 |
public static String getDataPath() { |
2 |
26 Feb 07 |
jari |
596 |
return dataPath; |
2 |
26 Feb 07 |
jari |
597 |
} |
2 |
26 Feb 07 |
jari |
598 |
|
2 |
26 Feb 07 |
jari |
599 |
|
2 |
26 Feb 07 |
jari |
600 |
public static void updateRPath( String rPath ) { |
2 |
26 Feb 07 |
jari |
601 |
if(rPath == null) |
2 |
26 Feb 07 |
jari |
602 |
return; |
2 |
26 Feb 07 |
jari |
603 |
|
2 |
26 Feb 07 |
jari |
//Read tmev.cfg |
2 |
26 Feb 07 |
jari |
605 |
try{ |
7 |
24 Aug 07 |
jari |
606 |
BufferedReader br = new BufferedReader(new InputStreamReader(TMEV.getConfigInputStream())); |
2 |
26 Feb 07 |
jari |
607 |
|
2 |
26 Feb 07 |
jari |
608 |
StringBuffer sb = new StringBuffer(); |
2 |
26 Feb 07 |
jari |
609 |
String line; |
2 |
26 Feb 07 |
jari |
610 |
while( (line = br.readLine()) != null ){ |
2 |
26 Feb 07 |
jari |
611 |
if( line.startsWith( "rserve-path" ) ) { |
2 |
26 Feb 07 |
jari |
//write the new rserve-path |
2 |
26 Feb 07 |
jari |
613 |
sb.append( "rserve-path " ); |
2 |
26 Feb 07 |
jari |
614 |
sb.append( rPath ); |
2 |
26 Feb 07 |
jari |
615 |
sb.append( "\r\n" ); |
2 |
26 Feb 07 |
jari |
616 |
} else { |
2 |
26 Feb 07 |
jari |
617 |
sb.append( line ); |
2 |
26 Feb 07 |
jari |
618 |
sb.append( "\r\n" ); |
2 |
26 Feb 07 |
jari |
619 |
} |
2 |
26 Feb 07 |
jari |
620 |
} |
2 |
26 Feb 07 |
jari |
621 |
|
2 |
26 Feb 07 |
jari |
622 |
|
2 |
26 Feb 07 |
jari |
623 |
BufferedWriter bfr = new BufferedWriter(new FileWriter(TMEV.getFile("config/tmev.cfg"))); |
2 |
26 Feb 07 |
jari |
624 |
bfr.write( sb.toString() ); |
2 |
26 Feb 07 |
jari |
625 |
bfr.flush(); |
2 |
26 Feb 07 |
jari |
626 |
bfr.close(); |
2 |
26 Feb 07 |
jari |
627 |
br.close(); |
2 |
26 Feb 07 |
jari |
628 |
|
2 |
26 Feb 07 |
jari |
629 |
} catch (IOException e){ |
2 |
26 Feb 07 |
jari |
630 |
System.out.println("Error updating rserve path in tmev.cfg file."); |
2 |
26 Feb 07 |
jari |
631 |
} |
2 |
26 Feb 07 |
jari |
632 |
} |
2 |
26 Feb 07 |
jari |
633 |
|
2 |
26 Feb 07 |
jari |
634 |
|
2 |
26 Feb 07 |
jari |
/** Updates the data path in config given a formatted data path string |
2 |
26 Feb 07 |
jari |
636 |
*/ |
2 |
26 Feb 07 |
jari |
637 |
public static void updateDataPath(String dataPath){ |
2 |
26 Feb 07 |
jari |
638 |
if(dataPath == null) |
2 |
26 Feb 07 |
jari |
639 |
return; |
2 |
26 Feb 07 |
jari |
640 |
|
2 |
26 Feb 07 |
jari |
641 |
String lineSep = System.getProperty("line.separator"); |
2 |
26 Feb 07 |
jari |
642 |
|
2 |
26 Feb 07 |
jari |
//Read tmev.cfg |
2 |
26 Feb 07 |
jari |
644 |
try{ |
7 |
24 Aug 07 |
jari |
645 |
BufferedReader br = new BufferedReader(new InputStreamReader(TMEV.getConfigInputStream())); |
2 |
26 Feb 07 |
jari |
646 |
|
2 |
26 Feb 07 |
jari |
647 |
String content = new String(); |
2 |
26 Feb 07 |
jari |
648 |
String line; |
2 |
26 Feb 07 |
jari |
649 |
while( (line = br.readLine()) != null && !((line).equals("#DATA PATH"))){ |
2 |
26 Feb 07 |
jari |
650 |
content += line+lineSep; |
2 |
26 Feb 07 |
jari |
651 |
} |
2 |
26 Feb 07 |
jari |
652 |
|
2 |
26 Feb 07 |
jari |
653 |
if(line == null) { //if at end of file |
2 |
26 Feb 07 |
jari |
654 |
content += lineSep; |
2 |
26 Feb 07 |
jari |
655 |
content += "#DATA PATH"+lineSep; |
2 |
26 Feb 07 |
jari |
656 |
content += "current-data-path "+dataPath+lineSep; |
2 |
26 Feb 07 |
jari |
657 |
} else { |
2 |
26 Feb 07 |
jari |
658 |
br.readLine(); //pass old path |
2 |
26 Feb 07 |
jari |
659 |
content += "#DATA PATH"+lineSep; |
2 |
26 Feb 07 |
jari |
660 |
content += "current-data-path "+dataPath+lineSep; |
2 |
26 Feb 07 |
jari |
661 |
while( (line = br.readLine()) != null ){ |
2 |
26 Feb 07 |
jari |
662 |
content += line+lineSep; |
2 |
26 Feb 07 |
jari |
663 |
} |
2 |
26 Feb 07 |
jari |
664 |
} |
2 |
26 Feb 07 |
jari |
665 |
|
2 |
26 Feb 07 |
jari |
666 |
|
2 |
26 Feb 07 |
jari |
667 |
BufferedWriter bfr = new BufferedWriter(new FileWriter(TMEV.getFile("config/tmev.cfg"))); |
2 |
26 Feb 07 |
jari |
668 |
bfr.write(content); |
2 |
26 Feb 07 |
jari |
669 |
bfr.flush(); |
2 |
26 Feb 07 |
jari |
670 |
bfr.close(); |
2 |
26 Feb 07 |
jari |
671 |
br.close(); |
2 |
26 Feb 07 |
jari |
672 |
|
2 |
26 Feb 07 |
jari |
673 |
} catch (IOException e){ |
2 |
26 Feb 07 |
jari |
674 |
System.out.println("Error updating data path in tmev.cfg file."); |
2 |
26 Feb 07 |
jari |
675 |
} |
2 |
26 Feb 07 |
jari |
676 |
} |
2 |
26 Feb 07 |
jari |
677 |
|
2 |
26 Feb 07 |
jari |
678 |
|
2 |
26 Feb 07 |
jari |
679 |
public static void setDataPath(String newPath) { |
2 |
26 Feb 07 |
jari |
680 |
dataPath = newPath; |
2 |
26 Feb 07 |
jari |
681 |
} |
2 |
26 Feb 07 |
jari |
682 |
|
2 |
26 Feb 07 |
jari |
683 |
|
2 |
26 Feb 07 |
jari |
684 |
public static AlgorithmFactory getAlgorithmFactory() { |
2 |
26 Feb 07 |
jari |
685 |
return algorithmFactory; |
2 |
26 Feb 07 |
jari |
686 |
} |
2 |
26 Feb 07 |
jari |
687 |
|
2 |
26 Feb 07 |
jari |
688 |
public static IGUIFactory getGUIFactory() { |
2 |
26 Feb 07 |
jari |
689 |
return guiFactory; |
2 |
26 Feb 07 |
jari |
690 |
} |
2 |
26 Feb 07 |
jari |
691 |
|
2 |
26 Feb 07 |
jari |
692 |
public static void quit() { |
2 |
26 Feb 07 |
jari |
693 |
try { |
2 |
26 Feb 07 |
jari |
694 |
connection.close(); |
2 |
26 Feb 07 |
jari |
695 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
696 |
; |
2 |
26 Feb 07 |
jari |
697 |
} |
2 |
26 Feb 07 |
jari |
698 |
System.exit(0); |
2 |
26 Feb 07 |
jari |
699 |
} |
2 |
26 Feb 07 |
jari |
700 |
|
2 |
26 Feb 07 |
jari |
701 |
|
2 |
26 Feb 07 |
jari |
/** Returns the configuration file indicated by the fileName argument |
2 |
26 Feb 07 |
jari |
703 |
*/ |
2 |
26 Feb 07 |
jari |
704 |
public static File getConfigurationFile(String fileName) { |
2 |
26 Feb 07 |
jari |
705 |
return new File("config/"+fileName); |
2 |
26 Feb 07 |
jari |
706 |
} |
2 |
26 Feb 07 |
jari |
707 |
|
2 |
26 Feb 07 |
jari |
/** Returns a file relative to the base directory |
2 |
26 Feb 07 |
jari |
709 |
*/ |
2 |
26 Feb 07 |
jari |
710 |
public static File getFile(String fileName) { |
2 |
26 Feb 07 |
jari |
711 |
return new File(fileName); |
2 |
26 Feb 07 |
jari |
712 |
} |
2 |
26 Feb 07 |
jari |
713 |
|
7 |
24 Aug 07 |
jari |
714 |
public static InputStream getConfigInputStream() { |
7 |
24 Aug 07 |
jari |
715 |
return TMEV.class.getClassLoader().getResourceAsStream("org/tigr/config/tmev.cfg"); |
7 |
24 Aug 07 |
jari |
716 |
} |
7 |
24 Aug 07 |
jari |
717 |
|
2 |
26 Feb 07 |
jari |
/** Returns a string representing the OS name |
2 |
26 Feb 07 |
jari |
719 |
*/ |
2 |
26 Feb 07 |
jari |
720 |
public static String getOSName() { |
2 |
26 Feb 07 |
jari |
721 |
return os; |
2 |
26 Feb 07 |
jari |
722 |
} |
2 |
26 Feb 07 |
jari |
723 |
} |