de.enough.polish.ui
Class Ticker

java.lang.Object
  extended by de.enough.polish.ui.Item
      extended by de.enough.polish.ui.StringItem
          extended by de.enough.polish.ui.IconItem
              extended by de.enough.polish.ui.Ticker
All Implemented Interfaces:
ImageConsumer

public class Ticker
extends IconItem

Implements a "ticker-tape", a piece of text that runs continuously across the display. The direction and speed of scrolling are determined by the implementation. While animating, the ticker string scrolls continuously. That is, when the string finishes scrolling off the display, the ticker starts over at the beginning of the string.

There is no API provided for starting and stopping the ticker. The application model is that the ticker is always scrolling continuously. However, the implementation is allowed to pause the scrolling for power consumption purposes, for example, if the user doesn't interact with the device for a certain period of time. The implementation should resume scrolling the ticker when the user interacts with the device again.

The text of the ticker may contain line breaks. The complete text MUST be displayed in the ticker; line break characters should not be displayed but may be used as separators.

The same ticker may be shared by several Displayable objects ("screens"). This can be accomplished by calling setTicker() on each of them. Typical usage is for an application to place the same ticker on all of its screens. When the application switches between two screens that have the same ticker, a desirable effect is for the ticker to be displayed at the same location on the display and to continue scrolling its contents at the same position. This gives the illusion of the ticker being attached to the display instead of to each screen.

An alternative usage model is for the application to use different tickers on different sets of screens or even a different one on each screen. The ticker is an attribute of the Displayable class so that applications may implement this model without having to update the ticker to be displayed as the user switches among screens.


Supported CSS Attributes, next to any IconItem and StringItem attributes:

Since:
MIDP 1.0
See Also:
StringItem, IconItem

Field Summary
 
Fields inherited from class de.enough.polish.ui.IconItem
horizontalAdjustment, image, imageAlign, imageHeight, imageWidth, isTextVisible, relativeIconX, relativeIconY, scaleData, scaleFinished, verticalAdjustment, yAdjustText
 
Fields inherited from class de.enough.polish.ui.StringItem
animateTextWrap, bitMapFont, bitMapFontViewer, clipText, font, text, textColor, textEffect, textHorizontalAdjustment, textLines, textVerticalAdjustment, textWrapDirection, textWrapSpeed, useSingleLine, xOffset
 
Fields inherited from class de.enough.polish.ui.Item
_bbField, _bbFieldAdded, appearanceMode, background, backgroundHeight, backgroundWidth, backgroundYOffset, border, borderWidth, BUTTON, colSpan, commands, completeBackground, completeBackgroundPadding, completeBorder, 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, opacity, opacityPaintNormally, opacityRgbData, paddingBottom, paddingHorizontal, paddingLeft, paddingRight, paddingTop, paddingVertical, parent, PLAIN, preferredHeight, preferredWidth, preserveViewType, relativeX, relativeY, rowSpan, screen, style, TRANSPARENT, useSingleRow, VERTICAL, view
 
Constructor Summary
Ticker(java.lang.String str)
          Constructs a new Ticker object, given its initial contents string.
Ticker(java.lang.String str, Style style)
          Constructs a new Ticker object, given its initial contents string.
 
Method Summary
 boolean animate()
          Animates this item.
protected  java.lang.String createCssSelector()
          Retrieves the CSS selector for this item.
 java.lang.String getString()
          Retrieves the shown text of this ticker.
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.
protected  void initContent(int firstLineWidth, int lineWidth)
          Initialises this item.
 void paintContent(int x, int y, int leftBorder, int rightBorder, javax.microedition.lcdui.Graphics g)
          Paints the content of this item.
 void setString(java.lang.String text)
          Sets the ticker text
 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.
 
Methods inherited from class de.enough.polish.ui.IconItem
animate, defocus, getImage, isTextVisible, releaseResources, setImage, setImage, setImage, setImage, setImageAlign, setTextVisible, toString
 
Methods inherited from class de.enough.polish.ui.StringItem
getFont, getFontHeight, getText, setFont, setText, setText, setTextColor, stringWidth
 
Methods inherited from class de.enough.polish.ui.Item
addCommand, addCommand, addCommands, addRelativeToBackgroundRegion, addRelativeToBackgroundRegion, addRelativeToContentRegion, containsCommand, focus, getAbsoluteX, getAbsoluteY, getAppearanceMode, getAttribute, getAttributes, getBackgroundHeight, getBackgroundWidth, getBackgroundX, getBackgroundY, getContentHeight, getContentWidth, getContentX, getContentY, getDefaultCommand, getFocusedStyle, getItemAt, getItemCommandListener, getItemCommands, getItemHeight, getItemStateListener, getItemWidth, getLabel, getLabelItem, getLayout, getMinimumHeight, getMinimumWidth, getParent, getPreferredHeight, getPreferredWidth, getScreen, getStyle, handleCommand, handleKeyPressed, handleKeyReleased, handleKeyRepeated, handlePointerPressed, handlePointerReleased, init, initStyle, isInContentArea, isInItemArea, isInItemArea, isInitialized, isVisible, notifyItemPressedEnd, notifyItemPressedStart, notifyStateChanged, paint, paintBackground, paintBackgroundAndBorder, paintBorder, removeCommand, repaint, repaint, repaintFully, requestInit, setAppearanceMode, setAttribute, setDefaultCommand, setItemCommandListener, setItemCommandListener, setItemStateListener, setLabel, setLayout, setParent, setParent, setPreferredSize, setVisible, show, showCommands
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ticker

public Ticker(java.lang.String str)
Constructs a new Ticker object, given its initial contents string.

Parameters:
str - string to be set for the Ticker
Throws:
java.lang.NullPointerException - if str is null

Ticker

public Ticker(java.lang.String str,
              Style style)
Constructs a new Ticker object, given its initial contents string.

Parameters:
str - string to be set for the Ticker
style - the CSS style for this item
Throws:
java.lang.NullPointerException - if str is null
Method Detail

getString

public java.lang.String getString()
Retrieves the shown text of this ticker.

Returns:
the ticker text

setString

public void setString(java.lang.String text)
Sets the ticker text

Parameters:
text - the text that is being scrolled

initContent

protected void initContent(int firstLineWidth,
                           int lineWidth)
Description copied from class: Item
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 IconItem
Parameters:
firstLineWidth - the maximum width of the first line
lineWidth - the maximum width of any following lines
See Also:
Item.contentWidth, Item.contentHeight, Item.preferredWidth, Item.preferredHeight

paintContent

public void paintContent(int x,
                         int y,
                         int leftBorder,
                         int rightBorder,
                         javax.microedition.lcdui.Graphics g)
Description copied from class: Item
Paints the content of this item. The background has already been painted and the border will be added after this method returns.

Overrides:
paintContent in class IconItem
Parameters:
x - the left start position
y - the upper start position
leftBorder - the left border, nothing must be painted left of this position
rightBorder - the right border, nothing must be painted right of this position
g - the Graphics on which this item should be painted.

createCssSelector

protected java.lang.String createCssSelector()
Description copied from class: Item
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 IconItem
Returns:
the appropriate CSS selector for this item. The selector needs to be in lower case.

setStyle

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

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

animate

public boolean animate()
Description copied from class: Item
Animates this item. Subclasses can override this method to create animations. The default implementation returns false

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

hideNotify

protected void hideNotify()
Description copied from class: Item
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 StringItem

showNotify

protected void showNotify()
Description copied from class: Item
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 StringItem