View Javadoc
1   /*** EventDispatcher.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 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.gui;
24  
25  import edu.asu.cri.MirkE.*;
26  import edu.asu.cri.MirkE.util.*;
27  import edu.asu.cri.MirkE.exceptions.MirkEApplicationException;
28  import edu.asu.cri.MirkE.exceptions.MirkESystemException;
29  import java.awt.event.*;
30  import javax.swing.*;
31  import java.io.*;
32  
33  import org.apache.commons.logging.Log;
34  import org.apache.commons.logging.LogFactory;
35  
36  /***
37   * @author smenor
38   *
39   */
40  public class EventDispatcher implements ActionListener
41  {
42      private MirkE mirke;
43      
44      
45      /***
46       * Logger
47       * */
48      private static final Log log = LogFactory.getLog(EventDispatcher.class);
49  
50      /*** constructor for an EventDispatcher for a specific instance of MirkE
51       * @param mirke
52      */
53      public EventDispatcher(MirkE mirke)
54      {
55          this.mirke = mirke;
56      }
57  
58      /*** Empty constructor for event despatcher
59      */
60      public EventDispatcher()
61      {
62          this.mirke = MirkeContext.getMirke();
63      }
64  
65      /***
66      @param mirke
67       */
68      public void setMirke(MirkE mirke)
69      {
70          this.mirke = mirke;
71      }
72  
73      /***
74      	@return mirke
75      	*/
76      public MirkE getMirke()
77      {
78          return mirke;
79      }
80  
81      // TODO - move this to a new import class and make it persistant 
82      static String currentPath = "";
83           
84      /*** import a DataSet
85       * @throws IOException
86       * @throws MirkEApplicationException
87      	*/
88      public void importDataSet() throws java.io.IOException, MirkEApplicationException,MirkESystemException
89      {
90          // TODO - move this to its own class
91          // TODO - remove hard coded constant path below
92          //JFileChooser fileChooser =
93          //    new JFileChooser("D://RND//Mirke//doc//sample Files");
94         
95          JFileChooser fileChooser =
96              new JFileChooser(currentPath);
97          fileChooser.setDialogTitle("Import a Data Set");
98          fileChooser.setMultiSelectionEnabled(true);
99          fileChooser.showDialog(
100             mirke.getMainFrame(),
101             "Import");
102         File[] files = fileChooser.getSelectedFiles();
103         if (files.length > 0)
104         {
105             new MirkE(files);
106         }
107         
108         currentPath = fileChooser.getCurrentDirectory().getAbsolutePath();
109     }
110     
111     /***
112      * 
113      */
114     public void close()
115     {
116         System.exit(0);
117     }
118 
119     /*** plot growth curves
120      * @throws IOException
121      * @throws MirkEApplicationException
122      */
123     public void plotGrowthCurves()throws IOException, MirkEApplicationException
124     {
125         GrowthCurveDataAnalyzer growthCurveDataAnalyzer =
126             new GrowthCurveDataAnalyzer(mirke);
127         growthCurveDataAnalyzer.computeGrowthCurves();
128 
129     }
130 
131     /***
132      * @throws MirkEApplicationException
133      */
134     public void metabolicAssays() throws MirkEApplicationException
135     {
136         new MetabolicAssayDataAnalyzer(mirke);
137     }
138 
139     
140     /***
141      * @throws MirkEApplicationException
142      
143      */
144     public void showPerWellAnalysis() throws MirkEApplicationException 
145     {
146         PerWellDataAnalyzer perWellDataAnalyzer = new PerWellDataAnalyzer(mirke);
147         perWellDataAnalyzer.computeAndDisplayPerWellMeans();
148         
149     }
150     
151     /*** process an event 
152     
153     /** process an event
154 
155     @param event
156     */
157     public void actionPerformed(ActionEvent event)
158     {
159         try
160         {
161             this
162                 .getClass()
163                 .getDeclaredMethod(event.getActionCommand(), new Class[0])
164                 .invoke(this, new Object[0]);
165 
166         }
167         catch (Exception exception)
168         {
169 
170             log.error("Error reflection --> "+exception);
171 
172             // TODO - recover gracefully
173         }
174     }
175 }