|
Java DTV API 1.3 18-Nov-2009 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.dtv.lwuit.Component
com.sun.dtv.lwuit.List
public class List
A set of elements that is rendered using a ListCellRenderer
and are extracted via the ListModel
.
A list can represent many UI concepts ranging from a carousel to a "todo" checklist, this is made possible thanks to extensive use of Swing's style of MVC. Specifically a list component is relatively simple, it invokes the model in order to extract the displayed/selected information and shows it to the user by invoking the cell renderer.
The list class itself is completely decoupled from everything, thus it allows us to extract its content from any source (e.g. network, storage etc.) and display the information in any form (e.g. checkboxed elements, icons etc.).
ListModel
Field Summary | |
---|---|
static int |
FIXED_CENTER
Indicates the list selection is fixed into place at the center of the list. |
static int |
FIXED_LEAD
Indicates the list selection is fixed into place at the top of the list or at the left of the list. |
static int |
FIXED_NONE
Indicates the list isn't fixed and that selection is movable. |
static int |
FIXED_NONE_CYCLIC
Indicates that the list is not fixed in place but cycles its elements. |
static int |
FIXED_NONE_ONE_ELEMENT_MARGIN_FROM_EDGE
Indicates the list selection will only reach the edge when there are no more elements in the list. |
static int |
FIXED_TRAIL
Indicates the list selection is fixed into place at the bottom of the list or at the right of the list. |
static int |
HORIZONTAL
Indicates the list orientation is HORIZONTAL. |
static int |
VERTICAL
Indicates the list orientation is VERTICAL. |
Fields inherited from class com.sun.dtv.lwuit.Component |
---|
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP |
Fields inherited from interface com.sun.dtv.ui.ViewOnlyComponent |
---|
HORIZONTAL_ALIGN_CENTER, HORIZONTAL_ALIGN_JUSTIFIED, HORIZONTAL_ALIGN_LEFT, HORIZONTAL_ALIGN_RIGHT, SCALE_ASPECT_PROOF, SCALE_NO, SCALE_NO_ASPECT_PROOF, STATE_DISABLED, STATE_ENABLED, VERTICAL_ALIGN_BOTTOM, VERTICAL_ALIGN_CENTER, VERTICAL_ALIGN_JUSTIFIED, VERTICAL_ALIGN_TOP |
Fields inherited from interface com.sun.dtv.ui.Animated |
---|
ALTERNATING, LOOP, REPEATING |
Constructor Summary | |
---|---|
List()
Creates a new instance of List with an empty default model. |
|
List(ListModel model)
Creates a new instance of List with the given model. |
|
List(Object[] items)
Creates a new instance of List. |
|
List(Vector items)
Creates a new instance of List. |
Method Summary | |
---|---|
void |
addActionListener(ActionListener l)
Allows binding a listener to user selection actions. |
void |
addItem(Object item)
Allows adding an element to a list if the underlying model supports this, notice that it is an optional operation and if the model does not support it (default list model does) then this operation may failed. |
void |
addSelectionListener(SelectionListener l)
Invoked to indicate interest in future selection events. |
boolean |
animate()
Allows the animation to reduce "repaint" calls when it returns false. |
Image[] |
getAnimateContent(int state)
Returns the animated content for this component, depending on the current state. |
int |
getBorderGap()
Getting the surrounding border gap. |
int |
getFixedSelection()
Indicates whether selection is fixable to place in which case all the elements in the list move and selection stays in place. |
Image |
getGraphicContent(int state)
Returns the graphical content for this component, depending on the current state. |
int |
getHorizontalAlignment()
Retrieve the horizontal alignment for any state-based content in this component. |
int |
getInteractionState()
Return the current interaction state of the component. |
int |
getItemGap()
Returns the gap between items. |
Matte |
getMatte()
Return the Matte currently associated with the
component implementing this interface. |
ListModel |
getModel()
Returns the model underlying the list. |
int |
getOrientation()
Returns the list orientation. |
ListCellRenderer |
getRenderer()
Returns the renderer which is used to draw list elements. |
Object |
getRenderingPrototype()
See set rendering prototype. |
int |
getScalingMode()
Retrieve the scaling mode for this component. |
int |
getSelectedIndex()
Returns the current selected offset in the list. |
Object |
getSelectedItem()
Returns the current selected item in the list or null for no selection. |
String |
getTextContent(int state)
Returns the text content for this component, depending on the current state. |
TextLayoutManager |
getTextLayoutManager()
Gets the text layout manager that is currently in use for text layout in this component. |
int |
getVerticalAlignment()
Retrieve the vertical alignment for any state-based content in this component. |
boolean |
isDoubleBuffered()
Returns true if double buffering is available and activated. |
boolean |
isNumericKeyActions()
Indicate whether pressing the number keys should trigger an action. |
boolean |
isOpaque()
Returns true if the whole area of the Component (as returned by the com.sun.dtv.lwuit.Component#getBounds method, is opaque. |
boolean |
isScrollableX()
Indicates whether the component should/could scroll on the X axis. |
boolean |
isScrollableY()
Indicates whether the component should/could scroll on the Y axis. |
void |
keyPressed(int keyCode)
If this Component is focused, the key pressed event will call this method. |
void |
keyReleased(int keyCode)
If this Component is focused, the key released event will call this method. |
void |
paint(Graphics g)
This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering. |
void |
pointerDragged(int x,
int y)
If this Component is focused, the pointer dragged event will call this method. |
void |
pointerReleased(int x,
int y)
If this Component is focused, the pointer released event will call this method. |
void |
processEvent(AWTEvent event)
Handle the specified AWTEvent. |
void |
refreshTheme()
Makes sure the component is up to date with the current style object. |
void |
removeActionListener(ActionListener l)
Allows binding a listener to user selection actions. |
void |
removeSelectionListener(SelectionListener l)
Invoked to indicate no further interest in future selection events. |
void |
scrollRectToVisible(Rectangle rect)
Makes sure the selected index is visible if it is not in the current view rect the list will scroll so it fits within. |
void |
setAnimateContent(Image[] images,
int state)
Assigns an array of graphical content to be used for animation to this component which is state-dependent. |
void |
setBorderGap(int borderGap)
Setting the surrounding border gap. |
void |
setFixedSelection(int fixedSelection)
Indicates whether selection is fixable to place in which case all the elements in the list move and selection stays in place. |
void |
setGraphicContent(Image image,
int state)
Assigns graphical content to this component which is state-dependent. |
void |
setHandlesInput(boolean b)
Prevents key events from being grabbed for focus traversal. |
void |
setHorizontalAlignment(int alignment)
Set the horizontal alignment for any state-based content in this component. |
void |
setInputOnFocus(boolean inputOnFocus)
A list can start handling input implicitly upon gaining focus, this can make for a more intuitive UI when no other focus elements exist or when their use case is infrequent. |
void |
setInteractionState(int state)
Set the current state of the component with respect to interaction. |
void |
setItemGap(int itemGap)
Set the gap between items. |
void |
setListCellRenderer(ListCellRenderer renderer)
Sets the renderer which is used to draw list elements. |
void |
setMatte(Matte matte)
Adds an Matte to the component implementing this
interface in order to enable matte compositing. |
void |
setModel(ListModel model)
Replaces/sets the model underlying the list. |
void |
setNumericKeyActions(boolean numericKeyActions)
Indicate whether pressing the number keys should trigger an action. |
void |
setOrientation(int orientation)
Sets the list orientation HORIZONTAL or VERTICAL. |
void |
setPaintFocusBehindList(boolean paintFocusBehindList)
This method determines if the animated focus is drawn on top of the List or behind the List when moving. |
void |
setRenderingPrototype(Object renderingPrototype)
The rendering prototype is optionally used in calculating the size of the List and is recommended for performance reasons. |
void |
setScalingMode(int scaling)
Set the scaling mode for this component. |
void |
setSelectedIndex(int index)
Sets the current selected offset in the list, by default this implementation will scroll the list to the selection if the selection is outside of the screen. |
void |
setSelectedIndex(int index,
boolean scrollToSelection)
Sets the current selected offset in the list. |
void |
setSelectedItem(Object item)
Sets the current selected item in the list. |
void |
setTextContent(String text,
int state)
Assigns text content to this component which is state-dependent. |
void |
setTextLayoutManager(TextLayoutManager manager)
Sets the text layout manager that should be used for text layout in this component. |
void |
setVerticalAlignment(int valign)
Set the vertical alignment for any state-based content in this component. |
int |
size()
Returns the number of elements in the list, shorthand for getModel().getSize(). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int FIXED_NONE
public static final int FIXED_NONE_CYCLIC
public static final int FIXED_NONE_ONE_ELEMENT_MARGIN_FROM_EDGE
public static final int FIXED_LEAD
public static final int FIXED_TRAIL
public static final int FIXED_CENTER
public static final int VERTICAL
public static final int HORIZONTAL
Constructor Detail |
---|
public List(Vector items)
items
- set of items placed into the list modelpublic List(Object[] items)
items
- set of items placed into the list modelpublic List()
public List(ListModel model)
model
- the model instanceMethod Detail |
---|
public boolean isScrollableY()
Component
isScrollableY
in class Component
public boolean isScrollableX()
Component
isScrollableX
in class Component
public int size()
public int getSelectedIndex()
setSelectedIndex(int)
,
setSelectedIndex(int, boolean)
public void setSelectedIndex(int index)
index
- the current selected offset in the listgetSelectedIndex()
public void setSelectedIndex(int index, boolean scrollToSelection)
index
- the current selected offset in the listscrollToSelection
- indicates whether scrolling to selection should
occur if the selection is outside of viewgetSelectedIndex()
public Object getSelectedItem()
setSelectedItem(java.lang.Object)
public void setSelectedItem(Object item)
item
- the current selected item in the listgetSelectedItem()
public ListModel getModel()
setModel(com.sun.dtv.lwuit.list.ListModel)
public void setModel(ListModel model)
model
- the new model underlying the listgetModel()
public boolean isNumericKeyActions()
public void setNumericKeyActions(boolean numericKeyActions)
numericKeyActions
- true to trigger an action on number keyspublic void setListCellRenderer(ListCellRenderer renderer)
renderer
- cell renderer instancepublic ListCellRenderer getRenderer()
public int getOrientation()
setOrientation(int)
,
HORIZONTAL
,
VERTICAL
public void refreshTheme()
Component
refreshTheme
in class Component
public void setOrientation(int orientation)
orientation
- the list orientation HORIZONTAL or VERTICALgetOrientation()
,
HORIZONTAL
,
VERTICAL
public void scrollRectToVisible(Rectangle rect)
rect
- the rectangle area to scroll topublic void setHandlesInput(boolean b)
Component
setHandlesInput
in class Component
b
- indicates whether key events can be grabbed for
focus traversalpublic void keyReleased(int keyCode)
Component
keyReleased
in class Component
keyCode
- the key code value to indicate a physical key.public void keyPressed(int keyCode)
Component
keyPressed
in class Component
keyCode
- the key code value to indicate a physical key.public void paint(Graphics g)
Component
paint
in interface Animation
paint
in interface ViewOnlyComponent
paint
in class Component
g
- the component graphicspublic void addSelectionListener(SelectionListener l)
l
- the selection listener to be addedremoveSelectionListener(com.sun.dtv.lwuit.events.SelectionListener)
public void removeSelectionListener(SelectionListener l)
l
- the selection listener to be removedaddSelectionListener(com.sun.dtv.lwuit.events.SelectionListener)
public void addActionListener(ActionListener l)
l
- the action listener to be addedremoveActionListener(com.sun.dtv.lwuit.events.ActionListener)
public void removeActionListener(ActionListener l)
l
- the action listener to be removedaddActionListener(com.sun.dtv.lwuit.events.ActionListener)
public void setInputOnFocus(boolean inputOnFocus)
inputOnFocus
- true is a list can start handling input
implicitly upon gaining focuspublic void setPaintFocusBehindList(boolean paintFocusBehindList)
paintFocusBehindList
- true for behind, false for on toppublic int getItemGap()
setItemGap(int)
public void setItemGap(int itemGap)
itemGap
- the gap between itemsgetItemGap()
public void setRenderingPrototype(Object renderingPrototype)
This allows list size calculations to work across look and feels and allows developers to predetermine size for list elements.
e.g. For a list of Strings which you would like to always be 5 characters wide you can use a prototype "XXXXX" which would use the preferred size of the XXXXX String to determine the size of the list element. E.g. for a list of dates you can use new Date(30, 12, 00) etc..
renderingPrototype
- a value that can be passed to the renderer to indicate the preferred
size of a list component.getRenderingPrototype()
public Object getRenderingPrototype()
setRenderingPrototype(java.lang.Object)
public void pointerDragged(int x, int y)
Component
pointerDragged
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic void pointerReleased(int x, int y)
Component
pointerReleased
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic void addItem(Object item)
item
- the item to be added to a list modelpublic int getFixedSelection()
setFixedSelection(int)
public void setFixedSelection(int fixedSelection)
fixedSelection
- one of: FIXED_NONE, FIXED_TRAIL, FIXED_LEAD,
FIXED_CENTER, FIXED_NONE_CYCLICgetFixedSelection()
public boolean animate()
Animation
animate
in interface Animation
animate
in class Component
public void setBorderGap(int borderGap)
borderGap
- number of pixels for the gapgetBorderGap()
public int getBorderGap()
setBorderGap(int)
public void setTextContent(String text, int state) throws IllegalArgumentException
ViewOnlyComponent
setTextContent
in interface ViewOnlyComponent
text
- the text content, or null (removes text content which had
been assigned before)state
- the state of the component for which this content should be
displayed, one of STATE_ENABLED
or STATE_DISABLED
IllegalArgumentException
- if the state parameter does not
represent a stateViewOnlyComponent.getTextContent(int)
public void setGraphicContent(Image image, int state) throws IllegalArgumentException
ViewOnlyComponent
setGraphicContent
in interface ViewOnlyComponent
image
- the graphical content, or null (removes graphical content
which had been assigned before)state
- the state of the component for which this content should be
displayed, one of STATE_ENABLED
or STATE_DISABLED
IllegalArgumentException
- if the state parameter does not
represent a stateViewOnlyComponent.getGraphicContent(int)
public void setAnimateContent(Image[] images, int state) throws IllegalArgumentException
ViewOnlyComponent
setAnimateContent
in interface ViewOnlyComponent
images
- the graphical content array, or null (removes any graphical
content which had been assigned before)state
- the state of the component for which this content should be
displayed, one of STATE_ENABLED
or STATE_DISABLED
IllegalArgumentException
- if the state parameter does not
represent a stateViewOnlyComponent.getAnimateContent(int)
public String getTextContent(int state) throws IllegalArgumentException
ViewOnlyComponent
getTextContent
in interface ViewOnlyComponent
state
- the state of the component for which this content is to
be retrieved, one of STATE_ENABLED
or STATE_DISABLED
IllegalArgumentException
- if the state parameter does not
represent a stateViewOnlyComponent.setTextContent(java.lang.String, int)
public Image getGraphicContent(int state) throws IllegalArgumentException
ViewOnlyComponent
getGraphicContent
in interface ViewOnlyComponent
state
- the state of the component for which this content is to
be retrieved, one of STATE_ENABLED
or STATE_DISABLED
IllegalArgumentException
- if the state parameter does not
represent a stateViewOnlyComponent.setGraphicContent(com.sun.dtv.lwuit.Image, int)
public Image[] getAnimateContent(int state) throws IllegalArgumentException
ViewOnlyComponent
getAnimateContent
in interface ViewOnlyComponent
state
- the state of the component for which this content is to
be retrieved, one of STATE_ENABLED
or STATE_DISABLED
IllegalArgumentException
- if the state parameter does not
represent a stateViewOnlyComponent.setAnimateContent(com.sun.dtv.lwuit.Image[], int)
public void setInteractionState(int state) throws IllegalArgumentException
ViewOnlyComponent
setInteractionState
in interface ViewOnlyComponent
state
- the interaction state for this content, one of STATE_ENABLED
or STATE_DISABLED
IllegalArgumentException
- if the state parameter does not
represent a stateViewOnlyComponent.getInteractionState()
public int getInteractionState()
ViewOnlyComponent
getInteractionState
in interface ViewOnlyComponent
ViewOnlyComponent.setInteractionState(int)
public void setTextLayoutManager(TextLayoutManager manager)
ViewOnlyComponent
setTextLayoutManager
in interface ViewOnlyComponent
manager
- the TextLayoutManager
ViewOnlyComponent.getTextLayoutManager()
public TextLayoutManager getTextLayoutManager()
ViewOnlyComponent
getTextLayoutManager
in interface ViewOnlyComponent
TextLayoutManager
ViewOnlyComponent.setTextLayoutManager(com.sun.dtv.ui.TextLayoutManager)
public void setHorizontalAlignment(int alignment)
ViewOnlyComponent
setHorizontalAlignment
in interface ViewOnlyComponent
alignment
- the horizontal alignment mode, one of
ViewOnlyComponent.HORIZONTAL_ALIGN_LEFT
,
ViewOnlyComponent.HORIZONTAL_ALIGN_CENTER
,
ViewOnlyComponent.HORIZONTAL_ALIGN_RIGHT
or
ViewOnlyComponent.HORIZONTAL_ALIGN_JUSTIFIED
.ViewOnlyComponent.getHorizontalAlignment()
public int getHorizontalAlignment()
ViewOnlyComponent
getHorizontalAlignment
in interface ViewOnlyComponent
ViewOnlyComponent.HORIZONTAL_ALIGN_LEFT
,
ViewOnlyComponent.HORIZONTAL_ALIGN_CENTER
,
ViewOnlyComponent.HORIZONTAL_ALIGN_RIGHT
or
ViewOnlyComponent.HORIZONTAL_ALIGN_JUSTIFIED
.ViewOnlyComponent.setHorizontalAlignment(int)
public void setScalingMode(int scaling)
ViewOnlyComponent
setScalingMode
in interface ViewOnlyComponent
scaling
- the scaling mode, one of
ViewOnlyComponent.SCALE_NO
,
ViewOnlyComponent.SCALE_NO_ASPECT_PROOF
or
ViewOnlyComponent.SCALE_ASPECT_PROOF
.ViewOnlyComponent.getScalingMode()
public int getScalingMode()
ViewOnlyComponent
getScalingMode
in interface ViewOnlyComponent
ViewOnlyComponent.SCALE_NO
,
ViewOnlyComponent.SCALE_NO_ASPECT_PROOF
or
ViewOnlyComponent.SCALE_ASPECT_PROOF
.ViewOnlyComponent.setScalingMode(int)
public boolean isDoubleBuffered()
ViewOnlyComponent
isDoubleBuffered
in interface ViewOnlyComponent
true
if double buffering is available and activated,
and false otherwisepublic boolean isOpaque()
ViewOnlyComponent
com.sun.dtv.lwuit.Component#getBounds
method, is opaque.
isOpaque
in interface ViewOnlyComponent
true
if all the pixels within the area
defined by the com.sun.dtv.lwuit.Component#getBounds
method
are opaque, i.e. all pixels are painted in an opaque color,
false
otherwise.public void processEvent(AWTEvent event)
ViewOnlyComponent
processEvent
in interface ViewOnlyComponent
event
- a java.awt.AWTEvent to handle.public void setMatte(Matte matte) throws MatteException
MatteEnabled
Matte
to the component implementing this
interface in order to enable matte compositing. If there is already a
Matte assigned to the component, and this Matte is animated, it has to be
stopped before any call to this method.
setMatte
in interface MatteEnabled
matte
- the Matte
to be assigned to the
component. At any point of time there can only be one matte associated to
the component, that's way any matte that has been associated before will
be overriden by a call to this method.
The Matte parameter can also be null, in this case there is no matte
associated with the component after the call, even if there had been one
before.
MatteException
- if the Matte
has an
unsupported type, the platform does not support mattes at all, or an
animated matte is associated with the component and is still runningMatteEnabled.getMatte()
public Matte getMatte()
MatteEnabled
Matte
currently associated with the
component implementing this interface.
getMatte
in interface MatteEnabled
Matte
currently associated with the
component or null if there is noneMatteEnabled.setMatte(com.sun.dtv.ui.Matte)
public void setVerticalAlignment(int valign)
ViewOnlyComponent
setVerticalAlignment
in interface ViewOnlyComponent
valign
- the vertical alignment mode, one of
ViewOnlyComponent.VERTICAL_ALIGN_TOP
,
ViewOnlyComponent.VERTICAL_ALIGN_CENTER
,
ViewOnlyComponent.VERTICAL_ALIGN_BOTTOM
or
ViewOnlyComponent.VERTICAL_ALIGN_JUSTIFIED
.ViewOnlyComponent.getVerticalAlignment()
public int getVerticalAlignment()
ViewOnlyComponent
getVerticalAlignment
in interface ViewOnlyComponent
ViewOnlyComponent.VERTICAL_ALIGN_TOP
,
ViewOnlyComponent.VERTICAL_ALIGN_CENTER
,
ViewOnlyComponent.VERTICAL_ALIGN_BOTTOM
or
ViewOnlyComponent.VERTICAL_ALIGN_JUSTIFIED
.ViewOnlyComponent.setVerticalAlignment(int)
|
Java DTV API 1.3 18-Nov-2009 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |