G7S Class Monitor
header with G7S emblem
Left End RoundButton Fill - Center Slice 25x25Buttom Right Normal - Left CropHomeScience LinksClassworkScience TopicsScience SimulationClass ClipsButton Fill - Right Normal - Left CropButton Fill - Center Slice 25x25Button - Right Round End
Java code:
-  Program in work: Only rotating perspective for atoms, not any other objects.  -

import java.applet.Applet;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.imageio.ImageIO;

import java.net.URL;
import java.net.UnknownHostException;

// Needed for Database code
import java.util.*;
import java.sql.*;

//import org.apache.derby.drda.NetworkServerControl;
import java.net.InetAddress;

//public class AuthClientDBTest8 extends java.applet.Applet implements Runnable {
//public class AuthClientDBTestMySQL10 extends Applet implements Runnable { // FROM OutputApplet.java
//==============================================================================
// This program is from C:\javaDev\AuClDBTestMySQL10\src\AuthClientDBTestMySQL10.java
// I am taking out the Database code just so I can demo it online.
//==============================================================================
public class TeacherMonitorWithoutDB extends Applet implements Runnable {
//    private Thread animator; // FROM OutputApplet.java

   public Thread animator;
//    Thread animator;
   //#### BELOW: Debug stuff
   String setErrorMessage = "bbbbbbbbbb";
   String SQLExcMessage = "bbbbbbb";
   String InterruptedExceptionMessage = "bbbbbbbbbbbbbbbbbbb";
   String[] message2 = {"b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b"};
   int numMessage = 15;
   int numPaint = 0;
   int numPaintNulls = 0;
   boolean justonce = true;
   String propUser;
   String propPassword;
   String uzr;
   String pswd;
   String uzrS;
   String pswdS;
   //#### ABOVE: Debug stuff
   int frame;
   int frame2;
   double delayMS; //The number of milliseconds between frames
   long delayNS; //The number of nanoseconds between frames
   Dimension offDimension;
   Image offImage;
   Graphics offGraphics;
   int appletWidth = 1120;
   int appletHeight = 680;
//    int appletWidth = 730;
//    int appletHeight = 400;
   Color myPurple = new Color(128, 0, 128);
   Color BGColor = new Color(166, 193, 221);
//    Color BGColor = new Color(220,220,220);
//    Color BGColor = new Color(200,200,200);
   Color LiteBGColor = new Color(203, 219, 235);
   Color orangeColor = new Color(240, 150, 70);
   Color glassCubeColor = new Color(154, 171, 192);
   Color windowBorder = new Color(110, 155, 200);
   long initNumCalls = 0;
   long startNumCalls = 0;
   long runNumCalls = 0;
   long stopNumCalls = 0;
   long updateNumCalls = 0;
   long paintNumCalls = 0;
   long paintFrameNumCalls = 0;
   long setErrorNumCalls = 0;
   long setResultsNumCalls = 0;
//    Font font = new Font("serif", Font.PLAIN, 50);
//    font = new Font("sanserif", Font.BOLD | Font.ITALIC, 20);
//     font = new Font("serif", Font.BOLD, 20);
//    Font fx = new Font("serif", Font.BOLD, 30).deriveFont(fontAT);
//     font = new Font("serif", Font.BOLD | Font.ITALIC, 30);
//     font = new Font("dialog", Font.PLAIN, 20);
//    Font font = new Font("dialog", Font.PLAIN, 40);
   //#############################     DATABASE BELOW    ####################################
//    private Thread worker;
   private Vector queryResults;
//    Vector results = new Vector();
//    private Vector results = new Vector();
//    private Vector results;
   Vector results = new Vector();
   private String message = "Initializing";
   int x;
   int y;
//	int xm;
//	int ym;
//--   int firstLightX = 250;
//--   int firstLightY = 93;
   int firstLightX = 247;
   int firstLightY = 90;
   int numOfQues = 32;
   int numOfStu = 22;
   int lightWidth = 20;
   int lightHeight = 18;
   int rowHeight = 23;
   int nameX = 18;
   int tenLightsGap = 10;
   int BALlightShiftX;
   int bX;
   int bY;
   int BALwidth = 500;
   int BALheight = 531;
   int qAveXPos = 0;
   int qAveYPos = 0;
   int[] currxm = new int[30];
   int lightShiftX = 0;
   int[][] qScore = new int[30][41];
//   int[][] qScoreDB = new int[30][41];
   double stuSum = 0.0;
   double quesSum = 0.0;
   double scoreVal;
   double[] stuAverage = new double[51];
   int[] numStuWithAns = new int[100];
   double[] questionAvg = new double[100];
//    double angleInDeg = 90.0;
   double halfPI = 1.5707963;//Math.PI * angleInDeg/180.0;
   double ClassAvg;
   int[] currentQuestion = {-5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5};
//	int[] timeNextAnswer = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
//	int[] timeNextAnswer = {0,15,7,15,16,12,14,12,7,6,30,6,14,8,15,13,13,9,6,3,11,13,6,20,14,20,7,16,14,12,30};
   int[] timeNextAnswer = {0, 12, 5, 7, 15, 6, 16, 4, 12, 7, 10, 40, 6, 3, 8, 5, 13, 5, 9, 6, 1, 17, 4, 2, 25, 20, 3, 7, 24, 12, 30};
//	int[] timeNextAnswer = {0,200,200,200,200,200,200,200,200,200,200
//			,200,200,200,200,200,200,200,200,200,200
//			,200,200,200,200,200,200,200,200,200,200};
   int[] nextAnswer = new int[30];
   boolean initCurQuest = true;
   boolean draw10line = false;
   boolean draw20line = false;
   boolean draw30line = false;
   int rowNum;
   String studentName;
   int ii = 0;
   int[] nextA = new int[20];
   String qS;
   Random rand = new Random();
   int rnumStudentRetries = 0;
   String questionName;
   int timerShutDown = 0;
   BufferedImage redLight;// = null;
   BufferedImage greenLight = null;
   BufferedImage blueLight = null;
   BufferedImage yellowLight = null;
   BufferedImage purpleLight = null;
   BufferedImage orangeLight = null;
   BufferedImage offLight = null;
   BufferedImage light = null;
   BufferedImage blueGradientBG = null;
   BufferedImage blueGradientBGflip = null;
   BufferedImage blueGradientInset = null;
   String[] qHeader = {"Q01", "Q02", "Q03", "Q04", "Q05", "Q06", "Q07", "Q08", "Q09", "Q10",
      "Q11", "Q12", "Q13", "Q14", "Q15", "Q16", "Q17", "Q18", "Q19", "Q20",
      "Q21", "Q22", "Q23", "Q24", "Q25", "Q26", "Q27", "Q28", "Q29", "Q30",
      "Q31", "Q32", "Q33", "Q34", "Q35", "Q36", "Q37", "Q38", "Q39", "Q40",
      "Q41", "Q42", "Q43", "Q44", "Q45", "Q46", "Q47", "Q48", "Q49", "Q50"};
//{7,7,5,5,5,3,2,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
//{8,8,8,8,8,3,1,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
//{9,9,9,9,9,9,3,1,3,0,5,3,2,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
//{5,4,3,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
//{3,4,3,4,1,3,2,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
//{3,2,4,1,4,3,1,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
//{1,3,2,4,3,2,3,1,3,0,5,3,2,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
//{4,3,4,2,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
   String[] lastName = {
      "wells", "Smith", "Wilson", "Kraft", "Brown", "Abar", "Bender", "Donalds", "Thomas", "Brown", "Rivers", "Edwards", "Santiago", "Taylor", "Buying", "Apple", "Righter", "Smith", "Dinber", "Gardner", "Holland", "Harris", "Karry", "Richards", "Walsh"};
   String[] firstName = {
      "billy", "Jim", "David", "Mike", "Carl", "Chrissy", "Jason", "Danny", "Ricky", "Trip", "Anne", "Jason", "Steven", "Charles", "Tashma", "Cory", "Alexys", "Jessi", "Katelyn", "Eddy", "Chris", "Kalyn", "Steven", "Erin", "Johnny"
   };
   // This is a [24]x[50] array.
   int[][] questAns = {
      {3, 4, 3, 4, 4, 3, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
      {3, 2, 4, 4, 4, 3, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
      {1, 3, 2, 4, 3, 2, 3, 4, 3, 4, 5, 3, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
      {4, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
      {2, 3, 4, 4, 4, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
      {4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 0, 0, 0, 0},
      {3, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
      {4, 4, 4, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};

   //#############################     DATABASE ABOVE    ####################################
   /**
    * Initialize the applet and compute the delay between frames.
    */
   public void init() {
      initNumCalls = initNumCalls + 1;
      message2[2] = "Entered init()";
//
//      for (int i = 0; i < qScoreDB.length - 1; i++) {
//         for (int j = 0; j < qScoreDB[0].length - 1; j++) {
//            if (qScoreDB[i][j] == 0) {
//               qScoreDB[i][j] = -5;
//            }
//         }
//      }
      for (int i = 0; i < qScoreDB.length - 1; i++) {
         for (int j = 0; j < qScoreDB[0].length - 1; j++) {
            System.out.print(", " + qScoreDB[i][j]);
         }
         System.out.println(" ");
      }

//
//    setSize(new Dimension(appletWidth, appletHeight));
      setSize(appletWidth, appletHeight);
      setBackground(BGColor);  // Original

      //---- Read in "Score Light" images ----------------------------------------------
      try {
         message2[2] = "Entered init()'s try";

//########### BELOW: This allow the images to be found when in a JAR file!!!! ########################################
         URL url1 = Thread.currentThread().getContextClassLoader().getResource("Graphics/RedSL-NoBrd20x20.png");
         redLight = ImageIO.read(url1);
         URL url2 = Thread.currentThread().getContextClassLoader().getResource("Graphics/GreenSL-NoBrd20x20.png");
         greenLight = ImageIO.read(url2);
         URL url4 = Thread.currentThread().getContextClassLoader().getResource("Graphics/YellowSL-NoBrd20x20.png");
         yellowLight = ImageIO.read(url4);
         URL url5 = Thread.currentThread().getContextClassLoader().getResource("Graphics/OFFlighter3SL-NoBrd20x20.png");
         offLight = ImageIO.read(url5);

         message2[2] = "End of init()'s try";

      } catch (IOException e) {
         System.out.println("Can't Read LIGHT png files");
      }

      String str = getParameter("fps");
      int fps = (str != null) ? Integer.parseInt(str) : 10;
      delayMS = 1000.0;  //(fps > 0) ? (200 / fps) : 100;
      // delayMS is the number of milliseconds between frames (ie calls to
      delayNS = (int) (delayMS * 1000000.0);
      setBackground(BGColor);  // Original
   } // END of public void init()

   /**
    * This method is called when the applet becomes visible on the screen. Create a thread and start it.
    */
   public void start() {
      startNumCalls = startNumCalls + 1;
      message2[2] = "Entered start()";

//    System.out.println("      start called = " + startNumCalls);

//    //########## BELOW: Original
//	animator = new Thread(this);
//	animator.start();
//    //########## ABOVE: Original

      //########## BELOW: New - FROM OutputApplet.java
      // Every time "start" is called we create a animator thread to
      // re-evaluate the database query.
      // ALSO, when the thread animator invokes the method start , the run method is
      // called automatically, and it executes the JDBC code in the thread animator.
      if (animator == null) {
         animator = new Thread(this);
         animator.start();
      } else {
      }
      //########## ABOVE: New - FROM OutputApplet.java

//###################    DATABASE BELOW    ###################################
////    public synchronized void start() {
//    	// Every time "start" is called we create a worker thread to
//    	// re-evaluate the database query.
//    	if (worker == null) {
//    	    message = "Connecting to database";
//            worker = new Thread(this);
//    	    worker.start();
//    	}
//###################    DATABASE ABOVE    ###################################
      message2[2] = "End of start()";

   } // END of public void start()

   /**
    * This method is called by the thread that was created in the start method. It does the main animation.
    */
   public void run() {
      runNumCalls = runNumCalls + 1;
      message2[2] = "Entered run()";
//    System.out.println("        run called = " + runNumCalls);


      message2[3] = "BEFORE try #2";

//--		try {
//			message2[4] = "Entered run()'s try #2";
//-- moved up      Vector results = new Vector();
//	    final Vector results = new Vector();
//	    ArrayList results = new ArrayList();

//			Statement stmt2 = null;
//			ResultSet rs2 = null;
//			Connection con2 = null;
//------------------------------------------------------------------------------
//------ Reset the database using this [24]x[50] array.
//------------------------------------------------------------------------------

      for (int r = 0; r < 22; r++) { // record #
         for (int q = 0; q < 50; q++) { // question #
//		System.out.println(" r=" + r + " q=" + q + "  qHeader[q] = " + qHeader[q]);
//					rs2.absolute(r+1);
//					rs2.updateInt(qHeader[q], questAns[r][q]);
//					rs2.updateRow();
         }
      }
      //----- Get Students' Name and Scores from Database -------------------------
      setFont(new Font("serif", Font.BOLD, 17));
      for (int stRec = 1; stRec <= numOfStu; stRec++) { //  Number of Students
//				rs2.absolute(stRec); // Move to Database RECORD ----------------------------
//--         String last = "Wells" + "                        ";//--rs2.getString("LAST_NAME") + ",                    ";
//--         String first = "Billy" + "                        ";//--rs2.getString("FIRST_NAME") + "                     ";
         String last = lastName[stRec] + "                        ";//--rs2.getString("LAST_NAME") + ",                    ";
         String first = firstName[stRec] + "                        ";//--rs2.getString("FIRST_NAME") + "                     ";
         last = last.substring(0, 13);
         first = first.substring(0, 13);
         String name = last + first;
         //----- Fill qScore array with student scores from database
         for (int questionNum = 1; questionNum <= 40; questionNum++) { // Number of Quiz Questions
            if (questionNum <= 9) {
               questionName = "Q0" + questionNum;
            } else {
               questionName = "Q" + questionNum;
            }
//--            qScore[stRec][questionNum] = 643;//rs2.getInt(questionName);
            qScore[stRec][questionNum] = qScoreDB[stRec][questionNum];//rs2.getInt(questionName);
         }
         //----- Add student names to "results" to display on "class monitor" window
         studentName = " " + name + " :";
         results.addElement(studentName);
      }
      setResults(results);

//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
//---------------- SCHEDULAR ----------------------------------------------
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
      long tn = System.nanoTime(); //tn is time in nanoseconds
      while (Thread.currentThread() == animator) {
         repaint(); // repaint()is supposed to be SLOW!!!!==============
         SimulatedClass();
         updateStudentValues();
         try {
//#########################################################################################
//#########################################################################################
//#########################################################################################
//#########################################################################################

            //----- Scheduler ---------------------------------------
            tn += delayNS; // delay is the number of nanoseconds between frames
            Thread.sleep(Math.max(0, (tn - System.nanoTime()) / 1000000));// sleep's argument requires milliseconds!!
            frame++;
//-------------------------------------------
//            	stmt2.close();
//            	con2.close();
         } catch (InterruptedException e) {
            InterruptedExceptionMessage = "BBBBBB = " + e; // DEBUG

            break;
         }
      } // END of while
//-------------------------------------------------------------------------

//    	stmt2.close();
//    	con2.close();
//    	setResults(results);

//--		} catch (SQLException ex) {
//--			SQLExcMessage = "BBBBBB = " + ex;
//--			setError("SQLException: " + ex);
//--			System.out.println("SQLException: " + ex);
//--		}

   } // END of public void run()

   /**
    * This method is called when the applet is no longer visible. Set the animator
    * variable to null so that the thread will exit before displaying the next frame.
    */
   public void SimulatedClass() {
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++ BELOW FOR TESTING: Classroom Model: Mimics students answering questions.		++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      //----- Initialize Display's border dividers between groups of 10 lights.
      if (initCurQuest) {
         initCurQuest = false;
         for (int stuRec = 1; stuRec <= numOfStu; stuRec++) {  //
            for (int quesNum = 1; quesNum <= 40; quesNum++) {  // uesNum is the number of quiz scores
               if (qScore[stuRec][quesNum] == 0 & currentQuestion[stuRec] == -5) {
                  currentQuestion[stuRec] = quesNum - 1;
                  if (numOfQues >= 11) {
                     draw10line = true;
                  }
                  if (numOfQues >= 21) {
                     draw20line = true;
                  }
                  if (numOfQues >= 31) {
                     draw30line = true;
                  }
               }
            } // End of number of quiz scores
         } // End of number of students
      }
//-----------------------------------------------------------------------------
      for (int stuRec = 1; stuRec <= numOfStu; stuRec++) {  // stuNum is the number of students
         if (!(stuRec == 8 || stuRec == 20 // absent students
                 || currentQuestion[stuRec] >= numOfQues)) { // at last quiz question
            if (timeNextAnswer[stuRec] <= 0) {
               //--- Give new random answer BELOW for LOWER scoring students
               int nextAns = rand.nextInt(30) + 1;  //NOTE: rand.nextInt(20) returns integers 0-19
               if (nextAns >= 12) { // 12 to 30 = 19.  So 19/30 = 63% of scores will be green
                  nextAnswer[stuRec] = 4;// green light
               } else if (nextAns >= 6) { // 6 to 11 = 6.  So 6/30 = 20% of scores will be yellow
                  nextAnswer[stuRec] = 3;// yellow light
               } else if (nextAns >= 1) { // 1 to 5 = 5.  So 5/30 = 17% of scores will be red
                  nextAnswer[stuRec] = 2;// red light
               }
               if (nextAnswer[stuRec] < 1) {
                  nextAnswer[stuRec] = 1;
               }
               //--- Give new random answer ABOVE for LOWER scoring students

//								//--- Give new random answer BELOW for HIGH scoring students
//								int nextAns = rand.nextInt(30) + 1;  //NOTE: rand.nextInt(20) returns integers 0-19
//								if (nextAns >= 7) { // 7 to 30 = 24.  So 24/30 = 80% of scores will be green
//									nextAnswer[stuRec] = 4;// green light
//								} else if (nextAns >= 2) { // 2 to 6 = 5.  So 5/30 = 17% of scores will be yellow
//									nextAnswer[stuRec] = 3;// yellow light
//								} else if (nextAns >= 1) { // 1 to 1 = 1.  So 1/30 = 3% of scores will be red
//									nextAnswer[stuRec] = 2;// red light
//								}
//								if (nextAnswer[stuRec] < 1) {
//									nextAnswer[stuRec] = 1;
//								}
//								//--- Give new random answer ABOVE for HIGH scoring students
               currentQuestion[stuRec] = currentQuestion[stuRec] + 1; // Update current question number
               if (currentQuestion[stuRec] >= 11) {
                  draw10line = true;
               }
               if (currentQuestion[stuRec] >= 21) {
                  draw20line = true;
               }
               if (currentQuestion[stuRec] >= 31) {
                  draw30line = true;
               }
//   	        	 			timeNextAnswer[stuRec] = rand.nextInt(10)+0;  // time students waits B4 next answer
               timeNextAnswer[stuRec] = rand.nextInt(10) + 0;  // time students waits B4 next answer
//--								rs2.absolute(stuRec); // Move to Database RECORD ----------------------------
               if ((currentQuestion[stuRec]) <= 9) {
                  questionName = "Q0" + (currentQuestion[stuRec]);
               } else {
                  questionName = "Q" + (currentQuestion[stuRec]);
               }
//--								rs2.updateInt(questionName, nextAnswer[stuRec]);
               qScoreDB[stuRec][currentQuestion[stuRec]] = nextAnswer[stuRec];
//--								rs2.updateRow();
//   	        	 			qScore[stuRec][currentQuestion[stuRec]] = rs2.getInt(questionName);
               qScore[stuRec][currentQuestion[stuRec]] = qScoreDB[stuRec][currentQuestion[stuRec]];
            } else {
               timeNextAnswer[stuRec] = timeNextAnswer[stuRec] - 1;
            }
         }// END of absent students
         // re-query all question scores from database for display ########################
//--						rs2.absolute(stuRec); // Move to Database RECORD ----------------------------
         for (int i = 1; i <= numOfQues; i++) {  // stuNum is the number of students
            if (i <= 9) {
               questionName = "Q0" + i;
            } else {
               questionName = "Q" + i;
            }
//--                  qScore[stuRec][i] = rs2.getInt(questionName);
            qScore[stuRec][i] = qScoreDB[stuRec][i];
         }
      } // End of for (student record)
      setResults(results);

// The following code had to be commented when using MySQL DB.  It produced an
// error. Also, with the MySQL DB is retaining changes without it.
//    			con2.commit(); // need this to retain changes to database. ##############################

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++ ABOVE FOR TESTING: Classroom Model: Mimics students answering questions.		++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
   }

   public void updateStudentValues() {
//#########################################################################################
//#########################################################################################
//##################### CALCULATING VARIOUS STUDENT AND CLASS VALUES ######################
//#########################################################################################
//#########################################################################################
      for (int stuRec = 1; stuRec <= numOfStu; stuRec++) {  // stuNum is the number of students
         // Calculate running average
         stuSum = 0.0;
         for (int questNum = 1; questNum <= currentQuestion[stuRec]; questNum++) {  // Calculate students new average
            if (qScore[stuRec][questNum] == 4) {
               scoreVal = 100.0;
            } else if (qScore[stuRec][questNum] == 3) {
               scoreVal = 75.0;
            } else if (qScore[stuRec][questNum] == 2) {
               scoreVal = 0.0;
            }
            stuSum = stuSum + scoreVal;
         } // End of for (question number)
         stuAverage[stuRec] = stuSum / ((double) currentQuestion[stuRec]);
      } // End of for (student record)
      //----- Calculate Class Average Each Question
      for (int questNum = 1; questNum <= numOfQues; questNum++) {  // Calculate students new average
         numStuWithAns[questNum] = 0;
         quesSum = 0.0;
         for (int stuRec = 1; stuRec <= numOfStu; stuRec++) {  // stuNum is the number of students
            if (qScore[stuRec][questNum] == 4) {
               scoreVal = 100.0;
               numStuWithAns[questNum] = numStuWithAns[questNum] + 1;
            } else if (qScore[stuRec][questNum] == 3) {
               scoreVal = 75.0;
               numStuWithAns[questNum] = numStuWithAns[questNum] + 1;
            } else if (qScore[stuRec][questNum] == 2) {
               scoreVal = 0.0;
               numStuWithAns[questNum] = numStuWithAns[questNum] + 1;
            } else {
               scoreVal = 0.0;
            }
            quesSum = quesSum + scoreVal;
         } // End of for (student record)
         questionAvg[questNum] = quesSum / ((double) numStuWithAns[questNum]);
      } // End of for (question number)
      //----- Calculate Class Average Each Question
      int numStuTesting = 0;
      double stuAvgSum = 0.0;
      for (int stuRec = 1; stuRec <= numOfStu; stuRec++) {  // stuNum is the number of students
         if (currentQuestion[stuRec] != 0) {
            stuAvgSum = stuAvgSum + stuAverage[stuRec];
            numStuTesting = numStuTesting + 1;
         }
      }
//    			ClassAvg = stuAvgSum / (double)numStuTesting;
      ClassAvg = stuAvgSum / (double) numStuTesting;

   }

   public void stop() {
      stopNumCalls = stopNumCalls + 1;
//    System.out.println("       stop called = " + stopNumCalls);
      animator = null;
      offImage = null;
      offGraphics = null;
   }

   /**
    * Update a frame of animation.
    */
   public void update(Graphics g) {
      updateNumCalls = updateNumCalls + 1;
//    System.out.println("     update called = " + updateNumCalls);
      Dimension d = getSize();
      frame2++;

      // Create the offscreen graphics context
      if ((offGraphics == null)
              || (d.width != offDimension.width)
              || (d.height != offDimension.height)) {
         offDimension = d;
         offImage = createImage(d.width, d.height);
         offGraphics = offImage.getGraphics();
      }

// Erase the previous image
      offGraphics.setColor(getBackground());
      offGraphics.fillRect(0, 0, d.width, d.height);
      offGraphics.setColor(Color.red);
      //offGraphics.setLineWidth(10);

      // Paint the frame into the image
      paintFrame(offGraphics);
      // Paint the image onto the screen
      g.drawImage(offImage, 0, 0, null);
   }

   /**
    * Paint the previous frame (if any).
    */
   public void paint(Graphics g) {
      paintNumCalls = paintNumCalls + 1;
//    System.out.println("      paint called = " + paintNumCalls);
      if (offImage != null) {
         g.drawImage(offImage, 0, 0, null);
      }

   }

//#####################################################################################################
//#####################################################################################################
//#####################################################################################################
   /**
    * Paint a frame of animation.
    */
   public void paintFrame(Graphics g) {
      paintFrameNumCalls = paintFrameNumCalls + 1;
//    System.out.println(" paintFrame called = " + paintFrameNumCalls);

//	Dimension d = size();
      setSize(appletWidth, appletHeight);
//----- General graphic settings
      Graphics2D g2d = (Graphics2D) g;
      g2d.setStroke(new BasicStroke(1.5f));    // line width
      g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//------------- BELOW: Build Teacher "Class Monitor" Display ---------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------

//    g.setColor(Color.red);
//	setFont(new Font("serif",Font.BOLD,30));
////    g2d.setStroke(new BasicStroke(1.5f));    // line width
//
//	g2d.fillRect(800-1,300-1,2,2);
//    g.setColor(Color.black);
//------------------------------------------------------
//------------------------------------------------------
//    g2d.translate(800.0,300.0);
//    g2d.rotate(-angleInRad);
//    g2d.drawString("testing",0,0);
//    g2d.rotate(angleInRad);
//    g2d.translate(-800.0,-300.0);
//---------- OR ----------------------------------------
//    g2d.rotate(-halfPI,800.0,300.0);
//    g2d.drawString("testing",800,300);
//    g2d.rotate(halfPI,800.0,300.0);
//------------------------------------------------------
//------------------------------------------------------


      bX = firstLightX - 5;
      bY = firstLightY - 18;
      BALheight = rowHeight * numOfStu + 2;

      //----- Boarder around Title
      Color BG4 = new Color(230, 230, 230);
      g2d.setPaint(BG4);
      g2d.setPaint(Color.lightGray);
      Color color1 = new Color(149, 182, 215);
      g2d.setPaint(color1);
      g.fillRect(411, firstLightY - 75, 294, 41);
      g2d.setPaint(Color.lightGray);
      g.draw3DRect(410, firstLightY - 77, 296, 45, true);
      g.draw3DRect(411, firstLightY - 76, 294, 43, true);
      g.draw3DRect(412, firstLightY - 75, 292, 41, true);
      g2d.setPaint(Color.darkGray);
      g2d.setStroke(new BasicStroke(0.3f));    // line width
      g.drawLine(379, firstLightY - 77, 381, firstLightY - 75);
      //----- Boarder around names
      Color BG5 = new Color(245, 245, 245);
      g2d.setPaint(BG5);
      g.fillRect(15, firstLightY - 20, 218, BALheight + 4);
      g2d.setPaint(Color.lightGray);
      g.draw3DRect(15, firstLightY - 20, 218, BALheight + 4, false);
      g.draw3DRect(14, firstLightY - 21, 220, BALheight + 6, false);
      //----- Border around ALL lights
      tenLightsGap = 10;
      BALlightShiftX = tenLightsGap * ((numOfQues - 1) / 10);
      BALwidth = 10 * ((numOfQues + 9) / 10) * lightWidth + BALlightShiftX + 9;
      g2d.setPaint(Color.lightGray);
      g.draw3DRect(bX, bY, BALwidth, BALheight, true);
      g.draw3DRect(bX - 1, bY - 1, BALwidth + 2, BALheight + 2, true);
      g.draw3DRect(bX - 2, bY - 2, BALwidth + 4, BALheight + 4, false);
      g.draw3DRect(bX - 3, bY - 3, BALwidth + 6, BALheight + 6, false);
      //----- Border dividers between groups of 10 lights.
      g2d.setStroke(new BasicStroke(0.5f));    // line width
      int xline;
      if (draw10line) {
         xline = firstLightX - 3 + 10 * 20 + 6;
         g2d.setStroke(new BasicStroke(1.0f));    // line width
         g2d.setPaint(Color.gray);
         g.drawLine(xline, firstLightY - 17, xline, BALheight + firstLightY - 18);
         g.drawLine(xline + 1, firstLightY - 18, xline + 1, BALheight + firstLightY - 17);
         g2d.setPaint(Color.white);
         g.drawLine(xline + 2, firstLightY - 18, xline + 2, BALheight + firstLightY - 17);
         g.drawLine(xline + 3, firstLightY - 17, xline + 3, BALheight + firstLightY - 18);
      }
      if (draw20line) {
         xline = firstLightX - 3 + 20 * 20 + 16;
         g2d.setStroke(new BasicStroke(1.0f));    // line width
         g2d.setPaint(Color.gray);
         g.drawLine(xline, firstLightY - 17, xline, BALheight + firstLightY - 18);
         g.drawLine(xline + 1, firstLightY - 18, xline + 1, BALheight + firstLightY - 17);
         g2d.setPaint(Color.white);
         g.drawLine(xline + 2, firstLightY - 18, xline + 2, BALheight + firstLightY - 17);
         g.drawLine(xline + 3, firstLightY - 17, xline + 3, BALheight + firstLightY - 18);
      }
      if (draw30line) {
         xline = firstLightX - 3 + 30 * 20 + 26;
         g2d.setStroke(new BasicStroke(1.0f));    // line width
         g2d.setPaint(Color.gray);
         g.drawLine(xline, firstLightY - 17, xline, BALheight + firstLightY - 18);
         g.drawLine(xline + 1, firstLightY - 18, xline + 1, BALheight + firstLightY - 17);
         g2d.setPaint(Color.white);
         g.drawLine(xline + 2, firstLightY - 18, xline + 2, BALheight + firstLightY - 17);
         g.drawLine(xline + 3, firstLightY - 17, xline + 3, BALheight + firstLightY - 18);
      }

      g.setColor(Color.black);
      setFont(new Font("serif", Font.BOLD, 17));
//    Graphics2D g2d = (Graphics2D) g;
      g2d.setStroke(new BasicStroke(1.5f));    // line width

      // Database related: If there are no results available, display the current message.
      if (queryResults == null) {
         g.drawString(message, 5, 50);
         return;
      }

//----- Display Text ---------------------------------------------
      //----- Titles
//  g.setColor(Color.black);
//		OR
      g2d.setPaint(Color.black);
      g.setFont(new Font("serif", Font.BOLD, 20));
      g.drawString("5th Period", 75, firstLightY - 30);
      g.setFont(new Font("serif", Font.BOLD, 25));
      g.drawString("Realtime Class Monitor", 432, firstLightY - 46);
      //----- Student names and running average
      g.setFont(new Font("serif", Font.BOLD, 17));
      x = firstLightX;
      y = firstLightY;
      java.util.Enumeration e = queryResults.elements();
//setFont(new Font("Courier",Font.PLAIN,15));
//	while (e.hasMoreElements()) {
//		k1 = k1 + 1;  // k1 is the number of students
      for (int stuNum = 1; stuNum <= numOfStu; stuNum++) {  // Current student
         int stuAvg = (int) stuAverage[stuNum];
         g2d.setPaint(Color.black);
         g.drawString(":", nameX + 163, y);
         g.drawString("(", nameX + 168, y);
         g.drawString(")", nameX + 204, y);
         //----- Change color of a student's name to lightGray if student has not started or is absent
         if (currentQuestion[stuNum] == 0) {
            g2d.setPaint(Color.lightGray);
            //----- Change color of a student's name to blue if student has completed the assignment
         } else {
            if (currentQuestion[stuNum] == numOfQues) {
               g2d.setPaint(Color.blue);
            } else {
               g2d.setPaint(Color.black);
               if (stuAvg < 75) {
                  g2d.setPaint(Color.red);
               }
            }

         }
         //----- Student names
//    	String last = rs2.getString("Last") + "                     ";
//    	String first = rs2.getString("First") + "                     ";
//    	last = last.substring(0, 13);
//    	first = first.substring(0, 13);
         String studentName = (String) e.nextElement();
         String studentLast = studentName.substring(0, 13);
         String studentFirst = studentName.substring(14, 26);
         g.drawString(studentLast, nameX, y);
         g.drawString(studentFirst, nameX + 92, y);
         //----- Student running average
         if (currentQuestion[stuNum] != 0) {  // Student has not started or is absent
            //----- Change color of a student's running average to red if below 70%
            if (stuAvg < 75) {
               g2d.setPaint(Color.red);
            }
            g.drawString("" + stuAvg, nameX + 176, y);
         }
//----- Draw score lights for current student -----------------------------------
         for (int qNum = 1; qNum <= numOfQues; qNum++) {
            if (qScore[stuNum][qNum] == 0) {
               qS = "0";
               light = offLight;
            } else if (qScore[stuNum][qNum] == 1) {
               qS = "1";
               light = redLight;
            } else if (qScore[stuNum][qNum] == 2) {
               qS = "2";
               light = redLight;
            } else if (qScore[stuNum][qNum] == 3) {
               qS = "3";
               light = yellowLight;
            } else if (qScore[stuNum][qNum] == 4) {
               qS = "4";
               light = greenLight;
            } else if (qScore[stuNum][qNum] == 6) {
               qS = "6";
               light = purpleLight;
            }
            lightShiftX = tenLightsGap * ((qNum - 1) / 10);

//^		 	if (qS != "0"){
            g.drawImage(light, x + lightShiftX, y - 14, lightWidth, lightHeight, null);
//		 		g.drawRect(x+lightShiftX, y-14, 20, 20);
//^		 	}
            x = x + 20;
         } // END of quiz scores
         x = firstLightX;
         y = y + rowHeight;
      } // END of current student
      //------------------------------------------------------

//    ClassAvg
//	g2d.setPaint(Color.black);
      g.setColor(Color.black);
      g.drawString(":", nameX + 163, firstLightY + BALheight + 5);
      g.drawString("(", nameX + 168, firstLightY + BALheight + 5);
      g.drawString(")", nameX + 204, firstLightY + BALheight + 5);
      g.drawString("" + (int) ClassAvg, nameX + 177, firstLightY + BALheight + 5);
      g.setFont(new Font("serif", Font.BOLD, 20));
      g.drawString("Class Average", nameX + 30, firstLightY + BALheight + 5);
      g.setFont(new Font("serif", Font.BOLD, 17));


      x = firstLightX + 20;
      y = firstLightY + BALheight + 50;
//	g.setFont(new Font("serif",Font.BOLD,20));
      for (int qNum = 1; qNum <= numOfQues; qNum++) {
         if (numStuWithAns[qNum] != 0) {
            lightShiftX = tenLightsGap * ((qNum - 1) / 10);
            qAveXPos = x + lightShiftX - 5;
//			g.setColor(Color.red);
//			g2d.fillRect(x+lightShiftX-5, y-14, 2, 2);
            g.setColor(Color.black);
            int qAvg = (int) questionAvg[qNum];
            if (qAvg >= 100) {
               qAveYPos = y - 30;
            } else if (qAvg >= 10) {
               qAveYPos = y - 39;
            } else {
               qAveYPos = y - 48;
            }
            if (qAvg < 70) {
               g.setColor(Color.red);
            } else if (qAvg < 80) {
               g.setColor(Color.yellow);
            } else {
               g.setColor(Color.black);
            }
            g2d.rotate(-halfPI, qAveXPos, qAveYPos);
            g2d.drawString("" + qAvg, qAveXPos, qAveYPos);
            g2d.rotate(halfPI, qAveXPos, qAveYPos);
         } // END of quiz scores
         x = x + 20;

      }
      //------------------------------------------------------

//	Dimension d = size();
//    setSize(new Dimension(746, 440));

//    Draw window border.
      g2d.setPaint(Color.gray);
//--      g.fillRect(appletWidth - 24, 10, 5, appletHeight - 29);
//--      g.fillRect(10, appletHeight - 24, appletWidth - 29, 5);
      g.fillRect(appletWidth - 27, 7, 5, appletHeight - 29);
      g.fillRect(7, appletHeight - 27, appletWidth - 29, 5);

//--      g2d.setStroke(new BasicStroke(2.5f));    // line width
      g2d.setStroke(new BasicStroke(4.0f));    // line width
      Color BG7 = new Color(46, 80, 122);
      g2d.setPaint(BG7);
//--      g.drawRect(5, 5, appletWidth - 30, appletHeight - 30);
      g.drawRect(2, 2, appletWidth - 30, appletHeight - 30);
//	g2d.setPaint(Color.darkGray);
      g2d.setPaint(Color.black);
      g2d.setPaint(Color.black);

//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//------------- ABOVE: Build Teacher "Class Monitor" Display ---------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------

//===== MONITORING OR DEBUG BELOW =========================================================
//    g2d.setPaint(Color.black);
//    g.drawString("       init called = " + initNumCalls,700,250);
//    g.drawString("      start called = " + startNumCalls,700,270);
//    g.drawString("        run called = " + runNumCalls,700,290);
//    g.drawString("       stop called = " + stopNumCalls,700,310);
//    g.drawString("     update called = " + updateNumCalls,700,330);
//    g.drawString("      paint called = " + paintNumCalls,700,350);
//    g.drawString(" paintFrame called = " + paintFrameNumCalls,700,370);
//    g.drawString("   setError called = " + setErrorNumCalls,700,390);
//    g.drawString(" setResults called = " + setResultsNumCalls,700,410);
//===== MONITORING OR DEBUG ABOVE =========================================================
   } // END of public void paintFrame(Graphics g)

   //#############################     DATABASE BELOW    ####################################
   /**
    * This private method is used to record an error message for later display.
    */
   private synchronized void setError(String mess) {
      setErrorNumCalls = setErrorNumCalls + 1;
//    System.out.println("   setError called = " + setErrorNumCalls);
      queryResults = null;
      message = mess;
      setErrorMessage = message; //DEBUG stuff

//	worker = null;
//	animator = null;
      // And ask AWT to repaint this applet.
      repaint();
   }

   /**
    * This private method is used to record the results of a query, for later display.
    */
   private synchronized void setResults(Vector results) {
      setResultsNumCalls = setResultsNumCalls + 1;
//    System.out.println(" setResults called = " + setResultsNumCalls);
      queryResults = results;
//	worker = null;
//	animator = null;
      // And ask AWT to repaint this applet.
      repaint();
   }
   //#############################     DATABASE ABOVE    ####################################
//########################################################################################################
}