|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.microedition.lcdui.Item
javax.microedition.lcdui.CustomItem
de.enough.polish.ui.FakeCustomItem
de.enough.polish.ui.FakeStringCustomItem
public class FakeStringCustomItem
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.
| Field Summary | |
|---|---|
protected boolean |
animateTextWrap
|
protected int |
availableTextWidth
|
protected boolean |
clipText
|
protected Font |
font
|
protected boolean |
isHorizontalAnimationDirectionRight
|
protected boolean |
isTextInitializationRequired
|
protected int |
maxLines
|
protected String |
maxLinesAppendix
|
protected int |
maxLinesAppendixPosition
|
protected String |
text
|
protected int |
textColor
|
protected TextEffect |
textEffect
|
protected int |
textHorizontalAdjustment
|
protected int |
textLayout
|
protected WrappedText |
textLines
|
protected int |
textVerticalAdjustment
|
protected int |
textWidth
|
protected int |
textWrapDirection
|
protected int |
textWrapSpeed
|
protected boolean |
useSingleLine
|
protected int |
xOffset
|
| 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(String label,
String text)
Creates a new StringItem object. |
|
FakeStringCustomItem(String label,
String text,
int appearanceMode)
Creates a new StringItem object with the given label,
textual content, and appearance mode. |
|
FakeStringCustomItem(String label,
String text,
int appearanceMode,
Style style)
Creates a new StringItem object with the given label,
textual content, and appearance mode. |
|
FakeStringCustomItem(String label,
String text,
Style style)
Creates a new StringItem object. |
|
| Method Summary | |
|---|---|
void |
addRepaintArea(ClippingRegion repaintRegion)
Adds a repaint request for this item's space. |
void |
animate(long currentTime,
ClippingRegion repaintRegion)
Animates this item. |
int |
charWidth(char c)
Retrieves the width of the given char |
protected String |
createCssSelector()
Retrieves the CSS selector for this item. |
protected void |
defocus(Style originalStyle)
Removes the focus from this item. |
void |
drawString(String line,
int x,
int y,
int anchor,
Graphics g)
|
Font |
getFont()
Gets the application's preferred font for rendering this StringItem. |
int |
getFontHeight()
Retrieves the height necessary for displaying a row of text without the padding-vertical. |
int |
getLineHeight()
Returns the height of one line |
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 availWidth,
int availHeight)
Initialises this item. |
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. |
protected void |
setContentWidth(int width)
Sets the content width of this item. |
void |
setFont(Font font)
Sets the application's preferred font for rendering this StringItem. |
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 |
setText(String text)
Sets the text contents of the StringItem. |
void |
setText(String text,
Style style)
Sets the text contents of the StringItem along with a style. |
void |
setTextColor(int color)
Sets the text color for contents of the StringItem. |
void |
setTextEffect(TextEffect effect)
Sets the effect for this StringItem Note that this method is only available when either using font-bitmap or the text-effect CSS attributes: |
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. |
int |
stringWidth(String str)
Calculates the width of the given text. |
String |
toString()
Generates a String representation of this item. |
protected void |
wrap(String body,
int firstLineWidth,
int availWidth)
Wraps the specified text and adds the result to the internal field 'wrappedText'. |
| 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 |
|---|
protected String text
protected final WrappedText textLines
protected int textColor
protected Font font
protected boolean useSingleLine
protected boolean clipText
protected int xOffset
protected int textWidth
protected boolean isHorizontalAnimationDirectionRight
protected boolean animateTextWrap
protected int availableTextWidth
protected int textWrapDirection
protected int textWrapSpeed
protected int textHorizontalAdjustment
protected int textVerticalAdjustment
protected TextEffect textEffect
protected int maxLines
protected String maxLinesAppendix
protected int maxLinesAppendixPosition
protected int textLayout
protected boolean isTextInitializationRequired
| Constructor Detail |
|---|
public FakeStringCustomItem(String label,
String text)
StringItem object. Calling this
constructor is equivalent to calling
StringItem(label, text, Item.PLAIN, null);
label - the Item labeltext - the text contentsFakeStringCustomItem(String, String, int, Style)
public FakeStringCustomItem(String label,
String text,
Style style)
StringItem object. Calling this
constructor is equivalent to calling
StringItem(label, text, Item.PLAIN, style);
label - the Item labeltext - the text contentsstyle - the styleFakeStringCustomItem(String, String, int, Style)
public FakeStringCustomItem(String label,
String text,
int appearanceMode)
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);
label - the StringItem's label, or null if no labeltext - the StringItem's text contents, or null if the contents are initially emptyappearanceMode - the appearance mode of the StringItem, one of Item.PLAIN, Item.HYPERLINK, or Item.BUTTON
IllegalArgumentException - if appearanceMode invalid
public FakeStringCustomItem(String label,
String text,
int appearanceMode,
Style style)
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);
label - the StringItem's label, or null if no labeltext - the StringItem's text contents, or null if the contents are initially emptyappearanceMode - the appearance mode of the StringItem, one of Item.PLAIN, Item.HYPERLINK, or Item.BUTTONstyle - the style for this item
IllegalArgumentException - if appearanceMode invalid| Method Detail |
|---|
public void animate(long currentTime,
ClippingRegion repaintRegion)
FakeCustomItem
animate in class FakeCustomItemcurrentTime - the current time in millisecondsrepaintRegion - the repaint area that needs to be updated when this item is animatedFakeCustomItem.addRelativeToContentRegion(ClippingRegion, int, int, int, int)public void addRepaintArea(ClippingRegion repaintRegion)
FakeCustomItem
addRepaintArea in class FakeCustomItemrepaintRegion - the clipping rectangle to which the repaint area should be addedprotected void defocus(Style originalStyle)
FakeCustomItem
defocus in class FakeCustomItemoriginalStyle - the original style which will be restored.protected void hideNotify()
FakeCustomItempaint() 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.
hideNotify in class FakeCustomItemprotected void showNotify()
FakeCustomItempaint() calls after
showNotify() has been called.
The default implementation of this method sets the isShown field to true and calls showNotify on style elements.
showNotify in class FakeCustomItempublic String getText()
StringItem, or
null if the StringItem is
empty.
setText(java.lang.String)public void setText(String text)
StringItem.
If text
is null,
the StringItem
is set to be empty.
text - the new contentgetText()
public void setText(String text,
Style style)
StringItem along with a style.
If text is null,
the StringItem
is set to be empty.
text - the new contentstyle - the new style, is ignored when nullgetText()public void setTextEffect(TextEffect effect)
//#if polish.css.font-bitmap || polish.css.text-effect
effect - the new text effect, use null for removing the current text effectpublic void setTextColor(int color)
StringItem.
color - the new color for the contentpublic void setFont(Font font)
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.
font - - the preferred font to use to render this StringItemgetFont()public Font getFont()
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.
setFont(javax.microedition.lcdui.Font)
public void paintContent(int x,
int y,
int leftBorder,
int rightBorder,
Graphics g)
FakeCustomItem
paintContent in class FakeCustomItemx - the left start positiony - the upper start positionleftBorder - the left border, nothing must be painted left of this positionrightBorder - the right border, nothing must be painted right of this positiong - the Graphics on which this item should be painted.
public void drawString(String line,
int x,
int y,
int anchor,
Graphics g)
line - x - y - anchor - public int getLineHeight()
public int stringWidth(String str)
str - the text of which the width should be determined
public int charWidth(char c)
c - the char
public int getFontHeight()
protected void initContent(int firstLineWidth,
int availWidth,
int availHeight)
FakeCustomItem
initContent in class FakeCustomItemfirstLineWidth - the maximum width of the first lineavailWidth - the available maximum width of this item in pixelsavailHeight - the available maximum height of this item in pixelsFakeCustomItem.contentWidth,
FakeCustomItem.contentHeight,
FakeCustomItem.preferredWidth,
FakeCustomItem.preferredHeight
protected void wrap(String body,
int firstLineWidth,
int availWidth)
body - the textfirstLineWidth - the available width for the first lineavailWidth - the available width for subsequent linesprotected void setContentWidth(int width)
FakeCustomItem
setContentWidth in class FakeCustomItemwidth - the new content width in pixelpublic void setStyle(Style style)
FakeCustomItem
setStyle in class FakeCustomItemstyle - the new style for this item.
public void setStyle(Style style,
boolean resetStyle)
FakeCustomItem
setStyle in class FakeCustomItemstyle - 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.protected String createCssSelector()
FakeCustomItem
createCssSelector in class FakeCustomItempublic String toString()
FakeCustomItem
toString in class FakeCustomItempublic void releaseResources()
FakeCustomItem
releaseResources in class FakeCustomItem
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||