de.enough.polish.ui
Class Spacer

java.lang.Object
  extended by de.enough.polish.ui.Item
      extended by de.enough.polish.ui.Spacer
All Implemented Interfaces:
Animatable, UiElement

public class Spacer
extends Item

A blank, non-interactive item that has a settable minimum size.

The usage of the Spacer item is discouraged for applications which use J2ME Polish, since margins and paddings can be set for each item anyhow.

The minimum width is useful for allocating flexible amounts of space between Items within the same row of a Form. The minimum height is useful for enforcing a particular minimum height of a row. The application can set the minimum width or height to any non-negative value. The implementation may enforce implementation-defined maximum values for the minimum width and height.

The unlocked preferred width of a Spacer is the same as its current minimum width. Its unlocked preferred height is the same as its current minimum height.

Since a Spacer's primary purpose is to position other items, it is restricted to be non-interactive, and the application is not allowed to add Commands to a Spacer. Since the presence of a label on an Item may affect layout in device-specific ways, the label of a Spacer is restricted to always be null, and the application is not allowed to change it.

Since:
MIDP 2.0
Author:
Robert Virkus, robert@enough.de

Field Summary
 
Fields inherited from class de.enough.polish.ui.Item
_androidView, _bbField, appearanceMode, availableHeight, availableWidth, availContentHeight, availContentWidth, background, backgroundHeight, backgroundWidth, backgroundYOffset, 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, isJustFocused, isLayoutCenter, isLayoutExpand, isLayoutRight, isPressed, isShown, isStyleInitialized, 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
 
Constructor Summary
Spacer(int minWidth, int minHeight)
          Creates a new Spacer with the given minimum size.
 
Method Summary
 void addCommand(Command cmd)
          Spacers are restricted from having Commands, so this method will always throw IllegalStateException whenever it is called.
protected  String createCssSelector()
          Retrieves the CSS selector for this item.
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 setDefaultCommand(Command cmd)
          Spacers are restricted from having Commands, so this method will always throw IllegalStateException whenever it is called.
 void setLabel(String label)
          Spacers are restricted to having null labels, so this method will always throw IllegalStateException whenever it is called.
 void setMinimumSize(int minWidth, int minHeight)
          Sets the minimum size for this spacer.
 
Methods inherited from class de.enough.polish.ui.Item
addCommand, addCommand, addCommands, addRelativeToBackgroundRegion, addRelativeToBackgroundRegion, addRelativeToContentRegion, addRepaintArea, animate, animate, containsCommand, defocus, destroy, fireContinueCycle, fireEvent, focus, getAbsoluteX, getAbsoluteY, getAfterWidthWithPadding, getAppearanceMode, getAttribute, getAttributes, getAvailableContentHeight, getAvailableContentWidth, getAvailableHeight, getAvailableWidth, getBackgroundHeight, getBackgroundWidth, getBackgroundX, getBackgroundY, getBeforeWidthWithPadding, getBorderWidthBottom, getBorderWidthLeft, getBorderWidthRight, getBorderWidthTop, getContentHeight, getContentWidth, getContentX, getContentY, getCycleListener, getDefaultCommand, getFocusedStyle, getInternalHeight, getInternalWidth, getInternalX, getInternalY, getItemAreaHeight, getItemAt, getItemCommandListener, getItemCommands, getItemHeight, getItemHeight, getItemStateListener, getItemWidth, getItemWidth, getLabel, getLabelItem, getLayout, getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getMaximumHeight, getMaximumHeight, getMaximumWidth, getMaximumWidth, getMinimumHeight, getMinimumHeight, getMinimumWidth, getMinimumWidth, getNativeItem, getPaddingBottom, getPaddingHorizontal, getPaddingLeft, getPaddingRight, getPaddingTop, getPaddingVertical, getParent, getParentRoot, getpreferredHeight, getpreferredWidth, getRgbData, getRgbData, getScreen, getStyle, getUiEventListener, getView, getView, handleCommand, handleCommand, handleGesture, handleGestureHold, handleGestureSwipeLeft, handleGestureSwipeRight, handleKeyPressed, handleKeyReleased, handleKeyRepeated, handleOnFocusSoftKeyboardDisplayBehavior, handlePointerDragged, handlePointerDragged, handlePointerPressed, handlePointerReleased, handlePointerTouchDown, handlePointerTouchUp, hideNotify, 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, isSameRowForContentAndLabel, isVisible, notifyItemPressedEnd, notifyItemPressedStart, notifyStateChanged, notifyUnvisited, notifyValueChanged, notifyVisited, onScreenSizeChanged, paint, paintBackground, paintBackgroundAndBorder, paintBorder, paintCommands, paintFilter, releaseResources, removeAttribute, removeCommand, repaint, repaint, repaintFully, requestInit, resetStyle, setAbsoluteY, setAppearanceMode, setAttribute, setBackground, setBorder, setContentHeight, setContentWidth, setCycleListener, setDefaultCommand, setInitialized, setItemCommandListener, setItemCommandListener, setItemHeight, setItemStateListener, setItemTransition, setItemWidth, setLayout, setNativeItem, setParent, setParent, setpreferredSize, setSameRowForContentAndLabel, setStyle, setStyle, setStyle, setUiEventListener, setView, setVisible, show, show, showCommands, showNotify, toImage, toRgbImage, toString, updateInternalArea
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Spacer

