import javax.swing.*;
import java.awt.Graphics;
import java.awt.*;
import java.awt.*;
 import java.awt.event.*;
 import java.awt.geom.*;
 import javax.swing.*;
 import java.net.*;
 import java.io.*;
 import java.awt.Graphics;
 import java.util.*;
 import java.text.*;
 import java.util.Locale;

class drawstar extends Thread 
{
JPanel a;
   public drawstar(JPanel 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 analogClockP extends JPanel
{ 
  drawstar y;
  double angle1,angle2,angle3;
  Date c;
  polar p;

  public analogClockP()
  {
    //super("Analog Saat");
    c=new Date();
    // Türkiye standart (3 hour advanced than Greenwith time)
    String[] ids = TimeZone.getAvailableIDs(+3 * 60 * 60 * 1000);
    if (ids.length == 0)
       System.exit(0);
    SimpleTimeZone pdt = new SimpleTimeZone(+3 * 60 * 60 * 1000, ids[0]);
    GregorianCalendar calender=new GregorianCalendar(pdt);
    calender.setTime(c);
    p=new polar();
    setBackground(Color.white);
    angle1=-calender.get(Calendar.SECOND)/60.0*Math.PI*2;
    angle2=-calender.get(Calendar.MINUTE)/60.0*Math.PI*2;
    angle3=-((calender.get(Calendar.HOUR))%12)/12.0*Math.PI*2+angle2/12.0;
    y=new drawstar(this);
    y.start();
  }

  public void paint(Graphics g)
  {
  try{
     g.setColor(Color.yellow);
     star.fillDaire(g,200,200,170);
     g.setColor(Color.blue);
     star.fillAkrep(g,200,200,16,160,angle2,0);
     g.setColor(Color.green);
     star.fillAkrep(g,200,200,8,110,angle3,0);
     g.setColor(Color.black);
     star.fillAkrep(g,200,200,10,60,angle1,0);
     g.setColor(Color.black);
     star.drawDaire(g,200,200,165);
     star.drawDaire(g,200,200,170);
     star.drawAkrep(g,200,200,16,160,angle2,0);
     star.drawAkrep(g,200,200,8,110,angle3,0);
     star.drawYildiz1(g,200,200,10,60,angle1);
     angle1-=Math.PI/30.0;
     angle2-=Math.PI/1800.0;
     angle3-=Math.PI/21600.0;
     for(int i=0;i<12;i++)
     {
       p.polar_input(165,Math.PI*i/6);
       g.setColor(Color.magenta);
       if(i==0||i==3||i==6||i==9||i==12)
       {
       star.fillYildiz(g,(int)(p.xi()+200),(int)(200-p.xj()),3,20,0);
       g.setColor(Color.black);
       star.drawYildiz1(g,(int)(p.xi()+200),(int)(200-p.xj()),3,20,0);
       }
       else
       {
       g.setColor(Color.black);
       star.fillYildiz(g,(int)(p.xi()+200),(int)(200-p.xj()),4,10,5);
       //yildiz.drawYildiz1(g,(int)(p.xi()+200),(int)(200-p.xj()),15,10,0);

       }
     }

     }
     catch(NullPointerException e){}
  }
}