com.sun.svg.component
Class SVGList

java.lang.Object
  extended by com.sun.svg.component.SVGList

public class SVGList
extends java.lang.Object

The SVGList class displays the items of an arbitrary long list of data items in a limited number of visual elements. The list triggers a scrolling effect to move up or down in the list and has a notion of selected item (i.e., the one which reprents the current user selection). The SVGList class facilitates creating a list where the appearance of the list and the list animations are defined in SVG markup and the data displayed by the list is controlled by the ListModel implementation associated to the SVGList. The conventions for the SVG this class can hook into are: - The various elements which compose the list share the same identifier prefix which is given to the SVGList at construction time (e.g., 'myList'). This prefix is call 'listIdPrefix' in the following. - The animations which produce the list's scroll up effect are started by the animation with id . The scroll down effect animations are started with the animation with id: . - The SVG elements used to display the list items have an id of the form: . The display items must be in consecutive order starting at zero. - The item which displays the currently selected item should have the additional "_selectedItem" suffix, so its id should be formed as: . If not selected item is specified, the selected item index defaults to zero. By default, SVGList assumes that the list items are SVG elements. However, the list can be associated to a list item binders to handle more sophisticated item rendering. Example of SVG content which can be bound by this class:

 
      
          item 0
          item 1
          item 2
          item 3
      

     
          item 4
          item 4 details
     

      
          item 5
          item 6
          item 7
          item 8
          item 8
      

      
      
 
 


Nested Class Summary
 class SVGList.DefaultListItemBinder
          Default ListItemBinder.
static interface SVGList.ListItemBinder
          Interface that item binders must implement.
static interface SVGList.ListModel
          Interface that list data sources must implement.
 
Field Summary
protected  SVGList.ListItemBinder commonItemBinder
          The list item binder used to display common list elements.
protected  int curIndex
          Index of the currently selected list item.
protected  java.lang.String listIdPrefix
          The prefix for the identifiers which make the various list elements.
protected  java.util.Vector listItems
          This vector holds all the SVGElement instances which represent items in the list.
protected  SVGList.ListModel listModel
          The model providing the list data.
protected  int nDisplayedItems
          The number of items displayed in the list.
static java.lang.String SCROLL_DOWN_ANIM_SUFFIX
          Id suffix used for the list scrollDown animation effect.
static java.lang.String SCROLL_UP_ANIM_SUFFIX
          Id suffix used for the list scrollUp animation effect.
protected  org.w3c.dom.svg.SVGAnimationElement scrollDownAnim
          The animation to play to scroll down the list.
protected  org.w3c.dom.svg.SVGAnimationElement scrollUpAnim
          The animation to play to scroll up the list.
protected  SVGList.ListItemBinder selectedItemBinder
          The list item binder used to display the selected list element.
protected  org.w3c.dom.svg.SVGElement selectedItemDetails
           
 
Constructor Summary
SVGList(SVGList.ListModel listModel, java.lang.String listIdPrefix)
          Creates a new instance of SVGList.
 
Method Summary
 int getCurIndex()
          Returns the current index in the list, in the [0, getSize()[ range.
 int getFocusedIndex()
          Returns the index of the index in the list with focus.
 float getPosition()
          Returns the current progress in the list, as a ration of the current index over the number of list items.
 void hookSkin(org.w3c.dom.Document doc)
          Hooks the specified sking to the application.
 void next()
           
 void prev()
           
 void scrollDown()
           
 void scrollUp()
           
 void setCommonItemBinder(SVGList.ListItemBinder commonItemBinder)
          Sets a new ListItemBinder for rendering common list entries.
 void setCurIndex(int curIndex)
          Sets the new current index, i.e., the index of the first displayed list item.
 void setDataItems()
          Transfers list data to the XML UI.
 void setSelectedIndex(int selectedIndex)
          Sets the index of the item with selection focus.
 void setSelectedItemBinder(SVGList.ListItemBinder selectedItemBinder)
          Sets a new ListItemBinder for rendering the selected list entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCROLL_UP_ANIM_SUFFIX

public static final java.lang.String SCROLL_UP_ANIM_SUFFIX
Id suffix used for the list scrollUp animation effect.

See Also:
Constant Field Values

SCROLL_DOWN_ANIM_SUFFIX

public static final java.lang.String SCROLL_DOWN_ANIM_SUFFIX
Id suffix used for the list scrollDown animation effect.

See Also:
Constant Field Values

scrollUpAnim

protected org.w3c.dom.svg.SVGAnimationElement scrollUpAnim
The animation to play to scroll up the list.


scrollDownAnim

protected org.w3c.dom.svg.SVGAnimationElement scrollDownAnim
The animation to play to scroll down the list.


nDisplayedItems

protected int nDisplayedItems
The number of items displayed in the list.


listModel

protected SVGList.ListModel listModel
The model providing the list data.


curIndex

protected int curIndex
Index of the currently selected list item.


listItems

protected java.util.Vector listItems
This vector holds all the SVGElement instances which represent items in the list.


listIdPrefix

protected java.lang.String listIdPrefix
The prefix for the identifiers which make the various list elements.


commonItemBinder

protected SVGList.ListItemBinder commonItemBinder
The list item binder used to display common list elements.


selectedItemBinder

protected SVGList.ListItemBinder selectedItemBinder
The list item binder used to display the selected list element.


selectedItemDetails

protected org.w3c.dom.svg.SVGElement selectedItemDetails
Constructor Detail

SVGList

public SVGList(SVGList.ListModel listModel,
               java.lang.String listIdPrefix)
Creates a new instance of SVGList.

Parameters:
listModel - - the ListModel which will provide the data for the list.
listIdPrefix - - the prefix used for the various elements which make the list.
Method Detail

setCommonItemBinder

public void setCommonItemBinder(SVGList.ListItemBinder commonItemBinder)
Sets a new ListItemBinder for rendering common list entries.

Parameters:
commonItemBinder - - the new ListItemBinder to use when rendering common list elements.

setSelectedItemBinder

public void setSelectedItemBinder(SVGList.ListItemBinder selectedItemBinder)
Sets a new ListItemBinder for rendering the selected list entry.

Parameters:
selectedItemBinder - - the new ListItemBinder to use when rendering the selected list element.

hookSkin

public void hookSkin(org.w3c.dom.Document doc)
Hooks the specified sking to the application.

Parameters:
doc - the new Document to hook into the application

getCurIndex

public int getCurIndex()
Returns the current index in the list, in the [0, getSize()[ range.

Returns:
the first shown list index.

setCurIndex

public void setCurIndex(int curIndex)
Sets the new current index, i.e., the index of the first displayed list item.

Parameters:
curIndex - - the index of the new first displayed list item.

getFocusedIndex

public int getFocusedIndex()
Returns the index of the index in the list with focus.

Returns:
the index of the currently selected list index.

setSelectedIndex

public void setSelectedIndex(int selectedIndex)
Sets the index of the item with selection focus.

Parameters:
selectedIndex - - the index of the new currently focused list item.

getPosition

public float getPosition()
Returns the current progress in the list, as a ration of the current index over the number of list items.


setDataItems

public void setDataItems()
Transfers list data to the XML UI.


next

public void next()

scrollDown

public void scrollDown()

prev

public void prev()

scrollUp

public void scrollUp()