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

 history
        04-Apr-2004 - rob creation
 

Author:
Robert Virkus, robert@enough.de

Field Summary
protected  int horizontalAdjustment
           
protected  Image image
           
protected  int imageAlign
           
protected  int imageHeight
           
protected  int imageWidth
           
protected  boolean isTextVisible
           
protected  int relativeIconX
           
protected  int relativeIconY
           
protected  Object[] scaleData
           
protected  boolean scaleFinished
           
protected  int verticalAdjustment
           
protected  int yAdjustText
           
 
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
FakeIconCustomItem(String text, Image image)
          Creates a new icon.
FakeIconCustomItem(String text, Image image, Style style)
          Creates a new icon.
FakeIconCustomItem(String label, String text, Image image)
          Creates a new icon.
FakeIconCustomItem(String label, String text, Image image, Style style)
          Creates a new icon.
 
Method Summary
 void animate(long currentTime, ClippingRegion repaintRegion)
          Animates this item.
protected  String createCssSelector()
          Retrieves the CSS selector for this item.
protected  void defocus(Style originalStyle)
          Removes the focus from this item.
 Image getImage()
          Retrieves the image of this item.
protected  void initContent(int firstLineWidth, int availWidth, int availHeight)
          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, 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(Image image)
          Sets the image for this icon.
 void setImage(Image img, Style style)
          Sets the image for this icon.
 void setImage(String url)
          Loads the specified image.
 void setImage(String name, 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 setStyle(Style style, boolean resetStyle)
          Sets the style of this item for animatable CSS attributes.
 void setTextVisible(boolean isTextVisible)
          Toggles the visibility of this icon's text
 String toString()
          Generates a String representation of this item.
 
Methods inherited from class de.enough.polish.ui.FakeStringCustomItem
addRepaintArea, charWidth, drawString, getFont, getFontHeight, getLineHeight, getText, hideNotify, setContentWidth, setFont, setText, setText, setTextColor, setTextEffect, showNotify, stringWidth, wrap
 
Methods inherited from class de.enough.polish.ui.FakeCustomItem
addCommand, addCommand, addCommand, addCommands, addRelativeToBackgroundRegion, addRelativeToBackgroundRegion, addRelativeToContentRegion, animate, 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
 

Field Detail

image

protected Image image

imageAlign

protected int imageAlign

imageHeight

protected int imageHeight

imageWidth

protected int imageWidth

yAdjustText

protected int yAdjustText

isTextVisible

protected boolean isTextVisible

scaleFinished

protected boolean scaleFinished

scaleData

protected Object[] scaleData

verticalAdjustment

protected int verticalAdjustment

horizontalAdjustment

protected int horizontalAdjustment

relativeIconX

protected int relativeIconX

relativeIconY

protected int relativeIconY
Constructor Detail

FakeIconCustomItem

public FakeIconCustomItem(String text,
                          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(String text,
                          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(String label,
                          String text,
                          Image image)
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

FakeIconCustomItem

public FakeIconCustomItem(String label,
                          String text,
                          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 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

paintContent

public void paintContent(int x,
                         int y,
                         int leftBorder,
                         int rightBorder,
                         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 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.

setStyle

public void setStyle(Style style,
                     boolean resetStyle)
Description copied from class: FakeCustomItem
Sets the style of this item for animatable CSS attributes.

Overrides:
setStyle in class FakeStringCustomItem
Parameters:
style - the new style for this element.
resetStyle - true when style settings should be resetted. This is not the case when styles are animated, for example.

setImage

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

Parameters:
url - the local URL of the image

setImage

public void setImage(String name,
                     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(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(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 FakeStringCustomItem
Parameters:
currentTime - the current time in milliseconds
repaintRegion - the repaint area that needs to be updated when this item is animated
See Also:
FakeCustomItem.addRelativeToContentRegion(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 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