import java.util.*; import java.awt.*; import java.applet.*; import java.net.URL; import java.net.MalformedURLException; // Radio Bergen 1998 public class DigitalClock extends Applet implements Runnable { Thread timer = null; int width, height, tz ; final int bars[]= {95,5,118,117,45,121,123,69,127,125,0}; Color CBack, CFront, CBorder; int bwidth,bsize,bspace,bdsize,between,bulletsize,startdst,sluttdst, bordersize ; int xoffset, yoffset, clockw, clockh; Color far[]; String lastdate = "00:00:00" ,today=lastdate; public void init() { int x,y; far=new Color[7]; bsize = readarg("barsize",8); bwidth = readarg("barwidth", 3 ); bspace = readarg("barspace", 1 ); bulletsize = readarg("bulletsize",(1 + bsize/4)); between = readarg("between", (1 + bsize/4) ); bordersize = readarg("bordersize", 0); startdst = readarg("dststart" ,0 ); sluttdst = readarg("dstend", 0); if (bsize<2) {bsize=2;} if (bwidth>bsize/2) {bwidth=bsize/2;} bdsize=bsize-1; CFront=colorFromString(getParameter("text"),Color.black); CBack=colorFromString(getParameter("bgcolor"),Color.lightGray); CBorder=colorFromString(getParameter("bordercolor"),Color.blue); Date dat = new Date(); tz = -dat.getTimezoneOffset(); if (((tz+1000) % 10)==9) {tz++;} String un = getParameter("tz"); if (un != null) {tz=(Integer.valueOf(un).intValue());}; tz*=60; clockw=(int) 6*bsize+bulletsize*2+12*bspace+7*between; /*=6*(bsize+bspace*2+between) + (between+bsize/4+1)*2;*/ clockh=3*bspace+2*bsize; width=size().width; height=size().height; xoffset=(width-clockw)/2; yoffset=(height-clockh)/2; calcval(); } private int readarg(String argtext, int defverdi) { String argvalue = getParameter(argtext); return( (argvalue == null) ? defverdi : (Integer.valueOf(argvalue).intValue())); } private void calcval() { String ts, tm, tt; int s, m, h; Date dat = new Date(); int tid=(int) (System.currentTimeMillis() /1000) + tz; if ((tid>=startdst)&&(tid0) { g.setColor(CBorder); g.fillRect(0,0,width,height); } g.setColor(CBack); g.fillRect(bordersize,bordersize,width-bordersize*2,height-bordersize*2); tegnny(g,false); } public boolean mouseDown(java.awt.Event evt, int x, int y) { try { URL homepage=new URL("http://members.tripod.com/~RadioBergen/tools/javaclock.pl"); getAppletContext().showDocument(homepage); } catch (MalformedURLException e){} return true; } private void tegnny(Graphics g,boolean ny) { int a, b, xh; xh = xoffset ; for(int i=0; i<8 ; i++) { a=(int) today.charAt(i) ; b=(int) lastdate.charAt(i) ; if ((a>47) && (a<58)) { if ((b!=a)|| (!ny)) { tegndigit(g,true,xh,a-48);} xh+=bsize+bspace*2+between; } else { if (!ny) { g.setColor(CFront); g.fillOval(xh+(between-bulletsize)/2,bsize*2/3+yoffset,bulletsize,bulletsize); g.fillOval(xh+(between-bulletsize)/2,bspace+bsize*4/3+yoffset,bulletsize,bulletsize); } xh+=between+bulletsize; } } lastdate = today; } private void tegndigit(Graphics g,boolean ny,int x,int val) { int y=yoffset,x0,y0,bw2; int offy=1- bwidth % 2; int x2=bspace*2+bsize-1; int y2=bspace*2+bsize+offy+y-1; int y3=y2+bspace+bsize; int y1=bspace/2+bspace+bsize+y; val=bars[val]; for(x0=0;x0<7;x0++) { far[x0]=(val>63) ? CFront : CBack; val=(val % 64)*2; } // Overste g.setColor(far[0]); for(x0=0;x0-->
Make your own free website on Tripod.com