de.enough.polish.ui
Class FakeStringCustomItem

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
Direct Known Subclasses:
AccelationInfoItem, ClockItem, FakeIconCustomItem, FakeTextFieldCustomItem, FilteredChoiceGroup

public class FakeStringCustomItem
extends FakeCustomItem

Meant for classes that want to be compatible with javax.microedition.lcdui.CustomItem for IDEs only while extending de.enough.polish.ui.StringItem in reality.

Subclasses can change the hierarchy with preprocessing like this:

 public class MyCustomItem
 //#if polish.LibraryBuild
                 extends FakeStringCustomItem
 //#else
                //# extends StringItem
 //#endif        
 

This allows subclasses to access all fields and methods of the J2ME Polish item class.

Note that this class can never be used in reality. Ever.

Since:
J2ME Polish 1.3
Author:
Robert Virkus, robert@enough.de

Field Summary
protected  BitMapFont bitMapFont
           
protected  BitMapFontViewer bitMapFontViewer
           
protected  boolean clipText
           
protected  javax.microedition.lcdui.Font font
           
protected  java.lang.String text
           
protected  int textColor
           
protected  TextEffect textEffect
           
protected  int textHorizontalAdjustment
           
protected  java.lang.String[] textLines
           
protected  int textVerticalAdjustment
           
protected  boolean useSingleLine
           
protected  int 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
FakeStringCustomItem(java.lang.String label, java.lang.String text)
          Creates a new StringItem object.
FakeStringCustomItem(java.lang.String label, java.lang.String text, int appearanceMode)
          Creates a new StringItem object with the given label, textual content, and appearance mode.
FakeStringCustomItem(java.lang.String label, java.lang.String text, int appearanceMode, Style style)
          Creates a new StringItem object with the given label, textual content, and appearance mode.
FakeStringCustomItem(java.lang.String label, java.lang.String text, Style style)
          Creates a new StringItem object.
 
Method Summary
 boolean animate()
          Animates this item.
protected  java.lang.String createCssSelector()
          Retrieves the CSS selector for this item.
protected  void defocus(Style originalStyle)
          Removes the focus from this item.
 javax.microedition.lcdui.Font getFont()
          Gets the application's preferred font for rendering this StringItem.
 java.lang.String getText()
          Gets the text contents of the StringItem, or null if the StringItem is empty.
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 releaseResources()
          Releases all (memory intensive) resources such as images or RGB arrays of this item.
 void setFont(javax.microedition.lcdui.Font font)
          Sets the application's preferred font for rendering this StringItem.
 void setStyle(Style style)
          Sets the style of this item.
 void setText(java.lang.String text)
          Sets the text contents of the StringItem.
 void setText(java.lang.String text, Style style)
          Sets the text contents of the StringItem along with a style.
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 toString()
          Generates a String representation of this item.
 
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
 

Field Detail

text

protected java.lang.String text

textLines

protected java.lang.String[] textLines

textColor

protected int textColor

font

protected javax.microedition.lcdui.Font font

bitMapFont

protected BitMapFont bitMapFont

bitMapFontViewer

protected BitMapFontViewer bitMapFontViewer

useSingleLine

protected boolean useSingleLine

clipText

protected boolean clipText

xOffset

protected int xOffset

textHorizontalAdjustment

protected int textHorizontalAdjustment

textVerticalAdjustment

protected int textVerticalAdjustment

textEffect

protected TextEffect textEffect
Constructor Detail

FakeStringCustomItem

public FakeStringCustomItem(java.lang.String label,
                            java.lang.String text)
Creates a new StringItem object. Calling this constructor is equivalent to calling

 StringItem(label, text, Item.PLAIN, null);     
 

Parameters:
label - the Item label
text - the text contents
See Also:
StringItem.StringItem(String, String, int, Style)

FakeStringCustomItem

public FakeStringCustomItem(java.lang.String label,
                            java.lang.String text,
                            Style style)
Creates a new StringItem object. Calling this constructor is equivalent to calling

 StringItem(label, text, Item.PLAIN, style);     
 

Parameters:
label - the Item label
text - the text contents
style - the style
See Also:
StringItem.StringItem(String, String, int, Style)

FakeStringCustomItem

public FakeStringCustomItem(java.lang.String label,
                            java.lang.String text,
                            int appearanceMode)
Creates a new StringItem object with the given label, textual content, and appearance mode. Either label or text may be present or null.

The appearanceMode parameter (see Appearance Modes) is a hint to the platform of the application's intended use for this StringItem. To provide hyperlink- or button-like behavior, the application should associate a default Command with this StringItem and add an ItemCommandListener to this StringItem.

