NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Easy Java Simulations (2001- ) => Collaborative Community of EJS => Topic started by: lookang on August 15, 2011, 02:39:23 pm



Title: Ejs Open Source Stop Watch Model Java Applet
Post by: lookang on August 15, 2011, 02:39:23 pm
Ejs Open Source Stop Watch Model Java Applet by dhasthagheer, added on by Fu-Kwun Hwang, and now slightly remixed by lookang
reference:
http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=2263.0


Title: Re: Ejs Open Source Stop Watch Model
Post by: lookang on August 15, 2011, 02:48:09 pm
changes
combined the magnification function into the main frame instead of the dialog by Fu-Kwun to allow a one view of the magnification.
mouse x and  mouse y = x and y respectively to allow on click to select region to magnify.
created code to force mouse screen from going too far
if (x >10)x = 10; // prevent magnifer from going beyond
if (x <-10)x = -10;
if (y >10)y = 10;
if (y <-10)y = -10;
i learn to make magnification
by changing the
xmin = x - ratio;
xmax = x + ratio;
ymin = x - ratio;
ymax = y + ratio;
which is something i always wanted to do, but could not figure out the codes in this kind of exact implementation.
will try to put in the vernier and micrometer soon.
move the RESET button to the right of the strop watch face for right handers.
created play setp and reset button to use simulation in addition to the screen press on button.
added color scheme to suit printing on paper for school use
change text to ARIAL 30 second text bigger
change text ARIAL 20 minutes text bigger
16 august 2011
add text using l_t= (int)(Math.floor(t/60))+" minute(s) & "+ (Math.round(((10*t)%600))/10.) + " second(s)";
17 august 2011
//http://www.daniweb.com/software-development/java/threads/32513
// String.format("%8.2f\n",0.912385) // for decimal places will give 0.91 in dp
// String.format("%.5g%n", 0.912385); // for significant figures will give 0.91 in sign fig
17 august 2011 night
add slider for minute and seconds and the associated controls
add answer Boolean
added "game" for time to be random for self assessment for learning
made the feedback appear only after input from user
if (showAnswerFlag==false)
{
A1correct = "";
A2correct = "";
}
else{
  if (Math.abs(minute - enterA1) <= 0.5) {
    A1correct = "Great! You have the right answer!";
    A1correctbackground = java.awt.Color.GREEN;
  }
  else {
    A1correct = "Your input is out by "+ String.format("%1.1f\n",(minute-enterA1 ));
    A1correctbackground = java.awt.Color.RED;
  }
  
  if (Math.abs(second - enterA2) <= 0.05) {
    A2correct = "Great! You have the right answer!";
    A2correctbackground = java.awt.Color.GREEN;
  }
  else {
    A2correct = "Your input is out by "+ String.format("%1.1f\n",(second-enterA2 ));
    A2correctbackground = java.awt.Color.RED;
  }

  }
 //}

made the start stop button fit to screen by making it a bit smaller
18 august 2011
made the drop down menu for ds = 0.1,0.2,0.5,1
checkbox for integer display of the minute hand to address possible misconception thanks to feedback from Søren ⎈⎝⏠⏝⏠⎠∰ Kyale on facebook
19 august 2011
made the hands a bit shorter to show the lines as aligned and not overlap for clearer visuals
made the random() to (int) to integer seconds for ease of gaming.

01 September 2011
added calibrate button from http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=990.0 to tell the time actually from
java.util.GregorianCalendar Calendar=new java.util.GregorianCalendar();
StopwatchDegreeSecond = Calendar.get(Calendar.SECOND)*6.+Calendar.get(Calendar.MINUTE)*6*60.;
_play();

04 September 2011
made the calibrate time follow dt = 0.05 and fps = 20 to imitate real time seconds following http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=990.0
add this option to the combo drop-down list

08 September 2011
made the hands drag-gable and correctly corresponding show the time using http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=990.0 as reference
made the magnify only when show==true
if (show ==true) // to make magnify enable only after show ==true
{
  x=xm;
  y=ym;
  }
improve the codes for displaying the numbers in exact format
//l_t= (int)(Math.floor(t/60))+" minute(s) & "+ String.format("%1.1f\n", t%60) + " second(s)";
l_t= _view.format(Math.floor(t/60),"00")+" minute(s) & "+ _view.format(t%60,"00.0") + " second(s)";
 



to do if time permits
http://stopwatch.onlineclock.net/ like the digital number display
http://javaboutique.internet.com/stop_watch_applet/
http://geogebrawiki.wikispaces.com/DIY+of+Stopwatch example of a stopwatch in geogebra

it appears that no many stop watch java applets around. this is indeed new knowledge

Enjoy!
original simulation is by dhasthagheer! thanks for sharing :)
magnification is by Fu-Kwun Hwang. thanks for the enhanced features which dhasthagheer wanted.
remixed with changes above in this simulation is by lookang :)