I lack focus...

Reply

Join Date: Jul 2005
Posts: 20
Reputation: MonkeyCode is an unknown quantity at this point 
Solved Threads: 0
MonkeyCode MonkeyCode is offline Offline
Newbie Poster

I lack focus...

 
0
  #1
Aug 8th, 2005
Or rather, my program does. I'm supposedly revising someone else's working code, but the stuff I compile doesn't do quite the same thing the packaged version they did... not sure whether it's a version difference, or a compiler difference (I used both JDK 1.3.1 and JBuilder 2005) or a computer difference (In Java? Heaven forbid!) or the problem exists between chair and keyboard.
The current problem I'm trying to address is a keyboard shortcuts class. It's being constructed, and attached to a Base (extends JWindow) class, and the Base is focusable, visible, and set as having focus, but none of the keyboard shortcuts respond. In fact, I have a System.out.println statement at the very start of the overridden KeyTyped class which doesn't print, even when I'm sure that I typed keys.
There's a program selector window that starts various different versions of Base, and for reasons unknown, after each subprogram starts, the program selector window pops up again (which is certainly not how the packaged version works. Even when I click on the window with the program I'm working with, the program selector comes to the front again. I minimize it to do the work with the subprogram, but I think it might still be grabbing the focus while minimized.
How would I determine who has focus, let alone make sure that Base keeps it until it's done? What else do you need to know?
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 45
Reputation: cheenu78 is an unknown quantity at this point 
Solved Threads: 0
cheenu78's Avatar
cheenu78 cheenu78 is offline Offline
Light Poster

Re: I lack focus...

 
0
  #2
Aug 9th, 2005
hi
can you attach necessary source code so that any body can run on their system and reply you back with their suggessions?
Regards
Srinivas
We come to love not by finding a perfect person, but by learning to see an imperfect person perfectly.

-Sam Keen, from To Love and Be Loved
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 20
Reputation: MonkeyCode is an unknown quantity at this point 
Solved Threads: 0
MonkeyCode MonkeyCode is offline Offline
Newbie Poster

Re: I lack focus...

 
0
  #3
