content:  /*
   * DigitalMeter.java
   * Created by John Melton G0ORX
   * Created on 02-Feb-2010, 14:08:40
   */
  
  /*
   * This code has been and reviewed modified.
   * John Tucker, N8MDP
   */
  
  /*
   * Revsion History
   * 01/20/13: No Change
   * 
   */
  
  package jmonitor;
  
  public class DigitalMeter extends javax.swing.JPanel {
  
      /** Creates new form DigitalMeter */
      public DigitalMeter() {
          initComponents();
      }
  
      protected void paintComponent(java.awt.Graphics g) {
          g.setColor(java.awt.Color.BLACK);
          g.fillRect(0,0,this.getWidth(),this.getHeight());
          if(dbm>54) {
              g.setColor(java.awt.Color.GREEN);
              g.fillRect(0,0,54,this.getHeight());
              g.setColor(java.awt.Color.RED);
              g.fillRect(54,0,dbm-54,this.getHeight());
          } else {
              g.setColor(java.awt.Color.GREEN);
              g.fillRect(0,0,dbm,this.getHeight());
          }
          g.setColor(java.awt.Color.YELLOW);
          g.drawLine(max,0,max,this.getHeight());
  
          g.setColor(java.awt.Color.WHITE);
  
              g.drawString("3",18-4,18);
              g.drawString("6",36-4,18);
              g.drawString("9",54-4,18);
              g.drawString("+20",74-8,18);
              g.drawString("+60",114-8,18);
  
              g.drawLine(0,0,0,5);    //0
              g.drawLine(6,0,6,5);    //1
              g.drawLine(12,0,12,5);  //2
              g.drawLine(18,0,18,7);  //3
              g.drawLine(24,0,24,5);  //4
              g.drawLine(30,0,30,5);  //5
              g.drawLine(36,0,36,7);  //6
              g.drawLine(42,0,42,5);  //7
              g.drawLine(48,0,48,5);//8
              g.drawLine(54,0,54,7);//9
              g.drawLine(74,0,74,7);//+20
              g.drawLine(94,0,94,5);//+40
              g.drawLine(114,0,114,7);//+60
  
      }
  
      public void update(int dbm) {
          this.dbm=dbm+121;
  
          if(this.dbm<0) this.dbm=0;
  
          count++;
          if(count==10) {
              max=this.dbm;
              count=0;
          } else if(this.dbm>max) {
              max=this.dbm;
          }
  
          this.repaint(new java.awt.Rectangle(getWidth(),getHeight()));
      }
  
      /** This method is called from within the constructor to
       * initialize the form.
       * WARNING: Do NOT modify this code. The content of this method is
       * always regenerated by the Form Editor.
       */
      @SuppressWarnings("unchecked")
      // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
      private void initComponents() {
  
          setMaximumSize(new java.awt.Dimension(90, 23));
          setMinimumSize(new java.awt.Dimension(90, 23));
          setPreferredSize(new java.awt.Dimension(90, 23));
  
          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
          this.setLayout(layout);
          layout.setHorizontalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGap(0, 173, Short.MAX_VALUE)
          );
          layout.setVerticalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGap(0, 23, Short.MAX_VALUE)
          );
      }// </editor-fold>//GEN-END:initComponents
  
  
      // Variables declaration - do not modify//GEN-BEGIN:variables
      // End of variables declaration//GEN-END:variables
  
      private int dbm = 121;
      private int max = 0;
      private int count = 0;
  }
  