|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.ui.Field
net.rim.device.api.ui.component.TreeField
public class TreeField
A simple field to show a tree structure.
Behaviour
Shows a field structure useful for displaying objects in a hierarchy (like a
set of nested folders).
Field Summary |
---|
Constructor Summary | ||
---|---|---|
TreeField(TreeFieldCallback callback,
long style)
Constructs an empty TreeField instance with given callback. |
Method Summary | ||
---|---|---|
int |
addChildNode(int parent,
Object cookie)
Adds a new child node to this tree field. |
|
int |
addChildNode(int parent,
Object cookie,
boolean updateLayout)
Adds a new child node to this tree field. |
|
int |
addSiblingNode(int previousSibling,
Object cookie)
Adds a new sibling node to this tree field. |
|
int |
addSiblingNode(int previousSibling,
Object cookie,
boolean updateLayout)
Adds a new sibling node to this tree field. |
|
void |
deleteAll()
Deletes all trees in this field. |
|
void |
deleteSubtree(int node)
Delete the entire subtree rooted at 'node'. |
|
protected void |
drawFocus(Graphics graphics,
boolean on)
Draws the focus indicator for this field. |
|
AccessibleContext |
getAccessibleContext()
Returns accessible representation of the field for a screen reader. |
|
Object |
getCookie(int node)
Retrieves the user-supplied cookie object for the given node. |
|
int |
getCurrentNode()
Retrieves ID of node with focus. |
|
String |
getEmptyString()
Retrieves empty marker string. |
|
int |
getEmptyStringStyle()
Retrieves drawing style of the empty marker string. |
|
boolean |
getExpanded(int node)
Determines if node is expanded or collapsed. |
|
int |
getFirstChild(int node)
Retrieves ID of first child of specified node. |
|
int |
getFirstRoot()
Retrieves ID of this tree's first root node. |
|
void |
getFocusRect(XYRect rect)
Retrieves this field's current focus region. |
|
void |
getFocusRectPhantom(XYRect rect)
Retrieves this field's current focus phantom region. |
|
int |
getLastNode(int node,
boolean followCollapsed)
Retrieves the last node in a prefix depth first traversal of the subtree rooted at the given node. |
|
int |
getNextSibling(int node)
Retrieves ID of next sibling of specified node. |
|
int |
getNodeCount()
Retrieves total number of nodes in this tree. |
|
int |
getParent(int node)
Retrieves ID of specified node's parent. |
|
int |
getPreviousSibling(int node)
Retrieves ID of the previous sibling of specified node. |
|
int |
getRowHeight()
Retrieves this field's row height. |
|
boolean |
getVisible(int node)
Determines if node is visible. |
|
int |
getVisibleNodeCount()
Retrieves number of visible nodes in this tree. |
|
void |
invalidateNode(int node)
Invalidates the given node for repainting. |
|
protected boolean |
keyChar(char character,
int status,
int time)
Handles character generation events. |
|
protected void |
layout(int width,
int height)
Lays out this field's contents. |
|
protected void |
makeContextMenu(ContextMenu contextMenu)
Builds this field's context menu. |
|
protected int |
moveFocus(int amount,
int status,
int time)
Handles moving the focus within this field. |
|
protected void |
moveFocus(int x,
int y,
int status,
int time)
Handles moving the focus within this field. |
|
int |
nextNode(int node,
int root,
boolean followCollapsed)
Retrieves the next node in a prefix depth first traversal of the tree. |
|
protected void |
onFocus(int direction)
Invoked when this field receives the focus. |
|
protected void |
onUnfocus()
Invoked when this field loses the focus. |
|
protected void |
paint(Graphics graphics)
Redraws this field. |
|
int |
previousNode(int node,
boolean followCollapsed)
Retrieves the previous node in a prefix depth first traversal of the tree. |
|
void |
setCookie(int node,
Object cookie)
Sets the user-supplied cookie object for the given node. |
|
void |
setCurrentNode(int node)
Sets the current node for this field. |
|
void |
setDefaultExpanded(boolean expanded)
Sets the default expansion state for future node allocations. |
|
void |
setEmptyString(String emptyString,
int style)
Sets the empty marker string for this field. |
|
void |
setExpanded(int node,
boolean expanded)
Sets the expansion state for the given node. |
|
void |
setExpanded(int node,
boolean expanded,
boolean updateLayout)
Sets the expansion state for the given node. |
|
void |
setIndentWidth(int indent)
Sets the indent width. |
|
void |
setRowHeight(int rowHeight)
Sets the height of each row in the list field. |
|
void |
setRowHeightInLines(int rowHeight)
Sets the height of each row in the list field. |
|
protected boolean |
touchEvent(TouchEvent message)
Traps touch input events. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TreeField(TreeFieldCallback callback, long style)
callback
- Drawing callback object for this field.style
- The only valid styles for tree fields are
Field.NON_FOCUSABLE
and Field.FOCUSABLE
.
NullPointerException
- If callback parameter is null and this is
not a TreeFieldCallback.
IllegalArgumentException
- If you specify an invalid style.Method Detail |
---|
protected void drawFocus(Graphics graphics, boolean on)
This method inverts the row of the current node offset by the indent. If moveMode is true, a rectangle is instead drawn around the current node with up/down arrows on the right
drawFocus
in class Field
graphics
- Graphics object for drawing the focus.on
- True if the focus should be set; otherwise, false.public AccessibleContext getAccessibleContext()
getAccessibleContext
in class Field
public Object getCookie(int node)
node
- ID of the node for which to retrieve the cookie.
public int getCurrentNode()
public boolean getExpanded(int node)
Note that this method does not tell you whether a node can be collapsed (i.e. has at least one child); nodes with no children are automatically and permanently expanded.
node
- ID of node to test.
public int getFirstChild(int node)
node
- ID of parent node; or 0 to retrieve the first root node.
public int getFirstRoot()
public void getFocusRect(XYRect rect)
getFocusRect
in class Field
rect
- To contain the focus extent for this field, in local
coordinates.public void getFocusRectPhantom(XYRect rect)
getFocusRectPhantom
in class Field
rect
- To contain the phantom focus extent for this field, in local
coordinates. This rect will be identical to, or a superset set of, the
current focus region.public int getNextSibling(int node)
node
- ID of sibling node.
public int getNodeCount()
Invoke this method to retrieve the total number of nodes contained in this tree, including all the child nodes of collapsed ancestors (i.e. those nodes not currently visible).
public int getParent(int node)
node
- ID of node for which to retrieve parent.
public int getPreviousSibling(int node)
node
- ID of sibling node.
public int getRowHeight()
public boolean getVisible(int node)
Note that this method does not necessarily report on whether the node is currently shown on the screen (i.e. visible to the user). It reports only whether or not the specified node is "hidden" by a collapsed ancestor.
node
- ID of node to test.
public void invalidateNode(int node)
node
- ID of the node to invalidatepublic int getVisibleNodeCount()
Invoke this method to retrieve the number of nodes currently shown in this tree (i.e. not including child nodes of currently collapsed ancestors).
protected boolean keyChar(char character, int status, int time)
This field's manager invokes this method to handle SPACE key generation events. All other key events are passed on, and this method then returns false.
If the key pressed is SPACE, then this method may do a number of things:
keyChar
in class Field
character
- Character generated.status
- Modifier key status.time
- Number of milliseconds since the device was turned on.
protected boolean touchEvent(TouchEvent message)
This method handles touch input events. DOWN events cause this TreeField to enter a focused state, which is in fact handled at the Manager level. UNCLICK events toggle the tree nodes. The remaining touch input events are consumed and/or ignored.
touchEvent
in class Field
message
- TouchEvent
object containing various input parameters
including the event type and touch coordinates.
IllegalArgumentException
- If message
is null.protected void layout(int width, int height)
This field's manager invokes this method during the layout process to instruct this field to arrange its contents, given an amount of available space.
layout
in class Field
width
- Amount of available horizontal space.height
- Amount of available vertical space.protected void makeContextMenu(ContextMenu contextMenu)
The framework invokes this method to construct this field's context
menu. This method overrides the one in Field
in order to provide
menu items to Collapse Item and Expand Item.
makeContextMenu
in class Field
contextMenu
- Context menu for this field.ContextMenu
protected void moveFocus(int x, int y, int status, int time)
This method is invoked by the framework to move the focus within this field. Given an x,y position in client coordinates, update the focus to point to the new location.
Does nothing if the x,y position is out of range.
moveFocus
in class Field
x
- Horizontal coordinate of the new focal pointy
- Vertical coordinate of the new focal pointstatus
- Modifier key state.time
- Ticks since device reset.protected int moveFocus(int amount, int status, int time)
The framework invokes this method to move the focus within this field. The value of the amount parameter determines the direction of the roll: a negative amount value indicates a backwards direction, whereas a positive amount indicates a forwards direction.
moveFocus
in class Field
amount
- Number of positions to move, positive means forwards in
the tree, negative means backwards in the tree.status
- Modifier key state.time
- Number of milliseconds since the device was turned on.
protected void onFocus(int direction)
onFocus
in class Field
direction
- If 1, the focus came from the previous field; if -1, the
focus came from the subsequent field; if 0, the focus was directly set
(not as a result of trackwheel movement).protected void onUnfocus()
onUnfocus
in class Field
protected void paint(Graphics graphics)
This field's manager invokes this method during the repainting process to instruct this field to repaint itself.
This method determines what tree elements require repainting, and
then invokes the registered TreeFieldCallback
to do the actual
repainting..
paint
in class Field
graphics
- Graphics context for repainting this field.public void setEmptyString(String emptyString, int style)
Provide this method with a string (and style) that this field can
display to signify that this tree field is empty (for example the string
"[Empty]
"). By default, the style for this string is
DrawStyle.HCENTER
(that is, horizontally centered text).
emptyString
- Empty marker string for this field.style
- Drawing style for the empty marker string.
NullPointerException
- If emptyString parameter is nullpublic String getEmptyString()
public int getEmptyStringStyle()
public void setCurrentNode(int node)
node
- ID of the node to make current.
IllegalArgumentException
- If the identified node is invalid or is
not currently visible.public void deleteAll()
public void deleteSubtree(int node)
The subtree root is also deleted from the tree.
node
- ID of the root node of the subtree to be deleted.public int addChildNode(int parent, Object cookie)
Invoke this method to create a new node and add it as the first child of the given parent node. If the parent node already has children, the new node is still placed as the first child.
parent
- ID of the parent node, 0 if this is to be the first root
node.cookie
- User supplied cookie object to associate with the new node.
public int addChildNode(int parent, Object cookie, boolean updateLayout)
Invoke this method to create a new node and add it as the first child of the given parent node. If the parent node already has children, the new node is still placed as the first child.
parent
- ID of the parent node, 0 if this is to be the first root
node.cookie
- User supplied cookie object to associate with the new node.updateLayout
- If false, layout will not be updated (good for batch operations)
public int addSiblingNode(int previousSibling, Object cookie)
Invoke this method to create a new node and add it as the first sibling of the given sibling node. This method inserts the sibling immediately after the one you identify.
previousSibling
- ID of the node after which to place the new node.cookie
- User supplied cookie object to associate with the new node.
public int addSiblingNode(int previousSibling, Object cookie, boolean updateLayout)
Invoke this method to create a new node and add it as the first sibling of the given sibling node. This method inserts the sibling immediately after the one you identify.
previousSibling
- ID of the node after which to place the new node.cookie
- User supplied cookie object to associate with the new node.updateLayout
- If false, layout will not be updated (good for batch operations)
public void setDefaultExpanded(boolean expanded)
expanded
- True if future nodes should be expanded, false if the nodes
should be collapsed.public void setExpanded(int node, boolean expanded)
node
- ID of the node.expanded
- True if the node should be expanded, false if the node
should be collapsed.public void setExpanded(int node, boolean expanded, boolean updateLayout)
node
- ID of the node.expanded
- True if the node should be expanded, false if the node
should be collapsed.updateLayout
- If false, layout will not be updated (good for batch operations)public int nextNode(int node, int root, boolean followCollapsed)
node
- ID of the current node, 0 to start at the beginning.root
- ID of the root node of the traversal, 0 to do a complete walk.followCollapsed
- True if the walk should traverse through collapsed
nodes; otherwise, false.
public int previousNode(int node, boolean followCollapsed)
node
- ID of the current node, 0 to start at the beginning.followCollapsed
- True if the walk should traverse through collapsed
nodes, false otherwise.
public int getLastNode(int node, boolean followCollapsed)
node
- ID of the root of the subtree to traverse.followCollapsed
- True if the walk should traverse through collapsed
nodes; otherwise, false.
public void setCookie(int node, Object cookie)
node
- ID of the node to associate with the cookie.cookie
- User supplied cookie object.public void setIndentWidth(int indent)
indent
- New indent width in pixels.
IllegalArgumentException
- If indent parameter is negative.public void setRowHeight(int rowHeight)
rowHeight
- Height of each row in the list field.
IllegalArgumentException
- If invalid row height parameter (if
zero, or too small proper display of current font).public void setRowHeightInLines(int rowHeight)
The row height is in multiples of the height of the font for this field.
rowHeight
- Height of each row in the list field.
IllegalArgumentException
- If invalid row height parameter (if
zero, or too small proper display of current font).
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.