/** HCITest
 *	@author: <a href="mailto:gsafko@mail.camdencc.edu">Gregory Safko</a>
 *	@version 1.0 Fall 2004
 *	Date: November, 2004
 *  Nova Southeastern University
 *  Course DISS 720: Human Computer Interaction
 *	Instructor: Maxine Cohen, PhD
 *	Purpose: A drive class used to test modified GUI 
 *  controls and their interaction and proficiency 
 *  among subjects with Musical Intelligence and those 
 *  without Musical Intelligence
 *  (Base on H. Gardner's Seven Intelligences)
 */

// Java core packages
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;

// Java extension packages
import javax.swing.*;

public class HCITest
{
	private static int pageNum = 6;
	private static final int MAXTIMES = 10;
	public static void main( String args[] )
   	{
    	String filename;
    	int startTime, endTime;
      	int compass;
      	int objNum;
      	Container ctr[], ctr1;
      	ButtonGroup bgroup[];
      	JFrame frame[];
		ctr = new Container[MAXTIMES];
      	frame = new JFrame[MAXTIMES];
      	bgroup = new ButtonGroup[MAXTIMES];  		  		
  		// call the Tutorial OptionPanes next...
  		tutor1();
  		tutor2();
  		tutor3();
  		tutor4();
  		tutor5();
  		filename = tutor6();
     	
  		
      	for(int i = 0; i < MAXTIMES; i++)
      	{
      		frame[i] = new JFrame("HCI Test: " + (MAXTIMES - i) + " of 10");
      		ctr[i] = new Container();
      		bgroup[i] = new ButtonGroup();
      		ctr[i].setLayout(new BorderLayout());
           	compass = (int) (Math.random() * 5);
           	objNum = (int) (Math.random() * 3);
           	
           	if( objNum == 0 ) // populate with a slider
      		{
				if(compass == 0)
      				ctr[i].add(new ModifiedSlider(filename + "sl.txt"), BorderLayout.NORTH);
				if(compass == 1)
      				ctr[i].add(new ModifiedSlider(filename + "sl.txt"), BorderLayout.SOUTH);      	
      			if(compass == 2)
      				ctr[i].add(new ModifiedSlider(filename + "sl.txt"), BorderLayout.EAST);
      			if(compass == 3)
      				ctr[i].add(new ModifiedSlider(filename + "sl.txt"), BorderLayout.WEST);
				if(compass == 4)
      				ctr[i].add(new ModifiedSlider(filename + "sl.txt"), BorderLayout.CENTER);
      		}
      		if( objNum == 1 ) // populate with a checkbox
			{
      		 	compass = (int) (Math.random() * 5);
      		 	for(int j = 0; j < 3; j++)
      		 	{
      		 		if(compass == 0)
      					ctr[i].add(new ModifiedCheckBox(filename + "cb.txt", "Check Box"), BorderLayout.NORTH);
					if(compass == 1)
      					ctr[i].add(new ModifiedCheckBox(filename + "cb.txt", "Check Box"), BorderLayout.SOUTH);      	
      				if(compass == 2)
      					ctr[i].add(new ModifiedCheckBox(filename + "cb.txt", "Check Box"), BorderLayout.EAST);
      				if(compass == 3)
      					ctr[i].add(new ModifiedCheckBox(filename + "cb.txt", "Check Box"), BorderLayout.WEST);
					if(compass == 4)
      					ctr[i].add(new ModifiedCheckBox(filename + "cb.txt", "Check Box"), BorderLayout.CENTER);
      				compass++;
      				if(compass > 4)
      					compass = 0;
      			}
			}
      		 
      		if( objNum == 2 ) // populate with radio buttons
      		{
      			compass = (int) (Math.random() * 5);
				for(int k = 0; k < 3; k++)
      		 	{
      		 		ModifiedRadioButton mrb = new ModifiedRadioButton(filename + "rb.txt", "Option Button "+ k);
      		 		bgroup[i].add(mrb);
      		 		if(compass == 0)
      					ctr[i].add(mrb, BorderLayout.NORTH);
					if(compass == 1)
      					ctr[i].add(mrb, BorderLayout.SOUTH);      	
      				if(compass == 2)
      					ctr[i].add(mrb, BorderLayout.EAST);
      				if(compass == 3)
      					ctr[i].add(mrb, BorderLayout.WEST);
					if(compass == 4)
      					ctr[i].add(mrb, BorderLayout.CENTER);
      				compass++;
      				if(compass > 4)
      					compass = 0;
      			}	
      		}
      		
      		frame[i].add(ctr[i]);
      		frame[i].setSize(350,350);	
      		frame[i].setVisible(true);
      		frame[i].setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);     	
      	}

	     
	}

	static void tutor1()
	{
		JOptionPane jop1 = new JOptionPane();
		jop1.setSize(220,220);
		jop1.showMessageDialog(null, 
      	"Welcome to the HCI GUI Proficiency Tester. \nThis program will " +
      	"test how skilled you are at selecting \ncontrol objects "+
      	"(Check boxes, Radio Buttons, and Sliders)" +
      	"\nYou will be given a random display of these controls."+
      	"\nYour job is to select them, and make them disappear" +
      	"\n or changes colors " ,
      	"Prototype - Page 1 of " + pageNum,
      	JOptionPane.PLAIN_MESSAGE); 
	}   
	
	static void tutor2()
	{
		JOptionPane jop2 = new JOptionPane();
		jop2.setSize(220,220);
		jop2.showMessageDialog(null, 
      	"To test a slider, move it to the extremes (max and min)."+
      	"\nTo test a check box, just select it...", 
      	"Prototype - Page 2 of " + pageNum,
      	JOptionPane.PLAIN_MESSAGE);     	      	
	}
	
	static void tutor3()
	{
		JOptionPane.showMessageDialog(null, 
      	"To test a series of check boxes, you must toggle them"+
      	"\nthree times...", 
      	"Prototype - Page 3 of " + pageNum,
      	JOptionPane.PLAIN_MESSAGE);	
	}
	
	static void tutor4()
	{
		JOptionPane.showMessageDialog(null, 
      	"To test a series of radio buttons, you must toggle them"+
      	"\nso their colors change from red to black...", 
      	"Prototype - Page 4 of " + pageNum,
      	JOptionPane.PLAIN_MESSAGE);
	}	
		
    static void tutor5()
	{
		JOptionPane.showMessageDialog(null, 
      	"When you finish each frame, just click the 'X' in the "+
      	"\nupper right hand corner. The time it takes to close the " +
      	"\nframes will not be recorded; only the time you work with " +
      	"\nthe controls will be recorded...", 
      	"Prototype - Page 5 of " + pageNum,
      	JOptionPane.PLAIN_MESSAGE);
	}	
    static String tutor6()
    {
    	return JOptionPane.showInputDialog(null, 
      	"Now you're ready to begin.\nPlease enter your initials (without spaces):",
      	"Prototype - Page 6 of " + pageNum,
      	JOptionPane.PLAIN_MESSAGE);
    }  	
      	
   	
}  // end class HCITest 


