de.enough.polish.ui
Class FakeIconCustomItem

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.FakeIconCustomItem
All Implemented Interfaces:
ImageConsumer
Direct Known Subclasses:
IconCustomItem

public class FakeIconCustomItem
extends FakeStringCustomItem
implements ImageConsumer

Shows a string with an optional image attached to it.

The dynamic CSS selector of the IconItem is "icon".

Following CSS attributes can be set:

Copyright Enough Software 2004 - 2008

 history
        04-Apr-2004 - rob creation
 

Author:
Robert Virkus, robert@enough.de

Field Summary
protected  boolean isTextVisible
           
 
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
FakeIconCustomItem(java.lang.String text, javax.microedition.lcdui.Image image)
          Creates a new icon.
FakeIconCustomItem(java.lang.String text, javax.microedition.lcdui.Image image, Style style)
          Creates a new icon.
FakeIconCustomItem(java.lang.String label, java.lang.String text, javax.microedition.lcdui.Image image, Style style)
          Creates a new icon.
 
Method Summary
 void animate(long currentTime, ClippingRegion repaintRegion)
          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.Image getImage()
          Retrieves the image of this item.
protected  void initContent(int firstLineWidth, int lineWidth)
          Initialises this item.
 boolean isTextVisible()
          Determines if the text of this icon item is visible
 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 setImage(javax.microedition.lcdui.Image image)
          Sets the image for this icon.
 void setImage(javax.microedition.lcdui.Image img, Style style)
          Sets the image for this icon.
 void setImage(java.lang.String url)
          Loads the specified image.
 void setImage(java.lang.String name, javax.microedition.lcdui.Image image)
          sets the image which has been loaded in the background.
 void setImageAlign(int imageAlign)
          Sets the image align for this icon.
 void setStyle(Style style)
          Sets the style of this item.
 void setTextVisible(boolean isTextVisible)
          Toggles the visibility of this icon's text
 java.lang.String toString()
          Generates a String representation of this item.
 
Methods inherited from class de.enough.polish.ui.FakeStringCustomItem
animate, getFont, getText, hideNotify, setFont, setText, setText, showNotify
 
Methods inherited from class de.enough.polish.ui.FakeCustomItem
addCommand, addCommand, addCommands, addRelativeToBackgroundRegion, addRelativeToContentRegion, 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

isTextVisible

protected boolean isTextVisible
Constructor Detail

FakeIconCustomItem

public FakeIconCustomItem(java.lang.String text,
                          javax.microedition.lcdui.Image image)
Creates a new icon.

Parameters:
text - the text of this item
image - the image of this item, null when no image should be displayed

FakeIconCustomItem

public FakeIconCustomItem(java.lang.String text,
                          javax.microedition.lcdui.Image image,
                          Style style)
Creates a new icon.

Parameters:
text - the text of this item
image - the image of this item, null when no image should be displayed
style - the style of this item

FakeIconCustomItem

public FakeIconCustomItem(java.lang.String label,
                          java.lang.String text,
                          javax.microedition.lcdui.Image image,
                          Style style)
Creates a new icon.

Parameters:
label - the label of this item
text - the text of this item
image - the image of this item, null when no image should be displayed
style - the style of this item
Method Detail

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

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.

Overrides:
paintContent in class FakeStringCustomItem
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.

getImage

public javax.microedition.lcdui.Image getImage()
Retrieves the image of this item.

Returns:
the image of this icon.

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.

setImage

public void setImage(java.lang.String url)
Loads the specified image.

Parameters:
url - the local URL of the image

setImage

public void setImage(java.lang.String name,
                     javax.microedition.lcdui.Image image)
Description copied from interface: ImageConsumer
sets the image which has been loaded in the background.

Specified by:
setImage in interface ImageConsumer
Parameters:
name - the name of the image. This allows the image-consumer to differentiate between several images.
image - the image which was loaded in the background thread.

setImage

public void setImage(javax.microedition.lcdui.Image image)
Sets the image for this icon.

Parameters:
image - the image for this icon, when null is given, no image is painted.

setImage

public void setImage(javax.microedition.lcdui.Image img,
                     Style style)
Sets the image for this icon.

Parameters:
img - the image for this icon, when null is given, no image is painted.
style - the new style of this item, is ignored when null

setImageAlign

public void setImageAlign(int imageAlign)
Sets the image align for this icon.

Parameters:
imageAlign - either Graphics.TOP, Graphics.LEFT, Graphics.BOTTOM or Graphics.RIGHT

animate

public void animate(long currentTime,
                    ClippingRegion repaintRegion)
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
Parameters:
currentTime - the current time in milliseconds
repaintRegion - the repaint area that needs to be updated when this item is animated
See Also:
#addRelativeRegion(ClippingRegion, int, int, int, int)

defocus

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

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

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 FakeStringCustomItem
Returns:
a String representation of this item.

releaseResources

public void releaseResources()
Releases all (memory intensive) resources such as images or RGB arrays of this item. The default implementation does release any background resources.

Overrides:
releaseResources in class FakeStringCustomItem

isTextVisible

public boolean isTextVisible()
Determines if the text of this icon item is visible

Returns:
true when the text is shown

setTextVisible

public void setTextVisible(boolean isTextVisible)
Toggles the visibility of this icon's text

Parameters:
isTextVisible - true when the text should be shown