// ------------------------------------------------------ 
// JavaClock.java 
// 
// JavaClock applet 
// Version 2.0 
// Copyright (c) 1998, 1999 Antony Pranata 
// http://www.antonypr.pair.com 
// 
// Java Clock 
// used to display either analog and digital clock 
// 
// This source code is available freely. You may only use 
// it for your personal purpose only (please do not use it 
// for commercial purpose). 
// 
// You may also use this applet on your web page freely 
// as long as credit is given (a link to my home page 
// is enough). 
// 
// What's new in this version? 
// - This new version of Java Clock support DST 
//   I added this feature in this version because many users 
//   asked me for it. Actually, I just knew DST when a user 
//   ask me: Do your Java Clock support DST? FYI, I live in 
//   Indonesia, South East Asia and we do not use DST here 
//   (our country lie on equator line). 
//
// ------------------------------------------------------
// Modified Feb 2000 to make a 24 hour analog clock
// Pete Boardman
// 
//
//
// ------------------------------------------------------ 
import java.awt.*; 
import java.applet.*; 
import java.util.*; 
 
// ------------------------------------------------------ 
// JavaClock class 
// ------------------------------------------------------ 
public class JavaClock extends Applet implements Runnable 
{ 
  static final Object[][] colors = 
    { { "BLACK",     Color.black     }, 
      { "BLUE",      Color.blue      }, 
      { "CYAN",      Color.cyan      }, 
      { "DARKGRAY",  Color.darkGray  }, 
      { "GRAY",      Color.gray      }, 
      { "GREEN",     Color.green     }, 
      { "LIGHTGRAY", Color.lightGray }, 
      { "MAGENTA",   Color.magenta   }, 
      { "ORANGE",    Color.orange    }, 
      { "PINK",      Color.pink      }, 
      { "RED",       Color.red       }, 
      { "WHITE",     Color.white     }, 
      { "YELLOW",    Color.yellow    } }; 
 
  // The first field is the name of a city 
  // The second field is a difference time from GMT 
  // The third field is 1 if the city support DST, 0 otherwise 
  static final Object[][] cityZone = 
    { 		
		{ "+12h IDLE/NZST", "720","1"},
		{ "Auckland", "720","1"},
		{ "Wellington", "720","1"},
		{ "Fiji", "720","1"},
		{ "+11h", "660","1"},
		{ "+10h GST", "600","1"},
		{ "Sydney", "600","1"},
		{ "Tasmania", "600","1"},
		{ "Adelaide", "570", "1"}, 
		{ "Darwin", "570", "0"}, 
		{ "+9h JST", "540","0"},
		{ "Tokyo", "540","0"},
		{ "+8h CCT/CST/RZ7", "480","1"},
		{ "Beijing", "480","0"},
		{ "Hong Kong", "480","0"},
		{ "Malaysia", "480","1"},
		{ "+7h WAST/RZ6", "420","0"},
		{ "Jakarta", "420","0" },
		{ "+6h RZ5", "360","1" },
		{ "New Delhi", "330", "0" }, 
		{ "+5h RZ4", "300","1" },
		{ "+4h RZ3", "240","0" },
		{ "Abu Dhabi", "240","0" },
		{ "Muscat", "240","0" },
		{ "Tblisi", "240","0" },
		{ "Volgograd", "240","0" },
		{ "Kabul", "240","0" },
		{ "+3h MST/BT/RZ2", "180","1" },
		{ "Kuwait", "180","1" },
		{ "Nairobi", "180","1" },
		{ "Riyadh", "180","1" },
		{ "Moscow", "180","1" },
		{ "Tehran", "180","1" },
		{ "+2h EET/EST", "120","1" },
		{ "Athens", "120","1" },
		{ "Helsinki", "120","1" },
		{ "Jerusalem", "120","1" },
		{ "Harare", "120","1" },
		{ "Cairo", "120","1" },
		{ "+1h MET/CET", "60","1" },
		{ "Paris", "60","1"},
		{ "Berlin", "60","1"},
		{ "Berne", "60","1"},
		{ "Brussels", "60","1"},
		{ "Amsterdam", "60","1"},
		{ "Vienna", "60","1"},
		{ "Madrid", "60","1"},
		{ "Amsterdam", "60","1"},
		{ "Rome", "60","1"},
		{ "Oslo", "60","1"},
		{ "0h GMT/UT/WET", "0","1" },
		{ "London", "0","1" },
		{ "Dublin", "0","1" },
		{ "Edinburgh", "0","1" },
		{ "Reykjavik", "0","1" },
		{ "Lisbon", "0","1" },
		{ "-1h WAT", "-60","1" },
		{ "Azores", "-60","1" },
		{ "-2h AT", "-120","1" },
		{ "-3h SAT", "-180","1" },
		{ "Brasilia", "-180","1" },
		{ "Buenos Aires", "-180","1" },
		{ "-4h AST", "-240","1" },
		{ "Atlantic", "-240","1" },
		{ "Caracas", "-240","1" },
		{ "La Paz", "-240","1" },
		{ "Chile", "-240","1" },
		{ "-5h EST", "-300","1" },
		{ "Eastern", "-300","1" },
		{ "New York", "-300","1" },
		{ "Lima", "-300","1" },
		{ "Bogota", "-300","1" },
		{ "-6h CST", "-360","1" },
		{ "Central", "-360","1" },
		{ "Mexico City", "-360","1" },
		{ "Saskatachewan", "-360","1" },
		{ "-7h MST", "-420","1" },
		{ "Mountain Time", "-420","1" },
		{ "Arizona", "-420","0" },
		{ "-8h PST", "-480","1" },
		{ "Pacific Time", "-480","1" },
		{ "Los Angeles", "-480","1" },
		{ "-9h YST", "-540","1" },
		{ "Alaska", "-540","1" },
		{ "-10h AHST/CAT/HST", "-600","0" },
		{ "Hawaii", "-600","0" },
		{ "-11h NT", "-660","1" },
		{ "-12h IDLW", "-720","1" } }; 
 
