org.zaval.lw
Class LwCompList
java.lang.Object
|
+--org.zaval.lw.LwCanvas
|
+--org.zaval.lw.LwPanel
|
+--org.zaval.lw.LwAList
|
+--org.zaval.lw.LwCompList
- All Implemented Interfaces:
- java.util.EventListener, Layoutable, LayoutContainer, LwComponent, LwComposite, LwContainer, LwFocusListener, LwKeyListener, LwMouseListener, LwMouseMotionListener, PosInfo, PosListener, ScrollObj, Validationable
- Direct Known Subclasses:
- LwMenu
- public class LwCompList
- extends LwAList
- implements LwFocusListener, LwComposite
This is an implementation of the list component where every list item is light-weight
component. The implementation provides the following abilities:
-
The list component uses other light weight component as the list items. Use
the
addItem, removeItem, insertItem
removeAllItems methods to control the list component content.
For example, if it is necessary to add the following three text items: "Item 1",
"Item 2", "Item 3", you can use LwLabel component as it is shown below:
...
LwCompList list = new LwCompList();
list.addItem(new LwLabel("Item 1"));
list.addItem(new LwLabel("Item 2"));
list.addItem(new LwLabel("Item 3"));
...
or
...
LwCompList list = new LwCompList();
list.addItem("Item 1");
list.addItem("Item 2");
list.addItem("Item 3");
...
In the last sample the list creates the LwLabel with the specified text
automatically.
-
The list component is a composite component, that allows you to use other composite
component as the list items. For example, it is possible to add LwButton component to the
list as an item and it is possible to work with the component after it has been
selected (the button component can be pressed).
-
The list component uses LwListLayout as default manager to layout the list items.
It is possible to use any other layout manager for the purpose, but the layout
manager should implement org.zaval.misc.PosInfo to have ability working together
with the a position manager of the list. The library provides two layout managers that
can be used as the layout manager: LwListLayout and LwGridLayout.
| Fields inherited from class org.zaval.lw.LwCanvas |
bits, bottom, height, isValidValue, left, parent, psHeight, psWidth, right, skins, temporary, top, width, x, y |
|
Constructor Summary |
LwCompList()
Constructs the list component and use standard mode as the default. |
LwCompList(boolean b)
Constructs the list component with the given mode. |
|
Method Summary |
boolean |
catchInput(LwComponent child)
Checks if the input event for the specified child component should be caught by the parent. |
protected void |
drawSelMarker(java.awt.Graphics g,
int x,
int y,
int w,
int h)
Invoked to paint the list selection marker for the specified rectangular area. |
void |
focusGained(LwVCLEvent e)
Invoked when the light weight component gained focus. |
void |
focusLost(LwVCLEvent e)
Invoked when the light weight component lost focus. |
protected LwLayout |
getDefaultLayout()
Gets the default layout manager that is set with the container during initialization.
|
java.lang.Object |
getItem(int index)
Gets the item at the specified index. |
int |
getItemIdxAt(int x,
int y)
Gets an item index that is located at the given location. |
LwView |
getItemView(int index)
Gets the view for the list item at the specified position. |
int |
getItemX(int index)
Gets the item x coordinate. |
int |
getItemY(int index)
Gets the item y coordinate. |
java.awt.Point |
getLayoutOffset()
Returns the offset. |
void |
insert(int i,
java.lang.Object s,
LwComponent d)
Inserts the specified lightweight component with the specified constraints as a child
of this container at the specified position in the container list. |
void |
insertItem(int i,
java.lang.Object o)
Inserts the given item at the specified index. |
int |
itemCount()
Gets the number of items that has been added in the list. |
protected int |
itemH(int index)
Fetches the item height The method should fetches the item
height from the an internal structure without performing any
list validation. |
protected int |
itemW(int index)
Fetches the item width. |
java.awt.Dimension |
maxItemSize()
Gets the maximal possible item size. |
void |
posChanged(java.lang.Object target,
int prevOffset,
int prevLine,
int prevCol)
Invoked when a virtual position has been changed. |
protected void |
recalc()
Invoked with validate method only if the component is not valid.
|
void |
remove(int i)
Removes the component, specified by the index, from this container.
|
void |
removeAll()
Removes all child components from this container.
|
void |
removeAllItems()
Removes all items from the list. |
void |
removeItem(int index)
Removes an item at the specified index. |
void |
setLwLayout(LwLayout l)
Sets the layout manager for this container. |
void |
setPosController(PosController c)
Sets the specified position controller. |
void |
setSOLocation(int x,
int y)
Sets the specified scroll object location. |
| Methods inherited from class org.zaval.lw.LwAList |
addItem, addSelectionListener, canHaveFocus, correctPM, drawPosMarker, endDragged, getColor, getItemGaps, getItemH, getItemW, getLines, getLineSize, getMaxOffset, getPosController, getSelected, getSelectedIndex, getSOLocation, getSOSize, isComboMode, isSelected, keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, moveContent, notifyScrollMan, pageSize, paintOnTop, perform, removeSelectionListener, repaint, select, setColor, setScrollMan, startDragged |
| Methods inherited from class org.zaval.lw.LwPanel |
add, add, calcPreferredSize, count, get, getLwComponentAt, getLwLayout, getPreferredSize, indexOf, insert, invalidate, isInvalidatedByChild, laidout, remove, setBackground, setOpaque, setSize, toFront, updateCashedPs, validate |
| Methods inherited from class org.zaval.lw.LwCanvas |
calcInsets, customize, cvp, getBackground, getBottom, getBounds, getHeight, getInsets, getLeft, getLocation, getLwParent, getOrigin, getPSImpl, getRight, getSize, getTop, getViewMan, getVisiblePart, getWidth, getX, getY, hasFocus, isEnabled, isOpaque, isValid, isVisible, paint, repaint, repaint, repaint, requestFocus, setEnabled, setInsets, setLocation, setLwParent, setPSSize, setViewMan, setVisible, update, viewManChanged, vrp |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.zaval.lw.LwComponent |
canHaveFocus, getBackground, getLwComponentAt, getLwParent, getOrigin, getViewMan, getVisiblePart, isEnabled, isOpaque, paint, repaint, repaint, repaint, setBackground, setEnabled, setInsets, setLwParent, setOpaque, setViewMan, setVisible, update |
| Methods inherited from interface org.zaval.lw.Layoutable |
getBounds, getHeight, getInsets, getLocation, getPreferredSize, getSize, getWidth, getX, getY, isVisible, setLocation, setSize |
LwCompList
public LwCompList()
- Constructs the list component and use standard mode as the default.
LwCompList
public LwCompList(boolean b)
- Constructs the list component with the given mode.
- Parameters:
b - the specified mode. Use true value to have the list
in combo mode. In this case the position changing doesn't bring to the item
selection.
setPosController
public void setPosController(PosController c)
- Description copied from class:
LwAList
- Sets the specified position controller. The controller manages the virtual cursor
location.
- Overrides:
setPosController in class LwAList
- Following copied from class:
org.zaval.lw.LwAList
- Parameters:
c - the specified position controller.
setLwLayout
public void setLwLayout(LwLayout l)
- Sets the layout manager for this container. The layout manager has to implement
org.zaval.misc.PosInfo interface, the interface allows you to control virtual position
of the list component with the position controller of the component.
- Specified by:
setLwLayout in interface LwContainer- Overrides:
setLwLayout in class LwPanel
- Parameters:
l - the specified layout manager.
focusGained
public void focusGained(LwVCLEvent e)
- Description copied from interface:
LwFocusListener
- Invoked when the light weight component gained focus.
- Specified by:
focusGained in interface LwFocusListener
- Following copied from interface:
org.zaval.lw.event.LwFocusListener
- Parameters:
e - the specified focus event.
drawSelMarker
protected void drawSelMarker(java.awt.Graphics g,
int x,
int y,
int w,
int h)
- Description copied from class:
LwAList
- Invoked to paint the list selection marker for the specified rectangular area.
- Overrides:
drawSelMarker in class LwAList
- Following copied from class:
org.zaval.lw.LwAList
- Parameters:
g - the graphics context to be used for painting.x - the x coordinate of the rectangular area.y - the y coordinate of the rectangular area.w - the width of the rectangular area.h - the height of the rectangular area.
focusLost
public void focusLost(LwVCLEvent e)
- Description copied from interface:
LwFocusListener
- Invoked when the light weight component lost focus.
- Specified by:
focusLost in interface LwFocusListener
- Following copied from interface:
org.zaval.lw.event.LwFocusListener
- Parameters:
e - the specified focus event.
catchInput
public boolean catchInput(LwComponent child)
- Description copied from interface:
LwComposite
- Checks if the input event for the specified child component should be caught by the parent.
- Specified by:
catchInput in interface LwComposite
- Following copied from interface:
org.zaval.lw.LwComposite
- Parameters:
child - the specified child component.- Returns:
true if input events for the child component should be caught by this
component; false otherwise.
posChanged
public void posChanged(java.lang.Object target,
int prevOffset,
int prevLine,
int prevCol)
- Description copied from interface:
PosListener
- Invoked when a virtual position has been changed.
- Overrides:
posChanged in class LwAList
- Following copied from interface:
org.zaval.misc.event.PosListener
- Parameters:
target - the specified pos controller.prevOffset - the previous offset.prevLine - the previous line.prevColumn - the previous column.
insert
public void insert(int i,
java.lang.Object s,
LwComponent d)
- Description copied from interface:
LwContainer
- Inserts the specified lightweight component with the specified constraints as a child
of this container at the specified position in the container list. The method should call
the
componentAdded method its layout manager to inform the layout manager
that the new child has been added with the given constraints.
- Specified by:
insert in interface LwContainer- Overrides:
insert in class LwPanel
- Following copied from interface:
org.zaval.lw.LwContainer
- Parameters:
i - the position in the container list at which to insert
the component.s - the object expressing layout constraints for this.c - the lightweight component to be added.
remove
public void remove(int i)
- Description copied from interface:
LwContainer
- Removes the component, specified by the index, from this container.
The layout manager of this container should be informed by calling
the
componentRemoved method of the manager.
- Specified by:
remove in interface LwContainer- Overrides:
remove in class LwPanel
- Following copied from interface:
org.zaval.lw.LwContainer
- Parameters:
i - the index of the component to be removed.
removeAll
public void removeAll()
- Description copied from interface:
LwContainer
- Removes all child components from this container.
The layout manager of this container should be informed by calling
the
componentRemoved method of the manager for every child component
that has been removed.
- Specified by:
removeAll in interface LwContainer- Overrides:
removeAll in class LwPanel
setSOLocation
public void setSOLocation(int x,
int y)
- Description copied from interface:
ScrollObj
- Sets the specified scroll object location. The method defines a mechanism that will be used to
scrool the object.
- Overrides:
setSOLocation in class LwAList
- Following copied from interface:
org.zaval.misc.ScrollObj
- Parameters:
x - the specified x coordinate.y - the specified y coordinate.
getLayoutOffset
public java.awt.Point getLayoutOffset()
- Description copied from interface:
LayoutContainer
- Returns the offset. The offset can be used with a layout manager to offset child components
locations of the container according to the offset values. The offset is represented
with java.awt.Point class, the
x is offset for x-coordinates and y
is offset for y-coordinates. The ability to offset child components with a layout manager
is used with the library to organize scrolling.
- Specified by:
getLayoutOffset in interface LayoutContainer- Overrides:
getLayoutOffset in class LwPanel
- Following copied from interface:
org.zaval.lw.LayoutContainer
- Returns:
- an offset to move children.
getItemView
public LwView getItemView(int index)
- Description copied from class:
LwAList
- Gets the view for the list item at the specified position.
- Overrides:
getItemView in class LwAList
- Following copied from class:
org.zaval.lw.LwAList
- Parameters:
index - the item position.- Returns:
- a view.
insertItem
public void insertItem(int i,
java.lang.Object o)
- Description copied from class:
LwAList
- Inserts the given item at the specified index.
- Overrides:
insertItem in class LwAList
- Following copied from class:
org.zaval.lw.LwAList
- Parameters:
index - the specified item index.o - the specified item.
getItem
public java.lang.Object getItem(int index)
- Description copied from class:
LwAList
- Gets the item at the specified index.
- Overrides:
getItem in class LwAList
- Following copied from class:
org.zaval.lw.LwAList
- Parameters:
i - the specified item index.- Returns:
- an item.
removeItem
public void removeItem(int index)
- Description copied from class:
LwAList
- Removes an item at the specified index.
- Overrides:
removeItem in class LwAList
- Following copied from class:
org.zaval.lw.LwAList
- Parameters:
i - the specified item index.
removeAllItems
public void removeAllItems()
- Description copied from class:
LwAList
- Removes all items from the list.
- Overrides:
removeAllItems in class LwAList
itemCount
public int itemCount()
- Description copied from class:
LwAList
- Gets the number of items that has been added in the list.
- Overrides:
itemCount in class LwAList
- Following copied from class:
org.zaval.lw.LwAList
- Returns:
- an number of the list items.
getItemX
public int getItemX(int index)
- Description copied from class:
LwAList
- Gets the item x coordinate.
- Overrides:
getItemX in class LwAList
- Following copied from class:
org.zaval.lw.LwAList
- Parameters:
index - the specified item index.- Returns:
- the item x coordinate.
getItemY
public int getItemY(int index)
- Description copied from class:
LwAList
- Gets the item y coordinate.
- Overrides:
getItemY in class LwAList
- Following copied from class:
org.zaval.lw.LwAList
- Parameters:
index - the specified item index.- Returns:
- the item y coordinate.
itemW
protected int itemW(int index)
- Description copied from class:
LwAList
- Fetches the item width. The method should fetches the item
width from the an internal structure without performing any
list validation.
- Overrides:
itemW in class LwAList
- Following copied from class:
org.zaval.lw.LwAList
- Parameters:
index - the specified item index.- Returns:
- the item width.
itemH
protected int itemH(int index)
- Description copied from class:
LwAList
- Fetches the item height The method should fetches the item
height from the an internal structure without performing any
list validation.
- Overrides:
itemH in class LwAList
- Following copied from class:
org.zaval.lw.LwAList
- Parameters:
index - the specified item index.- Returns:
- the item height.
recalc
protected void recalc()
- Description copied from class:
LwCanvas
- Invoked with
validate method only if the component is not valid.
The method should be overridden to calculate metrical characteristics of the component to
minimize computation time of the preferred size for the component. For example, you can
calculate a preferred size inside the method and just return it by
calcPreferredSize method.
- Overrides:
recalc in class LwCanvas
maxItemSize
public java.awt.Dimension maxItemSize()
- Description copied from class:
LwAList
- Gets the maximal possible item size.
- Overrides:
maxItemSize in class LwAList
- Following copied from class:
org.zaval.lw.LwAList
- Returns:
- a maximal possible item size.
getItemIdxAt
public int getItemIdxAt(int x,
int y)
- Description copied from class:
LwAList
- Gets an item index that is located at the given location.
- Overrides:
getItemIdxAt in class LwAList
- Following copied from class:
org.zaval.lw.LwAList
- Parameters:
x - the x coordinate of the given location.y - the y coordinate of the given location.- Returns:
- an item index that is located at the given location.
getDefaultLayout
protected LwLayout getDefaultLayout()
- Description copied from class:
LwPanel
- Gets the default layout manager that is set with the container during initialization.
This implementation of the method returns LwRastLayout as the default layout manager, the
layout manager is got as a static object by "def.lay" key.
- Overrides:
getDefaultLayout in class LwPanel
- Following copied from class:
org.zaval.lw.LwPanel
- Returns:
- a layout manager.
|