de.enough.polish.ui.containerviews
Class SlideContainerView

java.lang.Object
  extended by de.enough.polish.ui.ItemView
      extended by de.enough.polish.ui.ContainerView
          extended by de.enough.polish.ui.containerviews.SlideContainerView
All Implemented Interfaces:
Serializable

public class SlideContainerView
extends ContainerView

Slides the parent container in any direction, this animation can used for menus for example.

 menu {
        view-type: slide;
 }
 
 menu {
        view-type: slide;
        slideview-direction: leftop; // moving from bottom-right to the left-top corner
 }
 

Copyright Enough Software 2006 - 2009

 history
        Aug 21, 2006 - rob creation
 

Author:
Robert Virkus, j2mepolish@enough.de

Field Summary
 
Fields inherited from class de.enough.polish.ui.ContainerView
allowCycling, allowsAutoTraversal, allowsDirectSelectionByPointerEvent, appearanceMode, columnsSetting, columnsWidths, EQUAL_WIDTH_COLUMNS, focusedIndex, focusedItem, focusFirstElement, isAlignHeights, isExpandItems, isHorizontal, isPointerPressedHandled, isSequentialTraversal, isVertical, leftXOffset, NO_COLUMNS, NORMAL_WIDTH_COLUMNS, numberOfColumns, numberOfRows, parentContainer, restartAnimation, rightXOffset, rowsHeights, scrollContinuous, STATIC_WIDTH_COLUMNS, targetXOffset, topYOffset
 
Fields inherited from class de.enough.polish.ui.ItemView
availableHeight, availableWidth, contentHeight, contentWidth, isFocused, isLayoutCenter, isLayoutRight, layout, paddingHorizontal, paddingVertical, parentItem
 
Constructor Summary
SlideContainerView()
           
 
Method Summary
 void animate(long currentTime, ClippingRegion repaintRegion)
          Animates this item.
protected  int calculateNext(int current, int target, long currentTime, int completeDistance)
          Calculates the next value
protected  void initAnimation()
          Initializes the animation.
protected  void initContent(Item parentContainerItem, int firstLineWidth, int availWidth, int availHeight)
          Initializes this container view.
 void paintBackground(Background background, int x, int y, int width, int height, Graphics g)
           
 void paintBorder(Border border, int x, int y, int width, int height, Graphics g)
           
protected  void paintContent(Container container, Item[] myItems, int x, int y, int leftBorder, int rightBorder, int clipX, int clipY, int clipWidth, int clipHeight, Graphics g)
          Paints the content of this container view.
protected  void setStyle(Style style)
          Sets the style for this view.
 void showNotify()
          Notifies this view that it is about to be shown (again).
 
Methods inherited from class de.enough.polish.ui.ContainerView
addFullRepaintRegion, destroy, focusItem, focusItem, focusItem, getAppearanceMode, getChildAt, getChildHeight, getChildWidth, getContentHeight, getContentWidth, getItemRelativeY, getNextFocusableItem, getNextItem, getParentRelativeY, getScreen, getScrollTargetXOffset, getScrollXOffset, handleKeyPressed, handlePointerDragged, handlePointerPressed, handlePointerReleased, handlePointerTouchDown, handlePointerTouchUp, initMargin, initPadding, isInBottomRow, isLayoutExpand, isValid, isVerticalLayout, isVirtualContainer, paintContent, paintItem, releaseResources, scroll, setAppearanceMode, setScrollXOffset, setScrollXOffset, shiftFocus, shiftFocus, shiftFocus, startScroll
 
Methods inherited from class de.enough.polish.ui.ItemView
addItemBackground, addItemBackgroundBorder, addItemBorder, adjustToContentArea, animate, defocus, focus, handleKeyReleased, handlePointerDragged, hideNotify, init, initContentByParent, notifyItemPressedEnd, notifyItemPressedEnd, notifyItemPressedStart, notifyItemPressedStart, onScreenSizeChanged, paintContentByParent, removeItemBackground, removeItemBorder, removeParentBackground, removeParentBorder, removeViewFromParent, requestInit, setContentHeight, setContentWidth, setStyle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SlideContainerView

public SlideContainerView()
Method Detail

animate

public void animate(long currentTime,
                    ClippingRegion repaintRegion)
Description copied from class: ItemView
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 ContainerView
Parameters:
currentTime - the current time in milliseconds
repaintRegion - the repaint area that needs to be updated when this item is animated
See Also:
Item.getAbsoluteX(), Item.getAbsoluteY()

calculateNext

protected int calculateNext(int current,
                            int target,
                            long currentTime,
                            int completeDistance)
Calculates the next value

Parameters:
current - the current value
target - the target value
currentTime - the current time
completeDistance - the complete distance
Returns:
the next value

initAnimation

protected void initAnimation()
Initializes the animation.


showNotify

public void showNotify()
Description copied from class: ContainerView
Notifies this view that it is about to be shown (again). The default implementation just sets the restartAnimation-field to true.

Overrides:
showNotify in class ContainerView

initContent

protected void initContent(Item parentContainerItem,
                           int firstLineWidth,
                           int availWidth,
                           int availHeight)
Description copied from class: ContainerView
Initializes this container view. The implementation needs to calculate and set the contentWidth and contentHeight fields. The style of the focused item has already been set. When the contentWidth will be larger than the specified availWidth, the container view allows to scroll horizontally automatically using pointer events.

Overrides:
initContent in class ContainerView
Parameters:
parentContainerItem - the Container which uses this view, use parent.getItems() for retrieving all items.
firstLineWidth - the maximum width of the first line
availWidth - the maximum width of any following lines
availHeight - the maximum height of the view
See Also:
ItemView.contentWidth, ItemView.contentHeight

paintContent

protected void paintContent(Container container,
                            Item[] myItems,
                            int x,
                            int y,
                            int leftBorder,
                            int rightBorder,
                            int clipX,
                            int clipY,
                            int clipWidth,
                            int clipHeight,
                            Graphics g)
Description copied from class: ContainerView
Paints the content of this container view. This method calls

Overrides:
paintContent in class ContainerView
Parameters:
container - the parent container
myItems - the items that should be painted
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
clipX - absolute horizontal clipping start
clipY - absolute verical clipping start
clipWidth - clipping width
clipHeight - clipping height
g - the Graphics on which this item should be painted.

paintBackground

public void paintBackground(Background background,
                            int x,
                            int y,
                            int width,
                            int height,
                            Graphics g)
Overrides:
paintBackground in class ItemView

paintBorder

public void paintBorder(Border border,
                        int x,
                        int y,
                        int width,
                        int height,
                        Graphics g)
Overrides:
paintBorder in class ItemView

setStyle

protected void setStyle(Style style)
Description copied from class: ContainerView
Sets the style for this view. The style can include additional parameters for the view. Subclasses should call super.setStyle(style) first.

Overrides:
setStyle in class ContainerView
Parameters:
style - the style