de.enough.polish.ui
Class PictureBrowserItem

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.PictureBrowserItem

public class PictureBrowserItem
extends FakeCustomItem

The Picure Browser paints 5 in one row by scaling down the four outer ones and having a suitable large image in the middle.

Author:
Tim Muders

Field Summary
 
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
PictureBrowserItem(java.lang.String label, javax.microedition.lcdui.Image[] thumbnails, java.lang.String[] urls, int scaleFactor)
          Creates a new, PictureBrowserItem.
PictureBrowserItem(java.lang.String label, javax.microedition.lcdui.Image[] thumbnails, java.lang.String[] urls, int scaleFactor, Style style)
          Creates a new, PictureBrowserItem.
 
Method Summary
protected  java.lang.String createCssSelector()
          Retrieves the CSS selector for this item.
 int getNumberOfThumbnails()
          Retrieves the number of stored thumbnails
 int getSelectedThumbIndex()
          Returns the Array Position of the Selected Thumb.
 java.lang.String getUrl(int index)
          returns the url as an String.
protected  boolean handleKeyPressed(int keyCode, int gameAction)
          Changes the Selected Image if interaction: Canvas.RIGHT Canvas.LEFT.
protected  void initContent(int firstLineWidth, int lineWidth)
          Initialises this item.
protected  void paintContent(int x, int y, int leftBorder, int rightBorder, javax.microedition.lcdui.Graphics g)
          Paints the content of this item.
 void setSelectedThumbIndex(int index)
          Changes the Selected Thumb with the given int i, and scale the old Selected back to a normal Thumb.
 void setStyle(Style style)
          Sets the Font.
 
Methods inherited from class de.enough.polish.ui.FakeCustomItem
addCommand, addCommand, addCommands, addRelativeToBackgroundRegion, addRelativeToContentRegion, animate, animate, containsCommand, defocus, 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, handleKeyReleased, handleKeyRepeated, handlePointerPressed, handlePointerReleased, hideNotify, init, initStyle, isInContentArea, isInItemArea, isVisible, notifyItemPressedEnd, notifyItemPressedStart, notifyStateChanged, paint, paint, paintBackground, paintBackgroundAndBorder, paintBorder, releaseResources, removeCommand, repaintFully, requestInit, setAppearanceMode, setAttribute, setDefaultCommand, setItemCommandListener, setItemCommandListener, setItemStateListener, setLabel, setLayout, setPreferredSize, setVisible, show, showCommands, showNotify, toString
 
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
 

Constructor Detail

PictureBrowserItem

public PictureBrowserItem(java.lang.String label,
                          javax.microedition.lcdui.Image[] thumbnails,
                          java.lang.String[] urls,
                          int scaleFactor)
Creates a new, PictureBrowserItem.

Parameters:
label - the label
thumbnails - the images for the menu
urls - the urls for the target image
scaleFactor - the skale factor for the thumbs that are displayed on the side of the item. Note that the first given thumb is used for the calculation of the sizes for all images. The complete width off the item are 4*firstimage.getWidth()*scaleFactor/100 + 2*padding-horizontal

PictureBrowserItem

public PictureBrowserItem(java.lang.String label,
                          javax.microedition.lcdui.Image[] thumbnails,
                          java.lang.String[] urls,
                          int scaleFactor,
                          Style style)
Creates a new, PictureBrowserItem.

Parameters:
label - the label
thumbnails - the images for the menu
urls - the urls for the target image
scaleFactor - the skale factor for the thumbs that are displayed on the side of the item. Note that the first given thumb is used for the calculation of the sizes for all images. The complete width off the item are 4*firstimage.getWidth()*scaleFactor/100 + 2*padding-horizontal
style - the design settings
Method Detail

getNumberOfThumbnails

public int getNumberOfThumbnails()
Retrieves the number of stored thumbnails

Returns:
the number of stored thumbnails

setSelectedThumbIndex

public void setSelectedThumbIndex(int index)
Changes the Selected Thumb with the given int i, and scale the old Selected back to a normal Thumb.

Parameters:
index - next Selected Thumb

paintContent

protected 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.

setStyle

public void setStyle(Style style)
Sets the Font.

Overrides:
setStyle in class FakeCustomItem
Parameters:
style - - the Font to be painted

handleKeyPressed

protected boolean handleKeyPressed(int keyCode,
                                   int gameAction)
Changes the Selected Image if interaction: Canvas.RIGHT Canvas.LEFT.

Overrides:
handleKeyPressed in class FakeCustomItem
Parameters:
keyCode -
gameAction -
Returns:
true if handled, false otherwise

getSelectedThumbIndex

public int getSelectedThumbIndex()
Returns the Array Position of the Selected Thumb.

Returns:
int the Selected Thumb number

getUrl

public java.lang.String getUrl(int index)
returns the url as an String.

Parameters:
index - - the index where the url is Placed in the String Array urls
Returns:
the url of that image or null when no URLs have been defined

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.

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