Mercurial > hg > mep
comparison ExperimentGui.java @ 23:9fc8683b8fed
Fixed GUI button presses, had their background change as feedback and added ability to record responses for a probe tone at the end of a sequence
author | JShulver |
---|---|
date | Wed, 07 Nov 2012 18:22:01 +0000 |
parents | 3dd7636ca811 |
children | c5db34797ff3 |
comparison
equal
deleted
inserted
replaced
22:5c54f5213f3d | 23:9fc8683b8fed |
---|---|
31 | 31 |
32 /* accessors */ | 32 /* accessors */ |
33 public Boolean getAcceptingResponses() { return acceptingResponses; } | 33 public Boolean getAcceptingResponses() { return acceptingResponses; } |
34 public void setAcceptingResponses(Boolean b) { | 34 public void setAcceptingResponses(Boolean b) { |
35 if (exp.getDebug()) | 35 if (exp.getDebug()) |
36 System.out.println("Changing acceptingResponses from " + acceptingResponses + " to " + b); | 36 System.out.println("\n\nChanging acceptingResponses from " + acceptingResponses + " to " + b); |
37 acceptingResponses = b; | 37 acceptingResponses = b; |
38 } | 38 } |
39 public Experiment getExperiment() { return exp; } | 39 public Experiment getExperiment() { return exp; } |
40 public InstructionsPanel getInstructionsPanel() { return instructionsPanel; } | 40 public InstructionsPanel getInstructionsPanel() { return instructionsPanel; } |
41 public StimulusPanel getStimulusPanel() { return stimulusPanel; } | 41 public StimulusPanel getStimulusPanel() { return stimulusPanel; } |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 /* Show the Fixation Point */ | 110 /* Show the Fixation Point */ |
111 public void showFixationPoint() { | 111 public void showFixationPoint() { |
112 //System.out.println("showFixationPoint"); | 112 System.out.println("showFixationPoint"); |
113 clock.showClock = false; | 113 clock.showClock = false; |
114 clock.showFullClock = false; | 114 clock.showFullClock = false; |
115 clock.repaint(); | 115 clock.repaint(); |
116 } | 116 } |
117 | 117 |
128 } | 128 } |
129 try { Thread.sleep (1000); } catch (InterruptedException e) {} | 129 try { Thread.sleep (1000); } catch (InterruptedException e) {} |
130 showFixationPoint(); | 130 showFixationPoint(); |
131 } | 131 } |
132 | 132 |
133 | |
133 /* Run method for this thread */ | 134 /* Run method for this thread */ |
134 public void run() { | 135 public void run() { |
135 | 136 System.out.println("Run!"); |
136 //showFixationPoint(); | 137 //showFixationPoint(); |
137 clock.reset(); | 138 clock.reset(); |
138 showClock(); | 139 showClock(); |
139 | 140 |
140 int clockUnits = exp.getClockUnits(); | 141 int clockUnits = exp.getClockUnits(); |
158 long nextClockStartTime = ((Long)(ci.next())).longValue(); | 159 long nextClockStartTime = ((Long)(ci.next())).longValue(); |
159 | 160 |
160 int clockUnit = 0; | 161 int clockUnit = 0; |
161 boolean clockTicking = false; | 162 boolean clockTicking = false; |
162 | 163 |
163 while(oi.hasNext()) { | 164 do { //using a do-while construct allows the user to enter a value at the end |
165 //this should not really be in the 'view' anyway... | |
166 System.out.println("TATUM: " +tatum); | |
167 tatumInMilliseconds = tatum/1000; | |
164 if (exp.getDebug()) | 168 if (exp.getDebug()) |
165 System.out.println("Ticking = " + clockTicking + | 169 System.out.println("Ticking = " + clockTicking + |
166 "; clockUnit = " + clockUnit + | 170 "; clockUnit = " + clockUnit + |
167 "; currentOnset = " + currentOnset + | 171 "; currentOnset = " + currentOnset + |
168 "; nextEventOnset = " + nextEventOnset + | 172 "; nextEventOnset = " + nextEventOnset + |
169 "; nextClockStartTime = " + nextClockStartTime + | 173 "; nextClockStartTime = " + nextClockStartTime + |
170 "; probe = " + probe); | 174 "; probe = " + probe); |
171 if (clockTicking == true && clockUnit == 0) | 175 if (clockTicking == true && clockUnit == 0) |
172 tick(nMinutes); | 176 tick(nMinutes); |
173 | 177 |
174 if (currentOnset == nextClockStartTime) { | 178 if (currentOnset >= nextClockStartTime) { |
175 //new Thread(clock).start(); | 179 //new Thread(clock).start(); |
176 clock.reset(); | 180 clock.reset(); |
177 showClock(); | 181 showClock(); |
178 clockTicking = true; | 182 clockTicking = true; |
179 if (ci.hasNext()) | 183 if (ci.hasNext()) |
180 nextClockStartTime = ((Long)(ci.next())).longValue(); | 184 nextClockStartTime = ((Long)(ci.next())).longValue(); |
185 else | |
186 nextClockStartTime = Long.MAX_VALUE; | |
181 } | 187 } |
182 | 188 if (currentOnset >= nextEventOnset) { |
183 if (currentOnset == nextEventOnset) { | 189 probe = (ProbeID)pi.next(); |
184 // Manipulate display depending on probe identifier | 190 // Manipulate display depending on probe identifier |
185 switch (probe) { | 191 switch (probe) { |
186 case NOT_PROBE: | 192 case NOT_PROBE: |
187 // if (clock.showClock == true) | 193 // if (clock.showClock == true) |
188 // tick(nMinutes); | 194 // tick(nMinutes); |
220 default: | 226 default: |
221 System.out.println("Unexpected probe id: " + probe); | 227 System.out.println("Unexpected probe id: " + probe); |
222 break; | 228 break; |
223 } | 229 } |
224 // Update probe identifier and onset | 230 // Update probe identifier and onset |
225 probe = (ProbeID)pi.next(); | 231 |
226 if (exp.getDebug()) | 232 if (exp.getDebug()) |
227 System.out.println("Next probe = " + probe); | 233 System.out.println("Next probe = " + probe); |
228 nextEventOnset =((Long)(oi.next())).longValue(); | 234 nextEventOnset =((Long)(oi.next())).longValue(); |
229 } | 235 } |
230 // sleep for a tatum | 236 // sleep for a tatum |
231 try { Thread.sleep(tatumInMilliseconds); } | 237 try { Thread.sleep(tatumInMilliseconds); } |
232 catch (InterruptedException e) {} | 238 catch (InterruptedException e) {} |
233 currentOnset += tatum; | 239 currentOnset += tatum; |
234 clockUnit = (clockUnit + 1) % clockUnits; | 240 clockUnit = (clockUnit + 1) % clockUnits; |
235 } | 241 } while(oi.hasNext()); |
236 showFixationPoint(); | 242 showFixationPoint(); |
237 } | 243 } |
238 } | 244 } |