PenProfile 2.x

com.livescribe.display
Class BrowseList

java.lang.Object
  extended by com.livescribe.display.Displayable
      extended by com.livescribe.display.BrowseList
All Implemented Interfaces:
HorizontalFlickScrub, VerticalFlickScrub
Direct Known Subclasses:
Menu.MenuBrowseList

public class BrowseList
extends Displayable
implements VerticalFlickScrub, HorizontalFlickScrub

BrowseList is a UI component that enables a penlet to display a list of items and provide user navigation within the list. Only one item is visible at a time in the pen display, and the user can move up or down through the items. A BrowseList is constructed with a vector of String or BrowseList.Item objects. The vector serves as the data model for the browse list.

A BrowseList can optionally have a BrowseList.Title, which is visible the first time the component is displayed. The title indicates what kind of items the browse list contains. The user selects the title in order to access the items in the browse list.

The methods focusToNext() and focusToPrevious() move the focus to the next or the previous item, respectively.

See Also:
Display

Nested Class Summary
protected static class BrowseList.Insets
          Insets defines the decoration region for a menu item and the title for the BrowseList.
static interface BrowseList.Item
          The Item interface describes an item in a BrowseList.
static class BrowseList.Title
          Title encapsulates the title for a browse list.
 
Field Summary
protected  int focusIndex
           
protected  BrowseList.Insets insets
          Represents the borders for the item content.
protected  Vector itemModel
           
 
Constructor Summary
BrowseList()
          Deprecated.  
BrowseList(Vector itemModel)
          Constructs a BrowseList with item model and no title.
BrowseList(Vector itemModel, BrowseList.Title title)
          Constructs a BrowseList with item model and and a title.
BrowseList(Vector itemModel, BrowseList.Title title, MediaPlayer player)
          Constructs a BrowseList with an item model, a title, and a media player.
 
Method Summary
protected  void drawDecorations(Graphics g, BrowseList.Item item)
          Draws the decoration for the Item passed on to the Graphics.
protected  void drawItem(Graphics g, BrowseList.Item item, Image icon, Object text, int x, int y)
          Renders the item contents on the graphics.
 void enableFlickScrub(boolean enable)
          Flick n Scrub should be disabled if you want to process hand writting recognition while this controll is visible
 void flickHorizontally(int deltaX)
           
 void flickVertically(int deltaY)
           
 int focusToNext()
          Scrolls this BrowseList to display the item after the current one
 int focusToPrevious()
          Scrolls this BrowseList to display the item before the current one.
 int getFocusIndex()
          Gets the index of the item that currently has focus.
 Object getFocusItem()
          Gets the item that currently has focus.
protected  BrowseList.Item getItemAt(int index, com.livescribe.display.BrowseList.ItemHolder textItem)
           
 int getItemCount()
          Gets the number of items in this browse list.
 boolean isHorizontalFlickScrubEnabled()
           
 boolean isVerticalFlickScrubEnabled()
           
 boolean isWrapAroundEnabled()
          Indicates if wrap-around is enabled or not.
protected  void notifyHidden(Display d)
          This is invoked by the system to notify this Displayable when it is not current.
protected  void notifyShown(Display d)
          This is invoked by the system to notify this Displayable when it has become current.
protected  void notifySystemTrayHidden()
          This is invoked by the system to notify the Displayable when the system tray has been hidden.
protected  void notifySystemTrayShown()
          This is invoked by the system to notify the Displayable when the system tray has been displayed.
protected  void paint(Graphics g)
          Invoked by the system to allow the Displayable to render contents using the graphics context.
protected  void paintList(Graphics g)
           
protected  void renderInitialView()
           
protected  void scrollItem(Graphics graphics, ScrollLabel scroller, BrowseList.Item item, int x, int y)
          Renders the item contents on the graphics and use the scroller to scroll the textual content of the item.
 void scrubHorizontally(int deltaX)
           
 void scrubVertically(int deltaY)
           
 void setFocusItem(int index)
          Sets the focus to the item specified by the index.
protected  void setInsets(BrowseList.Insets insets)
          Set the Insets for the decoration.
protected  void setScrollerClipRegion(ScrollLabel scroller, short x, short y, short width, short height)
          Sets the clip region for the scroller.
