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.
/** Class for window used during tests
* Takes care of initiating tests, drawing tests, and
* cleaning up after test ends
**/
package yerkes;
import javax.swing.*;
import java.awt.Color;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.util.*;
import java.awt.Graphics;
import java.io.*;
import javax.sound.sampled.*;
/**
*
* @author Pearce Peck-Walden
*
**/
class Base extends JWindow {
public String Tester, imageDirectory, monkeyid, dbHost;
public boolean isDB, isSettingUp, written;
public KeyEvent buttonPress;
public int card, isBetween, correction, readytobypass;
public int[][] customGrid;
public Object[][] customImages;
public String[] imageNames;
private int skipInitial;
private program1aHandler p1a;
private program1bHandler p1b;
private program2aHandler p2a;
private program2bHandler p2b;
private program3aHandler p3a;
private program3bHandler p3b;
private program4Handler p4;
private program5Handler p5;
private program6Handler p6;
private program7Handler p7;
private program8Handler p8;
private startHandler sh;
private Vector theImages;
private JFrame tWindow;
private int number, trials, customSize, baseline;
private ImageIcon test;
private int count, theC, countValid, pr, csst, reward, comPort, time, delay, customShift, customNumberStimuli;
private int theX, theY, theX2, theY2, w, h, swap, numberOfImages, width, height, attention;
protected int started;
private java.util.Timer t;
private String Date, Id, prog, size;
private float[] delays;
private FileOutputStream outputFile = null;
private PrintWriter outputStream = null;
private Color[] colors = { Color.black, Color.blue, Color.gray, Color.green, Color.orange, Color.pink,
Color.yellow, Color.red, Color.white, new Color( 128, 64, 0 ), Color.cyan, Color.magenta, new Color( 153, 0, 153 ),
Color.red, Color.green };
private int[] theXs;
private int[] theYs;
private int[] csstData;
private float iti;
private Clip correctSound, incorrectSound;
private ImageIcon asterix;
private ImageIcon ii1, ii2;
private BufferedImage buf;
protected Graphics g2;
private String[] customTargets;
private boolean isProgressiveDelays;
/** Creates new Base */
public Base(Vector images, JFrame window, int program, String p, int theDelay,
int tallow, String date, String id, String tester, int tr, float[] d, String outFile,
String imageDir, String screenSize, int c, int v, int fr, String ititemp, String VD, String VT,
int at, int v2, int rgb, int port, int cursor, int crd, Clip CS, Clip IS, String db, String custom1,
String custom2, String custom3, String custom4, int stim, int shfts, int progDel, int corProc ) {
if ( progDel == 0 ) isProgressiveDelays = true;
else isProgressiveDelays = false;
isBetween = 0;
customTargets = new String[4];
skipInitial = 0;
customTargets[0] = custom1;
customTargets[1] = custom2;
customTargets[2] = custom3;
customTargets[3] = custom4;
customShift = shfts;
customNumberStimuli = stim + 2;
card = crd;
theImages = images;
tWindow = window;
number = program;
readytobypass = 0;
prog = p;
setBackground(Color.black);
Date = date;
Id = id;
monkeyid = id;
dbHost = db;
Tester = tester;
trials = tr;
time = tallow;
delays = d;
delay = theDelay;
size = screenSize;
imageDirectory = imageDir;
count = 0;
swap = 0;
numberOfImages = 1;
theC = c;
countValid = v;
pr = fr;
csst = v2;
try{ iti = Float.parseFloat(ititemp); } catch (Exception e) {}
attention = at;
t = new java.util.Timer();
correctSound = CS;
incorrectSound = IS;
comPort = port;
reward = rgb;
correction = corProc;
isSettingUp = written = false;
if ( dbHost.equals("")) {
isDB = false;
}
else {
isDB = true;
}
if(reward != 0)
{
com.setTime(Float.parseFloat(VD), Float.parseFloat(VT));
usbHandler.setTime(Float.parseFloat(VD), Float.parseFloat(VT));
}
started = -1;
asterix = new ImageIcon ( getClass().getResource("asterix.jpg") );
if(cursor == 0)
{
this.setCursor( Toolkit.getDefaultToolkit().createCustomCursor(
new ImageIcon ( getClass().getResource("cursor.gif")).getImage(),
new Point(0,0),""));
}
//If there is an output file, open it and write the general info
if( ! ( outFile.equals("") ) )
{
try {
outputFile = new FileOutputStream( outFile, true );
outputStream = new PrintWriter( outputFile, true );
writeHeader();
} catch ( FileNotFoundException err ) {}
}
//Data to for determining the position of items in the test
if( size.equals( "1024x768" ) )
{
setBounds(0,0,1024,768);
theX = ( 1024 / 2 ) - 200 / 2;
theY = ( 768 / 2 ) - 200 / 2;
w = 1024;
h = 768;
width = 200;
height = 200;
customSize = 200;
}
else
{
setBounds(0,0,800,600);
theX = ( 800 / 2 ) - 150 / 2;
theY = ( 600 / 2 ) - 150 / 2;
w = 800;
h = 600;
width = 150;
height = 150;
customSize = 150;
}
//Handler for quitting the program when q/Q is pressed
BypassHandler BP = new BypassHandler( this, t );
this.addKeyListener( BP );
//Handler for displaying the start image
sh = new startHandler( this, theX, theY, width, height);
this.addMouseListener( sh );
//Make the visible visible and get mouse/keyboard focus
this.setVisible(true);
System.out.println("Focusable = " + this.isFocusable());
this.setFocusable(true);
buf = new BufferedImage(w , h, BufferedImage.TYPE_INT_RGB);
g2 = buf.createGraphics();
this.requestFocus();
this.paintBuf( g2 );
}
//Function called by start handler when image is pressed
protected void setup()
{
//Remove the start handler (no longer needed)
removeMouseListener(sh);
isSettingUp = true;
//Program hasn't started, but init screen is not running
started = 0;
//Depending on which number program was selected, setup the appropriate variables
// and call the constructor for the program
// add the newly constructed program as a handlder to the window
// schedule the timeAllowance timer (if program doesnt start w/ flashing)
switch ( number )
{
//Shaping - Centered
case 1:
ii1 = ( ImageIcon ) theImages.elementAt( 0 );
p1a = new program1aHandler( this, theImages, theX, theY, delay,
time, t , trials, delays, outputStream, w, h, width, height, theC,
countValid, correctSound, incorrectSound, reward, comPort, iti );
addMouseListener( p1a );
t.schedule( new Time ( p1a ), time * 1000 );
break;
// Shaping - Random location
case 2:
ii1 = ( ImageIcon ) theImages.elementAt( 0 );
p1b = new program1bHandler( this, theImages, theX, theY, delay,
time, t , trials, delays, outputStream, w, h, width, height, theC,
countValid, correctSound, incorrectSound, reward, comPort, iti );
addMouseListener( p1b );
t.schedule( new Time ( p1b ), time * 1000 );
break;
// Matching to sample - DMS
case 3:
theX2 = 0;
theY2 = 0;
p2a = new program2aHandler( this, theImages, theX, theY, theX2, theY2, delay,
time, t , trials, delays, outputStream, w, h, width, height, theC,
countValid, correctSound, incorrectSound, reward, comPort, iti, isProgressiveDelays, correction );
addMouseListener( p2a );
t.schedule( new Time ( p2a ), time * 1000 );
break;
//Matching to sample - DNMS
case 4:
theX2 = 0;
theY2 = 0;
p2b = new program2bHandler( this, theImages, theX, theY, theX2, theY2, delay,
time, t , trials, delays, outputStream, w, h, width, height, theC,
countValid, correctSound, incorrectSound, reward, comPort, iti, isProgressiveDelays, correction );
addMouseListener( p2b );
t.schedule( new Time ( p2b ), time * 1000 );
break;
// 5-> Spacial DRST 6-> Object DRST
// These two programs are so similar and require a large amount of data
// so they are put togeather
case 5:
case 6:
{
Random r = new Random();
Vector positionX = new Vector(15);
Vector positionY = new Vector(15);
int xHelp, yHelp, theSize, whichOne, value, value2, ii;
theXs = new int[15];
theYs = new int[15];
count = 1;
baseline = 0;
imageNames = new String[15];
//Reset window data (images need to be smaller than standard to fit them all)
if( size.equals("1024x768") )
{
width = 180;
height = 180;
}
else
{
width = 125;
height = 125;
}
// Position of the first image
xHelp = 10;
yHelp = ( h - (height * 3 ) ) / 4;
// Create two vectors, one for the x coordinate valuse
// one for the y values
for( ii = 1; ii < 16; ii++ )
{
positionX.addElement( new Integer ( xHelp ) );
positionY.addElement( new Integer ( yHelp ) );
xHelp = xHelp + width + 10;
// If this was the last image in the row, reset
if ( ( ii % 5 ) == 0 )
{
xHelp = 10;
yHelp = yHelp + height + ( h - (height * 3) ) / 4;
}
}
//Pull the positions out of the vectors (in random order) and put them
// into arrays (creates a set of positons in random order)
for( ii = 0; ii < 15 ; ii++)
{
theSize = positionX.size() - 1;
if( theSize > 1 )
{
whichOne = r.nextInt( theSize );
value = ( ( Integer ) positionX.elementAt( whichOne ) ).intValue() ;
value2 = ( ( Integer ) positionY.elementAt( whichOne ) ).intValue() ;
}
else
{
whichOne = 0;
value = ( ( Integer ) positionX.elementAt( whichOne ) ).intValue() ;
value2 = ( ( Integer ) positionY.elementAt( whichOne ) ).intValue() ;
}
positionX.removeElementAt( whichOne );
positionY.removeElementAt( whichOne );
theXs[ii] = value;
theYs[ii] = value2;
}
// If the data point is in the middle row (of three) offset the X value
// So the images arent in straight columns
for( ii = 0; ii < 15; ii++)
{
if( theYs[ii] == ( ( h - (height * 3) ) / 4 ) + height + ( h - (height * 3) ) / 4 )
theXs[ii] = theXs[ii] + ( ( h - (height * 3) ) / 4 );
}
if( number == 5 )
{
p3a = new program3aHandler( this, theImages, theXs, theYs, delay,
time, t , trials, delays, outputStream, w, h, width, height, theC,
countValid, correctSound, incorrectSound, reward, comPort, iti );
addMouseListener( p3a );
t.schedule( new Time ( p3a ), time * 1000 );
}
else
{
count = 0;
p3b = new program3bHandler( this, theImages, theXs, theYs, delay,
time, t , trials, delays, outputStream, w, h, width, height, theC,
countValid, baseline, correctSound, incorrectSound, reward, comPort, iti );
addMouseListener( p3b );
t.schedule( new Time ( p3b ), time * 1000 );
}
}
break;
// Progressive Ratio
case 7:
p4 = new program4Handler( this, theX, theY, delay,
time, t , trials, delays, outputStream, w, h, width, height,
theC, countValid, pr, correctSound, incorrectSound, reward, comPort, iti );
addMouseListener( p4 );
t.schedule( new Time ( p4 ), time * 1000 );
break;
// Delayed response
case 8:
//Positions are not standard so reset
if( size.equals("1024x768") )
{
theX = 50;
theY = h /2 - height / 2 + height / 4;
theX2 = w - width - 50;
theY2 = h /2 - height / 2 + height / 4;
}
else
{
theX = 50;
theY = h /2 - height / 2 + height / 4;
theX2 = w - width - 50;
theY2 = h /2 - height / 2 + height / 4;
}
p5 = new program5Handler( this, theX, theY, theX2, theY2, delay,
time, t , trials, delays, outputStream, w, h, width, height, theC,
countValid, correctSound, incorrectSound, reward, comPort, iti, isProgressiveDelays, correction );
addMouseListener( p5 );
// Don't schedule timer. Timer shouldn't start until flashing has finished
break;
// Attention tasks
case 9:
{
int xHelp, yHelp, theSize, whichOne, value, value2, ii;
theXs = new int[12];
theYs = new int[12];
Random r = new Random();
count = r.nextInt( 12 );
//Positions are non standard so reset
if( size.equals("1024x768") )
{
width = 130;
height = 130;
}
else
{
width = 85;
height = 85;
}
xHelp = width - width / 4;
yHelp = (height / 4 );
//Setup an array of positions
for( ii = 1; ii < 13; ii++ )
{
theXs[ ii - 1 ] = xHelp;
theYs[ ii - 1 ] = yHelp;
xHelp = xHelp + w / 3 ;
if ( ( ii % 3 ) == 0 )
{
xHelp = width - width / 4;
yHelp = yHelp + h / 4;
}
}
p6 = new program6Handler( this, theXs, theYs, delay,
time, t , trials, delays, outputStream, w, h, width, height, theC,
countValid, attention, r, count, correctSound, incorrectSound, reward, comPort, iti );
addMouseListener( p6 );
//Schedule time unless this is cued seach b/c cued search flashes
if( attention != 3 ) t.schedule( new Time ( p6 ), time * 1000 );
}
break;
// Conceptual set shifting
case 10:
{
int isline;
Random r = new Random();
int xHelp, yHelp, theSize, whichOne, value, value2, ii, yStart;
theXs = new int[9];
theYs = new int[9];
csstData = new int[9];
xHelp = (w - width * 3 ) / 4;
yHelp = (height / 6);
yStart = yHelp;
//Create array of positions
for( ii = 1; ii < 10; ii++ )
{
theXs[ ii - 1 ] = xHelp;
theYs[ ii - 1 ] = yHelp;
xHelp = xHelp + (w - width * 3) / 4 + width;
if ( ( ii % 3 ) == 0 )
{
xHelp = (w - width * 3) / 4;
yHelp = yHelp + h / 3;
}
}
//this covers one row option
if ( (card == 2) || (card == 3) )
{
isline = 3;
yStart = yStart;
for ( ii = 0; ii < 9; ii++ ) {
theYs[ii] = yStart + h / 3;
}
}
else {
isline = 9;
}
p7 = new program7Handler( this, theXs, theYs, delay,
time, t , trials, delays, outputStream, w, h, width, height, theC,
countValid, csst, r, csstData, correctSound, incorrectSound, reward, comPort, isline, iti );
addMouseListener( p7 );
t.schedule( new Time ( p7 ), time * 1000 );
}
break;
//Custom CSST
case 11:
{
int xHelp, yHelp, ii, buffer, Xedging, Yedging;
customGrid = new int[9][3];
Yedging = ( h - ( customSize * 3 ) ) / 8;
buffer = ( h - ( customSize * 3 ) - ( Yedging * 2 ) ) / 2 ; //distance between cells
Xedging = ( w - ( customSize * 3 ) - ( buffer * 2 ) ) / 2; //on sides
xHelp = Xedging;
yHelp = Yedging;
//Create array of positions
for( ii = 1; ii < 10; ii++ )
{
customGrid[ ii - 1 ][0] = -1;
customGrid[ ii - 1 ][1] = xHelp;
customGrid[ ii - 1 ][2] = yHelp;
yHelp = yHelp + customSize + buffer;
if ( ( ii % 3 ) == 0 )
{
xHelp = xHelp + customSize + buffer;
yHelp = Yedging;
}
}
p8 = new program8Handler( this, delay, time, t, trials, delays, outputStream, theC,
countValid, correctSound, incorrectSound, reward, comPort,
iti, customTargets, customNumberStimuli, customSize, customShift );
addMouseListener( p8 );
t.schedule( new Time ( p8 ), time * 1000 );
}
break;
// This should never happen, buf if it does just end (go back)
default:
end( 0 );
}
//Mark programs as having started
started = 1;
//If the program flashes, start the flashing
if( number == 8 ) p5.flash();
if(( number == 9 ) && (attention == 3)) p6.flash();
//Create a new paint thread to make sure the screen has refreshed from the init screen
paintThread pt = new paintThread( this );
pt.start();
}
//When window is repainted draw the offscreen buffer to the window
public void paint( Graphics screen ) {
if(buf != null)
{
screen.drawImage( buf, 0, 0, null );
}
}
//This is for when an image updates (such as a moving GIF)
public void update(Graphics g) {
// DO NOTHING. This is because animated GIFS update too fast and generate all sorts of crazy stuff. This freezes them.
}
//This takes care of doing the actual drawing
public synchronized void paintBuf ( Graphics g ) {
//If the program hasn't started, draw the initial image
if( started == -1)
{
g.drawImage( asterix.getImage() , theX, theY, width, height, this );
return;
}
//If the program is out of the initial handler, but new programs hasnt finished
// Initializing, just draw a black screen
else if( started == 0 )
{
g.setColor( colors[ 0 ] );
g.fillRect(0, 0, w, h);
return;
}
// If the program has started, draw the appropriate images depending on data
// Manipulated by program handler
switch( number )
{
// For Shaping programs, if count is positive draw the image at specified position
// Otherwise fill screen with selected color
case 1:
case 2:
if ( count >= 0 )
{
g.setColor( colors[ 0 ] );
g.fillRect(0, 0, w, h);
ii1 = (ImageIcon) theImages.elementAt(count);
g.drawImage( ii1.getImage() , theX, theY, width, height, this );
}
else
{
g.setColor( colors[ (count * -1) - 1 ] );
g.fillRect(0, 0, w, h);
}
break;
// For DMS and DMNS if count >= 0 draw images
// Otherwise colored screen
case 3:
case 4:
if( ( count >= 0 ) )
{
g.setColor( colors[ 0 ] );
g.fillRect(0, 0, w, h);
if ( ( swap == 1) || ( numberOfImages == 1 ) )
{
ii1 = ( ImageIcon ) theImages.elementAt( count );
ii2 = ( ImageIcon ) theImages.elementAt( count + 1 );
}
else
{
ii1 = ( ImageIcon ) theImages.elementAt( count + 1 );
ii2 = ( ImageIcon ) theImages.elementAt( count );
}
g.drawImage( ii1.getImage() , theX, theY, width, height, this );
}
else
{
ii2 = null;
g.setColor( colors[ (count * -1) - 1 ] );
g.fillRect(0, 0, w, h);
}
// If this is a screen w/ 2 images, draw second image
if( ( ii2 != null ) && ( numberOfImages == 2 ) )
{
g.drawImage( ii2.getImage() , theX2, theY2, width, height, this );
}
break;
// if count > 0 draw all images needed, otherwise colored screen
case 5:
if( count > 0 )
{
g.setColor( colors[ 0 ] );
g.fillRect(0, 0, w, h);
ii1 = ( ImageIcon ) theImages.elementAt( 0 );
for (int ii = count - 1; ii >= 0 ; ii--)
{
g.drawImage( ii1.getImage() , theXs[ii] , theYs[ii], width, height, this );
}
}
else
{
g.setColor( colors[ (count * -1) - 1 ] );
g.fillRect(0, 0, w, h);
}
break;
// if count > 0 draw all images needed, otherwise colored screen
case 6:
if( count >= 0 )
{
int temp;
int temp2;
g.setColor( colors[ 0 ] );
g.fillRect(0, 0, w, h);
for (int ii = count; ii >= 0 + baseline ; ii--)
{
if ( ii >= theImages.size() )
temp = ii % theImages.size();
else
temp = ii;
ii1 = ( ImageIcon ) theImages.elementAt( temp );
g.drawImage( ii1.getImage() , theXs[ii % theXs.length ] , theYs[ii % theYs.length ], width, height, this );
String tempStr = new String(ii1.toString());
int temp3 = tempStr.lastIndexOf("\\"); //this section gets the filename
tempStr = tempStr.substring( temp3+1 , tempStr.length() );
imageNames[ii % theXs.length] = tempStr;
}
}
else
{
g.setColor( colors[ (count * -1) - 1 ] );
g.fillRect(0, 0, w, h);
}
break;
// if count >= 0 draw centered square, otherwise colored screen
case 7:
if ( count >= 0 )
{
g.setColor( colors[ 0 ] );
g.fillRect(0, 0, w, h);
g.setColor( colors[ 6 ] );
g.fillRect(theX, theY, width, height );
}
else
{
g.setColor( colors[ (count * -1) - 1 ] );
g.fillRect(0, 0, w, h);
}
break;
//If count is 100 draw the two squares
// If < 0 draw colored screen
// If equal to 0 draw the circle (cue during flash) by left sqauare
// If equal to 1 draw the circle (cue during flash) by right sqaure
case 8:
if(count >= 0 )
{
g.setColor( colors[ 0 ] );
g.fillRect(0, 0, w, h);
}
if( ( count == 100 ) )
{
g.setColor(colors[ 6 ]);
g.fillRect(50, h /2 - height / 2, width, height);
g.fillRect(w - width - 50, h /2 - height / 2, width, height);
}
else if ( count < 0 )
{
g.setColor( colors[ (count * -1) - 1 ] );
g.fillRect(0, 0, w, h);
}
else if ( count == 0 )
{
g.setColor(colors[ 7 ]);
g.fillArc(width / 2 + width / 4, h /2 - height / 2 + height / 4, width / 4, height / 4, 0 , 360);
}
else if ( count == 1 )
{
g.setColor(colors[ 7 ]);
g.fillArc(w - width / 2 - 50 - width / 4, h /2 - height / 2 + height / 4, width / 4, height / 4, 0 , 360);
}
break;
//If count is between 0 and 100 draw all the circles
// If < 0 draw colored screen
// If > 100 draw circle in specified position only (used for flashing)
case 9:
if (( count >= 0 ) && (count < 100))
{
g.setColor( colors[ 0 ] );
g.fillRect(0, 0, w, h);
//this controls the color of the circles before the star
if ( attention == 1 ) g.setColor(colors[ 6 ]);
else g.setColor(colors[ 7 ]);
for( int ii = 0; ii < 12; ii++ )
if(( ii != count) && (attention != 0))
g.fillArc(theXs[ii], theYs[ii], width, height, 0 , 360);
else if ( ii == count)
{
//The Star
int[] xPoints = { theXs[ii], theXs[ii] + width / 3,
theXs[ii] + width / 2,
theXs[ii] + 2 * (width / 3),
theXs[ii] + width,
theXs[ii] + 3 * (width / 4),
theXs[ii] + 7 * (width / 8),
theXs[ii] + width / 2,
theXs[ii] + (width / 8),
theXs[ii] + ( width / 4) };
int[] yPoints = { theYs[ii] + height / 3, theYs[ii] + height / 3, theYs[ii], theYs[ii] + height / 3,
theYs[ii] + height / 3, theYs[ii] + 3 * ( height / 5), theYs[ii] + height, theYs[ii] + 3 * (height / 4), theYs[ii] + height,
theYs[ii] + 3 * (height / 5) };
g.setColor(colors[ 7 ]); //the star
g.fillPolygon( xPoints, yPoints, xPoints.length);
//this controls the color of the circles after the star
if ( attention == 1 ) g.setColor(colors[ 6 ]);
else g.setColor(colors[ 7 ]);
}
}
else if ( count >= 100 )
{
g.setColor( colors[ 0 ] );
g.fillRect(0, 0, w, h);
g.setColor(colors[ 6 ]); //cue is yellow
g.fillArc(theXs[count - 100], theYs[count - 100], width , height, 0 , 360);
}
else
{
g.setColor( colors[ (count * -1) - 1 ] );
g.fillRect(0, 0, w, h);
}
break;
// If csstData[0] is greater than 0
// And csst equals 0 (discrimination) draw the three shapes
// Otherwise draw level X shapes
// If csstData[0] is less than 0 draw colored screen
case 10:
if ( (card == 0) || (card == 2) ) //no cards
{
if ( csstData[0] >= 0 )
{
g.setColor( colors[ 0 ] );
g.fillRect(0, 0, w, h);
if( csst == 0)
{
for( int ii = 0; ii < 3; ii++ )
{
g.setColor(colors[ 0 ]);
g.fillRect(theXs[csstData[ii]], theYs[csstData[ii]], width, height);
if( csstData[ ii + 3 ] == 0 )
{
g.setColor(colors[10] );
g.fillRect( theXs[csstData[ii]], theYs[csstData[ii]], width, height);
}
else if( csstData[ ii + 3 ] == 1 )
{
g.setColor(colors[11] );
g.fillRect( theXs[csstData[ii]], theYs[csstData[ii]] + height / 2 - height / 16, width, height / 8);
g.fillRect( theXs[csstData[ii]] + width / 2 - width / 16, theYs[csstData[ii]], width / 8, height);
}
else
{
g.setColor( colors[6] );
int[] xPoints = { theXs[csstData[ii]],
theXs[csstData[ii]] + width / 2,
theXs[csstData[ii]] + width,
theXs[csstData[ii]] + width,
theXs[csstData[ii]] + width / 2,
theXs[csstData[ii]]};
int[] yPoints = { theYs[csstData[ii]],
theYs[csstData[ii]] + height / 2,
theYs[csstData[ii]],
theYs[csstData[ii]] + height,
theYs[csstData[ii]] + height / 2,
theYs[csstData[ii]] + height};
g.fillPolygon( xPoints, yPoints, xPoints.length);
}
}
}
else
{
for( int ii = 0; ii < 3; ii++ )
{
g.setColor(colors[ 0 ]);
g.fillRect(theXs[csstData[ii]], theYs[csstData[ii]], width, height);
if ( csstData[ii+6] == 0) g.setColor(colors[7]);
else if ( csstData[ii+6] == 1) g.setColor(colors[3]);
else if ( csstData[ii+6] == 2) g.setColor(colors[1]);
if( csstData[ ii + 3 ] == 0 )
g.fillArc( theXs[csstData[ii]], theYs[csstData[ii]], width, height, 0, 360);
else if( csstData[ii + 3 ] == 1 )
{
int[] xPoints = { theXs[csstData[ii]], theXs[csstData[ii]] + width / 2 ,
theXs[csstData[ii]] + width};
int[] yPoints = { theYs[csstData[ii]] + height, theYs[csstData[ii]],
theYs[csstData[ii]] + height};
g.fillPolygon( xPoints, yPoints, xPoints.length);
}
else
{
int[] xPoints = { theXs[csstData[ii]],
theXs[csstData[ii]] + 2 * (width / 6 ),
theXs[csstData[ii]] + 3 * (width / 6 ),
theXs[csstData[ii]] + 4 * (width / 6 ),
theXs[csstData[ii]] + width,
theXs[csstData[ii]] + 4 * (width / 6 ),
theXs[csstData[ii]] + 5 * (width / 6 ),
theXs[csstData[ii]] + 3 * (width / 6 ),
theXs[csstData[ii]] + 1 * (width / 6 ),
theXs[csstData[ii]] + 2 * (width / 6 ) };
int[] yPoints = { theYs[csstData[ii]] + 4 * (height / 12),
theYs[csstData[ii]] + 4 * (height / 12),
theYs[csstData[ii]],
theYs[csstData[ii]] + 4 * (height / 12),
theYs[csstData[ii]] + 4 * (height / 12),
theYs[csstData[ii]] + 7 * (height / 12),
theYs[csstData[ii]] + height,
theYs[csstData[ii]] + 9 * (height / 12),
theYs[csstData[ii]] + height,
theYs[csstData[ii]] + 7 * (height / 12) };
g.fillPolygon( xPoints, yPoints, xPoints.length);
}
}
}
}
else
{
g.setColor( colors[ (csstData[0] * -1) - 1 ] );
g.fillRect(0, 0, w, h);
}
}//end if card == 0 or 2
else if ( (card == 1) || (card == 3) || (card == 4 ) ) //they want the cards
{
if ( card == 4) //we're using the alternate colors
{
colors[13] = colors[11];
colors[14] = colors[6];
}
if ( csstData[0] >= 0 )
{
g.setColor( colors[ 0 ] );
g.fillRect(0, 0, w, h);
if( csst == 0)
{
for( int ii = 0; ii < 3; ii++ )
{
g.setColor(colors[ 8 ]);
g.fillRect(theXs[csstData[ii]], theYs[csstData[ii]], width, height);
if( csstData[ ii + 3 ] == 0 )
{
g.setColor(colors[5] );
g.fillRect( theXs[csstData[ii]] + width / 4, theYs[csstData[ii]] + height / 4, width / 2, height / 2);
}
else if( csstData[ ii + 3 ] == 1 )
{
g.setColor(colors[4] );
g.fillRect( theXs[csstData[ii]] + width / 4, theYs[csstData[ii]] + height / 2 - height / 16, width / 2, height / 8);
g.fillRect( theXs[csstData[ii]] + width / 2 - width / 16, theYs[csstData[ii]] + height / 4, width / 8, height / 2);
}
else
{
g.setColor( colors[9] );
int[] xPoints = { theXs[csstData[ii]] + width / 4,
theXs[csstData[ii]] + width / 2,
theXs[csstData[ii]] + 3 * (width / 4),
theXs[csstData[ii]] + 3 * (width / 4),
theXs[csstData[ii]] + width / 2,
theXs[csstData[ii]] + width / 4 };
int[] yPoints = { theYs[csstData[ii]] + height / 4,
theYs[csstData[ii]] + height / 2,
theYs[csstData[ii]] + height / 4,
theYs[csstData[ii]] + 3 * ( height / 4),
theYs[csstData[ii]] + height / 2,
theYs[csstData[ii]] + 3 * ( height / 4)};
g.fillPolygon( xPoints, yPoints, xPoints.length);
}
}
}
else
{
for( int ii = 0; ii < 3; ii++ )
{
g.setColor(colors[ 8 ]);
g.fillRect(theXs[csstData[ii]], theYs[csstData[ii]], width, height);
if ( csstData[ii+6] == 0) g.setColor(colors[13]);
else if ( csstData[ii+6] == 1) g.setColor(colors[14]);
else if ( csstData[ii+6] == 2) g.setColor(colors[1]);
if( csstData[ ii + 3 ] == 0 )
g.fillArc( theXs[csstData[ii]] + width / 4, theYs[csstData[ii]] + height / 4, width / 2, height / 2, 0, 360);
else if( csstData[ii + 3 ] == 1 )
{
int[] xPoints = { theXs[csstData[ii]] + width / 4, theXs[csstData[ii]] + width / 2 ,
theXs[csstData[ii]] + width / 4 + width / 2};
int[] yPoints = { theYs[csstData[ii]] + height / 4 + height / 2, theYs[csstData[ii]] + height / 4,
theYs[csstData[ii]] + height / 4 + height / 2};
g.fillPolygon( xPoints, yPoints, xPoints.length);
}
else
{
int[] xPoints = { theXs[csstData[ii]] + width / 4,
theXs[csstData[ii]] + width / 3 + width / 4,
theXs[csstData[ii]] + width / 2 ,
theXs[csstData[ii]] + 2 * (width / 3) - width / 4,
theXs[csstData[ii]] + width - width / 4,
theXs[csstData[ii]] + 3 * (width / 4) - width / 8,
theXs[csstData[ii]] + 7 * (width / 8) - width / 6,
theXs[csstData[ii]] + width / 2,
theXs[csstData[ii]] + (width / 8) + width / 6,
theXs[csstData[ii]] + ( width / 4) + width / 8 };
int[] yPoints = { theYs[csstData[ii]] + height / 4 + height / 6,
theYs[csstData[ii]] + height / 4 + height / 6,
theYs[csstData[ii]] + height / 4,
theYs[csstData[ii]] + height / 4 + height / 6,
theYs[csstData[ii]] + height / 4 + height / 6,
theYs[csstData[ii]] + ( height / 2) + height / 20,
theYs[csstData[ii]] + height - height / 8 - height / 8,
theYs[csstData[ii]] + 3 * (height / 4) - height / 8,
theYs[csstData[ii]] + height - height / 8 - height / 8,
theYs[csstData[ii]] + (height / 2) + height / 20};
g.fillPolygon( xPoints, yPoints, xPoints.length);
}
}
}
}
else
{
g.setColor( colors[ (csstData[0] * -1) - 1 ] );
g.fillRect(0, 0, w, h);
}
}//end else for cards
break;
//custom CSST
case 11:
if (skipInitial == 0) {
skipInitial = 1;
return;
} //we do this because our handler draws the first screen
if ( isBetween == 3 ) {
g.setColor( colors[ 7 ] );
g.fillRect(0, 0, w, h);
}
else if ( isBetween == 2 ) {
g.setColor( colors[ theC ] );
g.fillRect(0, 0, w, h);
}
else {
g.setColor( colors[ 0 ] );
g.fillRect(0, 0, w, h); //paints the black background
if ( isBetween == 0 ) {
//now draw the images
for ( int i = 0 ; i < 9 ; i++ ) {
if ( customGrid[i][0] != -1 ) {
g.drawImage( (Image)customImages[customGrid[i][0]][1] , customGrid[i][1], customGrid[i][2], customSize, customSize, this );
}//end if
} //end for
} //end if
} //end else
break;
}
readytobypass = 1;
} //end paintBuf
//Used for program Handlers to change "count"
protected int changeCount( int c ) {
int old;
old = count;
count = c;
return old;
}
// Used for program Handlers to change "baseline" (used for DRST tasks)
protected void changeBaseline( int c ) { baseline = c; }
// Used for program Handlers to change x and y positions
protected void loc(int x, int y, int x2, int y2, int s, int nI )
{
theX = x;
theY = y;
theX2 = x2;
theY2 = y2;
swap = s;
numberOfImages = nI;
}
// When the program is supposed to stop
// Call the quit function of the running program (if one has started)
protected void end( int kill )
{
System.out.println("ending");
if( started > 0 )
{
switch( number )
{
case 1:
p1a.quit();
break;
case 2:
p1b.quit();
break;
case 3:
p2a.quit();
break;
case 4:
p2b.quit();
break;
case 5:
p3a.quit();
break;
case 6:
p3b.quit();
break;
case 7:
p4.quit();
break;
case 8:
p5.quit();
break;
case 9:
p6.quit();
break;
case 10:
p7.quit();
break;
case 11:
p8.quit();
break;
}
}
// Close the sounds
if( correctSound != null) correctSound.close();
if( incorrectSound != null) incorrectSound.close();
// If this was a Q then quit entire program
if ( kill == 1 )
System.exit(1);
// Otherwise hide this base and show program selector
else
{
tWindow.setVisible( true );
this.setVisible(false);
}
}
protected void updateGraphics()
{
paintThread pt = new paintThread( this );
pt.start();
}
// When the programs is supposed to stop
// Call the quit function of the running program (if one has started)
protected void bypass(KeyEvent k)
{
buttonPress = k;
if( (started > 0) && (readytobypass == 1 ) )
{
switch( number )
{
case 1:
p1a.bypass();
break;
case 2:
p1b.bypass();
break;
case 3:
p2a.bypass();
break;
case 4:
p2b.bypass();
break;
case 5:
p3a.bypass();
break;
case 6:
p3b.bypass();
break;
case 7:
p4.bypass();
break;
case 8:
p5.bypass();
break;
case 9:
p6.bypass();
break;
case 10:
p7.bypass();
break;
case 11:
p8.bypass();
break;
}
}
}
// This function writes the header in formation for a program
private void writeHeader( )
{
outputStream.println( "Date: " + Date );
outputStream.println( "Monkey ID: " + Id );
outputStream.println( "Task: " + prog );
if( (number == 3) || (number == 4) || (number == 8) ){
if (correction == 0)
outputStream.println("Forced correction procedure");
else if (correction == 1)
outputStream.println("No correction procedure");
else if (correction == 2)
outputStream.println("Correction procedure on");
}
else if (number == 10 )
{
if( csst == 0 ) outputStream.println(" (Discrimination)");
if( csst == 1 ) outputStream.println(" (Level 1)");
if( csst == 2 ) outputStream.println(" (Level 2)");
if( csst == 3 ) outputStream.println(" (Level 3)");
if( csst == 4 ) outputStream.println(" (Level 4)");
}
else if (number == 9)
{
if( attention == 0 ) outputStream.println(" (Training)");
else if( attention == 1 ) outputStream.println(" (Simple Search Easy)");
else if( attention == 2 ) outputStream.println(" (Simple Search Hard)");
else if( attention == 3 ) outputStream.println(" (Cued Search)");
}
else if (number == 7 )
{
if( pr == 0 ) outputStream.println(" (Fixed Ratio 1)");
else if( pr == 1 ) outputStream.println(" (Fixed Ratio 2)");
else if( pr == 2 ) outputStream.println(" (Fixed Ratio 3)");
else if( pr == 3 ) outputStream.println(" (Fixed Ratio 4)");
else if( pr == 4 ) outputStream.println(" (Fixed Ratio 5)");
else if( pr == 5 ) outputStream.println(" (Fixed Ratio 6)");
else if( pr == 6 ) outputStream.println(" (Progressive Ratio)");
}
outputStream.println( "Tested By: " + Tester );
outputStream.println( "Image Directory: " + imageDirectory );
outputStream.println( "ITI: " + iti );
outputStream.print( "Database Host: ");
if (dbHost.equals("")) {
outputStream.println("NONE");
}
else {
outputStream.println(dbHost);
}
outputStream.println( " " );
outputStream.println( "Trial" );
}
}
package yerkes;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
//This creates GUI for running programs
class ProgramSelector extends JFrame implements ActionListener{
// GUI components
private JPanel panel1 = new JPanel();
private JPanel panel2 = new JPanel();
private JPanel panel3 = new JPanel();
private JPanel panel4 = new JPanel();
private JMenuBar jmb = new JMenuBar();
private JMenu jmFile = new JMenu("File");
private JMenu jmHelp = new JMenu("Help");
private JMenu jmTools = new JMenu("Tools");
private JMenuItem jmi1 = new JMenuItem("Save Settings");
private JMenuItem jmi2 = new JMenuItem("Load Settings");
private JMenuItem jmi3 = new JMenuItem("Start");
private JMenuItem jmi4 = new JMenuItem("Exit");
private JMenuItem jmi5 = new JMenuItem("About");
private JMenuItem jmi6 = new JMenuItem("Image Converter");
protected JTextField jtfDate = new JTextField( 10 );
protected JTextField jtfOutputLoc = new JTextField( 3 );
protected JTextField jtfTimeout = new JTextField( 3 );
protected JTextField jtfTimeAllowance = new JTextField( 3 );
protected JTextField jtfTrials = new JTextField( 3 );
protected JTextField jtfDelay = new JTextField( 10 );
protected JTextField jtfId = new JTextField( 10 );
protected JTextField jtfTester = new JTextField( 10 );
protected JTextField jtfImageDir = new JTextField( 3 );
protected JTextField jtfDelayConstant = new JTextField( 3 );
protected JTextField jtfiti = new JTextField( 3 );
protected JTextField jtfDelayRangeStart = new JTextField( 3 );
protected JTextField jtfDelayRangeEnd = new JTextField( 3 );
protected JTextField jtfDelayInterval = new JTextField( 3 );
protected JTextField jtfVD = new JTextField( 3 );
protected JTextField jtfVT = new JTextField( 3 );
protected JTextField jtfCS = new JTextField( 3 );
protected JTextField jtfIS = new JTextField( 3 );
protected JTextField jtDB = new JTextField( 3 );
protected JTextField jtfCustom1 = new JTextField( 10 );
protected JTextField jtfCustom2 = new JTextField( 10 );
protected JTextField jtfCustom3 = new JTextField( 10 );
protected JTextField jtfCustom4 = new JTextField( 10 );
protected JTextField jtfCustom5 = new JTextField( 3 ); //this one is for number before shift
protected JComboBox chooser;
protected JComboBox chooser2;
protected JComboBox chooser3;
protected JComboBox chooser4;
protected JComboBox chooser5;
protected JComboBox chooser6;
protected JComboBox chooser7;
protected JComboBox chooser8;
protected JComboBox chooser9;
protected JComboBox chooser10;
protected JComboBox chooser11;
protected JComboBox chooser12;
protected JComboBox chooser13; //for Custom CSST
protected JComboBox chooser14; //increased delay toggle
protected JComboBox correctionChooser; //for correction procedure
private JButton startB;
private JButton exitB;
private JButton Choose = new JButton("Select");
private JButton Choose2 = new JButton("Select");
private JButton Choose3 = new JButton("Select");
private JButton Choose4 = new JButton("Select");
private JButton Choose5 = new JButton("Select");
protected JLabel jlVersion = new JLabel("Version:");
private JLabel blank1 = new JLabel(" ");
private JLabel blank2 = new JLabel(" ");
private JLabel blank3 = new JLabel(" ");
private JLabel blank4 = new JLabel(" ");
private JLabel blank6 = new JLabel(" ");
private JLabel jliti = new JLabel("Inter-trial Interval:");
private JLabel jloutput = new JLabel("Output To File:");
private JLabel jltOut = new JLabel("Time out length:");
private JLabel jltAllowance = new JLabel("Time Allowance:");
private JLabel jlTrials = new JLabel("Number of trials:");
private JLabel jlDate = new JLabel("Date:");
private JLabel jlId = new JLabel("Monkey ID:");
private JLabel jlTester = new JLabel("Tester:");
private JLabel jlImageDir = new JLabel("Image Directory:");
private JLabel jlDelay = new JLabel("Delay:");
private JLabel jlDelayConstant = new JLabel("Fixed:");
private JLabel jlDelayRange = new JLabel("Range:");
private JLabel jlDelayRangeStart = new JLabel("From:");
private JLabel jlDelayRangeEnd = new JLabel("To:");
private JLabel jlDelayFile = new JLabel("File:");
private JLabel jlScreenSize = new JLabel("Screen Size:");
private JLabel jlDelayInterval = new JLabel("Interval:");
private JLabel jlColor = new JLabel("Time Out Color:");
private JLabel jlValidClick = new JLabel("Non-image clicks:");
private JLabel jlCS = new JLabel("Correct Sound:");
private JLabel jlIS = new JLabel("Incorrect Sound:");
private JLabel jlReward = new JLabel("Reward:");
private JLabel jlOP = new JLabel("Output Port:");
private JLabel jlC = new JLabel("Cursor:");
private JLabel jlCorrectProc = new JLabel("Correction Procedure:");
private JLabel jlVD = new JLabel("Valve Delay:");
private JLabel jlVT = new JLabel("Valve Time:");
private JLabel jlDB = new JLabel("Database Host:");
private JLabel jlCustom1 = new JLabel("Conceptual Set 1:");
private JLabel jlCustom2 = new JLabel("Conceptual Set 2:");
private JLabel jlCustom3 = new JLabel("Conceptual Set 3:");
private JLabel jlCustom4 = new JLabel("Conceptual Set 4:");
private JLabel jlCustom5 = new JLabel("Number of Stimuli:");
private JLabel jlCustom6 = new JLabel("Shift After:");
protected JLabel jlProgressiveDelays = new JLabel("Progressive Delays:");
private GridBagConstraints gbc;
private GridBagLayout gbl;
private final String[] programs = {"Shaping - centered", "Shaping - random location", "Matching to sample - DMS",
"Non-Matching to sample - DNMS", "Spatial - DRST", "Object - DRST",
"Progressive Ratio", "Delayed Response",
"Attention Tasks", "Conceptual Set Shifting", "Custom CSST" };
private final String[] reward = {"None", "Positive", "Negative", "Both"};
private final String[] random = {"Fixed", "Random", "From File"};
private final String[] ccst = {"Discrimination", "Full - Level 1", "Full - Level 2", "Full - Level 3", "Full - Level 4"};
private final String[] yesno = {"Yes", "No"};
private final String[] allowDisallow = {"Allowed", "Disallowed"};
private final String[] cursorChoice = {"Blank", "Default"};
private final String[] screenSize = {"1024x768", "800x600"};
private final String[] theColor = {"Black", "Blue", "Gray", "Green", "Orange", "Pink", "Yellow"};
private final String[] PR = {"Fixed Ratio 1", "Fixed Ratio 2", "Fixed Ratio 3",
"Fixed Ratio 4", "Fixed Ratio 5", "Fixed Ratio 6",
"Progressive Ratio", };
private final String[] attention = {"Training", "Simple Search Easy", "Simple Search Hard", "Cued Search"};
private final String[] OP = {"COM1", "COM2", "COM3", "COM4", "LPT1", "LPT2", "USB" };
private Dimension size = new Dimension ( 750 /*675*/, 525 );
private final String[] cardChoice = {"Standard", "Card", "Standard - One Line", "Card - One Line", "Card - Alternate Colors" };
private JLabel cardLabel = new JLabel("Mode:");
private final String[] customNumber = { "2", "3", "4", "5", "6", "7", "8", "9" };
private final String[] progressiveDelays = { "Enabled", "Disabled" };
private final String[] correctionProcedures = { "force", "off", "on" };
// Handlers
private ProgramSelectorHandler Handle;
private QuitHandler QHandle;
private ChooserHandler CHandle;
private ChooserHandler CHandle2;
private ChooserHandler CHandle3;
private ChooserHandler CHandle4;
private ChooserHandler CHandle5;
private SaveLoadHandler sHandle;
private SaveLoadHandler lHandle;
private AboutHandler about;
private ConvertHandler convert;
private Calendar c;
/** Creates new ProgramSelector */
public ProgramSelector() {
this.setIconImage( new ImageIcon(getClass().getResource("logo.jpg")).getImage());
//Setup Menu Bar
jmFile.add(jmi1);
jmFile.add(jmi2);
jmFile.addSeparator();
jmFile.add(jmi3);
jmFile.add(jmi4);
jmTools.add(jmi6);
jmHelp.add(jmi5);
jmb.add(jmFile);
jmb.add(jmTools);
jmb.add(jmHelp);
jmb.setBorderPainted( true );
//Setup Setup drop down menu boxes
chooser = new JComboBox ( programs );
chooser2 = new JComboBox ( reward );
chooser3 = new JComboBox ( random );
chooser4 = new JComboBox ( screenSize );
chooser5 = new JComboBox ( theColor );
chooser6 = new JComboBox ( allowDisallow );
chooser7 = new JComboBox ( PR );
chooser8 = new JComboBox ( attention );
chooser9 = new JComboBox ( ccst );
chooser10 = new JComboBox ( OP );
chooser11 = new JComboBox ( cursorChoice );
chooser12 = new JComboBox ( cardChoice );
chooser13 = new JComboBox ( customNumber );
chooser14 = new JComboBox ( progressiveDelays );
correctionChooser = new JComboBox ( correctionProcedures );
//Set selected indexes and initialize some text fields
chooser5.setSelectedIndex( 3 );
chooser6.setSelectedIndex( 1 );
chooser9.setSelectedIndex( 1 );
chooser11.setSelectedIndex( 1 );
chooser12.setSelectedIndex( 0 );
chooser13.setSelectedIndex( 1 );
chooser14.setSelectedIndex( 1 );
correctionChooser.setSelectedIndex(1);
startB = new JButton("Start");
exitB = new JButton ("Exit");
jtfDelayConstant.setText("1");
jtfiti.setText("1");
jtfTrials.setText("3");
jtfTimeout.setText("5");
jtfTimeAllowance.setText("30");
jtfCustom5.setText("10");
this.setTitle("Yerkes Cognitive Battery");
//Setup up for the date, this is messy because Java is weird with dates
String help = new String();
c = Calendar.getInstance();
help = help.concat("" + ( c.get( Calendar.MONTH) + 1 ) );
help = help.concat("/");
help = help.concat("" + c.get( Calendar.DATE ) );
help = help.concat("/");
help = help.concat("" + c.get( Calendar.YEAR ) );
help = help.concat(" ");
if( c.get( Calendar.HOUR ) == 0)
help = help.concat("12" );
else
help = help.concat("" + c.get( Calendar.HOUR ) );
help = help.concat(":");
if( c.get (Calendar.MINUTE ) < 10 )
help = help.concat("0");
help = help.concat("" + c.get( Calendar.MINUTE ) );
if ( c.get( Calendar.AM_PM) == 0 )
help = help.concat("AM" );
else
help = help.concat("PM" );
jtfDate.setText( help );
//Dont let these fields be editable at start
jtfDelayRangeStart.setEditable( false );
jtfDelayRangeEnd.setEditable( false );
jtfDelay.setEditable( false );
jtfDelayInterval.setEditable( false );
//Setup layout for window
gbl = new GridBagLayout();
// Create three panels with borders for components
panel1.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createLineBorder(Color.black, 1 ),
BorderFactory.createEmptyBorder(5,5,5,5)));
panel2.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createLineBorder(Color.black, 1),
BorderFactory.createEmptyBorder(5,5,5,5)));
panel4.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createLineBorder(Color.black, 1),
BorderFactory.createEmptyBorder(5,5,5,5)));
/* Program Chooser */
panel1.setLayout( gbl );
gbc = new GridBagConstraints( 0, 0, 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0);
gbl.setConstraints(chooser, gbc);
panel1.add( chooser );
/* Date */
gbc = new GridBagConstraints( 0, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jlDate, gbc);
panel1.add( jlDate );
gbc = new GridBagConstraints( 1, 1, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfDate, gbc);
panel1.add( jtfDate );
/* Monkey ID */
gbc = new GridBagConstraints( 0, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jlId, gbc);
panel1.add( jlId );
gbc = new GridBagConstraints( 1, 2, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfId, gbc);
panel1.add( jtfId );
/* tester */
gbc = new GridBagConstraints( 0, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jlTester, gbc);
panel1.add( jlTester );
gbc = new GridBagConstraints( 1, 3, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfTester, gbc);
panel1.add( jtfTester );
/* choose output */
gbc = new GridBagConstraints( 0, 4, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0);
gbl.setConstraints(jloutput, gbc);
panel1.add( jloutput );
/* Display for save location */
gbc = new GridBagConstraints( 0, 5, 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfOutputLoc, gbc);
panel1.add ( jtfOutputLoc );
/* choose button */
gbc = new GridBagConstraints( 0, 6, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(Choose, gbc);
panel1.add( Choose );
/* Image Directory */
gbc = new GridBagConstraints( 0, 7, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0);
gbl.setConstraints(jlImageDir, gbc);
panel1.add( jlImageDir );
gbc = new GridBagConstraints( 0, 8, 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfImageDir, gbc);
panel1.add( jtfImageDir );
gbc = new GridBagConstraints( 0, 9, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(Choose3, gbc);
panel1.add( Choose3 );
//Correct Sound
gbc = new GridBagConstraints( 0, 10, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 0, 0, 0), 0, 0);
gbl.setConstraints(jlCS, gbc);
panel1.add( jlCS );
gbc = new GridBagConstraints( 0, 11, 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfCS, gbc);
panel1.add( jtfCS );
gbc = new GridBagConstraints( 0, 12, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 10, 0), 0, 0);
gbl.setConstraints(Choose4, gbc);
panel1.add( Choose4 );
//Incorrect Sound
gbc = new GridBagConstraints( 0, 13, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jlIS, gbc);
panel1.add( jlIS );
gbc = new GridBagConstraints( 0, 14, 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfIS, gbc);
panel1.add( jtfIS );
gbc = new GridBagConstraints( 0, 15, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(Choose5, gbc);
panel1.add( Choose5 );
//Database Host
gbc = new GridBagConstraints( 0, 16, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jlDB, gbc);
panel1.add( jlDB );
gbc = new GridBagConstraints( 0, 17, 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtDB, gbc);
panel1.add( jtDB );
//Blank to take up extra space
gbc = new GridBagConstraints( 0, 18, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(blank1, gbc);
panel1.add( blank1 );
//Middle panel
panel2.setLayout( gbl );
//Blank space at the top
gbc = new GridBagConstraints( 0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 0, 0, 0), 0, 0);
gbl.setConstraints(blank2, gbc);
panel2.add( blank2 );
/* number of trials */
gbc = new GridBagConstraints( 0, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 10), 0, 0);
gbl.setConstraints(jlTrials, gbc);
panel2.add( jlTrials );
gbc = new GridBagConstraints( 1, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfTrials, gbc);
panel2.add( jtfTrials );
/* Time Out */
gbc = new GridBagConstraints( 0, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 10), 0, 0);
gbl.setConstraints(jltOut, gbc);
panel2.add( jltOut );
gbc = new GridBagConstraints( 1, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfTimeout, gbc);
panel2.add( jtfTimeout );
/* time allowance */
gbc = new GridBagConstraints( 0, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 10), 0, 0);
gbl.setConstraints(jltAllowance, gbc);
panel2.add( jltAllowance );
gbc = new GridBagConstraints( 1, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfTimeAllowance, gbc);
panel2.add( jtfTimeAllowance );
gbc = new GridBagConstraints( 0, 4, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 10), 0, 0);
gbl.setConstraints(jlVT, gbc);
panel2.add( jlVT );
gbc = new GridBagConstraints( 1, 4, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfVT, gbc);
panel2.add( jtfVT );
gbc = new GridBagConstraints( 0, 5, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 10), 0, 0);
gbl.setConstraints(jlVD, gbc);
panel2.add( jlVD );
gbc = new GridBagConstraints( 1, 5, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfVD, gbc);
panel2.add( jtfVD );
// Timeout Color
gbc = new GridBagConstraints( 0, 6, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 0, 0, 0), 0, 0);
gbl.setConstraints(jlColor, gbc);
panel2.add( jlColor );
gbc = new GridBagConstraints( 1, 6, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 0, 0, 0), 0, 0);
gbl.setConstraints(chooser5, gbc);
panel2.add( chooser5 );
//ITI
gbc = new GridBagConstraints( 0, 7, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0);
gbl.setConstraints(jliti, gbc);
panel2.add( jliti );
gbc = new GridBagConstraints( 1, 7, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfiti, gbc);
panel2.add( jtfiti );
/* Delay chooser */
gbc = new GridBagConstraints( 0, 8, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0);
gbl.setConstraints(jlDelay, gbc);
panel2.add( jlDelay );
gbc = new GridBagConstraints( 1, 8, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0);
gbl.setConstraints(chooser3, gbc);
panel2.add( chooser3 );
/* display input file location or the random constant */
gbc = new GridBagConstraints( 0, 9, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0);
gbl.setConstraints(jlDelayConstant, gbc);
panel2.add( jlDelayConstant );
gbc = new GridBagConstraints( 1, 9, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfDelayConstant, gbc);
panel2.add( jtfDelayConstant );
//Delay Range for random numbers
gbc = new GridBagConstraints( 0, 10, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0);
gbl.setConstraints(jlDelayRange, gbc);
panel2.add( jlDelayRange );
gbc = new GridBagConstraints( 0, 11, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
gbl.setConstraints(jlDelayRangeStart, gbc);
panel2.add( jlDelayRangeStart );
gbc = new GridBagConstraints( 1, 11, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfDelayRangeStart, gbc);
panel2.add( jtfDelayRangeStart );
gbc = new GridBagConstraints( 0, 12, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jlDelayRangeEnd, gbc);
panel2.add( jlDelayRangeEnd );
gbc = new GridBagConstraints( 1, 12, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfDelayRangeEnd, gbc);
panel2.add( jtfDelayRangeEnd );
gbc = new GridBagConstraints( 0, 13, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jlDelayInterval, gbc);
panel2.add( jlDelayInterval );
gbc = new GridBagConstraints( 1, 13, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfDelayInterval, gbc);
panel2.add( jtfDelayInterval );
// Delays from file
gbc = new GridBagConstraints( 0, 14, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0);
gbl.setConstraints(jlDelayFile, gbc);
panel2.add( jlDelayFile );
gbc = new GridBagConstraints( 0, 15, 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfDelay, gbc);
panel2.add( jtfDelay );
gbc = new GridBagConstraints( 0, 16, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(Choose2, gbc);
panel2.add( Choose2 );
//Blank to take up extra space
gbc = new GridBagConstraints( 0, 17, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(blank3, gbc);
panel2.add( blank3 );
//Panel for start and exit buttons
panel3.setLayout ( new BorderLayout() );
panel3.add( startB, BorderLayout.WEST);
panel3.add( exitB, BorderLayout.EAST);
//Right panel
panel4.setLayout ( gbl );
//Blank to take up space
gbc = new GridBagConstraints( 0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 0, 0, 0), 0, 0);
gbl.setConstraints(blank4, gbc);
panel4.add( blank4 );
//Count valid clicks?
gbc = new GridBagConstraints( 0, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 10), 0, 0);
gbl.setConstraints(jlValidClick, gbc);
panel4.add( jlValidClick );
gbc = new GridBagConstraints( 0, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
gbl.setConstraints(chooser6, gbc);
panel4.add( chooser6 );
//Reward options
gbc = new GridBagConstraints( 0, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 0, 0, 0), 0, 0);
gbl.setConstraints(jlReward, gbc);
panel4.add( jlReward );
gbc = new GridBagConstraints( 0, 4, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
gbl.setConstraints(chooser2, gbc);
panel4.add( chooser2 );
//Port for output
gbc = new GridBagConstraints( 0, 5, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 0, 0, 0), 0, 0);
gbl.setConstraints(jlOP, gbc);
panel4.add( jlOP );
gbc = new GridBagConstraints( 0, 6, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
gbl.setConstraints(chooser10, gbc);
panel4.add( chooser10 );
//Screen size
gbc = new GridBagConstraints( 0, 7, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 0, 0, 0), 0, 0);
gbl.setConstraints(jlScreenSize, gbc);
panel4.add( jlScreenSize );
gbc = new GridBagConstraints( 0, 8, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
gbl.setConstraints(chooser4, gbc);
panel4.add( chooser4 );
gbc = new GridBagConstraints( 0, 9, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 0, 0, 0), 0, 0);
gbl.setConstraints(jlC, gbc);
panel4.add( jlC );
gbc = new GridBagConstraints( 0, 10, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
gbl.setConstraints(chooser11, gbc);
panel4.add( chooser11 );
//Program specific options
// These are all on top of each other, but only one set will be visable at a time
gbc = new GridBagConstraints( 0, 11, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 0, 0, 0), 0, 0);
gbl.setConstraints(jlVersion, gbc);
panel4.add( jlVersion );
gbc = new GridBagConstraints( 0, 12, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(chooser7, gbc);
panel4.add( chooser7 );
gbc = new GridBagConstraints( 0, 12, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(chooser8, gbc);
panel4.add( chooser8 );
gbc = new GridBagConstraints( 0, 12, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(chooser9, gbc);
panel4.add( chooser9 );
gbc = new GridBagConstraints( 0, 13, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 0, 0, 0), 0, 0);
gbl.setConstraints(cardLabel, gbc);
panel4.add( cardLabel );
gbc = new GridBagConstraints( 0, 14, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(chooser12, gbc);
panel4.add( chooser12 );
//correction procedure panel
gbc = new GridBagConstraints( 0, 13, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 0, 0, 0), 0, 0);
gbl.setConstraints(jlCorrectProc, gbc);
panel4.add( jlCorrectProc );
gbc = new GridBagConstraints( 0, 14, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(correctionChooser, gbc);
panel4.add( correctionChooser );
gbc = new GridBagConstraints( 0, 11, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 0, 0, 0), 0, 0);
gbl.setConstraints(jlProgressiveDelays, gbc);
panel4.add( jlProgressiveDelays );
gbc = new GridBagConstraints( 0, 12, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(chooser14, gbc);
panel4.add( chooser14 );
//Specific to Custom CSST, there's a lot of it
gbc = new GridBagConstraints( 0, 11, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jlCustom1, gbc);
panel4.add( jlCustom1 );
gbc = new GridBagConstraints( 1, 11, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfCustom1, gbc);
panel4.add( jtfCustom1 );
gbc = new GridBagConstraints( 0, 12, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jlCustom2, gbc);
panel4.add( jlCustom2 );
gbc = new GridBagConstraints( 1, 12, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfCustom2, gbc);
panel4.add( jtfCustom2 );
gbc = new GridBagConstraints( 0, 13, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jlCustom3, gbc);
panel4.add( jlCustom3 );
gbc = new GridBagConstraints( 1, 13, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfCustom3, gbc);
panel4.add( jtfCustom3 );
gbc = new GridBagConstraints( 0, 14, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jlCustom4, gbc);
panel4.add( jlCustom4 );
gbc = new GridBagConstraints( 1, 14, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfCustom4, gbc);
panel4.add( jtfCustom4 );
gbc = new GridBagConstraints( 0, 15, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jlCustom5, gbc);
panel4.add( jlCustom5 );
gbc = new GridBagConstraints( 1, 15, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(chooser13, gbc);
panel4.add( chooser13 );
gbc = new GridBagConstraints( 0, 16, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jlCustom6, gbc);
panel4.add( jlCustom6 );
gbc = new GridBagConstraints( 1, 16, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(jtfCustom5, gbc);
panel4.add( jtfCustom5 );
//Blank to take up space
gbc = new GridBagConstraints( 0, 17, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0);
gbl.setConstraints(blank6, gbc);
panel4.add( blank6 );
// Set all program specific stuff non-visible
jlVersion.setVisible(false);
chooser7.setVisible(false);
chooser8.setVisible(false);
chooser9.setVisible(false);
cardLabel.setVisible(false);
chooser12.setVisible(false);
correctionChooser.setVisible(false);
jlCustom1.setVisible(false);
jtfCustom1.setVisible(false);
jlCustom2.setVisible(false);
jtfCustom2.setVisible(false);
jlCustom3.setVisible(false);
jtfCustom3.setVisible(false);
jlCustom4.setVisible(false);
jtfCustom4.setVisible(false);
jlCustom5.setVisible(false);
chooser13.setVisible(false);
jlCustom6.setVisible(false);
jtfCustom5.setVisible(false);
jlProgressiveDelays.setVisible(false);
chooser14.setVisible(false);
jlCorrectProc.setVisible(false);
//Put all panels into main window
Container content = this.getContentPane();
content.setLayout ( gbl );
gbc = new GridBagConstraints( 0, 0, 1, 1, 0.2, 0.2, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0);
gbl.setConstraints(panel1, gbc);
gbc = new GridBagConstraints( 1, 0, 1, 1, 0.2, 0.2, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0);
gbl.setConstraints(panel2, gbc);
gbc = new GridBagConstraints( 2, 0, 1, 1, 0.2, 0.2, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0);
gbl.setConstraints(panel4, gbc);
gbc = new GridBagConstraints( 0, 1, 3, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0);
gbl.setConstraints(panel3, gbc);
this.getRootPane().setJMenuBar( jmb );
content.add( panel1 );
content.add( panel2 );
content.add( panel3 );
content.add( panel4 );
//Set size and location of window
this.setSize( size );
this.setLocation( 100, 100 );
//Handler to use when start is pressed
Handle = new ProgramSelectorHandler( this );
//Handlers to load and save settings
sHandle = new SaveLoadHandler( 0, this);
lHandle = new SaveLoadHandler( 1, this);
// Add handlers
about = new AboutHandler( this );
convert = new ConvertHandler( this );
QHandle = new QuitHandler( );
startB.addActionListener( Handle );
exitB.addActionListener( QHandle );
jmi6.addActionListener( convert );
jmi5.addActionListener( about );
jmi4.addActionListener( QHandle);
jmi3.addActionListener( Handle );
jmi2.addActionListener( lHandle );
jmi1.addActionListener( sHandle );
//Handlers for buttons
CHandle = new ChooserHandler ( this, jtfOutputLoc, 0 );
CHandle2 = new ChooserHandler ( this, jtfDelay, 0 );
CHandle3 = new ChooserHandler ( this, jtfImageDir, 1);
CHandle4 = new ChooserHandler ( this, jtfCS, 0 );
CHandle5 = new ChooserHandler ( this, jtfIS, 0 );
//Handlers for combo boxes
Choose.addActionListener( CHandle );
Choose2.addActionListener( CHandle2 );
Choose3.addActionListener( CHandle3 );
Choose4.addActionListener( CHandle4 );
Choose5.addActionListener( CHandle5 );
chooser3.addActionListener( this );
chooser.addActionListener( this );
//Add handler to keep window from getting to small
this.addComponentListener(new ResizeHandler(this, size.width, size.height));
//Make window visable
this.pack();
this.setVisible(true);
}
//If program change hide/show extra program specific options
public void actionPerformed( ActionEvent e) {
if ( chooser3.getSelectedIndex() == 0 )
//Shaping - centered
{
jtfDelay.setEditable( false );
jtfDelayRangeStart.setEditable( false );
jtfDelayRangeEnd.setEditable( false );
jtfDelayConstant.setEditable( true );
jtfDelayInterval.setEditable( false );
cardLabel.setVisible(false);
chooser12.setVisible(false);
jlCustom1.setVisible(false);
jtfCustom1.setVisible(false);
jlCustom2.setVisible(false);
jtfCustom2.setVisible(false);
jlCustom3.setVisible(false);
jtfCustom3.setVisible(false);
jlCustom4.setVisible(false);
jtfCustom4.setVisible(false);
jlCustom5.setVisible(false);
chooser13.setVisible(false);
jlCustom6.setVisible(false);
jtfCustom5.setVisible(false);
jlProgressiveDelays.setVisible(false);
chooser14.setVisible(false);
jlCorrectProc.setVisible(false);
correctionChooser.setVisible(false);
}
else if ( chooser3.getSelectedIndex() == 1 )
//Shaping - random location
{
jtfDelay.setEditable( false );
jtfDelayRangeStart.setEditable( true );
jtfDelayRangeEnd.setEditable( true );
jtfDelayConstant.setEditable( false );
jtfDelayInterval.setEditable( true );
cardLabel.setVisible(false);
chooser12.setVisible(false);
jlCustom1.setVisible(false);
jtfCustom1.setVisible(false);
jlCustom2.setVisible(false);
jtfCustom2.setVisible(false);
jlCustom3.setVisible(false);
jtfCustom3.setVisible(false);
jlCustom4.setVisible(false);
jtfCustom4.setVisible(false);
jlCustom5.setVisible(false);
chooser13.setVisible(false);
jlCustom6.setVisible(false);
jtfCustom5.setVisible(false);
jlProgressiveDelays.setVisible(false);
chooser14.setVisible(false);
jlCorrectProc.setVisible(false);
correctionChooser.setVisible(false);
}
else
//DRST
{
jtfDelay.setEditable( true );
jtfDelayRangeStart.setEditable( false );
jtfDelayRangeEnd.setEditable( false );
jtfDelayConstant.setEditable( false );
jtfDelayInterval.setEditable( false );
cardLabel.setVisible(false);
chooser12.setVisible(false);
jlCustom1.setVisible(false);
jtfCustom1.setVisible(false);
jlCustom2.setVisible(false);
jtfCustom2.setVisible(false);
jlCustom3.setVisible(false);
jtfCustom3.setVisible(false);
jlCustom4.setVisible(false);
jtfCustom4.setVisible(false);
jlCustom5.setVisible(false);
chooser13.setVisible(false);
jlCustom6.setVisible(false);
jtfCustom5.setVisible(false);
jlCorrectProc.setVisible(false);
correctionChooser.setVisible(false);
}
if ( (chooser.getSelectedIndex() == 2) || (chooser.getSelectedIndex() == 3) ) { //DMS and DNMS
jlVersion.setVisible(false);
chooser7.setVisible(false);
chooser8.setVisible(false);
chooser9.setVisible(false);
cardLabel.setVisible(false);
chooser12.setVisible(false);
jlCustom1.setVisible(false);
jtfCustom1.setVisible(false);
jlCustom2.setVisible(false);
jtfCustom2.setVisible(false);
jlCustom3.setVisible(false);
jtfCustom3.setVisible(false);
jlCustom4.setVisible(false);
jtfCustom4.setVisible(false);
jlCustom5.setVisible(false);
chooser13.setVisible(false);
jlCustom6.setVisible(false);
jtfCustom5.setVisible(false);
jlProgressiveDelays.setVisible(true);
chooser14.setVisible(true);
jlCorrectProc.setVisible(true);
correctionChooser.setVisible(true);
}
else if ( chooser.getSelectedIndex() == 6 )
{
//Progressive Ratio
chooser8.setVisible(false);
jlVersion.setVisible(true);
chooser7.setVisible(true);
cardLabel.setVisible(false);
chooser12.setVisible(false);
jlCustom1.setVisible(false);
jtfCustom1.setVisible(false);
jlCustom2.setVisible(false);
jtfCustom2.setVisible(false);
jlCustom3.setVisible(false);
jtfCustom3.setVisible(false);
jlCustom4.setVisible(false);
jtfCustom4.setVisible(false);
jlCustom5.setVisible(false);
chooser13.setVisible(false);
jlCustom6.setVisible(false);
jtfCustom5.setVisible(false);
jlProgressiveDelays.setVisible(false);
chooser14.setVisible(false);
jlCorrectProc.setVisible(false);
correctionChooser.setVisible(false);
}
else if ( chooser.getSelectedIndex() == 7 )
//Delayed Response
{
jlVersion.setVisible(false);
chooser7.setVisible(false);
chooser8.setVisible(false);
chooser9.setVisible(false);
cardLabel.setVisible(false);
chooser12.setVisible(false);
jlCustom1.setVisible(false);
jtfCustom1.setVisible(false);
jlCustom2.setVisible(false);
jtfCustom2.setVisible(false);
jlCustom3.setVisible(false);
jtfCustom3.setVisible(false);
jlCustom4.setVisible(false);
jtfCustom4.setVisible(false);
jlCustom5.setVisible(false);
chooser13.setVisible(false);
jlCustom6.setVisible(false);
jtfCustom5.setVisible(false);
jlProgressiveDelays.setVisible(true);
chooser14.setVisible(true);
jlCorrectProc.setVisible(true);
correctionChooser.setVisible(true);
}
else if ( chooser.getSelectedIndex() == 8 )
//Attention tasks
{
chooser7.setVisible(false);
chooser9.setVisible(false);
jlVersion.setVisible(true);
chooser8.setVisible(true);
cardLabel.setVisible(false);
chooser12.setVisible(false);
jlCustom1.setVisible(false);
jtfCustom1.setVisible(false);
jlCustom2.setVisible(false);
jtfCustom2.setVisible(false);
jlCustom3.setVisible(false);
jtfCustom3.setVisible(false);
jlCustom4.setVisible(false);
jtfCustom4.setVisible(false);
jlCustom5.setVisible(false);
chooser13.setVisible(false);
jlCustom6.setVisible(false);
jtfCustom5.setVisible(false);
jlProgressiveDelays.setVisible(false);
chooser14.setVisible(false);
jlCorrectProc.setVisible(false);
correctionChooser.setVisible(false);
}
else if ( chooser.getSelectedIndex() == 9 )
//Conceptual Set Shifting
{
chooser7.setVisible(false);
chooser8.setVisible(false);
chooser9.setVisible(true);
jlVersion.setVisible(true);
cardLabel.setVisible(true);
chooser12.setVisible(true);
jlCustom1.setVisible(false);
jtfCustom1.setVisible(false);
jlCustom2.setVisible(false);
jtfCustom2.setVisible(false);
jlCustom3.setVisible(false);
jtfCustom3.setVisible(false);
jlCustom4.setVisible(false);
jtfCustom4.setVisible(false);
jlCustom5.setVisible(false);
chooser13.setVisible(false);
jlCustom6.setVisible(false);
jtfCustom5.setVisible(false);
jlProgressiveDelays.setVisible(false);
chooser14.setVisible(false);
jlCorrectProc.setVisible(false);
correctionChooser.setVisible(false);
}
else if (chooser.getSelectedIndex() == 10 )
//Custom CSST
{
jlVersion.setVisible(false);
chooser7.setVisible(false);
chooser8.setVisible(false);
chooser9.setVisible(false);
cardLabel.setVisible(false);
chooser12.setVisible(false);
jlCustom1.setVisible(true);
jtfCustom1.setVisible(true);
jlCustom2.setVisible(true);
jtfCustom2.setVisible(true);
jlCustom3.setVisible(true);
jtfCustom3.setVisible(true);
jlCustom4.setVisible(true);
jtfCustom4.setVisible(true);
jlCustom5.setVisible(true);
chooser13.setVisible(true);
jlCustom6.setVisible(true);
jtfCustom5.setVisible(true);
jlProgressiveDelays.setVisible(false);
chooser14.setVisible(false);
jlCorrectProc.setVisible(false);
correctionChooser.setVisible(false);
}
else
//Nothing picked?
{
jlVersion.setVisible(false);
chooser7.setVisible(false);
chooser8.setVisible(false);
chooser9.setVisible(false);
cardLabel.setVisible(false);
chooser12.setVisible(false);
jlCustom1.setVisible(false);
jtfCustom1.setVisible(false);
jlCustom2.setVisible(false);
jtfCustom2.setVisible(false);
jlCustom3.setVisible(false);
jtfCustom3.setVisible(false);
jlCustom4.setVisible(false);
jtfCustom4.setVisible(false);
jlCustom5.setVisible(false);
chooser13.setVisible(false);
jlCustom6.setVisible(false);
jtfCustom5.setVisible(false);
jlProgressiveDelays.setVisible(false);
chooser14.setVisible(false);
jlCorrectProc.setVisible(false);
correctionChooser.setVisible(false);
}
}
}