|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.ibm.clock.IClock
public class IClock
An IClock
component is a Java bean that can be used
to display a clock in an application. The clock has two modes
of display - analog and digital. In both these modes, the developer
can completely customize the look and feel of the clock. The bean
supports different time-zones. Future releases, will let the developer
set an alarm and use the bean as a stopwatch.
Usage:
The IClock
bean can be customized from within an
application builder tool or by manually writing the requisite code.
At any point, the developer can get the time shown by the clock by
calling the getTime( )
method. The developer can also
set the time for the clock by calling the setTime( )
method. Time is represented by a separate class.
The clock can be started by calling the method start()
on the clock. The clock starts with the system time adjusted to the
currently set time zone. The time can be synchronized by setting the time
through the appropriate api at runtime.
The clock can be stopped by calling the method stop()
.
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. For the customizations possible on each display see the class documentations of each class. The IClock acts as a facade for each of the properties of Analog and Digital display.
Apart from the view related customizations on each of the displays the following properties can be set on the clock itself.
All the above properties let the developer have complete control over
the appearance and behaviour of the IClock
bean. For more
information on how to set a particular property, please see the
corresponding setter method.
The following code snippet demonstrates how to use the
IClock
bean from within an application to have a
customised clock display:
... import com.ibm.clock.IClock; import com.ibm.clock.AnalogDisplay; import com.ibm.clock.DigitalDisplay; import java.awt.Color; ... // Create a new clock for the default time-zone and locale. IClock myClock = new IClock( ); // set the borderwidth of analog display to 5 myClock.setAnalogBorderWidth( 5 ); // We wish to display ticks only at the 12, 1, 2 etc. marks. myClock.setAnalogTicksStyle( AnalogDisplay.TICK_STYLE_MAJOR); // The numerals should be roman numerals. myClock.setAnalogNumeralStyle( AnalogDisplay.NUMERAL_ROMAN ); ...
Important Notes and Caveats:
Due to a bug with the current release of JDK (1.1.4), for certain
time-zones the system reports incorrect time-zone values on Windows
NT and Windows 95. This causes the clock to show the time for a time-
zone other than the actual system time-zone. The only workaround
currently available seems to be to set the time-zone explicitly by
calling the setTimeZone( )
method.
Note: In the following descriptions, fully qualified class names have been omitted for brevity. Therefore,
AnalogDisplay
stands for com.ibm.clock.AnalogDisplay
DigitalDisplay
stands for com.ibm.clock.DigitalDisplay
Color
stands for java.awt.Color
Font
stands for java.awt.Font
TimeZone
stands for java.util.TimeZone
Time
,
AnalogDisplay
,
DigitalDisplay
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
javax.swing.JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
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 |
ANALOG
Analog mode of display. |
static int |
DIGITAL
Digital mode of display. |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
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 | |
---|---|
IClock()
Default Constructor. |
Method Summary | |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
Add a property change listener. |
java.awt.Color |
getAnalogBorderColor()
Get the analog clock border color. |
int |
getAnalogBorderWidth()
Get the border width of analog display. |
java.awt.Color |
getAnalogDialColor()
Get the dial color of analog display. |
java.awt.Color |
getAnalogHourHandColor()
Get the hour hand color in analog display. |
boolean |
getAnalogHourHandVisible()
Is the analog hour hand visible ? |
java.awt.Color |
getAnalogMinuteHandColor()
Get the minute hand color of analog display. |
boolean |
getAnalogMinuteHandVisible()
Is the analog minute hand visible ? |
java.awt.Color |
getAnalogNumeralColor()
Get the numeral Color of the Analog display. |
java.awt.Font |
getAnalogNumeralFont()
Get the font for the numerals used in Analog clock. |
int |
getAnalogNumeralStyle()
Get the numeral style of the analog display. |
java.awt.Color |
getAnalogSecondHandColor()
Get the second hand color of analog display. |
boolean |
getAnalogSecondHandVisible()
Is the analog second hand visible ? |
java.awt.Color |
getAnalogTickColor()
Get the tick color of the analog display. |
int |
getAnalogTickStyle()
Get the tick style of the analog display. |
java.awt.Color |
getDigitalBackGroundColor()
Get the background color of digital display. |
boolean |
getDigitalDisplayAMPM()
Get the display AMPM mode. |
int |
getDigitalDisplayStyle()
Get the display style in digital mode. |
java.awt.Color |
getDigitalForeGroundColor()
Get foreground color of digital display. |
java.awt.Font |
getDigitalNumeralFont()
Get the numeral font of digital display. |
boolean |
getDigitalTwelveHourMode()
Get the Twelve Hour Mode |
int |
getDisplayMode()
Get the current display mode. |
java.awt.Insets |
getInsets()
Override Container getInsets() to make room for some text above the image. |
Time |
getTime()
Get the current time as shown by the clock. |
java.util.TimeZone |
getTimeZone()
Get the current time zone. |
void |
propertyChange(java.beans.PropertyChangeEvent e)
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
Remove a property change listener. |
void |
setAnalogBorderColor(java.awt.Color c)
Set the border color of analog display. |
void |
setAnalogBorderWidth(int w)
Set the border width of analog display. |
void |
setAnalogDialColor(java.awt.Color c)
Set the dial color of the analog display. |
void |
setAnalogHourHandColor(java.awt.Color c)
Set the analog hour hand color. |
void |
setAnalogHourHandVisible(boolean v)
Set the visibility of hour hand of analog display. |
void |
setAnalogMinuteHandColor(java.awt.Color c)
Set the minute hand color of analog display. |
void |
setAnalogMinuteHandVisible(boolean v)
Set the visibility of minute hand of analog display. |
void |
setAnalogNumeralColor(java.awt.Color c)
Set the numeral color of the analog display. |
void |
setAnalogNumeralFont(java.awt.Font f)
Set the numeral font to be used in the Analog display. |
void |
setAnalogNumeralStyle(int w)
Set the numeral style of the analog display. |
void |
setAnalogSecondHandColor(java.awt.Color c)
Set the second hand color of analog display. |
void |
setAnalogSecondHandVisible(boolean v)
Set the visibility of second hand of analog display. |
void |
setAnalogTickColor(java.awt.Color c)
Set the tick color of the analog display. |
void |
setAnalogTickStyle(int w)
Set the tick style of the analog display. |
void |
setDigitalBackGroundColor(java.awt.Color c)
Set the background color of digital display. |
void |
setDigitalDisplayAMPM(boolean v)
Set the displayAMPM mode |
void |
setDigitalDisplayStyle(int w)
Set the display style in digital mode. |
void |
setDigitalForeGroundColor(java.awt.Color c)
Set the foreground color of digital display. |
void |
setDigitalNumeralFont(java.awt.Font f)
Set the numeral font of digital display. |
void |
setDigitalTwelveHourMode(boolean v)
Set twelve hour mode. |
void |
setDisplayMode(int newDisplayMode)
Set the display mode. |
static void |
setInset(int vetrical,
int horizontal)
|
void |
setLayout(java.awt.LayoutManager layout)
Overrides from super class. |
void |
setTime(Time time)
Set the time. |
void |
setTimeZone(java.util.TimeZone tz)
Set the timezone. |
void |
start()
Start the clock. |
void |
stop()
Stop the clock from runnning. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int ANALOG
getDisplayMode()
,
setDisplayMode(int)
,
Constant Field Valuespublic static final int DIGITAL
getDisplayMode()
,
setDisplayMode(int)
,
Constant Field ValuesConstructor Detail |
---|
public IClock()
Method Detail |
---|
public void setLayout(java.awt.LayoutManager layout)
setLayout
in class java.awt.Container
public java.awt.Insets getInsets()
getInsets
in class javax.swing.JComponent
public static void setInset(int vetrical, int horizontal)
public void start()
public void stop() throws java.lang.SecurityException
java.lang.SecurityException
- If the current thread does not have access rights
for stopping the clock.
Note : The thread which started the clock has access rights to stop the clock.public java.util.TimeZone getTimeZone()
public void setTimeZone(java.util.TimeZone tz) throws java.lang.IllegalArgumentException
tz
- The new time zone. Cannot be null.
java.lang.IllegalArgumentException
- If a null argument is passed.public void setTime(Time time) throws java.lang.IllegalArgumentException
time
- The time to be set.
java.lang.IllegalArgumentException
- if any of the parameters is incorrect.public void propertyChange(java.beans.PropertyChangeEvent e)
propertyChange
in interface java.beans.PropertyChangeListener
public Time getTime()
public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
addPropertyChangeListener
in class java.awt.Container
public void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
removePropertyChangeListener
in class java.awt.Component
public int getDisplayMode()
public void setDisplayMode(int newDisplayMode) throws java.lang.IllegalArgumentException
IClock.ANALOG
or IClock.DIGITAL
.
newDisplayMode
- The new display mode.
java.lang.IllegalArgumentException
- If the specified argument is illegal.public java.awt.Color getAnalogBorderColor()
AnalogDisplay.getBorderColor()
public void setAnalogBorderColor(java.awt.Color c)
c
- The new color. Cannot be null.AnalogDisplay.setBorderColor(java.awt.Color)
public int getAnalogBorderWidth()
AnalogDisplay.getBorderWidth()
public void setAnalogBorderWidth(int w)
w
- The new width.AnalogDisplay.setBorderWidth(int)
public java.awt.Color getAnalogDialColor()
AnalogDisplay.getDialColor()
public void setAnalogDialColor(java.awt.Color c)
c
- The new dial color. Cannot be null.AnalogDisplay.setDialColor(java.awt.Color)
public java.awt.Color getAnalogTickColor()
AnalogDisplay.getTickColor()
public void setAnalogTickColor(java.awt.Color c)
c
- The new tick color. Cannot be null.AnalogDisplay.setTickColor(java.awt.Color)
public int getAnalogTickStyle()
AnalogDisplay.getTickStyle()
public void setAnalogTickStyle(int w)
w
- The new tick style.AnalogDisplay.setTickStyle(int)
public int getAnalogNumeralStyle()
AnalogDisplay.getNumeralStyle()
public void setAnalogNumeralStyle(int w)
w
- The new numeral style.AnalogDisplay.setNumeralStyle(int)
public java.awt.Color getAnalogNumeralColor()
AnalogDisplay.getNumeralColor()
public void setAnalogNumeralColor(java.awt.Color c)
c
- The new color.AnalogDisplay.setNumeralColor(java.awt.Color)
public java.awt.Font getAnalogNumeralFont()
AnalogDisplay.getNumeralFont()
public void setAnalogNumeralFont(java.awt.Font f)
font
- The font to be used.AnalogDisplay.setNumeralFont(java.awt.Font)
public java.awt.Color getAnalogHourHandColor()
AnalogDisplay.getHourHandColor()
public void setAnalogHourHandColor(java.awt.Color c)
c
- The new hour hand color.AnalogDisplay.setHourHandColor(java.awt.Color)
public boolean getAnalogHourHandVisible()
AnalogDisplay.isHourHandVisible()
public void setAnalogHourHandVisible(boolean v)
v
- true => visible, false otherwise.AnalogDisplay.setHourHandVisible(boolean)
public java.awt.Color getAnalogMinuteHandColor()
AnalogDisplay.getMinuteHandColor()
public void setAnalogMinuteHandColor(java.awt.Color c)
c
- The new color.AnalogDisplay.setMinuteHandColor(java.awt.Color)
public boolean getAnalogMinuteHandVisible()
AnalogDisplay.isMinuteHandVisible()
public void setAnalogMinuteHandVisible(boolean v)
v
- true => visible, false otherwise.AnalogDisplay.setMinuteHandVisible(boolean)
public java.awt.Color getAnalogSecondHandColor()
AnalogDisplay.getSecondHandColor()
public void setAnalogSecondHandColor(java.awt.Color c)
c
- The new color.AnalogDisplay.setSecondHandColor(java.awt.Color)
public boolean getAnalogSecondHandVisible()
AnalogDisplay.isSecondHandVisible()
public void setAnalogSecondHandVisible(boolean v)
v
- true => visible, false otherwise.AnalogDisplay.setSecondHandVisible(boolean)
public java.awt.Font getDigitalNumeralFont()
DigitalDisplay.getNumeralFont()
public void setDigitalNumeralFont(java.awt.Font f)
f
- The new font.DigitalDisplay.setNumeralFont(java.awt.Font)
public java.awt.Color getDigitalForeGroundColor()
DigitalDisplay.getForeGroundColor()
public void setDigitalForeGroundColor(java.awt.Color c)
c
- The new color.DigitalDisplay.setForeGroundColor(java.awt.Color)
public java.awt.Color getDigitalBackGroundColor()
DigitalDisplay.getBackGroundColor()
public void setDigitalBackGroundColor(java.awt.Color c)
c
- The new color.DigitalDisplay.setBackGroundColor(java.awt.Color)
public int getDigitalDisplayStyle()
DigitalDisplay.getDisplayStyle()
public void setDigitalDisplayStyle(int w)
w
- The new digital display style.DigitalDisplay.setDisplayStyle(int)
public boolean getDigitalDisplayAMPM()
DigitalDisplay.getDisplayAMPM()
public void setDigitalDisplayAMPM(boolean v)
v
- the new modeDigitalDisplay.setDisplayAMPM(boolean)
public boolean getDigitalTwelveHourMode()
DigitalDisplay.getTwelveHourMode()
public void setDigitalTwelveHourMode(boolean v)
v
- the new mode.DigitalDisplay.setTwelveHourMode(boolean)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |