import javax.swing.*;
import java.util.*;
import java.awt.*;
//import yildizSW;
//import polar;
import java.awt.event.*;

class yildizCiz2ThreadSWF extends Thread 
{
JFrame a;
   public yildizCiz2ThreadSWF(JFrame ai)
   {
   a=ai;
   }

   public void run()
   {
   while(true)
   {
    a.repaint();
    try {Thread.sleep(1000);}
    catch(InterruptedException e)
    {System.err.println(e.toString());}
   }
   }
} //yıldızciz2Thread sınıfının sonu

public class analogSaatSWF extends JFrame
{
  yildizCiz2ThreadSWF y;
  double aci1,aci2,aci3;
  Date c;
  polar p;

  public analogSaatSWF()
  {
    super("Analog Saat");
    c=new Date();
    // Türkiye standart (Greenwitch zamanına göre iki saat ileride)
    String[] ids = TimeZone.getAvailableIDs(+2 * 60 * 60 * 1000);
    if (ids.length == 0)
       System.exit(0);
    SimpleTimeZone pdt = new SimpleTimeZone(+2 * 60 * 60 * 1000, ids[0]);
    GregorianCalendar takvim=new GregorianCalendar(pdt);
    takvim.setTime(c);
    p=new polar();
    setBackground(renk.beyaz);
    aci1=-takvim.get(Calendar.SECOND)/60.0*Math.PI*2;
    aci2=-takvim.get(Calendar.MINUTE)/60.0*Math.PI*2;
    aci3=-((takvim.get(Calendar.HOUR))%12)/12.0*Math.PI*2+aci2/12.0;
    y=new yildizCiz2ThreadSWF(this);
    y.start();
  }

  public void paint(Graphics g)
  {
  try{
     g.setColor(renk.camgobegi);
     yildizSW.fillDaire(g,200,200,170);
     g.setColor(renk.mavi);
     yildizSW.fillAkrep(g,200,200,16,160,aci2,0);
     g.setColor(renk.yesil);
     yildizSW.fillAkrep(g,200,200,8,110,aci3,0);
     g.setColor(renk.lacivert);
     yildizSW.fillAkrep(g,200,200,10,60,aci1,0);
     g.setColor(renk.siyah);
     yildizSW.drawDaire(g,200,200,165);
     yildizSW.drawDaire(g,200,200,170);
     yildizSW.drawAkrep(g,200,200,16,160,aci2,0);
     yildizSW.drawAkrep(g,200,200,8,110,aci3,0);
     yildizSW.drawYildiz1(g,200,200,10,60,aci1);
     aci1-=Math.PI/30.0;
     aci2-=Math.PI/1800.0;
     aci3-=Math.PI/21600.0;
     for(int i=0;i<12;i++)
     {
       p.polarGir(165,Math.PI*i/6);
       g.setColor(renk.camgobegi);
       if(i==0||i==3||i==6||i==9||i==12)
       {
       yildizSW.fillYildiz(g,(int)(p.xi()+200),(int)(200-p.xj()),5,20,0);
       g.setColor(renk.siyah);
       yildizSW.drawYildiz1(g,(int)(p.xi()+200),(int)(200-p.xj()),5,20,0);
       }
       else
       {
       g.setColor(renk.lacivert);
       yildizSW.fillYildiz(g,(int)(p.xi()+200),(int)(200-p.xj()),15,10,0);
       //yildiz.drawYildiz1(g,(int)(p.xi()+200),(int)(200-p.xj()),15,10,0);

       }
     }

     }
     catch(NullPointerException e){}
  }

      public static void main(String[] args)
      {
      analogSaatSWF pencere= new analogSaatSWF();
      pencere.addWindowListener(new BasicWindowMonitor());
      pencere.setSize(400,400);
      pencere.setVisible(true);
      }
}