  Thread threadClock; // thread of the clock 
 
  boolean isAnalog = true; // true if analog clock is displayed 
  Font fontText = null; // font used to display digital clock 
  Font dialText = null; // font used to display numbers on analog dial - not in 12h
  Color fontColor = Color.black; // font color; 
  Color backColor = Color.white; // background color 
  Color hHandColor = Color.darkGray; // hour hand color 
  Color mHandColor = Color.blue; // minute hand color 
  Color sHandColor = Color.black; // second hand color 
  Color hPointColor = Color.red; // hour point color 
  Color mPointColor = Color.lightGray; // minute point color 
 
  int xPoint[] = new int[4]; 
  int yPoint[] = new int[4]; 
 
  Image backImage; // background image 
  MediaTracker tracker; 
  Image imageBuffer; // buffer image 
 
  int fromGMT; // local time - GMT time 
  boolean isDST; // true if the city/country use DST 
  boolean isLocalUseDST; // true if local time use DST 
  int currentZone; // current time zone 
  int oldHour = -1, oldMinute = -1, oldSecond = -1; 
  
  //pb new stuff
  boolean noonAtTop = true; // true if noon at top, 24h at bottom
  boolean drawNumbers = true; // draw numbers on dial 
  boolean drawMinutePoints = true; // draw minute points on dial 
  boolean drawHourPoints = true; // draw hour points on dial 
  
 
  // ---------------------------------------------------- 
  // setZone method, set time zone 
  // ---------------------------------------------------- 
  public void setCityZone (String zone) { 
    currentZone = fromGMT; 
    isDST = isLocalUseDST; 
    for (int i = 0; i < cityZone.length; i++) 
      if (zone.indexOf ((String)cityZone[i][0]) != -1) 
      { 
        currentZone = Integer.parseInt ((String)cityZone[i][1]); 
        isDST = (Integer.parseInt ((String)cityZone[i][2]) == 1); 
      } 
  } 
 
  // ---------------------------------------------------- 
  // setIsLocalUseDST method 
  // ---------------------------------------------------- 
  public void setIsLocalUseDST (boolean usedst) { 
    isLocalUseDST = usedst; 
  } 
 
  // ---------------------------------------------------- 
  // findColor method, parse a string into color 
  // ---------------------------------------------------- 
  private Color findColor (String param, Color defColor) { 
    if (param != null) { 
      param = param.toUpperCase (); 
      if (param.charAt (0) == '#') { 
        return new Color (Integer.parseInt (param.substring (1), 16)); 
      } 
      else { 
        for (int i = 0; i < colors.length; i++) 
          if (param.compareTo ((String)colors[i][0]) == 0) { 
            return (Color)colors[i][1]; 
          } 
      } 
    } 
    return defColor; 
  } 
 
