uk.co.keang.gui
Class AnalogueClockPainter

java.lang.Object
  extended by uk.co.keang.gui.AnalogueClockPainter

 class AnalogueClockPainter
extends java.lang.Object

Paints an analogue clock face and hands using the graphics object provided by another component.

Version:
1.0, 12/09/2006
Author:
A.G.Docherty

Constructor Summary
AnalogueClockPainter()
          Constructs a default clock painter for this time zone
AnalogueClockPainter(java.util.TimeZone timezone)
          Constructs a clock painter for the given time zone
 
Method Summary
 void paint(java.awt.Graphics g)
          Paint the clock, repainting everything, not just what changed since the last call to paint.
 void setExternalTickColor(java.awt.Color[] c)
          Set the colors for the external ticks.
 void setExternalTicks(long[] times)
          Set the times of the ticks to show on the exterior of the rim.
 void setExternalTicksEnabled(boolean enable)
           
 void setFaceColor(java.awt.Color c)
          Set the color for the dial's face.
 void setFontMetrics(java.awt.FontMetrics fm)
          Set the font for the numbers
 void setHandsColor(java.awt.Color c)
          Set the color of the minute and hour hand
 void setNumbersEnabled(boolean state)
          Turn display of clock face numbers on or off.
 void setRadius(int rad)
          Set the radius of this analogue clock face
 void setRimColor(java.awt.Color c)
          Set the color for the dial's rim.
 void setSecondsEnabled(boolean state)
          Turn display of seconds and seconds hand on or off.
 void setTextColor(java.awt.Color c)
          Set the color for the text and the seconds hand.
 void setTime(java.util.Date d)
          Set the clock to a certain time.
 void setTimeZone(java.util.TimeZone tz)
          Set the clock to a certain time zone.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnalogueClockPainter

public AnalogueClockPainter()
Constructs a default clock painter for this time zone


AnalogueClockPainter

public AnalogueClockPainter(java.util.TimeZone timezone)
Constructs a clock painter for the given time zone

Parameters:
timezone - - the timezone to use
Method Detail

setRadius

public void setRadius(int rad)
Set the radius of this analogue clock face

Parameters:
rad - - the radius in pixels

setExternalTicks

public void setExternalTicks(long[] times)
Set the times of the ticks to show on the exterior of the rim.

Parameters:
times - - an array of times in seconds denoting the position of a tick

setSecondsEnabled

public void setSecondsEnabled(boolean state)
Turn display of seconds and seconds hand on or off.

Parameters:
state - - true to show seconds hand

setNumbersEnabled

public void setNumbersEnabled(boolean state)
Turn display of clock face numbers on or off.

Parameters:
state - - true to show clock face numbers 1 to 12

setTimeZone

public void setTimeZone(java.util.TimeZone tz)
Set the clock to a certain time zone. Example call:
 clock.setTimeZone(TimeZone.getTimeZone(tz));
 

Parameters:
tz - the time zone

setTime

public void setTime(java.util.Date d)
Set the clock to a certain time.

Parameters:
d - the time to display

setFontMetrics

public void setFontMetrics(java.awt.FontMetrics fm)
Set the font for the numbers

Parameters:
f - the font to use

setHandsColor

public void setHandsColor(java.awt.Color c)
Set the color of the minute and hour hand

Parameters:
c - - the color for the clock hands

setTextColor

public void setTextColor(java.awt.Color c)
Set the color for the text and the seconds hand.

Parameters:
c - - the color for the text and the seconds hand

setFaceColor

public void setFaceColor(java.awt.Color c)
Set the color for the dial's face.

Parameters:
c - - the color of the dial or null for a transparent face

setRimColor

public void setRimColor(java.awt.Color c)
Set the color for the dial's rim.

Parameters:
c - - the color of the rim or null for no rim

setExternalTickColor

public void setExternalTickColor(java.awt.Color[] c)
Set the colors for the external ticks. The first element of the array is used first and if lines are drawn over the same line subsequent colours are used until the last colour is reached. The array can be any length

Parameters:
c - - the colors of the external ticks

paint

public void paint(java.awt.Graphics g)
Paint the clock, repainting everything, not just what changed since the last call to paint.


setExternalTicksEnabled

public void setExternalTicksEnabled(boolean enable)