/* Copyright F. P. Marin ( April 07 13:12:53 1997 ) E-mail: felix@bloch.ciens.ucv.ve Permission to use, copy, modify and distribute this software and its documentation for NON-COMERCIAL purposes and without fee is hereby granted provided that this copyright notice appears in all copies. F. P. Marin makes no representations or warranties about the suitability of the software, either express or implied, including but no limited to the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. F. P. Marin shall not be liable for any damage suffered by license as a result of using, modifying or distributing this software or its derivatives. HTML code is */ import java.awt.Color; import java.awt.Graphics; import java.awt.Event; import java.awt.Image; import java.util.Date; public class UcvTop extends java.applet.Applet implements Runnable { final double TOHOURS=Math.PI/6.0,TOSECS=Math.PI/30.0; Date d; double x0[],x1[],y0[],y1[]; Graphics theg; Image theimg; int centerdiam,centerrad,cx,cy,diam,h,hlen,hourdashlen,m,mlen,rad,s; int slen,xh,yh,xm,ym,xs,ys; Thread ucvwatch=null; public void init() { // Set watch dimensions diam=size().height - 1; if ( (size().width -diam)<1 ) diam=size().width - 1; rad=diam/2; centerdiam=(int)Math.floor(0.026666666666666*diam + 0.5); if ( centerdiam<2 ) centerdiam=2; centerrad=centerdiam/2; hourdashlen=(int)Math.floor(0.02*diam + 0.5); if ( hourdashlen<1 ) hourdashlen=1; slen=rad - hourdashlen - 5; mlen=(int)Math.floor(0.96*slen + 0.5); hlen=(int)Math.floor(0.75*mlen + 0.5); // Set watch center cx=size().width/2; cy=size().height/2; // Set begin and end of hour dashes x0=new double[12]; x1=new double[x0.length]; y0=new double[x0.length]; y1=new double[x0.length]; double phase=0.0; for ( int i=0 ; i11 ) xh%=12; angle=TOHOURS*xh + angle/12.0; xh=cx + (int)Math.floor(hlen*Math.sin(angle) + 0.5); yh=cy + (int)Math.floor(-hlen*Math.cos(angle) + 0.5); // Repaint the actual date repaint(); // Wait one second to do it again try { Thread.sleep(1000); } catch (InterruptedException e) {} } } public void stop() { if ( ucvwatch!=null ) { ucvwatch.stop(); ucvwatch=null; } } public void draw_Watch(Graphics g) { // Draw background g.setColor(Color.white); g.fillRect(0,0,size().width,size().height); // Draw watch black circle g.setColor(Color.black); g.fillOval(cx - rad,cy - rad,diam,diam); // Draw watch small circle at the center g.setColor(Color.yellow); g.fillOval(cx - centerrad,cy - centerrad,centerdiam,centerdiam); // Draw hour dashes for ( int i=0 ; i