  // ---------------------------------------------------- 
  // init method, applet initialization 
  // ---------------------------------------------------- 
  public void init () { 
    // Read "typeface" & "fontsize" parameter from HTML file 
    String param = getParameter ("typeface"); 
    if (param == null) 
      param = "Helvetica"; 
 
    int paramSize; 
    try { 
      paramSize = Integer.parseInt ( 
        getParameter ("fontsize"), 10); 
    } 
    catch (NumberFormatException e) { 
      paramSize = 16; 
    } 
 
    fontText = new Font (param, Font.PLAIN, paramSize); 
 
    // Read color parameter from HTML file 
    backColor = findColor (getParameter ("backcolor"), backColor); 
    fontColor = findColor (getParameter ("fontcolor"), fontColor); 
    hHandColor = findColor (getParameter ("hhandcolor"), hHandColor); 
    mHandColor = findColor (getParameter ("mhandcolor"), mHandColor); 
    sHandColor = findColor (getParameter ("shandcolor"), sHandColor); 
    hPointColor = findColor (getParameter ("hpointcolor"), hPointColor); 
    mPointColor = findColor (getParameter ("mpointcolor"), mPointColor); 
 
    // Read "backimage" parameter from HTML file 
    tracker    = new MediaTracker (this); 
    param = getParameter ("backimage"); 
    if (param != null) { 
      backImage = getImage (getCodeBase (), param); 
      tracker.addImage (backImage, 0); 
    } 
    else 
      backImage = null; 
 
    // "analog" parameter 
    param = getParameter ("analog"); 
    if ((param != null) && (param.indexOf ("false") > -1)) 
      isAnalog = false; 
    else 
      isAnalog = true; 
 
    // "dst" parameter 
    param = getParameter ("dst"); 
    if ((param != null) && (param.indexOf ("false") > -1)) 
      isLocalUseDST = false; 
    else 
      isLocalUseDST = true; 
    isDST = isLocalUseDST;
    
    // "noonattop" parameter 
    param = getParameter ("noonattop"); 
    if ((param != null) && (param.indexOf ("false") > -1)) 
      noonAtTop = false; 
    else 
      noonAtTop = true; 
    
    // "numbers" parameter 
    param = getParameter ("numbers"); 
    if ((param != null) && (param.indexOf ("false") > -1)) 
      drawNumbers = false; 
    else 
      drawNumbers = true; 
      
    // "hourpoints" parameter 
    param = getParameter ("hourpoints"); 
    if ((param != null) && (param.indexOf ("false") > -1)) 
      drawHourPoints = false; 
    else 
      drawHourPoints = true; 
      
    // "minutepoints" parameter 
    param = getParameter ("minutepoints"); 
    if ((param != null) && (param.indexOf ("false") > -1)) 
      drawMinutePoints = false; 
    else 
      drawMinutePoints = true;   
    
    // find out local time zone and use it
	Date localDate = new Date ();
	fromGMT = -localDate.getTimezoneOffset ();
	currentZone = fromGMT; 
	
  } 
 
  // ---------------------------------------------------- 
  // start method 
  // ---------------------------------------------------- 
  public void start () { 
    // Create the buffer 
    if (imageBuffer == null) { 
      Dimension dim = size (); 
      imageBuffer = createImage (dim.width, dim.height); 
    } 
 
    // Create the thread 
    if (threadClock == null) { 
      threadClock = new Thread (this); 
      threadClock.start (); 
    } 
  } 
 
  // ---------------------------------------------------- 
  // stop method 
  // ---------------------------------------------------- 
  public void stop () { 
    // Stop the thread 
    if (threadClock != null) { 
      threadClock.stop (); 
      threadClock = null; 
      imageBuffer = null; 
    } 
  } 
 
  // ---------------------------------------------------- 
  // run method 
  // ---------------------------------------------------- 
  public void run () { 
    // Wait until background image loaded 
    try { 
      tracker.waitForAll (); 
    } 
    catch (InterruptedException e) { 
      return; 
    } 
 
    // If current thread is threadClock then ... 
    while (Thread.currentThread () == threadClock) { 
      // Draw the clock 
      repaint (); 
 
      // Delay for 500 ms 
      try { 
        threadClock.sleep (500); 
      } 
      catch (InterruptedException e) { 
        break; 
      } 
    } 
  } 
 