protected  void showScroller()
           
 
Methods inherited from class com.livescribe.display.Displayable
getSurface, isCurrent
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

itemModel

protected Vector itemModel

focusIndex

protected int focusIndex

insets

protected BrowseList.Insets insets
Represents the borders for the item content. The borders could be used for decoration or left blank

Constructor Detail

BrowseList

public BrowseList()
Deprecated. 


BrowseList

public BrowseList(Vector itemModel)
Constructs a BrowseList with item model and no title.

Parameters:
itemModel - a Vector of String or BrowseList.Item objects.

BrowseList

public BrowseList(Vector itemModel,
                  BrowseList.Title title)
Constructs a BrowseList with item model and and a title.

Parameters:
itemModel - a Vector of String or BrowseList.Item objects.
title - a BrowseList.Title that provides a title for the BrowseList.

BrowseList

public BrowseList(Vector itemModel,
                  BrowseList.Title title,
                  MediaPlayer player)
Constructs a BrowseList with an item model, a title, and a media player. The specified media player should be used instead of a new player.

Parameters:
itemModel - a Vector of String or BrowseList.Item objects.
title - a title for the list.
player - a MediaPlayer object to use for playing audio associated with the browse list items.
Since:
0.4
Method Detail

setInsets

protected final void setInsets(BrowseList.Insets insets)
Set the Insets for the decoration. The default value for the insets is BrowseList.Insets.DEFAULT

Parameters:
insets - the insets to set. If this value is null then the current insets is not changed.
Since:
0.6

getFocusItem

public Object getFocusItem()
Gets the item that currently has focus.

Returns:
the item that currently has focus. It will be an instance of or BrowseList.Item.

setFocusItem

public void setFocusItem(int index)
Sets the focus to the item specified by the index.

Parameters:
index - index of the item within the item model of this BrowseList. This should be >= 0 && < itemModel.size().

getItemCount

public int getItemCount()
Gets the number of items in this browse list. This is useful for determining valid values for setFocusItem(int).

Returns:
the number of items in this list.
See Also:
setFocusItem(int)

getFocusIndex

public int getFocusIndex()
Gets the index of the item that currently has focus.

Returns:
index of item that has focus; or -1 if there no item has focus. (This state occurs when a title is visible or this BrowseList is not set on the Display object.)

focusToPrevious

public int focusToPrevious()
Scrolls this BrowseList to display the item before the current one.

Returns:
index of the item that has focus after the operation.

focusToNext

public int focusToNext()
Scrolls this BrowseList to display the item after the current one

Returns:
index of the item that has focus after the operation.

notifyHidden

protected void notifyHidden(Display d)
Description copied from class: Displayable
This is invoked by the system to notify this Displayable when it is not current. Overriding methods should call super.notifyHidden(d) before its own implementation. Failure to do this could result in unknown behavior.

Overrides:
notifyHidden in class Displayable
Parameters:
d - The Display on which this Displayale was current

notifyShown

protected void notifyShown(Display d)
Description copied from class: Displayable
This is invoked by the system to notify this Displayable when it has become current. Overriding methods should call super.notifyShown(d) before its own implementation. Failure to do this could result in unknown behavior.

Overrides:
notifyShown in class Displayable
Parameters:
d - The Display on which this Displayale is current

paintList

protected void paintList(Graphics g)

renderInitialView

protected void renderInitialView()

getItemAt

protected BrowseList.Item getItemAt(int index,
                                    com.livescribe.display.BrowseList.ItemHolder textItem)

showScroller

protected void showScroller()

drawItem

protected void drawItem(Graphics g,
                        BrowseList.Item item,
                        Image icon,
                        Object text,
                        int x,
                        int y)
Renders the item contents on the graphics.

This is invoked to render the menu item during the up/down transition. The implementation draws the item's icon at the left and the textual content following the icon to the right.

This method can be overriden to provide alternate rendering of the item's content. If this is overriden then the companion method scrollItem(Graphics, ScrollLabel, Item, int, int) must also be overriden.

Parameters:
g - graphics to render the item contents
item - item to render
icon - item's icon
text - item's text
x - x coordinate to draw
y - y coordinate to draw
Since:
0.6
See Also:
scrollItem(Graphics, ScrollLabel, Item, int, int)

scrollItem

