|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.enough.polish.ui.Item
de.enough.polish.ui.ImageItem
public class ImageItem
An item that can contain an image.
Each ImageItem object contains a reference to an
Image object.
This Image may be mutable or immutable. If the
Image is mutable, the
effect is as if snapshot of its contents is taken at the time the
ImageItem
is constructed with this Image and when
setImage is called with an Image.
The snapshot is used whenever the contents of the
ImageItem are to be
displayed. Even if the application subsequently draws into the
Image, the
snapshot is not modified until the next call to
setImage. The snapshot is
not updated when the container of the
ImageItem becomes current or
becomes visible on the display. (This is because the application does not
have control over exactly when Displayables and Items
appear and disappear
from the display.)
The value null may be specified for the image
contents of an ImageItem.
If
this occurs (and if the label is also null) the
ImageItem will occupy no
space on the screen.
ImageItem contains layout directives that were
originally defined in
MIDP 1.0. These layout directives have been moved to the
Item class and now apply to all items. The declarations are left
in ImageItem for source compatibility purposes.
The altText parameter specifies a string to be
displayed in place of the
image if the image exceeds the capacity of the display. The
altText
parameter may be null.
| Field Summary |
|---|
| Constructor Summary | |
|---|---|
ImageItem(java.lang.String label,
javax.microedition.lcdui.Image image,
int layout,
java.lang.String altText)
Creates a new ImageItem with the given label, image, layout
directive, and alternate text string. |
|
ImageItem(java.lang.String label,
javax.microedition.lcdui.Image image,
int layout,
java.lang.String altText,
int appearanceMode)
Creates a new ImageItem object with the given label, image,
layout directive, alternate text string, and appearance mode. |
|
ImageItem(java.lang.String label,
javax.microedition.lcdui.Image image,
int layout,
java.lang.String altText,
int appearanceMode,
Style style)
Creates a new ImageItem object with the given label, image,
layout directive, alternate text string, and appearance mode. |
|
ImageItem(java.lang.String label,
javax.microedition.lcdui.Image image,
int layout,
java.lang.String altText,
Style style)
Creates a new ImageItem with the given label, image, layout
directive, and alternate text string. |
|
| Method Summary | |
|---|---|
protected java.lang.String |
createCssSelector()
Retrieves the CSS selector for this item. |
java.lang.String |
getAltText()
Gets the text string to be used if the image exceeds the device's capacity to display it. |
javax.microedition.lcdui.Image |
getImage()
Gets the image contained within the ImageItem, or
null if there is no
contained image. |
protected boolean |
handleKeyPressed(int keyCode,
int gameAction)
Handles the key-pressed event. |
protected boolean |
handlePointerPressed(int relX,
int relY)
Handles the event when a pointer has been pressed at the specified position. |
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 |
setAltText(java.lang.String text)
Sets the alternate text of the ImageItem, or
null if no alternate text is provided. |
void |
setImage(javax.microedition.lcdui.Image image)
Sets the Image object contained within the
ImageItem. |
void |
setStyle(Style style)
Sets the style of this item. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ImageItem(java.lang.String label,
javax.microedition.lcdui.Image image,
int layout,
java.lang.String altText)
ImageItem with the given label, image, layout
directive, and alternate text string. Calling this constructor is
equivalent to calling
ImageItem(label, image, layout, altText, PLAIN, null );
label - the label stringimage - the image, can be mutable or immutablelayout - a combination of layout directivesaltText - the text that may be used in place of the image
java.lang.IllegalArgumentException - - if the layout value is not a legal combination of directivesImageItem(String, Image, int, String, int)
public ImageItem(java.lang.String label,
javax.microedition.lcdui.Image image,
int layout,
java.lang.String altText,
Style style)
ImageItem with the given label, image, layout
directive, and alternate text string. Calling this constructor is
equivalent to calling
ImageItem(label, image, layout, altText, PLAIN, null );
label - the label stringimage - the image, can be mutable or immutablelayout - a combination of layout directivesaltText - the text that may be used in place of the imagestyle - the style of this image item.
java.lang.IllegalArgumentException - - if the layout value is not a legal combination of directivesImageItem(String, Image, int, String, int)
public ImageItem(java.lang.String label,
javax.microedition.lcdui.Image image,
int layout,
java.lang.String altText,
int appearanceMode)
ImageItem object with the given label, image,
layout directive, alternate text string, and appearance mode.
Either label or alternative 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 ImageItem. To provide hyperlink- or
button-like behavior,
the application should associate a default Command with this
ImageItem and add an
ItemCommandListener to this
ImageItem.
Here is an example showing the use of an
ImageItem as a button:
ImageItem imgItem =
new ImageItem("Default: ", img,
Item.LAYOUT_CENTER, null,
Item.BUTTON);
imgItem.setDefaultCommand(
new Command("Set", Command.ITEM, 1);
// icl is ItemCommandListener
imgItem.setItemCommandListener(icl);
label - the label stringimage - the image, can be mutable or immutablelayout - a combination of layout directivesaltText - the text that may be used in place of the imageappearanceMode - the appearance mode of the ImageItem, one of Item.PLAIN, Item.HYPERLINK, or Item.BUTTON
java.lang.IllegalArgumentException - - if the layout value is not a legal combination of directives
or if appearanceMode invalid
public ImageItem(java.lang.String label,
javax.microedition.lcdui.Image image,
int layout,
java.lang.String altText,
int appearanceMode,
Style style)
ImageItem object with the given label, image,
layout directive, alternate text string, and appearance mode.
Either label or alternative 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 ImageItem. To provide hyperlink- or
button-like behavior,
the application should associate a default Command with this
ImageItem and add an
ItemCommandListener to this
ImageItem.
Here is an example showing the use of an
ImageItem as a button:
ImageItem imgItem =
new ImageItem("Default: ", img,
Item.LAYOUT_CENTER, null,
Item.BUTTON);
imgItem.setDefaultCommand(
new Command("Set", Command.ITEM, 1);
// icl is ItemCommandListener
imgItem.setItemCommandListener(icl);
label - the label stringimage - the image, can be mutable or immutablelayout - a combination of layout directivesaltText - the text that may be used in place of the imageappearanceMode - the appearance mode of the ImageItem, one of Item.PLAIN, Item.HYPERLINK, or Item.BUTTONstyle - the style of this image item.
java.lang.IllegalArgumentException - - if the layout value is not a legal combination of directives
or if appearanceMode invalid| Method Detail |
|---|
public javax.microedition.lcdui.Image getImage()
ImageItem, or
null if there is no
contained image.
setImage(Image)public void setImage(javax.microedition.lcdui.Image image)
Image object contained within the
ImageItem. The image may be
mutable or immutable. If img is
null, the ImageItem is set to be
empty. If img is mutable, the effect is as if a
snapshot is taken of
img's contents immediately prior to the call to
setImage. This
snapshot is used whenever the contents of the
ImageItem are to be
displayed. If img is already the
Image of this ImageItem, the effect
is as if a new snapshot of img's contents is taken. Thus, after
painting into a mutable image contained by an
ImageItem, the
application can call
imageItem.setImage(imageItem.getImage());
to refresh the ImageItem's snapshot of its Image.
If the ImageItem is visible on the display when
the snapshot is
updated through a call to setImage, the display is
updated with the new
snapshot as soon as it is feasible for the implementation to so do.
image - the Image for this ImageItem, or null if nonegetImage()public java.lang.String getAltText()
setAltText(java.lang.String)public void setAltText(java.lang.String text)
ImageItem, or
null if no alternate text is provided.
text - the new alternate textgetAltText()
public void paintContent(int x,
int y,
int leftBorder,
int rightBorder,
javax.microedition.lcdui.Graphics g)
Item
paintContent in class Itemx - 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.
protected void initContent(int firstLineWidth,
int lineWidth)
Item
initContent in class ItemfirstLineWidth - the maximum width of the first linelineWidth - the maximum width of any following linesItem.contentWidth,
Item.contentHeight,
Item.preferredWidth,
Item.preferredHeightprotected java.lang.String createCssSelector()
Item
createCssSelector in class Itempublic void setStyle(Style style)
Item
setStyle in class Itemstyle - the new style for this item.
protected boolean handleKeyPressed(int keyCode,
int gameAction)
Item
handleKeyPressed in class ItemkeyCode - the code of the pressed key, e.g. Canvas.KEY_NUM2gameAction - the corresponding game-action, e.g. Canvas.UP
protected boolean handlePointerPressed(int relX,
int relY)
Item
handlePointerPressed in class ItemrelX - the x position of the pointer pressing relative to this item's left positionrelY - the y position of the pointer pressing relative to this item's top position
this method is used for determining whether the event belongs to this item,
for a helper method for determining whether the event took place into the actual content area,
Item.handleKeyPressed(int, int),
for calculating the horizontal position relative to the content (relX - contentX),
for calculating the vertical position relative to the content (relY - contentY)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||