  // ---------------------------------------------------- 
  // IsFirstAprLastOct method 
  // ---------------------------------------------------- 
  boolean IsFirstAprLastOct (Date checkDate) { 
    int dd = checkDate.getDate (); 
    int mm = checkDate.getMonth (); 
    if ((mm >= 3) && (mm <= 9)) { 
      Date dateApril = new Date (checkDate.getYear (), 3, 1); 
      int firstWeekApril = 8 - dateApril.getDay (); 
      if (firstWeekApril > 7) 
        firstWeekApril -= 7; 
 
      Date dateOct = new Date (checkDate.getYear (), 9, 31); 
      int lastWeekOct = 31 - dateOct.getDay (); 
 
      boolean isSetAhead1 = 
        ((mm == 3) && (dd > firstWeekApril)) || 
        ((mm == 3) && (dd == firstWeekApril) && (checkDate.getHours () >= 2)) || 
        (mm > 3); 
      boolean isSetAhead2 = 
        ((mm == 9) && (dd < lastWeekOct)) || 
        ((mm == 9) && (dd == lastWeekOct) && (checkDate.getHours () < 2)) || 
        (mm < 9); 
      if (isSetAhead1 && isSetAhead2) 
        return true; 
      else 
        return false; 
    } 
    return false; 
  } 
 
