import java.awt.*; import java.applet.*; import java.util.*; import java.io.*; import java.net.*; import java.awt.event.*; public class slidescroll extends Applet { String[] fontArray2 = {"Dialog","Helvetica","TimesRoman","Courier", "SansSerif", "Serif", "Monospaced", "DialogInput"}; String[] SStyleArray = {"PLAIN","ITALIC","BOLD", "BOLD+ITALIC", "ITALIC+BOLD"}; int[] StyleMap = {Font.PLAIN,Font.ITALIC,Font.BOLD, Font.BOLD|Font.ITALIC, Font.BOLD|Font.ITALIC}; String[] SColorArray = {"black","blue","cyan","darkGray","gray","green","lightGray", "magenta","orange","pink","red","white","yellow"}; Color[] ColorMap = {Color.black,Color.blue,Color.cyan,Color.darkGray,Color.gray, Color.green,Color.lightGray,Color.magenta,Color.orange, Color.pink,Color.red,Color.white,Color.yellow}; slidescroll_canvas nc; Color backgroundColor2; int borderPixel = 3; Color borderColor; boolean borderRaised = false; String temp; int z; Color backgroundColor; Panel p; boolean start_called = false; /** * This method is called once by the browser to initialize the applet. */ public void init() { setLayout(null); backgroundColor = getColor("backgroundColor"); if(backgroundColor == null) backgroundColor = new Color(0, 0,153); borderPixel = getNumber("borderPixel"); if(borderPixel < 0) borderPixel = 3; nc = new slidescroll_canvas(this, borderPixel, borderPixel, getBounds().width-(borderPixel*2), getBounds().height-(borderPixel*2)); add(nc); borderRaised = setBoolean("borderRaised"); backgroundColor2 = getColor("backgroundColor2"); if(backgroundColor2 == null) backgroundColor2 = new Color(0,0,153); borderColor = getColor("borderColor"); if(borderColor == null) borderColor = new Color(255,102,0); setBackground(backgroundColor); } /** * This method is called after by the browser after init() is called. */ public void start() { if(start_called) nc.init(this, borderPixel, borderPixel, getBounds().width-(borderPixel*2), getBounds().height-(borderPixel*2)); nc.setUpTree(); start_called = true; } /** * This method overrides the default update() method. The default update() always clears the screen. */ public void update(Graphics g) { paint(g); } /** * This method will paint the boarder around the applet. */ public void paint(Graphics g) { g.setColor(borderColor); for (int j = 0; j < borderPixel; j++) g.draw3DRect(j, j, getBounds().width - j * 2 - 1, getBounds().height - j * 2 - 1, borderRaised); } /** * This method will accept a string, and return the accociated int. */ int getNumber(String parm) { int num = 0; temp = getParameter(parm); if (temp == null) { return -1; } try {num = Integer.valueOf(temp).intValue();} catch (NumberFormatException e) { return -2; } return num; } /** * This method will read the param tag, and convert "yes" or "no" to a boolean value. */ boolean setBoolean(String pass) { String StringTemp = getParameter(pass); if (StringTemp == null) return true; z = StringTemp.toUpperCase().compareTo("YES"); if (z == 0) return true; else return false; } /** * This method will read the param tag and convert either the name or a color or a RGB value to a Color object. */ Color getColor(String parm) { int red = 0; int green = 0; int blue = 0; String sRed = ""; String sGreen = ""; String sBlue = ""; temp = getParameter(parm); if (temp == null ) return null; red = temp.indexOf(","); if(red > 0 ) { sRed = temp.substring(0, red); green = temp.indexOf(",", red+1); if(green < 0 ) return null; sGreen = temp.substring(red+1, green); sBlue = temp.substring(green+1, temp.length()); try {red = Integer.valueOf(sRed).intValue();} catch (NumberFormatException e) { return null; } try {green = Integer.valueOf(sGreen).intValue();} catch (NumberFormatException e) { return null; } try {blue = Integer.valueOf(sBlue).intValue();} catch (NumberFormatException e) { return null; } if( red > 255 || green > 255 || blue > 255) { return null; } return new Color(red, green, blue); } for (int i = 0; i < SColorArray.length; i++) { int z = temp.toUpperCase().compareTo(SColorArray[i].toUpperCase()); if (z == 0) return ColorMap[i]; } return null; } /** * This method will read the param tag and convert the font style to an int. */ int getStyle(String parm) { temp = getParameter(parm); if (temp == null ){ return -1; } for (int i = 0; i < SStyleArray.length; i++){ int z = temp.toUpperCase().compareTo(SStyleArray[i].toUpperCase()); if (z == 0) return i; } return -1; } /** * This method will read a param tag, and convert the Font to an int. */ int getFont(String parm) { temp = getParameter(parm); if (temp == null) return -1; for (int i = 0; i < fontArray2.length; i++) { int z = temp.toUpperCase().compareTo(fontArray2[i].toUpperCase()); if (z == 0) return i; } return -2; } public void keyReleased(KeyEvent event) {} public void keyTyped(KeyEvent event) {} }// end of class