import java.util.*; import java.applet.*; import java.awt.*; public class LevelApplet extends Applet { public void init() { String w = getParameter("width"); // System.out.println("Width is " + w); if(w != null) { width = Integer.parseInt(w); // System.out.println("Width = " + width); } String h = getParameter("height"); // System.out.println("Height is " + h); if(h != null) { height = Integer.parseInt(h); // System.out.println("Height = " + height); } _color_map = new ColorMap(); String color = getParameter("color"); _the_color = _color_map.getColorParameter(color, Color.blue); String level_str = getParameter("level"); if(level_str != null) { _level = Integer.parseInt(level_str); } } public void paint(Graphics g) { // System.out.println("W= " + width); // System.out.println("H = " + height); g.setColor(_the_color); g.drawRect(0, 0, width - 1 , height - 1); float _factor = (100 - _level)/100; int yval = (int) (_factor * height); int ywidth = (int) (_level * height/100); g.fillRect(0 , yval, width, ywidth); } public void setlevel(int level) { _level = level; repaint(0, 0, width, height); } public int getlevel() { return (int) _level; } int width = 200; int height= 300; ColorMap _color_map; Color _the_color; float _level = 100; }