home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 October / PCO1097.ISO / FilesBBS / FREI / DIGSIM.EXE / StatusPanel.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-05-21  |  2.4 KB  |  79 lines

  1. import java.awt.BorderLayout;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Dimension;
  6. import java.awt.Font;
  7. import java.awt.FontMetrics;
  8. import java.awt.Graphics;
  9. import java.awt.Panel;
  10.  
  11. class StatusPanel extends Panel {
  12.    DigSim applet;
  13.    public static final int STATUSPANEL_HEIGHT = 20;
  14.    protected Font StatusFont;
  15.    protected FontMetrics StatusFontMetrics;
  16.    protected static final Color BackGroundColor;
  17.    protected static final Color TextColor;
  18.    protected String ActMessage = "Please wait";
  19.    protected static final int STATUSLEDS_WIDTH = 20;
  20.    boolean SimulationInitializeInProgress = false;
  21.    boolean SimulationRunning = false;
  22.    boolean StatusLedOn = false;
  23.  
  24.    public StatusPanel(DigSim var1) {
  25.       this.applet = var1;
  26.       ((Container)this).setLayout(new BorderLayout());
  27.       this.StatusFont = new Font("TimesRoman", 0, 12);
  28.       ((Component)this).setFont(this.StatusFont);
  29.       this.StatusFontMetrics = ((Component)this).getFontMetrics(this.StatusFont);
  30.       ((Component)this).repaint();
  31.    }
  32.  
  33.    public boolean SimulateRunning() {
  34.       return this.SimulationRunning | this.SimulationInitializeInProgress;
  35.    }
  36.  
  37.    public Dimension preferredSize() {
  38.       int var1 = this.applet.size().width;
  39.       byte var2 = 20;
  40.       return new Dimension(var1, var2);
  41.    }
  42.  
  43.    public void DrawStatusLED(Graphics var1) {
  44.       this.StatusLedOn = !this.StatusLedOn;
  45.       int var2 = ((Component)this).size().width - 20;
  46.       if (this.SimulationRunning && this.StatusLedOn) {
  47.          var1.setColor(Color.green);
  48.       } else if (this.SimulationInitializeInProgress && this.StatusLedOn) {
  49.          var1.setColor(Color.red);
  50.       } else {
  51.          var1.setColor(Color.gray);
  52.       }
  53.  
  54.       var1.fillOval(var2 + 3, 3, 15, 15);
  55.    }
  56.  
  57.    public void paint(Graphics var1) {
  58.       var1.setColor(BackGroundColor);
  59.       var1.fillRect(0, 0, ((Component)this).size().width - 20, 20);
  60.       var1.setColor(TextColor);
  61.       var1.drawString(this.ActMessage, 2, this.StatusFontMetrics.getHeight() - 2);
  62.       var1.setColor(Color.black);
  63.       var1.fillRect(((Component)this).size().width - 20, 0, 20, 20);
  64.       var1.setColor(BackGroundColor);
  65.       var1.drawRect(((Component)this).size().width - 20, 0, 20, 20);
  66.       this.DrawStatusLED(var1);
  67.    }
  68.  
  69.    public void StatusMessage(String var1) {
  70.       this.ActMessage = var1;
  71.       ((Component)this).repaint();
  72.    }
  73.  
  74.    static {
  75.       BackGroundColor = Color.green;
  76.       TextColor = Color.black;
  77.    }
  78. }
  79.