public Spacer(int minWidth,
              int minHeight)
Creates a new Spacer with the given minimum size. The Spacer's label is null. The minimum size must be zero or greater. If minWidth is greater than the implementation-defined maximum width, the maximum width will be used instead. If minHeight is greater than the implementation-defined maximum height, the maximum height will be used instead.

Parameters:
minWidth - - the minimum width in pixels
minHeight - - the minimum height in pixels
Throws:
IllegalArgumentException - - if either minWidth or minHeight is less than zero
Method Detail

setMinimumSize

public void setMinimumSize(int minWidth,
                           int minHeight)
Sets the minimum size for this spacer. The Form will not be allowed to make the item smaller than this size. The minimum size must be zero or greater. If minWidth is greater than the implementation-defined maximum width, the maximum width will be used instead. If minHeight is greater than the implementation-defined maximum height, the maximum height will be used instead.

Parameters:
minWidth - - the minimum width in pixels
minHeight - - the minimum height in pixels
Throws:
IllegalArgumentException - - if either minWidth or minHeight is less than zero

addCommand

public void addCommand(Command cmd)
Spacers are restricted from having Commands, so this method will always throw IllegalStateException whenever it is called.

Overrides:
addCommand in class Item
Parameters:
cmd - - the Command
Throws:
IllegalStateException - - always
See Also:
in class Item

setDefaultCommand

public void setDefaultCommand(Command cmd)
Spacers are restricted from having Commands, so this method will always throw IllegalStateException whenever it is called.

Overrides:
setDefaultCommand in class Item
Parameters:
cmd - - the Command
Throws:
IllegalStateException - - always
See Also:
in class Item

setLabel

public void setLabel(String label)
Spacers are restricted to having null labels, so this method will always throw IllegalStateException whenever it is called.

Overrides:
setLabel in class Item
Parameters:
label - - the label string
Throws:
IllegalStateException - - always
See Also:
in class Item

paintContent

public void paintContent(int x,
                         int y,
                         int leftBorder,
                         int rightBorder,
                         Graphics g)
Description copied from class: Item
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 Item
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.

initContent

protected void initContent(int firstLineWidth,
                           int availWidth,
                           int availHeight)
Description copied from class: Item
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 Item
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:
Item.contentWidth, Item.contentHeight, Item.preferredWidth, Item.preferredHeight

createCssSelector

protected String createCssSelector()
Description copied from class: Item
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 Item
Returns:
the appropriate CSS selector for this item. The selector needs to be in lower case.