  // ---------------------------------------------------- 
  // update method 
  // ---------------------------------------------------- 
  public void update (Graphics g) { 
    Date newTime = new Date (); 
    long timeDest = newTime.getTime (); 
    timeDest += (currentZone - fromGMT) * 60 * 1000; 
    newTime = new Date (timeDest);
 
    int hour   = newTime.getHours (); 
 
    // Set DST 
    if ((isDST) && (!isLocalUseDST)) { 
      if (IsFirstAprLastOct (newTime)) 
        hour += 1; 
    } 
 
    if ((!isDST) && (isLocalUseDST)) { 
      Date newTime2 = new Date (); 
      if (IsFirstAprLastOct (newTime2)) 
        hour -= 1; 
    } 
 
    int minute = newTime.getMinutes (); 
    int second = newTime.getSeconds (); 
 
    if ((hour != oldHour) || (minute != oldMinute) || 
        (second != oldSecond)) { 
      // Draw background in the buffer 
      Graphics graphBuffer = imageBuffer.getGraphics (); 
      DrawBackground (graphBuffer); 
 
      Dimension dim = size (); 
      int centerX = dim.width >> 1; 
      int centerY = dim.height >> 1; 
 
      if (isAnalog) { 
        // Prepare the drawing of the analog clock 
        double radius1 = Math.min (centerX, centerY) * 0.75; 
        double radius2 = Math.min (centerX, centerY) * 0.04; 
 
        // Draw minute hand 
        double posMinute = Math.PI * (minute / 30.0 + second / 1800.0); 
        xPoint[0] = (int)Math.round (centerX - 2 * radius2 * Math.sin (posMinute)) - 1; 
        xPoint[1] = (int)Math.round (centerX - radius2 * Math.cos (posMinute)); 
        xPoint[2] = (int)Math.round (centerX + radius1 * Math.sin (posMinute)) + 1; 
        xPoint[3] = (int)Math.round (centerX + radius2 * Math.cos (posMinute)); 
 
        yPoint[0] = (int)Math.round (centerY + 2 * radius2 * Math.cos (posMinute)) - 1; 
        yPoint[1] = (int)Math.round (centerY - radius2 * Math.sin (posMinute)); 
        yPoint[2] = (int)Math.round (centerY - radius1 * Math.cos (posMinute)) + 1; 
        yPoint[3] = (int)Math.round (centerY + radius2 * Math.sin (posMinute)); 
 
        graphBuffer.setColor (mHandColor); 
        graphBuffer.fillPolygon (xPoint, yPoint, 4); 
 
        if (minute < 30) 
          graphBuffer.setColor (Color.white); 
        else 
          graphBuffer.setColor (Color.black); 
        graphBuffer.drawLine (xPoint[0], yPoint[0], xPoint[1], yPoint[1]); 
        graphBuffer.drawLine (xPoint[1], yPoint[1], xPoint[2], yPoint[2]); 
 
        if (minute < 30) 
          graphBuffer.setColor (Color.black); 
        else 
          graphBuffer.setColor (Color.white); 
        graphBuffer.drawLine (xPoint[2], yPoint[2], xPoint[3], yPoint[3]); 
        graphBuffer.drawLine (xPoint[3], yPoint[3], xPoint[0], yPoint[0]); 
 
        // Draw hour hand 
        // for 12h clock was: double posHour = Math.PI * (hour / 6.0 + minute / 360.0); 
        double noonOffset;
        if (noonAtTop) 
        	noonOffset = Math.PI;
        else
        	noonOffset = 0;
        	
        double posHour = noonOffset + (Math.PI * (hour / 12.0 + minute / 720.0));
        double sinposHour = Math.sin(posHour);
        double cosposHour = Math.cos(posHour);
        
        radius1 = Math.min (centerX, centerY) * 0.5;  
        radius2 = Math.min (centerX, centerY) * 0.05; 
        xPoint[0] = (int)Math.round (centerX - 2 * radius2 * sinposHour) - 1; 
        xPoint[1] = (int)Math.round (centerX - radius2 * cosposHour); 
        xPoint[2] = (int)Math.round (centerX + radius1 * sinposHour) + 1; 
        xPoint[3] = (int)Math.round (centerX + radius2 * cosposHour); 
 
        yPoint[0] = (int)Math.round (centerY + 2 * radius2 * cosposHour) - 1; 
        yPoint[1] = (int)Math.round (centerY - radius2 * sinposHour); 
        yPoint[2] = (int)Math.round (centerY - radius1 * cosposHour) + 1; 
        yPoint[3] = (int)Math.round (centerY + radius2 * sinposHour); 
 
        graphBuffer.setColor (hHandColor); 
        graphBuffer.fillPolygon (xPoint, yPoint, 4); 
 
        if ((hour >= 12) && (hour <= 24)) // was more complicated for 12h
          graphBuffer.setColor (Color.white); 
        else 
          graphBuffer.setColor (Color.black); 
        graphBuffer.drawLine (xPoint[0], yPoint[0], xPoint[1], yPoint[1]); 
        graphBuffer.drawLine (xPoint[1], yPoint[1], xPoint[2], yPoint[2]); 
 
        if ((hour >= 0) && (hour <= 12)) // was more complicated for 12h
          graphBuffer.setColor (Color.black); 
        else 
          graphBuffer.setColor (Color.white); 
        graphBuffer.drawLine (xPoint[2], yPoint[2], xPoint[3], yPoint[3]); 
        graphBuffer.drawLine (xPoint[3], yPoint[3], xPoint[0], yPoint[0]); 
 
        // Draw second hand 
        radius1 = Math.min (centerX, centerY) * 0.75; 
        graphBuffer.setColor (sHandColor); 
        double posSecond = Math.PI * second / 30.0; 
        graphBuffer.drawLine ( 
          centerX, centerY, 
          (int)Math.round (centerX + radius1 * Math.sin (posSecond)), 
          (int)Math.round (centerY - radius1 * Math.cos (posSecond)));           
      } 
      else { 
        // Draw digital clock 
        graphBuffer.setFont (fontText); 
        graphBuffer.setColor (fontColor); 
 
        String displayTime = 
          ((hour < 10) ? ("0" + hour) : Integer.toString (hour)) + ":" + 
          ((minute < 10) ? ("0" + minute) : Integer.toString (minute)) + ":" + 
          ((second < 10) ? ("0" + second) : Integer.toString (second)); 
 
        FontMetrics fm = graphBuffer.getFontMetrics (); 
        int LokY = dim.height >> 1; 
        if (LokY < 0) 
          LokY = 0; 
 
        int LokX = (dim.width - fm.stringWidth (displayTime)) >> 1; 
        if (LokX < 0) 
          LokX = 0; 
 
        graphBuffer.drawString (displayTime, LokX, LokY); 
      } 
 
      oldHour = hour; 
      oldMinute = minute; 
      oldSecond = second; 
    } 
 
    // Copy the buffer to the "screen" 
    g.drawImage (imageBuffer, 0, 0, null); 
  } 
 
  // ---------------------------------------------------- 
  // paint method 
  // ---------------------------------------------------- 
  public void paint (Graphics g) { 
    // If there's error, draw nothing to the screen 
    Dimension dim = size (); 
    if (tracker.isErrorAny ()) { 
      g.setColor (Color.white); 
      g.fillRect (0, 0, dim.width, dim.height); 
      return; 
    } 
 
    // If there's NO error, draw the image to the screen 
    if (tracker.checkAll (true)) 
      DrawBackground (g); 
  } 
 
    // ---------------------------------------------------- 
  // mouseDown method 
  // ---------------------------------------------------- 
  public boolean mouseDown (Event evt, int x, int y) { 
    isAnalog = !isAnalog; 
    return true; 
  } 
 
  // ---------------------------------------------------- 
  // DrawBackground method 
  // ---------------------------------------------------- 
  private void DrawBackground (Graphics g) { 
    // Fill background with solid color 
    Dimension dim = size (); 
    g.setColor (backColor); 
    g.fillRect (0, 0, dim.width, dim.height); 
 
    // Draw background image 
    if (backImage != null) { 
      int w = backImage.getWidth (this); 
      int h = backImage.getHeight (this); 
      if ((w < 0) || (h < 0)) 
        return; 
 
      g.drawImage (backImage, ( 
        dim.width - w) >> 1, (dim.height - h) >> 1, null); 
    } 
 
    if (isAnalog) { 
    	
      if (drawHourPoints) {
	      // Draw hour marks 
	      int centerX = dim.width >> 1; 
	      int centerY = dim.height >> 1; 
	      double radius = Math.min (centerX, centerY) * 0.9; 
	      for (int i = 1; i <= 24; i++) {  // was 12
	        double buffer = Math.PI * (0.5 - i / 12.0); // was 6.0 
	        int posX = (int)Math.floor (centerX + radius * Math.cos (buffer)); 
	        int posY = (int)Math.floor (centerY - radius * Math.sin (buffer)); 
	 
	        g.setColor (hPointColor); 
	        g.fill3DRect (posX - 2, posY - 2, 4, 4, true); 
	      	} // draw hours
		}
 
		
		if (drawMinutePoints) {
	     // Draw minute
	      int centerX = dim.width >> 1; 
	      int centerY = dim.height >> 1; 
	      double radius = Math.min (centerX, centerY) * 0.8; // new radius for minutes
	      for (int i = 1; i <= 60; i++) { 
	          double buffer = Math.PI * i / 30.0;    
	          int posX = (int)Math.floor (centerX + radius * Math.cos (buffer)); 
	          int posY = (int)Math.floor (centerY - radius * Math.sin (buffer)); 
	 
	          g.setColor (mPointColor); 
	          g.fill3DRect (posX - 1, posY - 1, 2, 2, false);
	    	  }
		}
      
       	if (drawNumbers) {
       	// draw numbers
       	// new - not in 12h original
        g.setColor (fontColor);
        dialText = new Font ("Helvetica", Font.PLAIN, 9);
        g.setFont (dialText);
        String hourNumber;

	    int centerX = dim.width >> 1; 
	    int centerY = dim.height >> 1; 
    	double radius = Math.min (centerX, centerY) * 0.8;

        if (noonAtTop) 
        	hourNumber = "12";
        else
        	hourNumber = "24";
        
        g.drawString (hourNumber, (int)Math.floor (centerX + (radius * Math.cos (Math.PI/2)) - 5), 
        (int)Math.floor (centerY - (radius * Math.sin (Math.PI/2)) + 15)); // placed by hand!

		// 06 am
        if (noonAtTop) 
        	hourNumber = "6";
        else
        	hourNumber = "18";
	
        g.drawString (hourNumber, (int)Math.floor (centerX + (radius * Math.cos (Math.PI)) + 5), 
        (int)Math.floor (centerY - (radius * Math.sin (Math.PI)) + 4)); 

        // 18 pm
        if (noonAtTop) 
        	hourNumber = "18";
        else
        	hourNumber = "6";
        
        g.drawString (hourNumber, (int)Math.floor (centerX + (radius * Math.cos (0)) - 15), 
        (int)Math.floor (centerY - (radius * Math.sin (0)) + 4)); 

		// 0 
        if (noonAtTop) 
        	hourNumber = "0";
        else
        	hourNumber = "12";
        g.drawString (hourNumber, (int)Math.floor (centerX + (radius * Math.cos (Math.PI * 1.5f)) - 1), 
        (int)Math.floor (centerY - (radius * Math.sin (Math.PI * 1.5f)) - 5));
		}
    } 
  } 
}
