UNB/ CS/ David Bremner/ teaching/ java/ Phoenix.java
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;

public class Phoenix extends Applet
{  public void paint(Graphics g)
   {  Graphics2D g2 = (Graphics2D)g;
   
      month = 0;
      units = new UnitConverter(0, 12, 0, 40, 
               getWidth(), getHeight());       

      final int JAN_TEMP = 11;
      final int FEB_TEMP = 13;
      final int MAR_TEMP = 16;
      final int APR_TEMP = 20;
      final int MAY_TEMP = 25;      
      final int JUN_TEMP = 31;
      final int JUL_TEMP = 33;
      final int AUG_TEMP = 32;
      final int SEP_TEMP = 29;
      final int OCT_TEMP = 23;
      final int NOV_TEMP = 16;
      final int DEC_TEMP = 12;

      drawBar(g2, JAN_TEMP);
      drawBar(g2, FEB_TEMP);
      drawBar(g2, MAR_TEMP);
      drawBar(g2, APR_TEMP);
      drawBar(g2, MAY_TEMP);
      drawBar(g2, JUN_TEMP);
      drawBar(g2, JUL_TEMP);
      drawBar(g2, AUG_TEMP);
      drawBar(g2, SEP_TEMP);
      drawBar(g2, OCT_TEMP);
      drawBar(g2, NOV_TEMP);
      drawBar(g2, DEC_TEMP);
   }
   
   public void drawBar(Graphics2D g2, int temperature)
   {  // construct rectangle for this month and temperature

      Rectangle rect 
         = new Rectangle(month, 0, 1, temperature);
         
      // convert to pixel coordinates and draw         

      units.convert(rect);
      g2.draw(rect);
      
      month++;
   }
   
   private int month;
   private UnitConverter units;
}