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 - 2009

 history
        02-Jul-2006 - rob creation
 

Author:
Robert Virkus, j2mepolish@enough.de

Field Summary
 
Fields inherited from class de.enough.polish.ui.FakeStringCustomItem
animateTextWrap, availableTextWidth, clipText, font, isHorizontalAnimationDirectionRight, isTextInitializationRequired, maxLines, maxLinesAppendix, maxLinesAppendixPosition, text, textColor, textEffect, textHorizontalAdjustment, textLayout, textLines, textVerticalAdjustment, textWidth, textWrapDirection, textWrapSpeed, useSingleLine, xOffset
 
Fields inherited from class de.enough.polish.ui.FakeCustomItem
_bbField, appearanceMode, availableHeight, availableWidth, availContentHeight, availContentWidth, background, backgroundHeight, backgroundWidth, backgroundYOffset, beforeWidth, bgBorder, border, BUTTON, cacheItemImage, colSpan, commands, completeBackground, completeBackgroundPadding, completeBorder, contentHeight, contentWidth, contentX, contentXAdjustment, contentY, contentYAdjustment, cssHeight, cssSelector, cssWidth, defaultCommand, focusedStyle, HORIZONTAL, HYPERLINK, ignoreRepaintRequests, includeLabel, INTERACTIVE, internalHeight, internalWidth, internalX, internalY, isContentVisible, isFocused, isInlineLabel, isInvisible, isLayoutCenter, isLayoutExpand, isLayoutRight, isPressed, isShown, isStyleInitialised, itemCommandListener, itemHeight, itemWidth, label, labelStyle, landscapeStyle, 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, maximumItemHeight, maximumItemWidth, maximumWidth, minimumHeight, minimumItemHeight, minimumItemWidth, minimumWidth, nativeItem, NO_POSITION_SET, opacity, opacityPaintNormally, opacityRgbData, paddingBottom, paddingHorizontal, paddingLeft, paddingRight, paddingTop, paddingVertical, parent, PLAIN, portraitStyle, preferredHeight, preferredWidth, preserveViewType, relativeX, relativeY, rowSpan, screen, setView, style, TRANSPARENT, useSingleRow, VERTICAL, view, xAdjustment, yAdjustment
 
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(String label)
          Creates a new clock.
ClockItem(String label, Style style)
          Creates a new clock.
 
Method Summary
 boolean animate()
          Animates this item.
protected  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 availWidth, int availHeight)
          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.
 String updateTime(String hours, String minutes, 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
addRepaintArea, animate, charWidth, defocus, drawString, getFont, getFontHeight, getLineHeight, getText, paintContent, releaseResources, setContentWidth, setFont, setStyle, setText, setText, setTextColor, setTextEffect, stringWidth, toString, wrap
 
Methods inherited from class de.enough.polish.ui.FakeCustomItem
addCommand, addCommand, addCommand, addCommands, addRelativeToBackgroundRegion, addRelativeToBackgroundRegion, addRelativeToContentRegion, containsCommand, destroy, fireEvent, focus, getAbsoluteX, getAbsoluteY, getAppearanceMode, getAttribute, getAttributes, getAvailableContentHeight, getAvailableContentWidth, getAvailableHeight, getAvailableWidth, getBackgroundHeight, getBackgroundWidth, getBackgroundX, getBackgroundY, getBorderWidthBottom, getBorderWidthLeft, getBorderWidthRight, getBorderWidthTop, getContentHeight, getContentWidth, getContentX, getContentY, getDefaultCommand, getFocusedStyle, getInternalHeight, getInternalWidth, getInternalX, getInternalY, getItemAreaHeight, getItemAt, getItemCommandListener, getItemCommands, getItemHeight, getItemHeight, getItemStateListener, getItemWidth, getItemWidth, getLabel, getLabelItem, getLayout, getMaximumHeight, getMaximumHeight, getMaximumWidth, getMaximumWidth, getMinContentHeight, getMinContentWidth, getMinimumHeight, getMinimumHeight, getMinimumWidth, getMinimumWidth, getNativeItem, getParent, getPrefContentHeight, getPrefContentWidth, getpreferredHeight, getpreferredWidth, getRgbData, getRgbData, getScreen, getStyle, getUiEventListener, getView, getView, handleCommand, handleCommand, handleGesture, handleGestureHold, handleGestureSwipeLeft, handleGestureSwipeRight, handleKeyPressed, handleKeyReleased, handleKeyRepeated, handlePointerDragged, handlePointerDragged, handlePointerPressed, handlePointerReleased, handlePointerTouchDown, handlePointerTouchUp, init, initLayout, initMargin, initPadding, initStyle, isFocused, isInContentArea, isInContentWithPaddingArea, isInItemArea, isInItemArea, isInitialized, isInteractive, isLayoutBottom, isLayoutCenter, isLayoutExpand, isLayoutLeft, isLayoutNewlineAfter, isLayoutNewlineBefore, isLayoutRight, isLayoutShrink, isLayoutTop, isLayoutVerticalCenter, isLayoutVerticalExpand, isLayoutVerticalShrink, isPressed, isVisible, notifyItemPressedEnd, notifyItemPressedStart, notifyStateChanged, notifyUnvisited, notifyValueChanged, notifyVisited, onScreenSizeChanged, paint, paint, paintBackground, paintBackgroundAndBorder, paintBorder, paintCommands, paintFilter, removeAttribute, removeCommand, repaintFully, requestInit, setAbsoluteY, setAppearanceMode, setAttribute, setBackground, setBorder, setContentHeight, setDefaultCommand, setDefaultCommand, setInitialized, setItemCommandListener, setItemCommandListener, setItemHeight, setItemStateListener, setItemTransition, setLabel, setLayout, setNativeItem, setParent, setParent, setpreferredSize, setStyle, setUiEventListener, setView, setVisible, show, showCommands, toImage, toRgbImage, updateInternalArea
 
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 javax.microedition.lcdui.Item
getPreferredHeight, getPreferredWidth, removeCommand, setPreferredSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClockItem

public ClockItem(String label)
Creates a new clock.

Parameters:
label - the label for the clock

ClockItem

public ClockItem(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 returns false

Overrides:
animate in class FakeCustomItem
Returns:
true when this item has been animated.
See Also:
FakeCustomItem.animate(long, ClippingRegion)

includeSeconds

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

Returns:
true when seconds should be visualized

createCssSelector

protected 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 availWidth,
                           int availHeight)
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
availWidth - the available maximum width of this item in pixels
availHeight - the available maximum height of this item in pixels
See Also:
FakeCustomItem.contentWidth, FakeCustomItem.contentHeight, FakeCustomItem.preferredWidth, FakeCustomItem.preferredHeight

updateTime

public String updateTime(String hours,
                         String minutes,
                         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 and calls hideNotify on style elements.

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 and calls showNotify on style elements.

Overrides:
showNotify in class FakeStringCustomItem