All pastes #934272 Raw Edit

Untitled

public text v1 · immutable
·published 2008-03-08 19:02 UTC
rendered paste body
// The "Clock" class.
import java.awt.*;
import hsa.Console;

public class Clock5test
{
    static Console c;           // The output console

    public static void main (String[] args) throws Exception
    {

        c = new Console ();

        int maxy = c.getHeight ();
        int maxx = c.getWidth ();
        c.drawRect (100, 15, 480, 480);
        c.drawOval (100, 15, 480, 482);
        c.drawLine (340, 495, 340, 15); // y-axis
        c.drawLine (100, 258, 580, 258); // x-axis

        c.drawString ("12", 335, 50);
        c.drawString ("3", 550, 258);
        c.drawString ("6", 338, 470);
        c.drawString ("9", 120, 258);

        c.drawLine (340, 258, 461, 48); // LINE AT 1 MIN.
        c.drawString ("1", 445, 78);
        c.drawLine (340, 258, 550, 137); // LINE AT 2 MIN.
        c.drawString ("2", 520, 155);
        c.drawLine (340, 258, 547, 378); // LINE AT 4 MIN.
        c.drawString ("4", 527, 373);
        c.drawLine (340, 258, 460, 464); // LINE AT 5 MIN.
        c.drawString ("5", 445, 450);
        c.drawLine (340, 258, 222, 465); // LINE AT 7 MIN.
        c.drawString ("7", 227, 455);
        c.drawLine (340, 258, 133, 377); // LINE AT 8 MIN.
        c.drawString ("8", 150, 372);
        c.drawLine (340, 258, 130, 137); // LINE AT 10 MIN.
        c.drawString ("10", 150, 155);
        c.drawLine (340, 258, 219, 48); // LINE AT 11 MIN.
        c.drawString ("11", 230, 80);

        for (double l = 0 ; l <= 6.28 ; l += 0.1046)
        {
            for (double i = l + 0 ; i <= 6.28 ; i += 0.1046)
            {
                double n = (258 - Math.cos (0.1046 + i) * 240);
                int y = (int) n;

                double m = (340 + Math.sin (0.1046 + i) * 240);
                int x = (int) m;
                c.setColor (Color.black);
                c.drawLine (340, 258, x, y);

                Thread.sleep (10); //1000 millisecs
                c.setColor (Color.white);
                c.drawLine (340, 258, x, y);
            }
            double n = (258 - Math.cos (0.1046 + l) * 240);
            int y = (int) n;

            double m = (340 + Math.sin (0.1046 + l) * 240);
            int x = (int) m;
            c.setColor (Color.red);
            c.drawLine (340, 258, x, y);
            /*      c.clear ();
                  try
                  {
                      Thread.sleep (10); //1000 millisecs
                  }
                  catch (Exception E)
                  {
                  }
            c.setColor(Color.white);
            c.drawLine(340,258,x,y);
            */
        }

    } // main method
} // Clock class