Here is an example showing the use of a StringItem as a button:


 StringItem strItem = new StringItem("Default: ", "Set", Item.BUTTON);
 strItem.setDefaultCommand(
 new Command("Set", Command.ITEM, 1);
 // icl is ItemCommandListener
 strItem.setItemCommandListener(icl);     
 

Parameters:
label - the StringItem's label, or null if no label
text - the StringItem's text contents, or null if the contents are initially empty
appearanceMode - the appearance mode of the StringItem, one of Item.PLAIN, Item.HYPERLINK, or Item.BUTTON
Throws:
java.lang.IllegalArgumentException - if appearanceMode invalid
Since:
MIDP 2.0

FakeStringCustomItem

public FakeStringCustomItem(java.lang.String label,
                            java.lang.String text,
                            int appearanceMode,
                            Style style)
Creates a new StringItem object with the given label, textual content, and appearance mode. Either label or text may be present or null.

The appearanceMode parameter (see Appearance Modes) is a hint to the platform of the application's intended use for this StringItem. To provide hyperlink- or button-like behavior, the application should associate a default Command with this StringItem and add an ItemCommandListener to this StringItem.

Here is an example showing the use of a StringItem as a button:


 StringItem strItem = new StringItem("Default: ", "Set", Item.BUTTON);
 strItem.setDefaultCommand(
 new Command("Set", Command.ITEM, 1);
 // icl is ItemCommandListener
 strItem.setItemCommandListener(icl);     
 

Parameters:
label - the StringItem's label, or null if no label
text - the StringItem's text contents, or null if the contents are initially empty
appearanceMode - the appearance mode of the StringItem, one of Item.PLAIN, Item.HYPERLINK, or Item.BUTTON
style - the style for this item
Throws:
java.lang.IllegalArgumentException - if appearanceMode invalid
Since:
MIDP 2.0
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 FakeCustomItem
Returns:
true when this item has been animated.

defocus

protected void defocus(Style originalStyle)
Description copied from class: FakeCustomItem
Removes the focus from this item.

Overrides:
defocus in class FakeCustomItem
Parameters:
originalStyle - the original style which will be restored.

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 FakeCustomItem

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 FakeCustomItem

getText

public java.lang.String getText()
Gets the text contents of the StringItem, or null if the StringItem is empty.

Returns:
a string with the content of the item
See Also:
setText(java.lang.String)

setText

public void setText(java.lang.String text)
Sets the text contents of the StringItem. If text is null, the StringItem is set to be empty.

Parameters:
text - the new content
See Also:
getText()

setText

public void setText(java.lang.String text,
                    Style style)
Sets the text contents of the StringItem along with a style. If text is null, the StringItem is set to be empty.

Parameters:
text - the new content
style - the new style, is ignored when null
See Also:
getText()

setFont

public void setFont(javax.microedition.lcdui.Font font)
Sets the application's preferred font for rendering this StringItem. The font is a hint, and the implementation may disregard the application's preferred font.

The font parameter must be a valid Font object or null. If the font parameter is null, the implementation must use its default font to render the StringItem.

Parameters:
font - - the preferred font to use to render this StringItem
Since:
MIDP 2.0
See Also:
getFont()

getFont

public javax.microedition.lcdui.Font getFont()
Gets the application's preferred font for rendering this StringItem. The value returned is the font that had been set by the application, even if that value had been disregarded by the implementation. If no font had been set by the application, or if the application explicitly set the font to null, the value is the default font chosen by the implementation.

Returns:
the preferred font to use to render this StringItem
Since:
MIDP 2.0
See Also:
setFont(javax.microedition.lcdui.Font)

paintContent

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

Specified by:
paintContent in class FakeCustomItem
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.

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.

Specified by:
initContent in class FakeCustomItem
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

setStyle

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

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

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.

Specified by:
createCssSelector in class FakeCustomItem
Returns:
the appropriate CSS selector for this item. The selector needs to be in lower case.

toString

public java.lang.String toString()
Description copied from class: FakeCustomItem
Generates a String representation of this item. This method is only implemented when the logging framework is active or the preprocessing variable "polish.keepToString" is set to true.

Overrides:
toString in class FakeCustomItem
Returns:
a String representation of this item.

releaseResources

public void releaseResources()
Description copied from class: FakeCustomItem
Releases all (memory intensive) resources such as images or RGB arrays of this item. The default implementation releases any background resources.

Overrides:
releaseResources in class FakeCustomItem