Aug 9th, 2005
Originally Posted by cheenu78
hi
can you attach necessary source code so that any body can run on their system and reply you back with their suggessions?
Regards
Srinivas
Well, I was hoping to avoid that; there's quite a lot of it...
Apologies in advance for the lack of commentary and the level of twistiness. I didn't write any of it to start off with, and am still trying to trim it down to something recognizable.
There's a y class with the main in it that calls the programselector.

  1. /** Class for window used during tests
  2.  * Takes care of initiating tests, drawing tests, and
  3.  * cleaning up after test ends
  4.  **/
  5.  
  6. package yerkes;
  7.  
  8. import javax.swing.*;
  9. import java.awt.Color;
  10. import java.awt.*;
  11. import java.awt.event.*;
  12. import java.awt.image.*;
  13. import java.util.*;
  14. import java.awt.Graphics;
  15. import java.io.*;
  16. import javax.sound.sampled.*;
  17.  
  18.  
  19. /**
  20.  *
  21.  * @author Pearce Peck-Walden
  22.  *
  23.  **/
  24. class Base extends JWindow {
  25.  
  26. public String Tester, imageDirectory, monkeyid, dbHost;
  27. public boolean isDB, isSettingUp, written;
  28. public KeyEvent buttonPress;
  29. public int card, isBetween, correction, readytobypass;
  30. public int[][] customGrid;
  31. public Object[][] customImages;
  32. public String[] imageNames;
  33. private int skipInitial;
  34. private program1aHandler p1a;
  35. private program1bHandler p1b;
  36. private program2aHandler p2a;
  37. private program2bHandler p2b;
  38. private program3aHandler p3a;
  39. private program3bHandler p3b;
  40. private program4Handler p4;
  41. private program5Handler p5;
  42. private program6Handler p6;
  43. private program7Handler p7;
  44. private program8Handler p8;
  45. private startHandler sh;
  46. private Vector theImages;
  47. private JFrame tWindow;
  48. private int number, trials, customSize, baseline;
  49. private ImageIcon test;
  50. private int count, theC, countValid, pr, csst, reward, comPort, time, delay, customShift, customNumberStimuli;
  51. private int theX, theY, theX2, theY2, w, h, swap, numberOfImages, width, height, attention;
  52. protected int started;
  53. private java.util.Timer t;
  54. private String Date, Id, prog, size;
  55. private float[] delays;
  56. private FileOutputStream outputFile = null;
  57. private PrintWriter outputStream = null;
  58. private Color[] colors = { Color.black, Color.blue, Color.gray, Color.green, Color.orange, Color.pink,
  59. Color.yellow, Color.red, Color.white, new Color( 128, 64, 0 ), Color.cyan, Color.magenta, new Color( 153, 0, 153 ),
  60. Color.red, Color.green };
  61. private int[] theXs;
  62. private int[] theYs;
  63. private int[] csstData;
  64. private float iti;
  65. private Clip correctSound, incorrectSound;
  66. private ImageIcon asterix;
  67. private ImageIcon ii1, ii2;
  68. private BufferedImage buf;
  69. protected Graphics g2;
  70. private String[] customTargets;
  71. private boolean isProgressiveDelays;
  72.  
  73. /** Creates new Base */
  74. public Base(Vector images, JFrame window, int program, String p, int theDelay,
  75. int tallow, String date, String id, String tester, int tr, float[] d, String outFile,
  76. String imageDir, String screenSize, int c, int v, int fr, String ititemp, String VD, String VT,
  77. int at, int v2, int rgb, int port, int cursor, int crd, Clip CS, Clip IS, String db, String custom1,
  78. String custom2, String custom3, String custom4, int stim, int shfts, int progDel, int corProc ) {
  79.  
  80. if ( progDel == 0 ) isProgressiveDelays = true;
  81. else isProgressiveDelays = false;
  82. isBetween = 0;
  83. customTargets = new String[4];
  84. skipInitial = 0;
  85. customTargets[0] = custom1;
  86. customTargets[1] = custom2;
  87. customTargets[2] = custom3;
  88. customTargets[3] = custom4;
  89. customShift = shfts;
  90. customNumberStimuli = stim + 2;
  91. card = crd;
  92. theImages = images;
  93. tWindow = window;
  94. number = program;
  95. readytobypass = 0;
  96. prog = p;
  97. setBackground(Color.black);
  98. Date = date;
  99. Id = id;
  100. monkeyid = id;
  101. dbHost = db;
  102. Tester = tester;
  103. trials = tr;
  104. time = tallow;
  105. delays = d;
  106. delay = theDelay;
  107. size = screenSize;
  108. imageDirectory = imageDir;
  109. count = 0;
  110. swap = 0;
  111. numberOfImages = 1;
  112. theC = c;
  113. countValid = v;
  114. pr = fr;
  115. csst = v2;
  116. try{ iti = Float.parseFloat(ititemp); } catch (Exception e) {}
  117. attention = at;
  118. t = new java.util.Timer();
  119. correctSound = CS;
  120. incorrectSound = IS;
  121. comPort = port;
  122. reward = rgb;
  123. correction = corProc;
  124. isSettingUp = written = false;
  125.  
  126. if ( dbHost.equals("")) {
  127. isDB = false;
  128. }
  129. else {
  130. isDB = true;
  131. }
  132.  
  133.  
  134. if(reward != 0)
  135. {
  136. com.setTime(Float.parseFloat(VD), Float.parseFloat(VT));
  137. usbHandler.setTime(Float.parseFloat(VD), Float.parseFloat(VT));
  138. }
  139.  
  140. started = -1;
  141. asterix = new ImageIcon ( getClass().getResource("asterix.jpg") );
  142. if(cursor == 0)
  143. {
  144. this.setCursor( Toolkit.getDefaultToolkit().createCustomCursor(
  145. new ImageIcon ( getClass().getResource("cursor.gif")).getImage(),
  146. new Point(0,0),""));
  147. }
  148.  
  149.  
  150. //If there is an output file, open it and write the general info
  151. if( ! ( outFile.equals("") ) )
  152. {
  153. try {
  154. outputFile = new FileOutputStream( outFile, true );
  155. outputStream = new PrintWriter( outputFile, true );
  156. writeHeader();
  157. } catch ( FileNotFoundException err ) {}
  158. }
  159.  
  160. //Data to for determining the position of items in the test
  161. if( size.equals( "1024x768" ) )
  162. {
  163. setBounds(0,0,1024,768);
  164. theX = ( 1024 / 2 ) - 200 / 2;
  165. theY = ( 768 / 2 ) - 200 / 2;
  166. w = 1024;
  167. h = 768;
  168. width = 200;
  169. height = 200;
  170. customSize = 200;
  171. }
  172. else
  173. {
  174. setBounds(0,0,800,600);
  175. theX = ( 800 / 2 ) - 150 / 2;
  176. theY = ( 600 / 2 ) - 150 / 2;
  177. w = 800;
  178. h = 600;
  179. width = 150;
  180. height = 150;
  181. customSize = 150;
  182. }
  183. //Handler for quitting the program when q/Q is pressed
  184. BypassHandler BP = new BypassHandler( this, t );
  185. this.addKeyListener( BP );
  186.  
  187. //Handler for displaying the start image
  188. sh = new startHandler( this, theX, theY, width, height);
  189. this.addMouseListener( sh );
  190.  
  191. //Make the visible visible and get mouse/keyboard focus
  192. this.setVisible(true);
  193. System.out.println("Focusable = " + this.isFocusable());
  194. this.setFocusable(true);
  195. buf = new BufferedImage(w , h, BufferedImage.TYPE_INT_RGB);
  196. g2 = buf.createGraphics();
  197. this.requestFocus();
  198. this.paintBuf( g2 );
  199. }
  200.  
  201. //Function called by start handler when image is pressed
  202. protected void setup()
  203. {
  204. //Remove the start handler (no longer needed)
  205. removeMouseListener(sh);
  206. isSettingUp = true;
  207.  
  208. //Program hasn't started, but init screen is not running
  209. started = 0;
  210.  
  211. //Depending on which number program was selected, setup the appropriate variables
  212. // and call the constructor for the program
  213. // add the newly constructed program as a handlder to the window
  214. // schedule the timeAllowance timer (if program doesnt start w/ flashing)
  215.  
  216. switch ( number )
  217. {
  218.  
  219. //Shaping - Centered
  220. case 1:
  221. ii1 = ( ImageIcon ) theImages.elementAt( 0 );
  222. p1a = new program1aHandler( this, theImages, theX, theY, delay,
  223. time, t , trials, delays, outputStream, w, h, width, height, theC,
  224. countValid, correctSound, incorrectSound, reward, comPort, iti );
  225.  
  226. addMouseListener( p1a );
  227. t.schedule( new Time ( p1a ), time * 1000 );
  228. break;
  229.  
  230. // Shaping - Random location
  231. case 2:
  232. ii1 = ( ImageIcon ) theImages.elementAt( 0 );
  233.  
  234. p1b = new program1bHandler( this, theImages, theX, theY, delay,
  235. time, t , trials, delays, outputStream, w, h, width, height, theC,
  236. countValid, correctSound, incorrectSound, reward, comPort, iti );
  237.  
  238. addMouseListener( p1b );
  239. t.schedule( new Time ( p1b ), time * 1000 );
  240. break;
  241.  
  242. // Matching to sample - DMS
  243. case 3:
  244. theX2 = 0;
  245. theY2 = 0;
  246. p2a = new program2aHandler( this, theImages, theX, theY, theX2, theY2, delay,
  247. time, t , trials, delays, outputStream, w, h, width, height, theC,
  248. countValid, correctSound, incorrectSound, reward, comPort, iti, isProgressiveDelays, correction );
  249.  
  250. addMouseListener( p2a );
  251. t.schedule( new Time ( p2a ), time * 1000 );
  252. break;
  253.  
  254. //Matching to sample - DNMS
  255. case 4:
  256. theX2 = 0;
  257. theY2 = 0;
  258.  
  259. p2b = new program2bHandler( this, theImages, theX, theY, theX2, theY2, delay,
  260. time, t , trials, delays, outputStream, w, h, width, height, theC,
  261. countValid, correctSound, incorrectSound, reward, comPort, iti, isProgressiveDelays, correction );
  262.  
  263. addMouseListener( p2b );
  264. t.schedule( new Time ( p2b ), time * 1000 );
  265. break;
  266.  
  267. // 5-> Spacial DRST 6-> Object DRST
  268. // These two programs are so similar and require a large amount of data
  269. // so they are put togeather
  270.  
  271. case 5:
  272. case 6:
  273. {
  274. Random r = new Random();
  275. Vector positionX = new Vector(15);
  276. Vector positionY = new Vector(15);
  277. int xHelp, yHelp, theSize, whichOne, value, value2, ii;
  278. theXs = new int[15];
  279. theYs = new int[15];
  280. count = 1;
  281. baseline = 0;
  282. imageNames = new String[15];
  283.  
  284. //Reset window data (images need to be smaller than standard to fit them all)
  285. if( size.equals("1024x768") )
  286. {
  287. width = 180;
  288. height = 180;
  289. }
  290. else
  291. {
  292. width = 125;
  293. height = 125;
  294. }
  295.  
  296. // Position of the first image
  297. xHelp = 10;
  298. yHelp = ( h - (height * 3 ) ) / 4;
  299.  
  300. // Create two vectors, one for the x coordinate valuse
  301. // one for the y values
  302. for( ii = 1; ii < 16; ii++ )
  303. {
  304. positionX.addElement( new Integer ( xHelp ) );
  305. positionY.addElement( new Integer ( yHelp ) );
  306. xHelp = xHelp + width + 10;
  307. // If this was the last image in the row, reset
  308. if ( ( ii % 5 ) == 0 )
  309. {
  310. xHelp = 10;
  311. yHelp = yHelp + height + ( h - (height * 3) ) / 4;
  312. }
  313. }
  314.  
  315. //Pull the positions out of the vectors (in random order) and put them
  316. // into arrays (creates a set of positons in random order)
  317. for( ii = 0; ii < 15 ; ii++)
  318. {
  319. theSize = positionX.size() - 1;
  320.  
  321. if( theSize > 1 )
  322. {
  323. whichOne = r.nextInt( theSize );
  324. value = ( ( Integer ) positionX.elementAt( whichOne ) ).intValue() ;
  325. value2 = ( ( Integer ) positionY.elementAt( whichOne ) ).intValue() ;
  326. }
  327. else
  328. {
  329. whichOne = 0;
  330. value = ( ( Integer ) positionX.elementAt( whichOne ) ).intValue() ;
  331. value2 = ( ( Integer ) positionY.elementAt( whichOne ) ).intValue() ;
  332. }
  333. positionX.removeElementAt( whichOne );
  334. positionY.removeElementAt( whichOne );
  335. theXs[ii] = value;
  336. theYs[ii] = value2;
  337. }
  338.  
  339. // If the data point is in the middle row (of three) offset the X value
  340. // So the images arent in straight columns
  341.  
  342. for( ii = 0; ii < 15; ii++)
  343. {
  344. if( theYs[ii] == ( ( h - (height * 3) ) / 4 ) + height + ( h - (height * 3) ) / 4 )
  345. theXs[ii] = theXs[ii] + ( ( h - (height * 3) ) / 4 );
  346. }
  347.  
  348. if( number == 5 )
  349. {
  350. p3a = new program3aHandler( this, theImages, theXs, theYs, delay,
  351. time, t , trials, delays, outputStream, w, h, width, height, theC,
  352. countValid, correctSound, incorrectSound, reward, comPort, iti );
  353.  
  354. addMouseListener( p3a );
  355. t.schedule( new Time ( p3a ), time * 1000 );
  356. }
  357.  
  358. else
  359. {
  360. count = 0;
  361. p3b = new program3bHandler( this, theImages, theXs, theYs, delay,
  362. time, t , trials, delays, outputStream, w, h, width, height, theC,
  363. countValid, baseline, correctSound, incorrectSound, reward, comPort, iti );
  364.  
  365. addMouseListener( p3b );
  366. t.schedule( new Time ( p3b ), time * 1000 );
  367. }
  368. }
  369. break;
  370.  
  371. // Progressive Ratio
  372. case 7:
  373. p4 = new program4Handler( this, theX, theY, delay,
  374. time, t , trials, delays, outputStream, w, h, width, height,
  375. theC, countValid, pr, correctSound, incorrectSound, reward, comPort, iti );
  376.  
  377. addMouseListener( p4 );
  378. t.schedule( new Time ( p4 ), time * 1000 );
  379. break;
  380.  
  381. // Delayed response
  382. case 8:
  383. //Positions are not standard so reset
  384. if( size.equals("1024x768") )
  385. {
  386. theX = 50;
  387. theY = h /2 - height / 2 + height / 4;
  388. theX2 = w - width - 50;
  389. theY2 = h /2 - height / 2 + height / 4;
  390. }
  391. else
  392. {
  393. theX = 50;
  394. theY = h /2 - height / 2 + height / 4;
  395. theX2 = w - width - 50;
  396. theY2 = h /2 - height / 2 + height / 4;
  397. }
  398.  
  399. p5 = new program5Handler( this, theX, theY, theX2, theY2, delay,
  400. time, t , trials, delays, outputStream, w, h, width, height, theC,
  401. countValid, correctSound, incorrectSound, reward, comPort, iti, isProgressiveDelays, correction );
  402.  
  403. addMouseListener( p5 );
  404. // Don't schedule timer. Timer shouldn't start until flashing has finished
  405. break;
  406.  
  407. // Attention tasks
  408. case 9:
  409. {
  410. int xHelp, yHelp, theSize, whichOne, value, value2, ii;
  411. theXs = new int[12];
  412. theYs = new int[12];
  413. Random r = new Random();
  414. count = r.nextInt( 12 );
  415.  
  416. //Positions are non standard so reset
  417. if( size.equals("1024x768") )
  418. {
  419. width = 130;
  420. height = 130;
  421. }
  422. else
  423. {
  424. width = 85;
  425. height = 85;
  426. }
  427.  
  428. xHelp = width - width / 4;
  429. yHelp = (height / 4 );
  430.  
  431. //Setup an array of positions
  432. for( ii = 1; ii < 13; ii++ )
  433. {
  434. theXs[ ii - 1 ] = xHelp;
  435. theYs[ ii - 1 ] = yHelp;
  436. xHelp = xHelp + w / 3 ;
  437. if ( ( ii % 3 ) == 0 )
  438. {
  439. xHelp = width - width / 4;
  440. yHelp = yHelp + h / 4;
  441. }
  442. }
  443.  
  444. p6 = new program6Handler( this, theXs, theYs, delay,
  445. time, t , trials, delays, outputStream, w, h, width, height, theC,
  446. countValid, attention, r, count, correctSound, incorrectSound, reward, comPort, iti );
  447.  
  448. addMouseListener( p6 );
  449. //Schedule time unless this is cued seach b/c cued search flashes
  450. if( attention != 3 ) t.schedule( new Time ( p6 ), time * 1000 );
  451. }
  452. break;
  453.  
  454. // Conceptual set shifting
  455. case 10:
  456. {
  457. int isline;
  458. Random r = new Random();
  459.  
  460. int xHelp, yHelp, theSize, whichOne, value, value2, ii, yStart;
  461. theXs = new int[9];
  462. theYs = new int[9];
  463. csstData = new int[9];
  464.  
  465. xHelp = (w - width * 3 ) / 4;
  466. yHelp = (height / 6);
  467. yStart = yHelp;
  468.  
  469. //Create array of positions
  470. for( ii = 1; ii < 10; ii++ )
  471. {
  472. theXs[ ii - 1 ] = xHelp;
  473. theYs[ ii - 1 ] = yHelp;
  474.  
  475.  
  476. xHelp = xHelp + (w - width * 3) / 4 + width;
  477. if ( ( ii % 3 ) == 0 )
  478. {
  479. xHelp = (w - width * 3) / 4;
  480. yHelp = yHelp + h / 3;
  481. }
  482. }
  483.  
  484. //this covers one row option
  485. if ( (card == 2) || (card == 3) )
  486. {
  487. isline = 3;
  488. yStart = yStart;
  489. for ( ii = 0; ii < 9; ii++ ) {
  490. theYs[ii] = yStart + h / 3;
  491. }
  492. }
  493. else {
  494. isline = 9;
  495. }
  496.  
  497.  
  498.  
  499. p7 = new program7Handler( this, theXs, theYs, delay,
  500. time, t , trials, delays, outputStream, w, h, width, height, theC,
  501. countValid, csst, r, csstData, correctSound, incorrectSound, reward, comPort, isline, iti );
  502.  
  503. addMouseListener( p7 );
  504. t.schedule( new Time ( p7 ), time * 1000 );
  505. }
  506. break;
  507.  
  508.  
  509. //Custom CSST
  510. case 11:
  511. {
  512.  
  513. int xHelp, yHelp, ii, buffer, Xedging, Yedging;
  514. customGrid = new int[9][3];
  515.  
  516. Yedging = ( h - ( customSize * 3 ) ) / 8;
  517. buffer = ( h - ( customSize * 3 ) - ( Yedging * 2 ) ) / 2 ; //distance between cells
  518. Xedging = ( w - ( customSize * 3 ) - ( buffer * 2 ) ) / 2; //on sides
  519.  
  520.  
  521. xHelp = Xedging;
  522. yHelp = Yedging;
  523.  
  524. //Create array of positions
  525. for( ii = 1; ii < 10; ii++ )
  526. {
  527. customGrid[ ii - 1 ][0] = -1;
  528. customGrid[ ii - 1 ][1] = xHelp;
  529. customGrid[ ii - 1 ][2] = yHelp;
  530.  
  531. yHelp = yHelp + customSize + buffer;
  532.  
  533. if ( ( ii % 3 ) == 0 )
  534. {
  535. xHelp = xHelp + customSize + buffer;
  536. yHelp = Yedging;
  537. }
  538. }
  539.  
  540. p8 = new program8Handler( this, delay, time, t, trials, delays, outputStream, theC,
  541. countValid, correctSound, incorrectSound, reward, comPort,
  542. iti, customTargets, customNumberStimuli, customSize, customShift );
  543.  
  544. addMouseListener( p8 );
  545. t.schedule( new Time ( p8 ), time * 1000 );
  546. }
  547. break;
  548.  
  549. // This should never happen, buf if it does just end (go back)
  550. default:
  551. end( 0 );
  552. }
  553.  
  554. //Mark programs as having started
  555. started = 1;
  556.  
  557.  
  558. //If the program flashes, start the flashing
  559. if( number == 8 ) p5.flash();
  560. if(( number == 9 ) && (attention == 3)) p6.flash();
  561.  
  562. //Create a new paint thread to make sure the screen has refreshed from the init screen
  563. paintThread pt = new paintThread( this );
  564. pt.start();
  565.  
  566. }
  567.  
  568.  
  569. //When window is repainted draw the offscreen buffer to the window
  570. public void paint( Graphics screen ) {
  571.  
  572. if(buf != null)
  573. {
  574. screen.drawImage( buf, 0, 0, null );
  575. }
  576.  
  577. }
  578.  
  579. //This is for when an image updates (such as a moving GIF)
  580. public void update(Graphics g) {
  581. // DO NOTHING. This is because animated GIFS update too fast and generate all sorts of crazy stuff. This freezes them.
  582. }
  583.  
  584. //This takes care of doing the actual drawing
  585. public synchronized void paintBuf ( Graphics g ) {
  586.  
  587. //If the program hasn't started, draw the initial image
  588. if( started == -1)
  589. {
  590.  
  591. g.drawImage( asterix.getImage() , theX, theY, width, height, this );
  592. return;
  593. }
  594.  
  595. //If the program is out of the initial handler, but new programs hasnt finished
  596. // Initializing, just draw a black screen
  597.  
  598. else if( started == 0 )
  599. {
  600. g.setColor( colors[ 0 ] );
  601. g.fillRect(0, 0, w, h);
  602. return;
  603. }
  604.  
  605. // If the program has started, draw the appropriate images depending on data
  606. // Manipulated by program handler
  607. switch( number )
  608. {
  609.  
  610. // For Shaping programs, if count is positive draw the image at specified position
  611. // Otherwise fill screen with selected color
  612. case 1:
  613. case 2:
  614. if ( count >= 0 )
  615. {
  616. g.setColor( colors[ 0 ] );
  617. g.fillRect(0, 0, w, h);
  618.  
  619. ii1 = (ImageIcon) theImages.elementAt(count);
  620. g.drawImage( ii1.getImage() , theX, theY, width, height, this );
  621.  
  622. }
  623. else
  624. {
  625. g.setColor( colors[ (count * -1) - 1 ] );
  626. g.fillRect(0, 0, w, h);
  627. }
  628.  
  629. break;
  630.  
  631. // For DMS and DMNS if count >= 0 draw images
  632. // Otherwise colored screen
  633. case 3:
  634. case 4:
  635. if( ( count >= 0 ) )
  636. {
  637. g.setColor( colors[ 0 ] );
  638. g.fillRect(0, 0, w, h);
  639. if ( ( swap == 1) || ( numberOfImages == 1 ) )
  640. {
  641. ii1 = ( ImageIcon ) theImages.elementAt( count );
  642. ii2 = ( ImageIcon ) theImages.elementAt( count + 1 );
  643. }
  644. else
  645. {
  646. ii1 = ( ImageIcon ) theImages.elementAt( count + 1 );
  647. ii2 = ( ImageIcon ) theImages.elementAt( count );
  648. }
  649.  
  650. g.drawImage( ii1.getImage() , theX, theY, width, height, this );
  651. }
  652. else
  653. {
  654. ii2 = null;
  655. g.setColor( colors[ (count * -1) - 1 ] );
  656. g.fillRect(0, 0, w, h);
  657. }
  658.  
  659.  
  660. // If this is a screen w/ 2 images, draw second image
  661. if( ( ii2 != null ) && ( numberOfImages == 2 ) )
  662. {
  663. g.drawImage( ii2.getImage() , theX2, theY2, width, height, this );
  664. }
  665.  
  666. break;
  667.  
  668. // if count > 0 draw all images needed, otherwise colored screen
  669. case 5:
  670. if( count > 0 )
  671. {
  672. g.setColor( colors[ 0 ] );
  673. g.fillRect(0, 0, w, h);
  674. ii1 = ( ImageIcon ) theImages.elementAt( 0 );
  675. for (int ii = count - 1; ii >= 0 ; ii--)
  676. {
  677. g.drawImage( ii1.getImage() , theXs[ii] , theYs[ii], width, height, this );
  678. }
  679. }
  680.  
  681. else
  682. {
  683. g.setColor( colors[ (count * -1) - 1 ] );
  684. g.fillRect(0, 0, w, h);
  685. }
  686. break;
  687.  
  688. // if count > 0 draw all images needed, otherwise colored screen
  689. case 6:
  690. if( count >= 0 )
  691. {
  692. int temp;
  693. int temp2;
  694. g.setColor( colors[ 0 ] );
  695. g.fillRect(0, 0, w, h);
  696. for (int ii = count; ii >= 0 + baseline ; ii--)
  697. {
  698. if ( ii >= theImages.size() )
  699. temp = ii % theImages.size();
  700. else
  701. temp = ii;
  702.  
  703. ii1 = ( ImageIcon ) theImages.elementAt( temp );
  704. g.drawImage( ii1.getImage() , theXs[ii % theXs.length ] , theYs[ii % theYs.length ], width, height, this );
  705. String tempStr = new String(ii1.toString());
  706. int temp3 = tempStr.lastIndexOf("\\"); //this section gets the filename
  707. tempStr = tempStr.substring( temp3+1 , tempStr.length() );
  708. imageNames[ii % theXs.length] = tempStr;
  709. }
  710.  
  711. }
  712. else
  713. {
  714. g.setColor( colors[ (count * -1) - 1 ] );
  715. g.fillRect(0, 0, w, h);
  716. }
  717. break;
  718.  
  719. // if count >= 0 draw centered square, otherwise colored screen
  720. case 7:
  721. if ( count >= 0 )
  722. {
  723. g.setColor( colors[ 0 ] );
  724. g.fillRect(0, 0, w, h);
  725. g.setColor( colors[ 6 ] );
  726. g.fillRect(theX, theY, width, height );
  727. }
  728. else
  729. {
  730. g.setColor( colors[ (count * -1) - 1 ] );
  731. g.fillRect(0, 0, w, h);
  732. }
  733.  
  734. break;
  735.  
  736. //If count is 100 draw the two squares
  737. // If < 0 draw colored screen
  738. // If equal to 0 draw the circle (cue during flash) by left sqauare
  739. // If equal to 1 draw the circle (cue during flash) by right sqaure
  740. case 8:
  741. if(count >= 0 )
  742. {
  743. g.setColor( colors[ 0 ] );
  744. g.fillRect(0, 0, w, h);
  745. }
  746.  
  747. if( ( count == 100 ) )
  748. {
  749. g.setColor(colors[ 6 ]);
  750. g.fillRect(50, h /2 - height / 2, width, height);
  751. g.fillRect(w - width - 50, h /2 - height / 2, width, height);
  752. }
  753. else if ( count < 0 )
  754. {
  755. g.setColor( colors[ (count * -1) - 1 ] );
  756. g.fillRect(0, 0, w, h);
  757. }
  758. else if ( count == 0 )
  759. {
  760. g.setColor(colors[ 7 ]);
  761. g.fillArc(width / 2 + width / 4, h /2 - height / 2 + height / 4, width / 4, height / 4, 0 , 360);
  762. }
  763. else if ( count == 1 )
  764. {
  765. g.setColor(colors[ 7 ]);
  766. g.fillArc(w - width / 2 - 50 - width / 4, h /2 - height / 2 + height / 4, width / 4, height / 4, 0 , 360);
  767. }
  768.  
  769. break;
  770. //If count is between 0 and 100 draw all the circles
  771. // If < 0 draw colored screen
  772. // If > 100 draw circle in specified position only (used for flashing)
  773. case 9:
  774. if (( count >= 0 ) && (count < 100))
  775. {
  776. g.setColor( colors[ 0 ] );
  777. g.fillRect(0, 0, w, h);
  778.  
  779. //this controls the color of the circles before the star
  780. if ( attention == 1 ) g.setColor(colors[ 6 ]);
  781. else g.setColor(colors[ 7 ]);
  782.  
  783. for( int ii = 0; ii < 12; ii++ )
  784. if(( ii != count) && (attention != 0))
  785. g.fillArc(theXs[ii], theYs[ii], width, height, 0 , 360);
  786. else if ( ii == count)
  787. {
  788. //The Star
  789. int[] xPoints = { theXs[ii], theXs[ii] + width / 3,
  790. theXs[ii] + width / 2,
  791. theXs[ii] + 2 * (width / 3),
  792. theXs[ii] + width,
  793. theXs[ii] + 3 * (width / 4),
  794. theXs[ii] + 7 * (width / 8),
  795. theXs[ii] + width / 2,
  796. theXs[ii] + (width / 8),
  797. theXs[ii] + ( width / 4) };
  798.  
  799. int[] yPoints = { theYs[ii] + height / 3, theYs[ii] + height / 3, theYs[ii], theYs[ii] + height / 3,
  800. theYs[ii] + height / 3, theYs[ii] + 3 * ( height / 5), theYs[ii] + height, theYs[ii] + 3 * (height / 4), theYs[ii] + height,
  801. theYs[ii] + 3 * (height / 5) };
  802. g.setColor(colors[ 7 ]); //the star
  803. g.fillPolygon( xPoints, yPoints, xPoints.length);
  804.  
  805. //this controls the color of the circles after the star
  806. if ( attention == 1 ) g.setColor(colors[ 6 ]);
  807. else g.setColor(colors[ 7 ]);
  808. }
  809. }
  810. else if ( count >= 100 )
  811. {
  812. g.setColor( colors[ 0 ] );
  813. g.fillRect(0, 0, w, h);
  814. g.setColor(colors[ 6 ]); //cue is yellow
  815. g.fillArc(theXs[count - 100], theYs[count - 100], width , height, 0 , 360);
  816.  
  817. }
  818. else
  819. {
  820. g.setColor( colors[ (count * -1) - 1 ] );
  821. g.fillRect(0, 0, w, h);
  822. }
  823. break;
  824.  
  825. // If csstData[0] is greater than 0
  826. // And csst equals 0 (discrimination) draw the three shapes
  827. // Otherwise draw level X shapes
  828. // If csstData[0] is less than 0 draw colored screen
  829. case 10:
  830. if ( (card == 0) || (card == 2) ) //no cards
  831. {
  832. if ( csstData[0] >= 0 )
  833. {
  834. g.setColor( colors[ 0 ] );
  835. g.fillRect(0, 0, w, h);
  836.  
  837. if( csst == 0)
  838. {
  839. for( int ii = 0; ii < 3; ii++ )
  840. {
  841. g.setColor(colors[ 0 ]);
  842. g.fillRect(theXs[csstData[ii]], theYs[csstData[ii]], width, height);
  843.  
  844. if( csstData[ ii + 3 ] == 0 )
  845. {
  846. g.setColor(colors[10] );
  847. g.fillRect( theXs[csstData[ii]], theYs[csstData[ii]], width, height);
  848. }
  849.  
  850. else if( csstData[ ii + 3 ] == 1 )
  851. {
  852. g.setColor(colors[11] );
  853. g.fillRect( theXs[csstData[ii]], theYs[csstData[ii]] + height / 2 - height / 16, width, height / 8);
  854. g.fillRect( theXs[csstData[ii]] + width / 2 - width / 16, theYs[csstData[ii]], width / 8, height);
  855. }
  856.  
  857. else
  858. {
  859. g.setColor( colors[6] );
  860. int[] xPoints = { theXs[csstData[ii]],
  861. theXs[csstData[ii]] + width / 2,
  862. theXs[csstData[ii]] + width,
  863. theXs[csstData[ii]] + width,
  864. theXs[csstData[ii]] + width / 2,
  865. theXs[csstData[ii]]};
  866.  
  867.  
  868. int[] yPoints = { theYs[csstData[ii]],
  869. theYs[csstData[ii]] + height / 2,
  870. theYs[csstData[ii]],
  871. theYs[csstData[ii]] + height,
  872. theYs[csstData[ii]] + height / 2,
  873. theYs[csstData[ii]] + height};
  874.  
  875. g.fillPolygon( xPoints, yPoints, xPoints.length);
  876. }
  877. }
  878. }
  879. else
  880. {
  881. for( int ii = 0; ii < 3; ii++ )
  882. {
  883. g.setColor(colors[ 0 ]);
  884. g.fillRect(theXs[csstData[ii]], theYs[csstData[ii]], width, height);
  885.  
  886. if ( csstData[ii+6] == 0) g.setColor(colors[7]);
  887. else if ( csstData[ii+6] == 1) g.setColor(colors[3]);
  888. else if ( csstData[ii+6] == 2) g.setColor(colors[1]);
  889.  
  890. if( csstData[ ii + 3 ] == 0 )
  891. g.fillArc( theXs[csstData[ii]], theYs[csstData[ii]], width, height, 0, 360);
  892.  
  893. else if( csstData[ii + 3 ] == 1 )
  894. {
  895. int[] xPoints = { theXs[csstData[ii]], theXs[csstData[ii]] + width / 2 ,
  896. theXs[csstData[ii]] + width};
  897.  
  898. int[] yPoints = { theYs[csstData[ii]] + height, theYs[csstData[ii]],
  899. theYs[csstData[ii]] + height};
  900.  
  901. g.fillPolygon( xPoints, yPoints, xPoints.length);
  902. }
  903.  
  904. else
  905. {
  906. int[] xPoints = { theXs[csstData[ii]],
  907. theXs[csstData[ii]] + 2 * (width / 6 ),
  908. theXs[csstData[ii]] + 3 * (width / 6 ),
  909. theXs[csstData[ii]] + 4 * (width / 6 ),
  910. theXs[csstData[ii]] + width,
  911. theXs[csstData[ii]] + 4 * (width / 6 ),
  912. theXs[csstData[ii]] + 5 * (width / 6 ),
  913. theXs[csstData[ii]] + 3 * (width / 6 ),
  914. theXs[csstData[ii]] + 1 * (width / 6 ),
  915. theXs[csstData[ii]] + 2 * (width / 6 ) };
  916.  
  917. int[] yPoints = { theYs[csstData[ii]] + 4 * (height / 12),
  918. theYs[csstData[ii]] + 4 * (height / 12),
  919. theYs[csstData[ii]],
  920. theYs[csstData[ii]] + 4 * (height / 12),
  921. theYs[csstData[ii]] + 4 * (height / 12),
  922. theYs[csstData[ii]] + 7 * (height / 12),
  923. theYs[csstData[ii]] + height,
  924. theYs[csstData[ii]] + 9 * (height / 12),
  925. theYs[csstData[ii]] + height,
  926. theYs[csstData[ii]] + 7 * (height / 12) };
  927.  
  928. g.fillPolygon( xPoints, yPoints, xPoints.length);
  929. }
  930. }
  931. }
  932. }
  933. else
  934. {
  935. g.setColor( colors[ (csstData[0] * -1) - 1 ] );
  936. g.fillRect(0, 0, w, h);
  937. }
  938. }//end if card == 0 or 2
  939. else if ( (card == 1) || (card == 3) || (card == 4 ) ) //they want the cards
  940. {
  941.  
  942. if ( card == 4) //we're using the alternate colors
  943. {
  944. colors[13] = colors[11];
  945. colors[14] = colors[6];
  946. }
  947.  
  948. if ( csstData[0] >= 0 )
  949. {
  950. g.setColor( colors[ 0 ] );
  951. g.fillRect(0, 0, w, h);
  952.  
  953. if( csst == 0)
  954. {
  955. for( int ii = 0; ii < 3; ii++ )
  956. {
  957. g.setColor(colors[ 8 ]);
  958. g.fillRect(theXs[csstData[ii]], theYs[csstData[ii]], width, height);
  959.  
  960. if( csstData[ ii + 3 ] == 0 )
  961. {
  962. g.setColor(colors[5] );
  963. g.fillRect( theXs[csstData[ii]] + width / 4, theYs[csstData[ii]] + height / 4, width / 2, height / 2);
  964. }
  965.  
  966. else if( csstData[ ii + 3 ] == 1 )
  967. {
  968. g.setColor(colors[4] );
  969. g.fillRect( theXs[csstData[ii]] + width / 4, theYs[csstData[ii]] + height / 2 - height / 16, width / 2, height / 8);
  970. g.fillRect( theXs[csstData[ii]] + width / 2 - width / 16, theYs[csstData[ii]] + height / 4, width / 8, height / 2);
  971. }
  972.  
  973. else
  974. {
  975. g.setColor( colors[9] );
  976. int[] xPoints = { theXs[csstData[ii]] + width / 4,
  977. theXs[csstData[ii]] + width / 2,
  978. theXs[csstData[ii]] + 3 * (width / 4),
  979. theXs[csstData[ii]] + 3 * (width / 4),
  980. theXs[csstData[ii]] + width / 2,
  981. theXs[csstData[ii]] + width / 4 };
  982.  
  983.  
  984. int[] yPoints = { theYs[csstData[ii]] + height / 4,
  985. theYs[csstData[ii]] + height / 2,
  986. theYs[csstData[ii]] + height / 4,
  987. theYs[csstData[ii]] + 3 * ( height / 4),
  988. theYs[csstData[ii]] + height / 2,
  989. theYs[csstData[ii]] + 3 * ( height / 4)};
  990.  
  991. g.fillPolygon( xPoints, yPoints, xPoints.length);
  992. }
  993. }
  994. }
  995. else
  996. {
  997. for( int ii = 0; ii < 3; ii++ )
  998. {
  999. g.setColor(colors[ 8 ]);
  1000. g.fillRect(theXs[csstData[ii]], theYs[csstData[ii]], width, height);
  1001.  
  1002. if ( csstData[ii+6] == 0) g.setColor(colors[13]);
  1003. else if ( csstData[ii+6] == 1) g.setColor(colors[14]);
  1004. else if ( csstData[ii+6] == 2) g.setColor(colors[1]);
  1005.  
  1006. if( csstData[ ii + 3 ] == 0 )
  1007. g.fillArc( theXs[csstData[ii]] + width / 4, theYs[csstData[ii]] + height / 4, width / 2, height / 2, 0, 360);
  1008.  
  1009. else if( csstData[ii + 3 ] == 1 )
  1010. {
  1011. int[] xPoints = { theXs[csstData[ii]] + width / 4, theXs[csstData[ii]] + width / 2 ,
  1012. theXs[csstData[ii]] + width / 4 + width / 2};
  1013.  
  1014. int[] yPoints = { theYs[csstData[ii]] + height / 4 + height / 2, theYs[csstData[ii]] + height / 4,
  1015. theYs[csstData[ii]] + height / 4 + height / 2};
  1016.  
  1017. g.fillPolygon( xPoints, yPoints, xPoints.length);
  1018. }
  1019.  
  1020. else
  1021. {
  1022. int[] xPoints = { theXs[csstData[ii]] + width / 4,
  1023. theXs[csstData[ii]] + width / 3 + width / 4,
  1024. theXs[csstData[ii]] + width / 2 ,
  1025. theXs[csstData[ii]] + 2 * (width / 3) - width / 4,
  1026. theXs[csstData[ii]] + width - width / 4,
  1027. theXs[csstData[ii]] + 3 * (width / 4) - width / 8,
  1028. theXs[csstData[ii]] + 7 * (width / 8) - width / 6,
  1029. theXs[csstData[ii]] + width / 2,
  1030. theXs[csstData[ii]] + (width / 8) + width / 6,
  1031. theXs[csstData[ii]] + ( width / 4) + width / 8 };
  1032.  
  1033. int[] yPoints = { theYs[csstData[ii]] + height / 4 + height / 6,
  1034. theYs[csstData[ii]] + height / 4 + height / 6,
  1035. theYs[csstData[ii]] + height / 4,
  1036. theYs[csstData[ii]] + height / 4 + height / 6,
  1037. theYs[csstData[ii]] + height / 4 + height / 6,
  1038. theYs[csstData[ii]] + ( height / 2) + height / 20,
  1039. theYs[csstData[ii]] + height - height / 8 - height / 8,
  1040. theYs[csstData[ii]] + 3 * (height / 4) - height / 8,
  1041. theYs[csstData[ii]] + height - height / 8 - height / 8,
  1042. theYs[csstData[ii]] + (height / 2) + height / 20};
  1043.  
  1044. g.fillPolygon( xPoints, yPoints, xPoints.length);
  1045. }
  1046. }
  1047. }
  1048. }
  1049. else
  1050. {
  1051. g.setColor( colors[ (csstData[0] * -1) - 1 ] );
  1052. g.fillRect(0, 0, w, h);
  1053. }
  1054.  
  1055. }//end else for cards
  1056. break;
  1057.  
  1058.  
  1059. //custom CSST
  1060. case 11:
  1061. if (skipInitial == 0) {
  1062. skipInitial = 1;
  1063. return;
  1064. } //we do this because our handler draws the first screen
  1065.  
  1066.  
  1067. if ( isBetween == 3 ) {
  1068. g.setColor( colors[ 7 ] );
  1069. g.fillRect(0, 0, w, h);
  1070. }
  1071.  
  1072. else if ( isBetween == 2 ) {
  1073. g.setColor( colors[ theC ] );
  1074. g.fillRect(0, 0, w, h);
  1075. }
  1076.  
  1077. else {
  1078. g.setColor( colors[ 0 ] );
  1079. g.fillRect(0, 0, w, h); //paints the black background
  1080.  
  1081. if ( isBetween == 0 ) {
  1082. //now draw the images
  1083. for ( int i = 0 ; i < 9 ; i++ ) {
  1084. if ( customGrid[i][0] != -1 ) {
  1085. g.drawImage( (Image)customImages[customGrid[i][0]][1] , customGrid[i][1], customGrid[i][2], customSize, customSize, this );
  1086. }//end if
  1087. } //end for
  1088. } //end if
  1089. } //end else
  1090.  
  1091. break;
  1092.  
  1093. }
  1094. readytobypass = 1;
  1095. } //end paintBuf
  1096.  
  1097. //Used for program Handlers to change "count"
  1098. protected int changeCount( int c ) {
  1099. int old;
  1100. old = count;
  1101. count = c;
  1102. return old;
  1103. }
  1104.  
  1105. // Used for program Handlers to change "baseline" (used for DRST tasks)
  1106. protected void changeBaseline( int c ) { baseline = c; }
  1107.  
  1108. // Used for program Handlers to change x and y positions
  1109. protected void loc(int x, int y, int x2, int y2, int s, int nI )
  1110. {
  1111. theX = x;
  1112. theY = y;
  1113. theX2 = x2;
  1114. theY2 = y2;
  1115. swap = s;
  1116. numberOfImages = nI;
  1117. }
  1118.  
  1119. // When the program is supposed to stop
  1120. // Call the quit function of the running program (if one has started)
  1121. protected void end( int kill )
  1122. {
  1123. System.out.println("ending");
  1124. if( started > 0 )
  1125. {
  1126. switch( number )
  1127. {
  1128. case 1:
  1129. p1a.quit();
  1130. break;
  1131. case 2:
  1132. p1b.quit();
  1133. break;
  1134. case 3:
  1135. p2a.quit();
  1136. break;
  1137. case 4:
  1138. p2b.quit();
  1139. break;
  1140. case 5:
  1141. p3a.quit();
  1142. break;
  1143. case 6:
  1144. p3b.quit();
  1145. break;
  1146. case 7:
  1147. p4.quit();
  1148. break;
  1149. case 8:
  1150. p5.quit();
  1151. break;
  1152. case 9:
  1153. p6.quit();
  1154. break;
  1155. case 10:
  1156. p7.quit();
  1157. break;
  1158. case 11:
  1159. p8.quit();
  1160. break;
  1161. }
  1162. }
  1163.  
  1164. // Close the sounds
  1165. if( correctSound != null) correctSound.close();
  1166. if( incorrectSound != null) incorrectSound.close();
  1167.  
  1168. // If this was a Q then quit entire program
  1169. if ( kill == 1 )
  1170. System.exit(1);
  1171.  
  1172. // Otherwise hide this base and show program selector
  1173. else
  1174. {
  1175. tWindow.setVisible( true );
  1176. this.setVisible(false);
  1177. }
  1178. }
  1179.  
  1180. protected void updateGraphics()
  1181. {
  1182. paintThread pt = new paintThread( this );
  1183. pt.start();
  1184. }
  1185.  
  1186. // When the programs is supposed to stop
  1187. // Call the quit function of the running program (if one has started)
  1188. protected void bypass(KeyEvent k)
  1189. {
  1190. buttonPress = k;
  1191. if( (started > 0) && (readytobypass == 1 ) )
  1192. {
  1193. switch( number )
  1194. {
  1195. case 1:
  1196. p1a.bypass();
  1197. break;
  1198. case 2:
  1199. p1b.bypass();
  1200. break;
  1201. case 3:
  1202. p2a.bypass();
  1203. break;
  1204. case 4:
  1205. p2b.bypass();
  1206. break;
  1207. case 5:
  1208. p3a.bypass();
  1209. break;
  1210. case 6:
  1211. p3b.bypass();
  1212. break;
  1213. case 7:
  1214. p4.bypass();
  1215. break;
  1216. case 8:
  1217. p5.bypass();
  1218. break;
  1219. case 9:
  1220. p6.bypass();
  1221. break;
  1222. case 10:
  1223. p7.bypass();
  1224. break;
  1225. case 11:
  1226. p8.bypass();
  1227. break;
  1228. }
  1229. }
  1230. }
  1231.  
  1232.  
  1233.  
  1234.  
  1235. // This function writes the header in formation for a program
  1236. private void writeHeader( )
  1237. {
  1238.  
  1239. outputStream.println( "Date: " + Date );
  1240. outputStream.println( "Monkey ID: " + Id );
  1241. outputStream.println( "Task: " + prog );
  1242. if( (number == 3) || (number == 4) || (number == 8) ){
  1243. if (correction == 0)
  1244. outputStream.println("Forced correction procedure");
  1245. else if (correction == 1)
  1246. outputStream.println("No correction procedure");
  1247. else if (correction == 2)
  1248. outputStream.println("Correction procedure on");
  1249. }
  1250. else if (number == 10 )
  1251. {
  1252. if( csst == 0 ) outputStream.println(" (Discrimination)");
  1253. if( csst == 1 ) outputStream.println(" (Level 1)");
  1254. if( csst == 2 ) outputStream.println(" (Level 2)");
  1255. if( csst == 3 ) outputStream.println(" (Level 3)");
  1256. if( csst == 4 ) outputStream.println(" (Level 4)");
  1257. }
  1258. else if (number == 9)
  1259. {
  1260. if( attention == 0 ) outputStream.println(" (Training)");
  1261. else if( attention == 1 ) outputStream.println(" (Simple Search Easy)");
  1262. else if( attention == 2 ) outputStream.println(" (Simple Search Hard)");
  1263. else if( attention == 3 ) outputStream.println(" (Cued Search)");
  1264. }
  1265. else if (number == 7 )
  1266. {
  1267. if( pr == 0 ) outputStream.println(" (Fixed Ratio 1)");
  1268. else if( pr == 1 ) outputStream.println(" (Fixed Ratio 2)");
  1269. else if( pr == 2 ) outputStream.println(" (Fixed Ratio 3)");
  1270. else if( pr == 3 ) outputStream.println(" (Fixed Ratio 4)");
  1271. else if( pr == 4 ) outputStream.println(" (Fixed Ratio 5)");
  1272. else if( pr == 5 ) outputStream.println(" (Fixed Ratio 6)");
  1273. else if( pr == 6 ) outputStream.println(" (Progressive Ratio)");
  1274. }
  1275.  
  1276. outputStream.println( "Tested By: " + Tester );
  1277. outputStream.println( "Image Directory: " + imageDirectory );
  1278. outputStream.println( "ITI: " + iti );
  1279. outputStream.print( "Database Host: ");
  1280.  
  1281. if (dbHost.equals("")) {
  1282. outputStream.println("NONE");
  1283. }
  1284. else {
  1285. outputStream.println(dbHost);
  1286. }
  1287.  
  1288.  
  1289. outputStream.println( " " );
  1290. outputStream.println( "Trial" );
  1291. }
  1292.  
  1293.  
  1294.  
  1295. }
  1. package yerkes;
  2.  
  3. import java.awt.event.*;
  4. import java.util.*;
  5.  
  6. /**
  7.  * Title:
  8.  * Description:
  9.  * Copyright: Copyright (c) 2005
  10.  * Company:
  11.  * @author Zachary William Anderson
  12.  * @version 1.0
  13.  */
  14.  
  15. //Used while program is running to end it
  16. public class BypassHandler implements KeyListener {
  17. private Base theBase;
  18. private java.util.Timer time;
  19.  
  20. public BypassHandler(Base b, java.util.Timer t) {
  21. System.out.println("Bypass constructed");
  22. theBase = b;
  23. time = t;
  24. }
  25.  
  26. public void keyPressed(KeyEvent k) {}
  27.  
  28. public void keyTyped(KeyEvent k) {
  29. System.out.println("The key is " + k.getKeyChar());
  30. if (k.getKeyChar() == 'q') {
  31. time.cancel();
  32. theBase.end(0);
  33. }
  34.  
  35. else if (k.getKeyChar() == 'Q') {
  36. time.cancel();
  37. theBase.end(1);
  38. }
  39. else if (k.getKeyChar() == ' ') {
  40. if (theBase.readytobypass == 1) {
  41.  
  42. theBase.bypass(k);
  43. }
  44. //this is for bypassing the openning image
  45. else if (!theBase.isSettingUp) {
  46. theBase.started = 0;
  47. theBase.updateGraphics();
  48. try {
  49. Thread.sleep(750);
  50. }
  51. catch (Exception ex) {}
  52. theBase.setup();
  53. }
  54. }
  55.  
  56.  
  57. }
  58.  
  59. //When a key is pressed do associated action
  60. public void keyReleased(KeyEvent k) {
  61. }
  62. }
  1. /*handles the shaping - centered task*/
  2.  
  3. package yerkes;
  4.  
  5. import java.awt.event.*;
  6. import java.util.*;
  7. import java.io.*;
  8. import java.text.*;
  9. import javax.sound.sampled.*;
  10.  
  11.  
  12. public class program1aHandler extends programGenericHandler {
  13. private int count, number, trials, color, running, countValid, numrefused;
  14. private int X, Y, Width, Height, wWidth, wHeight, reward, comPort;
  15. private Base theBase;
  16. private int delay, time;
  17. private java.util.Timer t2;
  18. private float[] delays;
  19. private float meanResponseTime, correct;
  20. private PrintWriter out;
  21. private long timeStart, timeEnd;
  22. private DecimalFormat f = new DecimalFormat( "0.000" );
  23. private DecimalFormat f2 = new DecimalFormat( "0.00" );
  24. private DecimalFormat f3 = new DecimalFormat( "0" );
  25. private paintThread pt;
  26. private static long lastTime, offsetTime;
  27. private Clip correctSound, incorrectSound;
  28. private com runOutput;
  29.  
  30. //this is all db stuff
  31. private databaseHandler dbase = new databaseHandler();
  32. private String sessionid, trialline, summaryline, datetime, tester, completed, imageDirectory;
  33. private String result, monkeyid, dbMeanResponseTime, dbCorrect, dbWrong, dbPercentCorrect;
  34. private String DV, finial, stakes, trialstakes, dbTime;
  35. private String[] sessiondate;
  36. private int trialNumber;
  37. private float iti;
  38.  
  39.  
  40. public program1aHandler( Base b, Vector Images, int x, int y, int d, int t,
  41. java.util.Timer timer, int tr, float[] de, PrintWriter pOut, int w, int h,
  42. int iW, int iH, int c, int v, Clip CS, Clip IS, int rgb, int cP, float ititemp ) {
  43.  
  44. iti = ititemp;
  45. numrefused = 0;
  46. theBase = b;
  47. X = x;
  48. Y = y;
  49. delay = d;
  50. time = t ;
  51. t2 = timer;
  52. trials = tr;
  53. number = 0;
  54. delays = de;
  55. out = pOut;
  56. correct = 0;
  57. meanResponseTime = 0;
  58. Width = iW;
  59. Height = iH;
  60. color = c;
  61. running = 1;
  62. countValid = v;
  63. correctSound = CS;
  64. incorrectSound = IS;
  65. lastTime = System.currentTimeMillis();
  66. offsetTime = 0;
  67. reward = rgb;
  68. comPort = cP;
  69.  
  70. //db variable initializers
  71. monkeyid = theBase.monkeyid;
  72. sessiondate = dbase.getSessionInfo(monkeyid);
  73. sessionid = sessiondate[0];
  74. datetime = sessiondate[1];
  75. tester = theBase.Tester;
  76. imageDirectory = theBase.imageDirectory;
  77. finial = "')"; //end of db strings
  78. DV = "', '"; //divider for db strings
  79.  
  80. timeStart = System.currentTimeMillis();
  81. }
  82.  
  83. //Handles spacebar shortcut
  84. public void bypass() {
  85. if( theBase.buttonPress.getWhen() <= timeStart ) return;
  86. performactions( X, Y, 1, 1 );
  87. }
  88.  
  89.  
  90.  
  91.  
  92. //When click occurs, do this
  93. public void mousePressed(MouseEvent e) {
  94. int x, y, good;
  95.  
  96. //If the click came before the last handler was finished (before image was shown)
  97. // then ignore it
  98. if( e.getWhen() <= timeStart ) return;
  99.  
  100. //If Program is no longer running, ignore clicks
  101. if( running == 0 ) return;
  102.  
  103. x = e.getX();
  104. y = e.getY();
  105.  
  106. /*
  107.   Should this be a valid click?
  108.   If non-image clicks are allowed, the click is valid
  109.   If the click was at position -1 -1 (generated by timeout timer) it is valid
  110.   If the click is inside the image it is valid
  111. */
  112. if ( (countValid == 0 ) || ( x == -1 ) ) good = 1;
  113. else good = check(x,y);
  114.  
  115. performactions( x, y, good, 0 );
  116. }
  117.  
  118. //this performs the actions after a mouseclick or the bypass key
  119. public void performactions( int x, int y, int good, int assumegood ) {
  120. //If this is a valid click and the program is still running
  121. if ( ( running == 1 ) && ( good == 1 ) )
  122. {
  123.  
  124. //Cancel the timeout timer, and record the end time
  125.  
  126. t2.cancel();
  127. timeEnd = System.currentTimeMillis();
  128.  
  129. if ( check( x, y ) == 1 ) clear_good();
  130. else clear_bad(x);
  131.  
  132. //If we are still running, reschedule the timeout timer and start time
  133. if ( running == 1)
  134. {
  135. t2 = new java.util.Timer();
  136. t2.schedule( new Time( this ), time * 1000 );
  137. }
  138. timeStart = System.currentTimeMillis();
  139. }
  140.  
  141. }
  142.  
  143. //Checks to see if click was correct
  144. int check(int x,int y) {
  145. if ( ( ( x >= X ) && ( x <= ( X + Width ) ) ) && ( ( y >= Y ) && ( y <= ( Y + Height ) ) ) )
  146. return 1;
  147. else return 0;
  148. }
  149.  
  150.  
  151. //Do this if a correct response was given
  152. private void clear_good( ){
  153. int old;
  154.  
  155. playSound(correctSound);
  156.  
  157. rewardGood( reward, comPort);
  158.  
  159. old = theBase.changeCount( -1 );
  160.  
  161. theBase.updateGraphics();
  162.  
  163. if( out != null ) updateHeader( 0 );
  164.  
  165. pause(iti);
  166.  
  167. number++;
  168.  
  169. //If all the trials have completed, show the red screen, print summary info, and stop
  170. if( number >= trials )
  171. {
  172. running = 0;
  173. old = theBase.changeCount( -8 );
  174. theBase.updateGraphics();
  175. if( out != null ) summary();
  176. return;
  177. }
  178.  
  179. //If still running, move to next image and start again
  180. else {
  181. old = theBase.changeCount ( old + 1 );
  182. theBase.updateGraphics();
  183. }
  184.  
  185. }
  186.  
  187. private void clear_bad( int x ) {
  188. int old, old2;
  189. playSound(incorrectSound);
  190. rewardBad(reward, comPort);
  191.  
  192. old = theBase.changeCount( ( color * -1) -1 );
  193. theBase.updateGraphics();
  194.  
  195. if ((out != null) && ( x == -1))
  196. {
  197. updateHeader( 2 );
  198. numrefused++;
  199. }
  200. else if( out != null ) updateHeader( 1 );
  201.  
  202. pause( delay );
  203. number++;
  204.  
  205. //If all the trials have completed, show the red screen, print summary info, and stop
  206. if( number >= trials )
  207. {
  208. running = 0;
  209. old = theBase.changeCount( -8 );
  210. theBase.updateGraphics();
  211. if( out != null ) summary();
  212. return;
  213. }
  214. else {
  215. old2 = theBase.changeCount ( old + 1 );
  216. theBase.updateGraphics();
  217. }
  218. }
  219.  
  220. private void updateHeader ( int status ) {
  221.  
  222. double time;
  223. time = (timeEnd - timeStart ) / 1000.0;
  224. out.print( (number + 1) + " ");
  225. if ( status == 0 )
  226. {
  227. out.print( "Correct" + "\t " );
  228. result = "correct";
  229. correct++;
  230. }
  231. else if (status == 2) {
  232. out.print( "Refused " + "\t " );
  233. result = "refused";
  234. }
  235. else {
  236. out.print( "Wrong " + "\t " );
  237. result = "wrong";
  238. }
  239.  
  240. out.println( f.format( time ) );
  241.  
  242. if (status != 2) meanResponseTime += time;
  243.  
  244.  
  245.  
  246. //Insert Trial into DB
  247. trialNumber = number + 1;
  248. dbTime = f.format( time );
  249.  
  250. trialstakes = "insert into shaping_centered_trials (id, trialNumber, result, responseTime ) values ( '";
  251.  
  252. trialline = trialstakes +
  253. sessionid + DV + trialNumber + DV + result + DV + dbTime +
  254. finial;
  255.  
  256. if ( ! theBase.dbHost.equals("")) {
  257. try {
  258. dbase.DBupdate( theBase.dbHost, trialline); }
  259. catch ( java.lang.Exception e ) {
  260. System.out.println ( "Error executing sql statement" ); }
  261. }
  262.  
  263. }
  264.  
  265. public void summary( )
  266. {
  267. out.println("");
  268. out.println("Summary: ");
  269. out.println("");
  270.  
  271. out.println("Number of Trials: " + number );
  272. out.println("Number Refused: " + numrefused );
  273. out.println("Number Correct: " + f3.format(correct) );
  274. out.println("Number Wrong: " + f3.format( (number - correct - numrefused) ) );
  275. if(( correct == 0 ) || (number == 0)) {
  276. out.println("Percent Correct: " + "0.00" + "%");
  277. dbPercentCorrect = "0";
  278. }
  279. else {
  280. out.println("Percent Correct: " + f2.format ( ( correct / ( number - numrefused ) ) * 100.0 ) +"%" );
  281. dbPercentCorrect = f2.format ( ( correct / ( number - numrefused ) ) * 100.0 );
  282. }
  283. if(number != 0 ) {
  284. out.println("Mean Response Time: " + f.format( meanResponseTime / ( number - numrefused ) ) );
  285. dbMeanResponseTime = f.format( meanResponseTime / ( number - numrefused ) );
  286. }
  287. else {
  288. out.println("Average Span: 0");
  289. dbMeanResponseTime = "";
  290. }
  291. out.println("Session ID: " + sessionid );
  292. out.println("------------------------------------------------------------------" );
  293. out.println(" ");
  294. out.close();
  295.  
  296.  
  297. //Insert Summary into DB
  298. dbCorrect = f3.format(correct);
  299. dbWrong = f3.format( (number - correct - numrefused) );
  300. completed = "yes";
  301.  
  302. stakes =
  303. "insert into shaping_centered (id, date, monkey, tester, timeout, numberTrials, numberRefused, numberCorrect, numberWrong, percentCorrect, meanResponseTime, completed, imageDirectory, iti ) values ( '";
  304.  
  305. summaryline = stakes +
  306. sessionid + DV + datetime + DV + monkeyid + DV + tester + DV + delay + DV +
  307. number + DV + numrefused + DV + dbCorrect + DV + dbWrong + DV +
  308. dbPercentCorrect + DV + dbMeanResponseTime + DV + completed + DV + imageDirectory + DV + iti +
  309. finial;
  310.  
  311. if ( ! theBase.dbHost.equals("")) {
  312. try {
  313. dbase.DBupdate( theBase.dbHost, summaryline); }
  314. catch ( java.lang.Exception e ) {
  315. System.out.println ( "Error executing sql statement" ); }
  316. }
  317.  
  318. }
  319.  
  320. //This is called if the program is terminated before it has finished
  321. public void summaryBad()
  322. {
  323. out.println("");
  324. out.println("Summary: ");
  325. out.println("");
  326. out.println("TEST ABORTED");
  327. out.println("Session ID: " + sessionid );
  328. out.println("------------------------------------------------------------------" );
  329. out.println(" ");
  330. out.close();
  331.  
  332.  
  333. //Insert Summary into DB
  334. if ( completed == "yes" )
  335. return;
  336.  
  337. completed = "no";
  338.  
  339. stakes =
  340. "insert into shaping_centered (id, date, monkey, tester, timeout, numberTrials, completed, imageDirectory, iti ) values ( '";
  341.  
  342. summaryline = stakes +
  343. sessionid + DV + datetime + DV + monkeyid + DV + tester + DV + delay + DV +
  344. number + DV + completed + DV + imageDirectory + DV + iti +
  345. finial;
  346.  
  347. if ( ! theBase.dbHost.equals("")) {
  348. try {
  349. dbase.DBupdate( theBase.dbHost, summaryline); }
  350. catch ( java.lang.Exception e ) {
  351. System.out.println ( "Error executing sql statement" ); }
  352. }
  353.  
  354. }
  355. public void quit(){ t2.cancel(); if(out != null) summaryBad(); }
  356. }
  1. package yerkes;
  2. import java.awt.event.*;
  3. import javax.sound.sampled.*;
  4.  
  5. /**
  6.  * Title: CRS
  7.  * Description:
  8.  * Copyright: Copyright (c) 2001
  9.  * Company: Yerkes
  10.  * @author Pearce Peck-Walden
  11.  * @version 1.0
  12.  */
  13.  
  14.  
  15. //This class provides the methods that are common to all programHandlers
  16.  
  17. abstract class programGenericHandler implements MouseListener{
  18.  
  19. public programGenericHandler() {
  20. }
  21.  
  22. public void mouseExited(MouseEvent e) { }
  23. public void mouseEntered(MouseEvent e) { }
  24. public void mouseReleased(MouseEvent e) { }
  25. public void mouseClicked(MouseEvent e) { }
  26.  
  27. abstract public void mousePressed(MouseEvent e);
  28.  
  29. abstract public void bypass();
  30.  
  31. abstract public void performactions( int x, int y, int good, int assumegood );
  32.  
  33. abstract int check(int x, int y);
  34.  
  35.  
  36. //Pause for a specified amount of time
  37. void pause(float time)
  38. {
  39. try {
  40. Thread.sleep( ( int ) ( time * 1000 ) );
  41. } catch (InterruptedException e ) {}
  42.  
  43. }
  44.  
  45. //Play a sound
  46. void playSound(Clip sound)
  47. {
  48. if(sound != null)
  49. {
  50. sound.start();
  51. sound.setFramePosition( 0 );
  52. }
  53. }
  54.  
  55. //Ouput a good reward if the option was specified
  56. void rewardGood(int reward, int comPort)
  57. {
  58. if( (reward == 1) || (reward == 3))
  59. {
  60. if ( comPort == 6 )
  61. {
  62. //do usb stuff here
  63. usbHandler runOutput;
  64. runOutput = new usbHandler();
  65. runOutput.start();
  66. }
  67. else
  68. {
  69. com runOutput;
  70. runOutput = new com(comPort, 0 );
  71. runOutput.start();
  72. }
  73. }
  74. }
  75.  
  76. //Output a bad reward if the option was specified
  77. void rewardBad(int reward, int comPort)
  78. {
  79.  
  80. if( (reward == 2) || (reward == 3))
  81. {
  82. if ( comPort == 6 )
  83. {
  84. //do usb stuff here
  85. usbHandler runOutput;
  86. runOutput = new usbHandler();
  87. runOutput.usbRewardBad();
  88. }
  89. else
  90. {
  91. com runOutput;
  92. runOutput = new com(comPort, 1 );
  93. runOutput.start();
  94. }
  95. }
  96. }
  97.  
  98. public void quit(){}
  99. }
  1. package yerkes;
  2.  
  3. import javax.swing.*;
  4. import java.awt.*;
  5. import java.awt.event.*;
  6. import java.util.*;
  7.  
  8.  
  9.  
  10. //This creates GUI for running programs
  11. class ProgramSelector extends JFrame implements ActionListener{
  12.  
  13.  
  14. // GUI components
  15. private JPanel panel1 = new JPanel();
  16. private JPanel panel2 = new JPanel();
  17. private JPanel panel3 = new JPanel();
  18. private JPanel panel4 = new JPanel();
  19. private JMenuBar jmb = new JMenuBar();
  20. private JMenu jmFile = new JMenu("File");
  21. private JMenu jmHelp = new JMenu("Help");
  22. private JMenu jmTools = new JMenu("Tools");
  23. private JMenuItem jmi1 = new JMenuItem("Save Settings");
  24. private JMenuItem jmi2 = new JMenuItem("Load Settings");
  25. private JMenuItem jmi3 = new JMenuItem("Start");
  26. private JMenuItem jmi4 = new JMenuItem("Exit");
  27. private JMenuItem jmi5 = new JMenuItem("About");
  28. private JMenuItem jmi6 = new JMenuItem("Image Converter");
  29.  
  30. protected JTextField jtfDate = new JTextField( 10 );
  31. protected JTextField jtfOutputLoc = new JTextField( 3 );
  32. protected JTextField jtfTimeout = new JTextField( 3 );
  33. protected JTextField jtfTimeAllowance = new JTextField( 3 );
  34. protected JTextField jtfTrials = new JTextField( 3 );
  35. protected JTextField jtfDelay = new JTextField( 10 );
  36. protected JTextField jtfId = new JTextField( 10 );
  37. protected JTextField jtfTester = new JTextField( 10 );
  38. protected JTextField jtfImageDir = new JTextField( 3 );
  39. protected JTextField jtfDelayConstant = new JTextField( 3 );
  40. protected JTextField jtfiti = new JTextField( 3 );
  41. protected JTextField jtfDelayRangeStart = new JTextField( 3 );
  42. protected JTextField jtfDelayRangeEnd = new JTextField( 3 );
  43. protected JTextField jtfDelayInterval = new JTextField( 3 );
  44. protected JTextField jtfVD = new JTextField( 3 );
  45. protected JTextField jtfVT = new JTextField( 3 );
  46. protected JTextField jtfCS = new JTextField( 3 );
  47. protected JTextField jtfIS = new JTextField( 3 );
  48. protected JTextField jtDB = new JTextField( 3 );
  49. protected JTextField jtfCustom1 = new JTextField( 10 );
  50. protected JTextField jtfCustom2 = new JTextField( 10 );
  51. protected JTextField jtfCustom3 = new JTextField( 10 );
  52. protected JTextField jtfCustom4 = new JTextField( 10 );
  53. protected JTextField jtfCustom5 = new JTextField( 3 ); //this one is for number before shift
  54.  
  55. protected JComboBox chooser;
  56. protected JComboBox chooser2;
  57. protected JComboBox chooser3;
  58. protected JComboBox chooser4;
  59. protected JComboBox chooser5;
  60. protected JComboBox chooser6;
  61. protected JComboBox chooser7;
  62. protected JComboBox chooser8;
  63. protected JComboBox chooser9;
  64. protected JComboBox chooser10;
  65. protected JComboBox chooser11;
  66. protected JComboBox chooser12;
  67. protected JComboBox chooser13; //for Custom CSST
  68. protected JComboBox chooser14; //increased delay toggle
  69. protected JComboBox correctionChooser; //for correction procedure
  70.  
  71. private JButton startB;
  72. private JButton exitB;
  73. private JButton Choose = new JButton("Select");
  74. private JButton Choose2 = new JButton("Select");
  75. private JButton Choose3 = new JButton("Select");
  76. private JButton Choose4 = new JButton("Select");
  77. private JButton Choose5 = new JButton("Select");
  78.  
  79.  
  80. protected JLabel jlVersion = new JLabel("Version:");
  81. private JLabel blank1 = new JLabel(" ");
  82. private JLabel blank2 = new JLabel(" ");
  83. private JLabel blank3 = new JLabel(" ");
  84. private JLabel blank4 = new JLabel(" ");
  85. private JLabel blank6 = new JLabel(" ");
  86. private JLabel jliti = new JLabel("Inter-trial Interval:");
  87. private JLabel jloutput = new JLabel("Output To File:");
  88. private JLabel jltOut = new JLabel("Time out length:");
  89. private JLabel jltAllowance = new JLabel("Time Allowance:");
  90. private JLabel jlTrials = new JLabel("Number of trials:");
  91. private JLabel jlDate = new JLabel("Date:");
  92. private JLabel jlId = new JLabel("Monkey ID:");
  93. private JLabel jlTester = new JLabel("Tester:");
  94. private JLabel jlImageDir = new JLabel("Image Directory:");
  95. private JLabel jlDelay = new JLabel("Delay:");
  96. private JLabel jlDelayConstant = new JLabel("Fixed:");
  97. private JLabel jlDelayRange = new JLabel("Range:");
  98. private JLabel jlDelayRangeStart = new JLabel("From:");
  99. private JLabel jlDelayRangeEnd = new JLabel("To:");
  100. private JLabel jlDelayFile = new JLabel("File:");
  101. private JLabel jlScreenSize = new JLabel("Screen Size:");
  102. private JLabel jlDelayInterval = new JLabel("Interval:");
  103. private JLabel jlColor = new JLabel("Time Out Color:");
  104. private JLabel jlValidClick = new JLabel("Non-image clicks:");
  105. private JLabel jlCS = new JLabel("Correct Sound:");
  106. private JLabel jlIS = new JLabel("Incorrect Sound:");
  107. private JLabel jlReward = new JLabel("Reward:");
  108. private JLabel jlOP = new JLabel("Output Port:");
  109. private JLabel jlC = new JLabel("Cursor:");
  110. private JLabel jlCorrectProc = new JLabel("Correction Procedure:");
  111. private JLabel jlVD = new JLabel("Valve Delay:");
  112. private JLabel jlVT = new JLabel("Valve Time:");
  113. private JLabel jlDB = new JLabel("Database Host:");
  114. private JLabel jlCustom1 = new JLabel("Conceptual Set 1:");
  115. private JLabel jlCustom2 = new JLabel("Conceptual Set 2:");
  116. private JLabel jlCustom3 = new JLabel("Conceptual Set 3:");
  117. private JLabel jlCustom4 = new JLabel("Conceptual Set 4:");
  118. private JLabel jlCustom5 = new JLabel("Number of Stimuli:");
  119. private JLabel jlCustom6 = new JLabel("Shift After:");
  120. protected JLabel jlProgressiveDelays = new JLabel("Progressive Delays:");
  121. private GridBagConstraints gbc;
  122. private GridBagLayout gbl;
  123.  
  124. private final String[] programs = {"Shaping - centered", "Shaping - random location", "Matching to sample - DMS",
  125. "Non-Matching to sample - DNMS", "Spatial - DRST", "Object - DRST",
  126. "Progressive Ratio", "Delayed Response",
  127. "Attention Tasks", "Conceptual Set Shifting", "Custom CSST" };
  128.  
  129.  
  130. private final String[] reward = {"None", "Positive", "Negative", "Both"};
  131. private final String[] random = {"Fixed", "Random", "From File"};
  132. private final String[] ccst = {"Discrimination", "Full - Level 1", "Full - Level 2", "Full - Level 3", "Full - Level 4"};
  133. private final String[] yesno = {"Yes", "No"};
  134. private final String[] allowDisallow = {"Allowed", "Disallowed"};
  135. private final String[] cursorChoice = {"Blank", "Default"};
  136. private final String[] screenSize = {"1024x768", "800x600"};
  137. private final String[] theColor = {"Black", "Blue", "Gray", "Green", "Orange", "Pink", "Yellow"};
  138. private final String[] PR = {"Fixed Ratio 1", "Fixed Ratio 2", "Fixed Ratio 3",
  139. "Fixed Ratio 4", "Fixed Ratio 5", "Fixed Ratio 6",
  140. "Progressive Ratio", };
  141. private final String[] attention = {"Training", "Simple Search Easy", "Simple Search Hard", "Cued Search"};
  142. private final String[] OP = {"COM1", "COM2", "COM3", "COM4", "LPT1", "LPT2", "USB" };
  143. private Dimension size = new Dimension ( 750 /*675*/, 525 );
  144.  
  145. private final String[] cardChoice = {"Standard", "Card", "Standard - One Line", "Card - One Line", "Card - Alternate Colors" };
  146. private JLabel cardLabel = new JLabel("Mode:");
  147. private final String[] customNumber = { "2", "3", "4", "5", "6", "7", "8", "9" };
  148. private final String[] progressiveDelays = { "Enabled", "Disabled" };
  149.  
  150. private final String[] correctionProcedures = { "force", "off", "on" };
  151.  
  152. // Handlers
  153. private ProgramSelectorHandler Handle;
  154. private QuitHandler QHandle;
  155. private ChooserHandler CHandle;
  156. private ChooserHandler CHandle2;
  157. private ChooserHandler CHandle3;
  158. private ChooserHandler CHandle4;
  159. private ChooserHandler CHandle5;
  160. private SaveLoadHandler sHandle;
  161. private SaveLoadHandler lHandle;
  162. private AboutHandler about;
  163. private ConvertHandler convert;
  164. private Calendar c;
  165.  
  166. /** Creates new ProgramSelector */
  167. public ProgramSelector() {
  168. this.setIconImage( new ImageIcon(getClass().getResource("logo.jpg")).getImage());
  169. //Setup Menu Bar
  170. jmFile.add(jmi1);
  171. jmFile.add(jmi2);
  172. jmFile.addSeparator();
  173. jmFile.add(jmi3);
  174. jmFile.add(jmi4);
  175. jmTools.add(jmi6);
  176. jmHelp.add(jmi5);
  177. jmb.add(jmFile);
  178. jmb.add(jmTools);
  179. jmb.add(jmHelp);
  180. jmb.setBorderPainted( true );
  181.  
  182. //Setup Setup drop down menu boxes
  183. chooser = new JComboBox ( programs );
  184. chooser2 = new JComboBox ( reward );
  185. chooser3 = new JComboBox ( random );
  186. chooser4 = new JComboBox ( screenSize );
  187. chooser5 = new JComboBox ( theColor );
  188. chooser6 = new JComboBox ( allowDisallow );
  189. chooser7 = new JComboBox ( PR );
  190. chooser8 = new JComboBox ( attention );
  191. chooser9 = new JComboBox ( ccst );
  192. chooser10 = new JComboBox ( OP );
  193. chooser11 = new JComboBox ( cursorChoice );
  194. chooser12 = new JComboBox ( cardChoice );
  195. chooser13 = new JComboBox ( customNumber );
  196. chooser14 = new JComboBox ( progressiveDelays );
  197. correctionChooser = new JComboBox ( correctionProcedures );
  198.  
  199. //Set selected indexes and initialize some text fields
  200. chooser5.setSelectedIndex( 3 );
  201. chooser6.setSelectedIndex( 1 );
  202. chooser9.setSelectedIndex( 1 );
  203. chooser11.setSelectedIndex( 1 );
  204. chooser12.setSelectedIndex( 0 );
  205. chooser13.setSelectedIndex( 1 );
  206. chooser14.setSelectedIndex( 1 );
  207. correctionChooser.setSelectedIndex(1);
  208. startB = new JButton("Start");
  209. exitB = new JButton ("Exit");
  210. jtfDelayConstant.setText("1");
  211. jtfiti.setText("1");
  212. jtfTrials.setText("3");
  213. jtfTimeout.setText("5");
  214. jtfTimeAllowance.setText("30");
  215. jtfCustom5.setText("10");
  216. this.setTitle("Yerkes Cognitive Battery");
  217.  
  218. //Setup up for the date, this is messy because Java is weird with dates
  219. String help = new String();
  220. c = Calendar.getInstance();
  221. help = help.concat("" + ( c.get( Calendar.MONTH) + 1 ) );
  222. help = help.concat("/");
  223. help = help.concat("" + c.get( Calendar.DATE ) );
  224. help = help.concat("/");
  225. help = help.concat("" + c.get( Calendar.YEAR ) );
  226. help = help.concat(" ");
  227. if( c.get( Calendar.HOUR ) == 0)
  228. help = help.concat("12" );
  229. else
  230. help = help.concat("" + c.get( Calendar.HOUR ) );
  231.  
  232. help = help.concat(":");
  233. if( c.get (Calendar.MINUTE ) < 10 )
  234. help = help.concat("0");
  235. help = help.concat("" + c.get( Calendar.MINUTE ) );
  236. if ( c.get( Calendar.AM_PM) == 0 )
  237. help = help.concat("AM" );
  238. else
  239. help = help.concat("PM" );
  240.  
  241. jtfDate.setText( help );
  242.  
  243. //Dont let these fields be editable at start
  244. jtfDelayRangeStart.setEditable( false );
  245. jtfDelayRangeEnd.setEditable( false );
  246. jtfDelay.setEditable( false );
  247. jtfDelayInterval.setEditable( false );
  248.  
  249. //Setup layout for window
  250. gbl = new GridBagLayout();
  251.  
  252. // Create three panels with borders for components
  253. panel1.setBorder(BorderFactory.createCompoundBorder(
  254. BorderFactory.createLineBorder(Color.black, 1 ),
  255. BorderFactory.createEmptyBorder(5,5,5,5)));
  256. panel2.setBorder(BorderFactory.createCompoundBorder(
  257. BorderFactory.createLineBorder(Color.black, 1),
  258. BorderFactory.createEmptyBorder(5,5,5,5)));
  259. panel4.setBorder(BorderFactory.createCompoundBorder(
  260. BorderFactory.createLineBorder(Color.black, 1),
  261. BorderFactory.createEmptyBorder(5,5,5,5)));
  262.  
  263. /* Program Chooser */
  264. panel1.setLayout( gbl );
  265. gbc = new GridBagConstraints( 0, 0, 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0);
  266. gbl.setConstraints(chooser, gbc);
  267. panel1.add( chooser );
  268.  
  269. /* Date */
  270. gbc = new GridBagConstraints( 0, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
  271. gbl.setConstraints(jlDate, gbc);
  272. panel1.add( jlDate );
  273.  
  274. gbc = new GridBagConstraints( 1, 1, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  275. gbl.setConstraints(jtfDate, gbc);
  276. panel1.add( jtfDate );
  277.  
  278. /* Monkey ID */
  279. gbc = new GridBagConstraints( 0, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
  280. gbl.setConstraints(jlId, gbc);
  281. panel1.add( jlId );
  282.  
  283. gbc = new GridBagConstraints( 1, 2, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  284. gbl.setConstraints(jtfId, gbc);
  285. panel1.add( jtfId );
  286.  
  287. /* tester */
  288. gbc = new GridBagConstraints( 0, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
  289. gbl.setConstraints(jlTester, gbc);
  290. panel1.add( jlTester );
  291.  
  292. gbc = new GridBagConstraints( 1, 3, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  293. gbl.setConstraints(jtfTester, gbc);
  294. panel1.add( jtfTester );
  295.  
  296. /* choose output */
  297. gbc = new GridBagConstraints( 0, 4, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0);
  298. gbl.setConstraints(jloutput, gbc);
  299. panel1.add( jloutput );
  300.  
  301. /* Display for save location */
  302. gbc = new GridBagConstraints( 0, 5, 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  303. gbl.setConstraints(jtfOutputLoc, gbc);
  304. panel1.add ( jtfOutputLoc );
  305.  
  306. /* choose button */
  307. gbc = new GridBagConstraints( 0, 6, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
  308. gbl.setConstraints(Choose, gbc);
  309. panel1.add( Choose );
  310.  
  311. /* Image Directory */
  312. gbc = new GridBagConstraints( 0, 7, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0);
  313. gbl.setConstraints(jlImageDir, gbc);
  314. panel1.add( jlImageDir );
  315.  
  316. gbc = new GridBagConstraints( 0, 8, 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  317. gbl.setConstraints(jtfImageDir, gbc);
  318. panel1.add( jtfImageDir );
  319.  
  320. gbc = new GridBagConstraints( 0, 9, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
  321. gbl.setConstraints(Choose3, gbc);
  322. panel1.add( Choose3 );
  323.  
  324. //Correct Sound
  325. gbc = new GridBagConstraints( 0, 10, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 0, 0, 0), 0, 0);
  326. gbl.setConstraints(jlCS, gbc);
  327. panel1.add( jlCS );
  328.  
  329. gbc = new GridBagConstraints( 0, 11, 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  330. gbl.setConstraints(jtfCS, gbc);
  331. panel1.add( jtfCS );
  332.  
  333. gbc = new GridBagConstraints( 0, 12, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 10, 0), 0, 0);
  334. gbl.setConstraints(Choose4, gbc);
  335. panel1.add( Choose4 );
  336.  
  337. //Incorrect Sound
  338. gbc = new GridBagConstraints( 0, 13, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
  339. gbl.setConstraints(jlIS, gbc);
  340. panel1.add( jlIS );
  341.  
  342. gbc = new GridBagConstraints( 0, 14, 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  343. gbl.setConstraints(jtfIS, gbc);
  344. panel1.add( jtfIS );
  345.  
  346. gbc = new GridBagConstraints( 0, 15, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
  347. gbl.setConstraints(Choose5, gbc);
  348. panel1.add( Choose5 );
  349.  
  350. //Database Host
  351. gbc = new GridBagConstraints( 0, 16, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
  352. gbl.setConstraints(jlDB, gbc);
  353. panel1.add( jlDB );
  354.  
  355. gbc = new GridBagConstraints( 0, 17, 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  356. gbl.setConstraints(jtDB, gbc);
  357. panel1.add( jtDB );
  358.  
  359.  
  360.  
  361. //Blank to take up extra space
  362. gbc = new GridBagConstraints( 0, 18, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0);
  363. gbl.setConstraints(blank1, gbc);
  364. panel1.add( blank1 );
  365.  
  366. //Middle panel
  367. panel2.setLayout( gbl );
  368.  
  369. //Blank space at the top
  370. gbc = new GridBagConstraints( 0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 0, 0, 0), 0, 0);
  371. gbl.setConstraints(blank2, gbc);
  372. panel2.add( blank2 );
  373.  
  374. /* number of trials */
  375. gbc = new GridBagConstraints( 0, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 10), 0, 0);
  376. gbl.setConstraints(jlTrials, gbc);
  377. panel2.add( jlTrials );
  378.  
  379. gbc = new GridBagConstraints( 1, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
  380. gbl.setConstraints(jtfTrials, gbc);
  381. panel2.add( jtfTrials );
  382.  
  383. /* Time Out */
  384. gbc = new GridBagConstraints( 0, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 10), 0, 0);
  385. gbl.setConstraints(jltOut, gbc);
  386. panel2.add( jltOut );
  387.  
  388. gbc = new GridBagConstraints( 1, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  389. gbl.setConstraints(jtfTimeout, gbc);
  390. panel2.add( jtfTimeout );
  391.  
  392. /* time allowance */
  393. gbc = new GridBagConstraints( 0, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 10), 0, 0);
  394. gbl.setConstraints(jltAllowance, gbc);
  395. panel2.add( jltAllowance );
  396.  
  397. gbc = new GridBagConstraints( 1, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  398. gbl.setConstraints(jtfTimeAllowance, gbc);
  399. panel2.add( jtfTimeAllowance );
  400.  
  401. gbc = new GridBagConstraints( 0, 4, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 10), 0, 0);
  402. gbl.setConstraints(jlVT, gbc);
  403. panel2.add( jlVT );
  404.  
  405. gbc = new GridBagConstraints( 1, 4, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
  406. gbl.setConstraints(jtfVT, gbc);
  407. panel2.add( jtfVT );
  408.  
  409. gbc = new GridBagConstraints( 0, 5, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 10), 0, 0);
  410. gbl.setConstraints(jlVD, gbc);
  411. panel2.add( jlVD );
  412.  
  413. gbc = new GridBagConstraints( 1, 5, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  414. gbl.setConstraints(jtfVD, gbc);
  415. panel2.add( jtfVD );
  416.  
  417. // Timeout Color
  418. gbc = new GridBagConstraints( 0, 6, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 0, 0, 0), 0, 0);
  419. gbl.setConstraints(jlColor, gbc);
  420. panel2.add( jlColor );
  421.  
  422. gbc = new GridBagConstraints( 1, 6, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 0, 0, 0), 0, 0);
  423. gbl.setConstraints(chooser5, gbc);
  424. panel2.add( chooser5 );
  425.  
  426. //ITI
  427.  
  428. gbc = new GridBagConstraints( 0, 7, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0);
  429. gbl.setConstraints(jliti, gbc);
  430. panel2.add( jliti );
  431.  
  432. gbc = new GridBagConstraints( 1, 7, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0);
  433. gbl.setConstraints(jtfiti, gbc);
  434. panel2.add( jtfiti );
  435.  
  436. /* Delay chooser */
  437. gbc = new GridBagConstraints( 0, 8, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0);
  438. gbl.setConstraints(jlDelay, gbc);
  439. panel2.add( jlDelay );
  440.  
  441. gbc = new GridBagConstraints( 1, 8, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0);
  442. gbl.setConstraints(chooser3, gbc);
  443. panel2.add( chooser3 );
  444.  
  445. /* display input file location or the random constant */
  446. gbc = new GridBagConstraints( 0, 9, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0);
  447. gbl.setConstraints(jlDelayConstant, gbc);
  448. panel2.add( jlDelayConstant );
  449.  
  450. gbc = new GridBagConstraints( 1, 9, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0);
  451. gbl.setConstraints(jtfDelayConstant, gbc);
  452. panel2.add( jtfDelayConstant );
  453.  
  454. //Delay Range for random numbers
  455. gbc = new GridBagConstraints( 0, 10, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0);
  456. gbl.setConstraints(jlDelayRange, gbc);
  457. panel2.add( jlDelayRange );
  458.  
  459. gbc = new GridBagConstraints( 0, 11, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
  460. gbl.setConstraints(jlDelayRangeStart, gbc);
  461. panel2.add( jlDelayRangeStart );
  462.  
  463. gbc = new GridBagConstraints( 1, 11, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
  464. gbl.setConstraints(jtfDelayRangeStart, gbc);
  465. panel2.add( jtfDelayRangeStart );
  466.  
  467. gbc = new GridBagConstraints( 0, 12, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  468. gbl.setConstraints(jlDelayRangeEnd, gbc);
  469. panel2.add( jlDelayRangeEnd );
  470.  
  471. gbc = new GridBagConstraints( 1, 12, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  472. gbl.setConstraints(jtfDelayRangeEnd, gbc);
  473. panel2.add( jtfDelayRangeEnd );
  474.  
  475. gbc = new GridBagConstraints( 0, 13, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  476. gbl.setConstraints(jlDelayInterval, gbc);
  477. panel2.add( jlDelayInterval );
  478.  
  479. gbc = new GridBagConstraints( 1, 13, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  480. gbl.setConstraints(jtfDelayInterval, gbc);
  481. panel2.add( jtfDelayInterval );
  482.  
  483. // Delays from file
  484. gbc = new GridBagConstraints( 0, 14, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0);
  485. gbl.setConstraints(jlDelayFile, gbc);
  486. panel2.add( jlDelayFile );
  487.  
  488. gbc = new GridBagConstraints( 0, 15, 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  489. gbl.setConstraints(jtfDelay, gbc);
  490. panel2.add( jtfDelay );
  491.  
  492. gbc = new GridBagConstraints( 0, 16, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
  493. gbl.setConstraints(Choose2, gbc);
  494. panel2.add( Choose2 );
  495.  
  496. //Blank to take up extra space
  497. gbc = new GridBagConstraints( 0, 17, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0);
  498. gbl.setConstraints(blank3, gbc);
  499. panel2.add( blank3 );
  500.  
  501. //Panel for start and exit buttons
  502. panel3.setLayout ( new BorderLayout() );
  503. panel3.add( startB, BorderLayout.WEST);
  504. panel3.add( exitB, BorderLayout.EAST);
  505.  
  506. //Right panel
  507. panel4.setLayout ( gbl );
  508.  
  509. //Blank to take up space
  510. gbc = new GridBagConstraints( 0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 0, 0, 0), 0, 0);
  511. gbl.setConstraints(blank4, gbc);
  512. panel4.add( blank4 );
  513.  
  514. //Count valid clicks?
  515. gbc = new GridBagConstraints( 0, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 10), 0, 0);
  516. gbl.setConstraints(jlValidClick, gbc);
  517. panel4.add( jlValidClick );
  518.  
  519. gbc = new GridBagConstraints( 0, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
  520. gbl.setConstraints(chooser6, gbc);
  521. panel4.add( chooser6 );
  522.  
  523. //Reward options
  524. gbc = new GridBagConstraints( 0, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 0, 0, 0), 0, 0);
  525. gbl.setConstraints(jlReward, gbc);
  526. panel4.add( jlReward );
  527.  
  528. gbc = new GridBagConstraints( 0, 4, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
  529. gbl.setConstraints(chooser2, gbc);
  530. panel4.add( chooser2 );
  531.  
  532. //Port for output
  533. gbc = new GridBagConstraints( 0, 5, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 0, 0, 0), 0, 0);
  534. gbl.setConstraints(jlOP, gbc);
  535. panel4.add( jlOP );
  536.  
  537. gbc = new GridBagConstraints( 0, 6, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
  538. gbl.setConstraints(chooser10, gbc);
  539. panel4.add( chooser10 );
  540.  
  541. //Screen size
  542. gbc = new GridBagConstraints( 0, 7, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 0, 0, 0), 0, 0);
  543. gbl.setConstraints(jlScreenSize, gbc);
  544. panel4.add( jlScreenSize );
  545.  
  546. gbc = new GridBagConstraints( 0, 8, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
  547. gbl.setConstraints(chooser4, gbc);
  548. panel4.add( chooser4 );
  549.  
  550. gbc = new GridBagConstraints( 0, 9, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 0, 0, 0), 0, 0);
  551. gbl.setConstraints(jlC, gbc);
  552. panel4.add( jlC );
  553.  
  554. gbc = new GridBagConstraints( 0, 10, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
  555. gbl.setConstraints(chooser11, gbc);
  556. panel4.add( chooser11 );
  557.  
  558. //Program specific options
  559. // These are all on top of each other, but only one set will be visable at a time
  560. gbc = new GridBagConstraints( 0, 11, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 0, 0, 0), 0, 0);
  561. gbl.setConstraints(jlVersion, gbc);
  562. panel4.add( jlVersion );
  563.  
  564. gbc = new GridBagConstraints( 0, 12, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  565. gbl.setConstraints(chooser7, gbc);
  566. panel4.add( chooser7 );
  567.  
  568.  
  569. gbc = new GridBagConstraints( 0, 12, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  570. gbl.setConstraints(chooser8, gbc);
  571. panel4.add( chooser8 );
  572.  
  573. gbc = new GridBagConstraints( 0, 12, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  574. gbl.setConstraints(chooser9, gbc);
  575. panel4.add( chooser9 );
  576.  
  577. gbc = new GridBagConstraints( 0, 13, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 0, 0, 0), 0, 0);
  578. gbl.setConstraints(cardLabel, gbc);
  579. panel4.add( cardLabel );
  580.  
  581. gbc = new GridBagConstraints( 0, 14, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  582. gbl.setConstraints(chooser12, gbc);
  583. panel4.add( chooser12 );
  584.  
  585. //correction procedure panel
  586. gbc = new GridBagConstraints( 0, 13, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 0, 0, 0), 0, 0);
  587. gbl.setConstraints(jlCorrectProc, gbc);
  588. panel4.add( jlCorrectProc );
  589.  
  590. gbc = new GridBagConstraints( 0, 14, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  591. gbl.setConstraints(correctionChooser, gbc);
  592. panel4.add( correctionChooser );
  593.  
  594.  
  595. gbc = new GridBagConstraints( 0, 11, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 0, 0, 0), 0, 0);
  596. gbl.setConstraints(jlProgressiveDelays, gbc);
  597. panel4.add( jlProgressiveDelays );
  598.  
  599. gbc = new GridBagConstraints( 0, 12, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  600. gbl.setConstraints(chooser14, gbc);
  601. panel4.add( chooser14 );
  602.  
  603. //Specific to Custom CSST, there's a lot of it
  604. gbc = new GridBagConstraints( 0, 11, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  605. gbl.setConstraints(jlCustom1, gbc);
  606. panel4.add( jlCustom1 );
  607.  
  608. gbc = new GridBagConstraints( 1, 11, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  609. gbl.setConstraints(jtfCustom1, gbc);
  610. panel4.add( jtfCustom1 );
  611.  
  612. gbc = new GridBagConstraints( 0, 12, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  613. gbl.setConstraints(jlCustom2, gbc);
  614. panel4.add( jlCustom2 );
  615.  
  616. gbc = new GridBagConstraints( 1, 12, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  617. gbl.setConstraints(jtfCustom2, gbc);
  618. panel4.add( jtfCustom2 );
  619.  
  620. gbc = new GridBagConstraints( 0, 13, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  621. gbl.setConstraints(jlCustom3, gbc);
  622. panel4.add( jlCustom3 );
  623.  
  624. gbc = new GridBagConstraints( 1, 13, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  625. gbl.setConstraints(jtfCustom3, gbc);
  626. panel4.add( jtfCustom3 );
  627.  
  628. gbc = new GridBagConstraints( 0, 14, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  629. gbl.setConstraints(jlCustom4, gbc);
  630. panel4.add( jlCustom4 );
  631.  
  632. gbc = new GridBagConstraints( 1, 14, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  633. gbl.setConstraints(jtfCustom4, gbc);
  634. panel4.add( jtfCustom4 );
  635.  
  636. gbc = new GridBagConstraints( 0, 15, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  637. gbl.setConstraints(jlCustom5, gbc);
  638. panel4.add( jlCustom5 );
  639.  
  640. gbc = new GridBagConstraints( 1, 15, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  641. gbl.setConstraints(chooser13, gbc);
  642. panel4.add( chooser13 );
  643.  
  644. gbc = new GridBagConstraints( 0, 16, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  645. gbl.setConstraints(jlCustom6, gbc);
  646. panel4.add( jlCustom6 );
  647.  
  648. gbc = new GridBagConstraints( 1, 16, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
  649. gbl.setConstraints(jtfCustom5, gbc);
  650. panel4.add( jtfCustom5 );
  651.  
  652.  
  653. //Blank to take up space
  654. gbc = new GridBagConstraints( 0, 17, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0);
  655. gbl.setConstraints(blank6, gbc);
  656. panel4.add( blank6 );
  657.  
  658. // Set all program specific stuff non-visible
  659. jlVersion.setVisible(false);
  660. chooser7.setVisible(false);
  661.  
  662.  
  663. chooser8.setVisible(false);
  664. chooser9.setVisible(false);
  665.  
  666. cardLabel.setVisible(false);
  667. chooser12.setVisible(false);
  668. correctionChooser.setVisible(false);
  669.  
  670. jlCustom1.setVisible(false);
  671. jtfCustom1.setVisible(false);
  672. jlCustom2.setVisible(false);
  673. j