de.enough.polish.ui
Class ClockItem

java.lang.Object
  extended by javax.microedition.lcdui.Item
      extended by javax.microedition.lcdui.CustomItem
          extended by de.enough.polish.ui.FakeCustomItem
              extended by de.enough.polish.ui.FakeStringCustomItem
                  extended by de.enough.polish.ui.ClockItem

public class ClockItem
extends FakeStringCustomItem

Display the current time digitally.

Copyright Enough Software 2006 - 2008

 history
        02-Jul-2006 - rob creation
 

Author:
Robert Virkus, j2mepolish@enough.de

Field Summary
 
Fields inherited from class de.enough.polish.ui.FakeStringCustomItem
bitMapFont, bitMapFontViewer, clipText, font, text, textColor, textEffect, textHorizontalAdjustment, textLines, textVerticalAdjustment, useSingleLine, xOffset
 
Fields inherited from class de.enough.polish.ui.FakeCustomItem
_bbField, _bbFieldAdded, appearanceMode, background, backgroundHeight, backgroundWidth, backgroundYOffset, border, borderWidth, BUTTON, colSpan, commands, contentHeight, contentWidth, contentX, contentY, cssSelector, defaultCommand, focusedStyle, HORIZONTAL, HYPERLINK, includeLabel, INTERACTIVE, internalHeight, internalWidth, internalX, internalY, isFocused, isInitialized, isInvisible, isLayoutCenter, isLayoutExpand, isLayoutRight, isPressed, isShown, isStyleInitialised, itemCommandListener, itemHeight, itemWidth, label, labelStyle, layout, LAYOUT_2, LAYOUT_BOTTOM, LAYOUT_CENTER, LAYOUT_DEFAULT, LAYOUT_EXPAND, LAYOUT_LEFT, LAYOUT_NEWLINE_AFTER, LAYOUT_NEWLINE_BEFORE, LAYOUT_RIGHT, LAYOUT_SHRINK, LAYOUT_TOP, LAYOUT_VCENTER, LAYOUT_VEXPAND, LAYOUT_VSHRINK, marginBottom, marginLeft, marginRight, marginTop, maximumHeight, maximumWidth, minimumHeight, minimumWidth, NO_POSITION_SET, paddingBottom, paddingHorizontal, paddingLeft, paddingRight, paddingTop, paddingVertical, parent, PLAIN, preferredHeight, preferredWidth, preserveViewType, relativeX, relativeY, rowSpan, screen, style, TRANSPARENT, VERTICAL, view
 
Fields inherited from class javax.microedition.lcdui.CustomItem
KEY_PRESS, KEY_RELEASE, KEY_REPEAT, NONE, POINTER_DRAG, POINTER_PRESS, POINTER_RELEASE, TRAVERSE_HORIZONTAL, TRAVERSE_VERTICAL
 
Constructor Summary
ClockItem(java.lang.String label)
          Creates a new clock.
ClockItem(java.lang.String label, Style style)
          Creates a new clock.
 
Method Summary
 boolean animate()
          Animates this item.
protected  java.lang.String createCssSelector()
          Retrieves the CSS selector for this item.
protected  void hideNotify()
          Called by the system to notify the item that it is now completely invisible, when it previously had been at least partially visible.
 boolean includeSeconds()
          Determines whether seconds should be appended to this clock view.
protected  void initContent(int firstLineWidth, int lineWidth)
          Initialises this item.
 void setStyle(Style style)
          Sets the style of this item.
protected  void showNotify()
          Called by the system to notify the item that it is now at least partially visible, when it previously had been completely invisible.
 java.lang.String updateTime(java.lang.String hours, java.lang.String minutes, java.lang.String seconds)
          Fills in specific formats for time - this can be adjusted using the clock-format CSS attribute.
 
Methods inherited from class de.enough.polish.ui.FakeStringCustomItem
defocus, getFont, getText, paintContent, releaseResources, setFont, setText, setText, toString
 
