/**
 * RomanNumeralClock.java   version 2.0
 *
 * Copyright (c) 1997 H.J. Tsai, Inc. All Rights Reserved.
 *
 * Permission to use, copy, modify, and distribute this software
 * and its documentation for any purposes and without
 * fee is hereby granted provided that this copyright notice
 * appears in all copies. 
 *
 * H.J. Tsai MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
 * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
 * PURPOSE, OR NON-INFRINGEMENT. H.J. Tsai SHALL NOT BE LIABLE FOR
 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.

 * Author: H.J. Tsai hjtsai@cargobay.com
 *
 * Version: 2.0     Oct. 15, 1996
 *                  Minor change. Version number changed
 *                  to match its superclass DigitalClock.java
 * Version: 1.0     Sep. 08, 1996
 *                  Initial version
 */

import java.util.*;
import java.awt.*;
import java.applet.*;

/**
 * A class to represent a RomanNumeral Clock.
 */
public final class RomanNumeralClock extends DigitalClock {
    private static final String clockname = "RomanNumeralClock 97";
    private static final String clocksmith = "The Java Clock Shop";
    private static String one2sixty[] = {                                          
        "",                                                            
        "I", "II", "III", "IV", "V",                                   
        "VI", "VII", "VIII", "IX", "X",                                
        "XI", "XII", "XIII", "XIV", "XV",                              
        "XVI", "XVII", "XVIII", "XIX", "XX",                           
        "XXI", "XXII", "XXIII", "XXIV", "XXV",                         
        "XXVI", "XXVII", "XXVIII", "XXIX", "XXX",                      
        "XXXI", "XXXII", "XXXIII", "XXXIV", "XXXV",                    
        "XXXVI", "XXXVII", "XXXVIII", "XXXIX", "XL",                   
        "XLI", "XLII", "XLIII", "XLIV", "XLV",                         
        "XLVI", "XLVII", "XLVIII", "XLIX", "L",                        
        "LI", "LII", "LIII", "LIV", "LV",                              
        "LVI", "LVII", "LVIII", "LIX", "LX"                            
    };
    
	public String getAppletInfo() {
		String info = clockname + " " + clocksmith;
		return info;
	}


	public String [][] getParamterInfo() {
		String info[][] = {
			{"show24Hours", "boolean", "use 24 hours format"},
			{"ForegroundColor", "String", "foreground color"},
			{"BackgroundColor", "String", "background color"},
			{"ClockFontName", "String", "font name for the clock digits"},
			{"ClockFontStyle", "String", "font style for the clock digits"},
			{"ClockFontSize", "integer", "font size for the clock digits"},
			{"ShowFrame", "boolean", "option to display the frame"},
			{"FrameStyle", "String", "various styles for the frame"},
			{"FrameThickness", "integer", "the thickness of the clock frame"},
			{"FrameColor", "String", "color for the clock frame"},
		};

		return info;
	}

	public void init() {
		super.init();
		super.showDate = false; // make sure no date
		super.clockname = this.clockname;
		super.clocksmith = this.clocksmith;
	}
   

	/**
	* Sets up the digit related values for the Digital Clock
	* Note: the colon is used to separate the hour, minute and second.
	*  We put additional space around the ':' to make it look a little better.
	*  Other variables are used to do leading '0's padding is not really needed for
	*  this clock.
	*/    
	protected void setDigitsForClock(int radix) {
		super.colon = " : ";
 
		// maxdigits = "XXX : XXXVIII : XXXVIII";
		super.maxHourlen = 3;
		super.maxMinlen = 7;
		super.maxSeclen = 7;
	}
    
   
	/**
	* Converts an integer i to string. This routine is used to
	* covert the integers representing hour (0-23), minute and second (0-59)
	* @param n must be 0 <= n < 60
	*/
	protected String i2a(int n, int len, char padch) {                  
		if (n >= 60 || n < 0) 
			return "?";

		return (one2sixty[n]);  
	}
}