protected void scrollItem(Graphics graphics,
                          ScrollLabel scroller,
                          BrowseList.Item item,
                          int x,
                          int y)
Renders the item contents on the graphics and use the scroller to scroll the textual content of the item.

This is invoked to render the menu item after the up/down transition is completed. The implementation draws the item's icon at the left and scrolls the textual content following the icon to the right.

This method can be overriden to provide alternate rendering of the item's content. If this is overriden then the companion method drawItem(Graphics, Item, Image, Object, int, int) must also be overriden.

Parameters:
graphics -
scroller - UI component that allows for text scrolling. The graphics associated with the scroller points to the same drawing surface as the graphics parameter.
item -
x -
y -
Since:
0.6
See Also:
drawItem(Graphics, Item, Image, Object, int, int)

setScrollerClipRegion

protected final void setScrollerClipRegion(ScrollLabel scroller,
                                           short x,
                                           short y,
                                           short width,
                                           short height)
Sets the clip region for the scroller. This should be called from scrollItem(Graphics, ScrollLabel, Item, int, int) implementation to set a region within the viewport for text scrolling.

Parameters:
scroller - scoller UI component.
x - clip x coordinate
y - clip y coordinate
width - clip width
height - clip height
Since:
0.6

isWrapAroundEnabled

public boolean isWrapAroundEnabled()
Indicates if wrap-around is enabled or not. "Wrap-around" means the same as "wrapping," which is described at BrowseList(Vector, Title, boolean).

Returns:
true if wrap-around is enabled; false if wrap-around is disabled.

notifySystemTrayHidden

protected void notifySystemTrayHidden()
Description copied from class: Displayable
This is invoked by the system to notify the Displayable when the system tray has been hidden.

The default implementation would schedule a paint call that allows the Displayable to render to the full screen.

Overrides:
notifySystemTrayHidden in class Displayable

notifySystemTrayShown

protected void notifySystemTrayShown()
Description copied from class: Displayable
This is invoked by the system to notify the Displayable when the system tray has been displayed.

Overrides:
notifySystemTrayShown in class Displayable

drawDecorations

protected void drawDecorations(Graphics g,
                               BrowseList.Item item)
Draws the decoration for the Item passed on to the Graphics. The implementation is as follows
   if ( there are no insets ) {
      return;
   }
   if ( the item is selectable ) {
      draw right decoration (arrow)
   }
   if ( wrap around is set ) {
      draw top and bottom decoration (arrows)
   }
   else {
      if ( item is the last one ) {
         draw decoration for last item marker
      }
      else {
         draw bottom decoration (arrow)
      }
      if ( item is the first one ) {
         draw decoration for first item marker
      }
      else {
         draw top decoration (arrow)
      }
    }
 

Subclasses should override this method if they want to provide alternate decorations.

Parameters:
g - graphics to draw the decorations
item - item that is in focus
Since:
0.6

paint

protected void paint(Graphics g)
Description copied from class: Displayable
Invoked by the system to allow the Displayable to render contents using the graphics context.

Specified by:
paint in class Displayable
Parameters:
g - the Graphics context to be used to render on the Displayable.

scrubVertically

public void scrubVertically(int deltaY)
Specified by:
scrubVertically in interface VerticalFlickScrub

flickVertically

public void flickVertically(int deltaY)
Specified by:
flickVertically in interface VerticalFlickScrub

enableFlickScrub

public void enableFlickScrub(boolean enable)
Flick n Scrub should be disabled if you want to process hand writting recognition while this controll is visible

Parameters:
enable -

isVerticalFlickScrubEnabled

public boolean isVerticalFlickScrubEnabled()
Specified by:
isVerticalFlickScrubEnabled in interface VerticalFlickScrub

scrubHorizontally

public void scrubHorizontally(int deltaX)
Specified by:
scrubHorizontally in interface HorizontalFlickScrub

flickHorizontally

public void flickHorizontally(int deltaX)
Specified by:
flickHorizontally in interface HorizontalFlickScrub

isHorizontalFlickScrubEnabled

public boolean isHorizontalFlickScrubEnabled()
Specified by:
isHorizontalFlickScrubEnabled in interface HorizontalFlickScrub

PenProfile 2.x

Copyright © 2010 Livescribe Inc. All Rights Reserved.
Confidential and subject to NDA.