Methods inherited from class de.enough.polish.ui.FakeCustomItem
addCommand, addCommand, addCommands, addRelativeToBackgroundRegion, addRelativeToContentRegion, animate, containsCommand, focus, getAbsoluteX, getAbsoluteY, getAppearanceMode, getAttribute, getAttributes, getBackgroundHeight, getBackgroundWidth, getBackgroundX, getBackgroundY, getContentHeight, getContentWidth, getContentX, getContentY, getDefaultCommand, getFocusedStyle, getItemAt, getItemCommandListener, getItemHeight, getItemStateListener, getItemWidth, getLabel, getLabelItem, getLayout, getMinContentHeight, getMinContentWidth, getMinimumHeight, getMinimumWidth, getParent, getPrefContentHeight, getPrefContentWidth, getPreferredHeight, getPreferredWidth, getScreen, getStyle, handleCommand, handleKeyPressed, handleKeyReleased, handleKeyRepeated, handlePointerPressed, handlePointerReleased, init, initStyle, isInContentArea, isInItemArea, isVisible, notifyItemPressedEnd, notifyItemPressedStart, notifyStateChanged, paint, paint, paintBackground, paintBackgroundAndBorder, paintBorder, removeCommand, repaintFully, requestInit, setAppearanceMode, setAttribute, setDefaultCommand, setItemCommandListener, setItemCommandListener, setItemStateListener, setLabel, setLayout, setPreferredSize, setVisible, show, showCommands
 
Methods inherited from class javax.microedition.lcdui.CustomItem
getGameAction, getInteractionModes, invalidate, keyPressed, keyReleased, keyRepeated, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, sizeChanged, traverse, traverseOut
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClockItem

public ClockItem(java.lang.String label)
Creates a new clock.

Parameters:
label - the label for the clock

ClockItem

public ClockItem(java.lang.String label,
                 Style style)
Creates a new clock.

Parameters:
label - the label for the clock
style - the style for the clock string etc
Method Detail

animate

public boolean animate()
Description copied from class: FakeCustomItem
Animates this item. Subclasses can override this method to create animations. The default implementation animates the background and the item view if present.

Overrides:
animate in class FakeStringCustomItem
Returns:
true when this item has been animated.

includeSeconds

public boolean includeSeconds()
Determines whether seconds should be appended to this clock view.

Returns:
true when seconds should be visualized

createCssSelector

protected java.lang.String createCssSelector()
Description copied from class: FakeCustomItem
Retrieves the CSS selector for this item. The CSS selector is used for the dynamic assignment of styles - that is the styles are assigned by the usage of the item and not by a predefined style-name. With the #style preprocessing command styles are set fix, this method yields in a faster GUI and is recommended. When in a style-sheet dynamic styles are used, e.g. "Form>p", than the selector of the item is needed.
This abstract method needs only be implemented, when dynamic styles are used: #ifdef polish.useDynamicStyles
The returned selector needs to be in lower case.

Overrides:
createCssSelector in class FakeStringCustomItem
Returns:
the appropriate CSS selector for this item. The selector needs to be in lower case.

initContent

protected void initContent(int firstLineWidth,
                           int lineWidth)
Description copied from class: FakeCustomItem
Initialises this item. The implementation needs to calculate and set the contentWidth and contentHeight fields. The implementation should take the fields preferredWidth and preferredHeight into account.

Overrides:
initContent in class FakeStringCustomItem
Parameters:
firstLineWidth - the maximum width of the first line
lineWidth - the maximum width of any following lines
See Also:
FakeCustomItem.contentWidth, FakeCustomItem.contentHeight, FakeCustomItem.preferredWidth, FakeCustomItem.preferredHeight

updateTime

public java.lang.String updateTime(java.lang.String hours,
                                   java.lang.String minutes,
                                   java.lang.String seconds)
Fills in specific formats for time - this can be adjusted using the clock-format CSS attribute.

Parameters:
hours - the hours
minutes - the minutes of the time
seconds - the seconds of the time
Returns:
the time adjusted by additional formats - e.g. "hh:mm:ss"

setStyle

public void setStyle(Style style)
Description copied from class: FakeCustomItem
Sets the style of this item.

Overrides:
setStyle in class FakeStringCustomItem
Parameters:
style - the new style for this item.

hideNotify

protected void hideNotify()
Description copied from class: FakeCustomItem
Called by the system to notify the item that it is now completely invisible, when it previously had been at least partially visible. No further paint() calls will be made on this item until after a showNotify() has been called again.

The default implementation of this method sets the isShown field to false.

Overrides:
hideNotify in class FakeStringCustomItem

showNotify

protected void showNotify()
Description copied from class: FakeCustomItem
Called by the system to notify the item that it is now at least partially visible, when it previously had been completely invisible. The item may receive paint() calls after showNotify() has been called.

The default implementation of this method sets the isShown field to true.

Overrides:
showNotify in class FakeStringCustomItem