|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--org.zaval.util.ValidationObject
|
+--org.zaval.lw.LwCanvas
|
+--org.zaval.lw.tree.LwTree
This is tree view component. The component renders the specified TreeModel
and organizes navigation through the tree. The sample below illustrates
the component usage:
...
Item root = new Item("root");
TreeModel data = new Tree(root);
data.add(data.getRoot(), new Item("First Child root"));
data.add(data.getRoot(), new Item("Second Child root"));
LwTree tree = new LwTree(data);
...
The class provides ability to customize the tree node rendering by defining the
LwViewProvider provider. It allows to specify the view for the tree item.
The default tree item view is LwTextRender.
Use addSelectionListener and removeSelectionListener methods to
handle selection events. The events are performed by the component whenever the tree node
has been selected, deselected.
Use addActionListener and removeActionListener methods to
be notified whenever the node has been expanded or collapsed. The action event contains
the tree expanded or collapsed item that can be got by getData method of the
action event object.
It is possible to disable node selection by the enableSelection method.
It is possible to customize views for some elements of the tree by setView
The default views of the elements are read as static objects by following keys:
The tree nodes height and width can be extended by setGaps method that
defines horizontal and vertical gaps between the nodes.
It is possible disables tree view line rendering by showLines method.
| Field Summary | |
static int |
CLOSED_VIEW
Defines closed view element type. |
static int |
LEAST_VIEW
Defines list view element type. |
static int |
OPENED_VIEW
Defines opened view element type. |
static int |
TOGGLE_OFF_VIEW
Defines toggle off view element type. |
static int |
TOGGLE_ON_VIEW
Defines toggle on view element type. |
| Fields inherited from class org.zaval.lw.LwCanvas |
bits, height, insets, parent, psHeight, psWidth, skins, width, x, y |
| Fields inherited from class org.zaval.util.ValidationObject |
isValidFlag |
| Constructor Summary | |
LwTree(TreeModel d)
Constructs a tree view component with the specified tree model. |
|
LwTree(TreeModel d,
boolean b)
Constructs a tree view component with the specified tree model and tree node state. |
|
| Method Summary | |
void |
addActionListener(LwActionListener l)
Adds the specified action listener to receive action events from this tree. |
void |
addSelectionListener(LwActionListener l)
Adds the specified selection listener to be notified whenever the tree item has been selected, deselected. |
protected java.awt.Dimension |
calcPreferredSize()
Gets the preferred size of this component. |
boolean |
canHaveFocus()
Specifies if the component can have focus. |
void |
enableSelection(boolean b)
Enables the tree node selecting. |
void |
focusGained(LwFocusEvent e)
Invoked when the light weight component gained focus. |
void |
focusLost(LwFocusEvent e)
Invoked when the light weight component lost focus. |
ItemMetrics |
getItemMetrics(Item i)
Gets the item metric for the specified item. |
java.awt.Color |
getLinesColor()
Gets the color that is used to paint tree lines. |
TreeModel |
getModel()
Gets the tree model that is rendered with the tree view component. |
java.awt.Point |
getOrigin()
Returns an origin of the component. |
Item |
getSelectedItem()
Gets the item that is selected at the moment. |
java.awt.Color |
getSelectionColor(boolean isHasFocus)
Gets the selection marker color for the specified component focus state. |
java.awt.Point |
getSOLocation()
Gets the scroll object location. |
java.awt.Dimension |
getSOSize()
Gets the scroll object size. |
LwView |
getView(Drawable d,
java.lang.Object obj)
Gets the view for the specified object of the specified component. |
LwViewProvider |
getViewProvider()
Gets the view provider. |
void |
invalidate()
Invalidates this component. |
boolean |
isLinesShown()
Tests if the tree line rendering is enabled. |
boolean |
isOpen(Item i)
Checks if the tree item is expanded. |
boolean |
isSelectionEnabled()
Tests if the tree items selection is enabled. |
void |
itemInserted(TreeEvent e)
Invoked when the item has been inserted as a memeber of the source tree. |
void |
itemModified(TreeEvent e)
Invoked when the item of the source tree has been modified. |
void |
itemRemoved(TreeEvent e)
Invoked when the item has been removed from the source tree. |
void |
keyPressed(LwKeyEvent e)
Invoked when a key has been pressed. |
void |
keyReleased(LwKeyEvent e)
Invoked when a key has been released. |
void |
keyTyped(LwKeyEvent e)
Invoked when a key has been typed. |
void |
mouseClicked(LwMouseEvent e)
Invoked when the mouse button has been clicked on a light weight component. |
void |
mouseEntered(LwMouseEvent e)
Invoked when the mouse enters a light weight component. |
void |
mouseExited(LwMouseEvent e)
Invoked when the mouse exits a light weight component. |
void |
mousePressed(LwMouseEvent e)
Invoked when the mouse button has been pressed on a light weight component. |
void |
mouseReleased(LwMouseEvent e)
Invoked when the mouse button has been released on a light weight component. |
boolean |
moveContent()
Tests if the scroll component performs scrolling by changing its location or moving view. |
void |
paint(java.awt.Graphics g)
Paints this component. |
protected void |
recalc()
The method is overrided to calculate metrical characteristics of the tree view component. |
void |
removeActionListener(LwActionListener l)
Removes the specified action listener. |
void |
removeSelectionListener(LwActionListener l)
Removes the specified selection listener. |
void |
select(Item item)
Selects the specified node of the tree. |
void |
setGaps(int gx,
int gy)
Sets the specified vertical and horizontal gaps. |
void |
setLinesColor(java.awt.Color c)
Sets the specified color to paint tree lines. |
void |
setModel(TreeModel d)
Sets the specified tree model to be rendered with the component. |
void |
setScrollMan(ScrollMan m)
Sets the specified scroll manager for the scroll object. |
void |
setSelectionColor(java.awt.Color c,
boolean isHasFocus)
Sets the selection marker color for the given tree view component state. |
void |
setSOLocation(int x,
int y)
Sets the specified scroll object location. |
void |
setView(int id,
LwView v)
Sets the specified view for the specified tree view element. |
void |
setViewProvider(LwViewProvider p)
Sets the specified view provider. |
void |
showLines(boolean b)
Enables the tree lines rendering. |
void |
toggle(Item item)
Switches a toggle state for the specified tree item. |
| Methods inherited from class org.zaval.lw.LwCanvas |
getBackground, getBounds, getHeight, getInsets, getLocation, getLwComponentAt, getLwParent, getPreferredSize, getSize, getViewMan, getVisiblePart, getWidth, getX, getY, hasFocus, isEnabled, isOpaque, isVisible, repaint, repaint, requestFocus, setBackground, setEnabled, setInsets, setLocation, setLwParent, setOpaque, setPSSize, setSize, setViewMan, setVisible, toString, update, validate, viewManChanged, vrp |
| Methods inherited from class org.zaval.util.ValidationObject |
isValid |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.zaval.util.Validationable |
isValid |
| Field Detail |
public static final int LEAST_VIEW
public static final int OPENED_VIEW
public static final int CLOSED_VIEW
public static final int TOGGLE_OFF_VIEW
public static final int TOGGLE_ON_VIEW
| Constructor Detail |
public LwTree(TreeModel d)
d - the specified tree model.
public LwTree(TreeModel d,
boolean b)
d - the specified tree model.b - the specified tree node state.| Method Detail |
public boolean canHaveFocus()
LwComponentcanHaveFocus in class LwCanvasorg.zaval.lw.LwComponenttrue if the component can have the focus.public void enableSelection(boolean b)
b - use true to enable the tree node selecting;
false otherwise.public boolean isSelectionEnabled()
true if the tree items selection is enabled;
false otherwise.public void showLines(boolean b)
b - use true to enable the tree line rendering;
false otherwise.public boolean isLinesShown()
true if the line rendering is enabled;
false otherwise.public java.awt.Color getLinesColor()
a - color.public void setLinesColor(java.awt.Color c)
c - the specified color.
public void setGaps(int gx,
int gy)
gx - the specified horizontal gap.gy - the specified vertical gap.public TreeModel getModel()
public void setViewProvider(LwViewProvider p)
null value
as the input argument, in this case the LwTextRender view is used (the method
sets itself as the view provider) to paint the node.p - the specified view provider.public LwViewProvider getViewProvider()
public void setView(int id,
LwView v)
id - the specified element id.v - the specified view.public void setModel(TreeModel d)
d - the specified tree model.public void paint(java.awt.Graphics g)
paint in class LwCanvasg - the graphics context to be used for painting.protected void recalc()
recalc in class LwCanvaspublic void addSelectionListener(LwActionListener l)
l - the specified selection listener.public void removeSelectionListener(LwActionListener l)
l - the specified selection listener.
public LwView getView(Drawable d,
java.lang.Object obj)
LwViewProvidergetView in interface LwViewProviderorg.zaval.lw.LwViewProviderd - the specified component.obj - the specified object.public void focusGained(LwFocusEvent e)
LwFocusListenerfocusGained in interface LwFocusListenerorg.zaval.lw.event.LwFocusListenere - the specified focus event.public void focusLost(LwFocusEvent e)
LwFocusListenerfocusLost in interface LwFocusListenerorg.zaval.lw.event.LwFocusListenere - the specified focus event.public void mouseClicked(LwMouseEvent e)
LwMouseListenermouseClicked in interface LwMouseListenerorg.zaval.lw.event.LwMouseListenere - the specified mouse event.public void mouseEntered(LwMouseEvent e)
LwMouseListenermouseEntered in interface LwMouseListenerorg.zaval.lw.event.LwMouseListenere - the specified mouse event.public void mouseExited(LwMouseEvent e)
LwMouseListenermouseExited in interface LwMouseListenerorg.zaval.lw.event.LwMouseListenere - the specified mouse event.public void mouseReleased(LwMouseEvent e)
LwMouseListenermouseReleased in interface LwMouseListenerorg.zaval.lw.event.LwMouseListenere - the specified mouse event.public void keyReleased(LwKeyEvent e)
LwKeyListenerkeyReleased in interface LwKeyListenerorg.zaval.lw.event.LwKeyListenere - the specified key event.public void keyTyped(LwKeyEvent e)
LwKeyListenerkeyTyped in interface LwKeyListenerorg.zaval.lw.event.LwKeyListenere - the specified key event.public void keyPressed(LwKeyEvent e)
LwKeyListenerkeyPressed in interface LwKeyListenerorg.zaval.lw.event.LwKeyListenere - the specified key event.public void mousePressed(LwMouseEvent e)
LwMouseListenermousePressed in interface LwMouseListenerorg.zaval.lw.event.LwMouseListenere - the specified mouse event.
public void setSelectionColor(java.awt.Color c,
boolean isHasFocus)
c - the selection marker color. Use null if the marker should not be
rendered.isHasFocus - the given tree view component focus state. Use true
to identify the selection color when the component has focus, otherwise use falsepublic java.awt.Color getSelectionColor(boolean isHasFocus)
isHasFocus - the given tree view component focus state. Use true
to identify the selection color when the component has focus, otherwise use falsepublic void toggle(Item item)
item - the specified tree item.public void select(Item item)
item - the specified node.public Item getSelectedItem()
public void addActionListener(LwActionListener l)
getData method of the action event.l - the specified action listener.public void removeActionListener(LwActionListener l)
l - the specified action listener.public void itemInserted(TreeEvent e)
TreeListeneritemInserted in interface TreeListenerorg.zaval.data.event.TreeListenere - the specified event.public void itemRemoved(TreeEvent e)
TreeListeneritemRemoved in interface TreeListenerorg.zaval.data.event.TreeListenere - the specified event.public void itemModified(TreeEvent e)
TreeListeneritemModified in interface TreeListenerorg.zaval.data.event.TreeListenere - the specified event.public void invalidate()
LwCanvasinvalidate in class LwCanvaspublic java.awt.Point getOrigin()
LwCanvasnull, in this case the origin is (0, 0).getOrigin in class LwCanvasorg.zaval.lw.LwCanvaspublic java.awt.Point getSOLocation()
ScrollObjgetSOLocation in interface ScrollObjorg.zaval.misc.ScrollObj
public void setSOLocation(int x,
int y)
ScrollObjsetSOLocation in interface ScrollObjorg.zaval.misc.ScrollObjx - the specified x coordinate.y - the specified y coordinate.public java.awt.Dimension getSOSize()
ScrollObjgetSOSize in interface ScrollObjorg.zaval.misc.ScrollObjpublic void setScrollMan(ScrollMan m)
ScrollObjsetScrollMan in interface ScrollObjorg.zaval.misc.ScrollObjm - the specified scroll manager.public boolean moveContent()
ScrollObjmoveContent in interface ScrollObjorg.zaval.misc.ScrollObjtrue if the scroll component organizes scrolling by moving
its view; otherwise false.public boolean isOpen(Item i)
i - the specified tree item.true if the item and its parent item is expanded too;
false otherwise.public ItemMetrics getItemMetrics(Item i)
i - the specified item.protected java.awt.Dimension calcPreferredSize()
calcPreferredSize in class LwCanvas
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||