// Chart class for 24 hour analysis



        import java.awt.*;



        public class chart

        {

        protected int nbars;     // defines number of bars in chart

        protected float Tmp[];

        protected Color background, foreground;

        int u,y,i,max, n;

        float xbar1;





        public chart (float Tmpvals[], int n)   // constructor

        {



        nbars = n;

        Tmp = new float[nbars];

        for (int i=0; i<nbars; i++)

        Tmp[i] = Tmpvals[i];

        background = Color.white;

        foreground = Color.blue;

        }



        private int toRasters(float number,float scale)

        {

        return Math.round(number*scale);

        }



        public float getMin ()

        {

        if (nbars <= 0) return 0;

        // determine minimum value

        float min = Tmp[0];

        for (int i=1; i<nbars; i++)

        if (Tmp[i] < min) min = Tmp[i];



        return (min);

        }



        public float getMax ()

        {

        if (nbars <= 0) return 0;

        // determine max value

        float max = Tmp[0];

        for (int i=1; i<nbars; i++)

        if (Tmp[i] > max) max = Tmp[i];

        return (max);

        }



        public void setColors (Color newbackground, Color newforeground)

        {

        background = newbackground;

        foreground = newforeground;

        }





        //function to setT[];



        public void setTmp(float T[])

        {

        for(int i = 0; i<nbars; i++)

        Tmp[i] = T[i];

        //repaint();

        }



        public void paint (Graphics g, int x, int y, int width, int height)

        {

         g.setColor (background);

         g.fillRect (x,y-height,width,height);

         if (nbars > 0)  // draw bars

         {

            // determine scale

            float scaleY = (float)(height)/getMax();

            //float scaleY = (float)(height-10)/getMax();

            int barWidth = (width)/nbars;

            int xbar = x+5;

            for (int i=0; i<nbars; i++)



           {

              int barHeight = (int)(scaleY*Tmp[i]);

              Math.abs(barHeight);



              g.setColor (Color.gray);

              barHeight=Math.abs(barHeight);

              g.fillRect (xbar,y-barHeight,barWidth,barHeight);

              g.setColor (Color.black);

              g.drawRect (xbar,y-barHeight,barWidth,barHeight);



              //I cancelled the option to draw values on top because of mess

              //g.drawString(String.valueOf((int)Tmp[i]),xbar,y/12);



              xbar = xbar + barWidth;

              }



              getMax ();



              //the top line

              g.drawString(String.valueOf((float)(Tmp[15])),2,y/15);

              //the higher quarter line

              g.drawString(String.valueOf((float)(Tmp[15]/4)*3),2,y/4);

              //the middle line

              g.drawString(String.valueOf((float)(Tmp[15])/2),2,(y/2));

              //the bottom quarter line

               g.drawString(String.valueOf((float)(Tmp[15])/4),2,(y-y/4));





              g.drawString ("(Deg C)",2,y/6);

              g.drawString ("0 C",2,y*24/25+10);



              }

            }

          }

