com.ibm.clock
Class DigitalDisplay

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by com.ibm.clock.DigitalDisplay
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Cloneable, javax.accessibility.Accessible

public class DigitalDisplay
extends java.awt.Canvas
implements java.io.Serializable, java.lang.Cloneable

The clock has two modes of display -- Analog and Digital. The display can be set to either analog or display. Both the display modes support a variety of customizations. The Digital Display is responsible for the Digital Rendering of the clock.

The following properties can be set on the DigitalDisplay itself.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int FULL
          Constant representing the "full" display style
static int LONG
          Constant representing the "long" display style.
static int SHORT
          Constant representing the "short" display style.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DigitalDisplay()
          The default constructor for the class Default values are displayStyle default value FULL foreGroundColor default value color.black backGroundColor default value color.lightGray numeralFont default value Dialog displayAMPM default value true twelveHourMode default value true
DigitalDisplay(int displayStyle, java.awt.Color foreGroundColor, java.awt.Color backGroundColor, java.awt.Font numeralFont, boolean displayAMPM, boolean twelveHourMode)
          The constructor with arguments
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
          Add a property change listener.
 java.awt.Color getBackGroundColor()
          Get the current Background color.
 java.awt.Image getDigitalImage()
           
 boolean getDisplayAMPM()
          Get the displayAMPM mode
 int getDisplayStyle()
          Get the current Display Style
 java.awt.Color getForeGroundColor()
          Get the current Foreground color.
 java.awt.Font getNumeralFont()
          Get the font for the numerals.
 java.awt.Dimension getPreferredSize()
          Get the Preferred Size
 boolean getTwelveHourMode()
          Get the Twelve Hour Mode
 void invalidate()
          Overridden Invalidate for double buffering purposes.
 void paint(java.awt.Graphics og)
          Repaints the bean
 void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
          Remove a property change listener.
 void setBackGroundColor(java.awt.Color newBackGroundColor)
          Set the Background color.
 void setDisplayAMPM(boolean newDisplayAMPM)
          Set the displayAMPM mode
 void setDisplayStyle(int newDisplayStyle)
          Set the current display style.
 void setForeGroundColor(java.awt.Color newForeGroundColor)
          Set the Foreground color.
 void setNumeralFont(java.awt.Font newNumeralFont)
          Set the Numeral font.
 void setTime(int hours, int minutes, int seconds)
          Set the Time
 void setTimeZone(java.util.TimeZone tz)
          Sets the current timezone
 void setTwelveHourMode(boolean newTwelveHourMode)
          Set the Twelve Hour Mode
 void update(java.awt.Graphics g)
          Overridden update for double buffering purposes.
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FULL

public static final int FULL
Constant representing the "full" display style

See Also:
Constant Field Values

LONG

public static final int LONG
Constant representing the "long" display style.

See Also:
Constant Field Values

SHORT

public static final int SHORT
Constant representing the "short" display style.

See Also:
Constant Field Values
Constructor Detail

DigitalDisplay

public DigitalDisplay()
The default constructor for the class Default values are


DigitalDisplay

public DigitalDisplay(int displayStyle,
                      java.awt.Color foreGroundColor,
                      java.awt.Color backGroundColor,
                      java.awt.Font numeralFont,
                      boolean displayAMPM,
                      boolean twelveHourMode)
The constructor with arguments

Parameters:
displayStyle - the displayStyle for the bean
foreGroundColor - the fore ground color for the bean
backGroundColor - the back ground color for the bean
numeralFont - the font for displaying the clock numerals
displayAMPM - to specify whether AMPM display is required
twelHourMode - to specify whether the twelveHourMode display is required
Method Detail

getNumeralFont

public java.awt.Font getNumeralFont()
Get the font for the numerals.

Returns:
the current font.

setNumeralFont

public void setNumeralFont(java.awt.Font newNumeralFont)
                    throws java.lang.NullPointerException
Set the Numeral font.

Parameters:
tfont - The font to be used.
Throws:
java.lang.NullPointerException - If a null argument is passed.

setTime

public void setTime(int hours,
                    int minutes,
                    int seconds)
Set the Time

Parameters:
hours - the current hour
minutes - the current minute
seconds - the current seconds

getPreferredSize

public java.awt.Dimension getPreferredSize()
Get the Preferred Size

Overrides:
getPreferredSize in class java.awt.Component
Returns:
Returns the preferred size

invalidate

public void invalidate()
Overridden Invalidate for double buffering purposes.

Overrides:
invalidate in class java.awt.Component

update

public void update(java.awt.Graphics g)
Overridden update for double buffering purposes.

Overrides:
update in class java.awt.Canvas

paint

public void paint(java.awt.Graphics og)
Repaints the bean

Overrides:
paint in class java.awt.Canvas
Parameters:
g - The graphics context

getDigitalImage

public java.awt.Image getDigitalImage()

setForeGroundColor

public void setForeGroundColor(java.awt.Color newForeGroundColor)
Set the Foreground color.

Parameters:
color - The new Foreground color.
Throws:
java.lang.IllegalArgumentException - If the argument passed is null.

setBackGroundColor

public void setBackGroundColor(java.awt.Color newBackGroundColor)
Set the Background color.

Parameters:
color - The new Background color.
Throws:
java.lang.IllegalArgumentException - If the argument passed is null.

getForeGroundColor

public java.awt.Color getForeGroundColor()
Get the current Foreground color. The default color is black.

Returns:
the current Foreground color.

getBackGroundColor

public java.awt.Color getBackGroundColor()
Get the current Background color. The default color is black.

Returns:
the current Background color.

setTwelveHourMode

public void setTwelveHourMode(boolean newTwelveHourMode)
Set the Twelve Hour Mode

Parameters:
newMode - The new Mode to be set

getTwelveHourMode

public boolean getTwelveHourMode()
Get the Twelve Hour Mode

Returns:
TwelveHour Clock Mode

setDisplayAMPM

public void setDisplayAMPM(boolean newDisplayAMPM)
Set the displayAMPM mode

Parameters:
newValue - The AMPM value to be set

getDisplayAMPM

public boolean getDisplayAMPM()
Get the displayAMPM mode

Returns:
displayAMPM mode

setDisplayStyle

public void setDisplayStyle(int newDisplayStyle)
Set the current display style. This can be one of the following : DigitalDisplay.FULL : time along with ampm and timezone DigitalDisplay.LONG : time with ampm DigitalDisplay.SHORT : time without seconds and with ampm

Parameters:
newStyle - The new display style to be used.

getDisplayStyle

public int getDisplayStyle()
Get the current Display Style

Returns:
displayStyle

setTimeZone

public void setTimeZone(java.util.TimeZone tz)
                 throws java.lang.IllegalArgumentException
Sets the current timezone

Parameters:
tz - The new timezone to be set
Throws:
java.lang.IllegalArgumentException

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
Add a property change listener.

Overrides:
addPropertyChangeListener in class java.awt.Component

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
Remove a property change listener.

Overrides:
removePropertyChangeListener in class java.awt.Component