1 /*** MirkE.java - part of the MirkE (say murky) application for colormetric analysis emphesizing
2 kinetics.
3
4 Created by: Scott Menor on 21 July, 2004.
5
6 Copyright (c) 2004,2005 Arizona State University - Cancer Research Institute. All rights reserved.
7
8 MirkE is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 MirkE is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with MirkE; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
21 */
22
23 package edu.asu.cri.MirkE;
24
25 import edu.asu.cri.MirkE.dataStructures.DataSet;
26 import edu.asu.cri.MirkE.exceptions.MirkESystemException;
27 import edu.asu.cri.MirkE.exceptions.MirkEApplicationException;
28 import edu.asu.cri.MirkE.gui.EventDispatcher;
29 import edu.asu.cri.MirkE.gui.MainFrame;
30 import edu.asu.cri.MirkE.gui.MirkeContext;
31 import edu.asu.cri.MirkE.io.VictorTextFileDataSetLoader;
32 import edu.asu.cri.MirkE.trace.*;
33
34 import edu.asu.cri.MirkE.exceptions.MirkEIOException;
35
36
37 import java.io.File;
38 import java.io.IOException;
39 import java.util.Locale;
40
41 import org.apache.commons.logging.Log;
42 import org.apache.commons.logging.LogFactory;
43
44 /*** MirkE - developed to facilitate simple (and not so simple) tasks for colormetric analysis assays
45
46 @author Scott Menor
47 @version 0.3.0, 2 februrary, 2004
48 */
49 public class MirkE
50 {
51 private DataSet dataSet;
52
53
54 final static int FALSE_COLOR = 0;
55 final static int QUASI_TRUE_COLOR = 1;
56 final static int MEASURED_COLORS = 2;
57 final static int GRAY_SCALE = 3;
58 private static long mirkeId;
59
60 /***
61 * Comment for <code>colorModel</code>
62 */
63 public int colorModel = GRAY_SCALE;
64
65
66 final static int LINEAR_SCALE = 0;
67 final static int LOG_SCALE = 1;
68 /***
69 * Logger
70 * */
71 private static final Log log = LogFactory.getLog(MirkE.class);
72
73 /***
74 * Comment for <code>scale</code>
75 */
76 public int scale = LINEAR_SCALE;
77
78 /***
79
80 @param dataSet
81 */
82 public void setDataSet(DataSet dataSet)
83 {
84 this.dataSet = dataSet;
85 }
86
87 /***
88
89 @return dataSet
90 */
91 public DataSet getDataSet()
92 {
93 return dataSet;
94 }
95
96
97 private MainFrame mainFrame;
98
99 /***
100 * @param mainFrame
101 */
102 public void setMainFrame(MainFrame mainFrame)
103 {
104 this.mainFrame = mainFrame;
105 }
106
107 /***
108 @return mainFrame
109 */
110 public MainFrame getMainFrame()
111 {
112 return this.mainFrame;
113 }
114
115 private EventDispatcher eventDispatcher;
116
117 /***
118 @param eventDispatcher
119 */
120 public void setEventDispatcher(EventDispatcher eventDispatcher)
121 {
122 this.eventDispatcher = eventDispatcher;
123 }
124
125 /***
126 @return eventDispatcher
127 */
128 public EventDispatcher getEventDispatcher()
129 {
130 return this.eventDispatcher;
131 }
132
133 /*** default constructor
134 *
135 // TODO - open to a simple spreadsheet like view
136 */
137 public MirkE()
138 {
139 try{
140
141
142 dataSet = new edu.asu.cri.MirkE.dataStructures.DataSet();
143 }catch(MirkESystemException mae){
144 System.exit(-1);
145 }
146 eventDispatcher = new edu.asu.cri.MirkE.gui.EventDispatcher(this);
147
148 MirkeContext.setMirke(this);
149 new MainFrame(this);
150 }
151
152 /***
153 * @param filename
154 * @throws IOException
155 * @throws MirkEApplicationException
156 * @throws MirkESystemException
157 */
158 public MirkE(String filename) throws IOException, MirkEApplicationException,MirkESystemException
159
160 {
161
162 try{
163 dataSet = VictorTextFileDataSetLoader.load(filename);
164 } catch (IOException io){
165 throw new MirkEIOException((Throwable)io);
166 }
167
168 eventDispatcher = new edu.asu.cri.MirkE.gui.EventDispatcher(this);
169 MirkE_ExceptionHandler.setErrorMapRequired(true,++mirkeId);
170
171 new MainFrame(this);
172 }
173
174 /***
175 * @param files
176 * @throws MirkEApplicationException
177 * @throws IOException
178 * @throws MirkESystemException
179 */
180 public MirkE(File[] files) throws IOException, MirkEApplicationException,MirkESystemException
181 {
182
183
184
185 MirkE_ExceptionHandler.setErrorMapRequired(true,++mirkeId);
186 dataSet = VictorTextFileDataSetLoader.load(files);
187
188
189 eventDispatcher = new edu.asu.cri.MirkE.gui.EventDispatcher(this);
190 MirkE_ExceptionHandler.setErrorMapRequired(true,++mirkeId);
191 new MainFrame(this);
192 }
193
194 /***
195 * @param args
196 */
197 public static void main(String args[])
198 {
199 Locale.setDefault(Locale.US);
200 log.debug("main ... ");
201 if(args == null || args.length <= 0) {
202 MirkE_ExceptionHandler.setTraceEnabled(false);
203
204 }else if(("trace").equalsIgnoreCase(args[0])){
205 MirkE_ExceptionHandler.setTraceEnabled(true);
206 System.out.println(" ***** setting trace to true -->"+args[0]);
207 }else{
208 MirkE_ExceptionHandler.setTraceEnabled(false);
209 System.out.println("***** setting trace to false -->"+args[0]);
210 }
211 try{
212
213
214 MirkE_ExceptionHandler.setErrorMapRequired(false,++mirkeId);
215 new MirkE();
216 } catch (Exception exception) {
217 exception.printStackTrace();
218 }
219
220 }
221 }