org.zaval.lw
Class LwAList
java.lang.Object
|
+--org.zaval.lw.LwCanvas
|
+--org.zaval.lw.LwPanel
|
+--org.zaval.lw.LwAList
- All Implemented Interfaces:
- java.util.EventListener, Layoutable, LayoutContainer, LwComponent, LwContainer, LwKeyListener, LwMouseListener, LwMouseMotionListener, PosInfo, PosListener, ScrollObj, Validationable
- Direct Known Subclasses:
- LwCompList, LwList
- public abstract class LwAList
- extends LwPanel
- implements ScrollObj, LwMouseMotionListener, LwMouseListener, LwKeyListener, PosListener, PosInfo
This is abstract list component. The component provides the following abilities:
-
Control the list content by the
addItem, insertItem,
removeItem, removeAllItems,
getItem, itemCount methods. Most of the listed methods
are abstract.
-
Control the list items metrics by the
getItemW, getItemH,
getItemX, getItemY, methods. Most of the listed methods
are abstract.
-
The list has PosController class to control current position. Pay attention that
selection index and position are two different things. To control the list position
use the position controller that can be got by
getPosController method.
To control selection use the select, getSelected,
getSelectedIndex, isSelected methods.
-
The list can work in combo mode or standard mode. In combo mode the position is
changed by moving the mouse cursor and item is selected by the mouse button. In
standard mode the position changing brings to an item selection.
-
Use the
addSelectionListener and removeSelectionListener methods
to listen whenever the selected item has been changed. The passed data argument
is an item index or null if the item has been re-selected.
|
Field Summary |
protected PosController |
controller
The position controller field. |
protected int |
dx
The horizontal offset field. |
protected int |
dy
The vertical offset field. |
static int |
POS_COLOR
Defines the pos marker color type. |
static int |
SEL_COLOR
Defines the selection marker color type. |
protected int |
selectedIndex
The selected index field. |
| 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 |
LwAList()
Constructs the list component and use standard mode as the default. |
LwAList(boolean b)
Constructs the list component with the given mode. |
|
Method Summary |
void |
addItem(java.lang.Object o)
Adds the specified item in the list. |
void |
addSelectionListener(LwActionListener l)
Adds the specified selection listener to receive selection events from this list component.
|
boolean |
canHaveFocus()
Specifies if the component can have focus. |
protected void |
correctPM(int x,
int y)
Sets the list position to an item at the specified location. |
protected void |
drawPosMarker(java.awt.Graphics g,
int x,
int y,
int w,
int h)
Invoked to paint the list position marker for the specified rectangular area. |
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 |
endDragged(LwMouseEvent e)
Invoked when the mouse ends dragged. |
java.awt.Color |
getColor(int type)
Gets the specified element color. |
abstract java.lang.Object |
getItem(int i)
Gets the item at the specified index. |
protected int |
getItemGaps()
Gets the item gaps. |
int |
getItemH(int index)
Gets the specified item height. |
abstract 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 |
getItemW(int index)
Gets the specified item width. |
abstract int |
getItemX(int index)
Gets the item x coordinate. |
abstract int |
getItemY(int index)
Gets the item y coordinate. |
int |
getLines()
Gets the number of lines. |
int |
getLineSize(int l)
Gets the line size for the specified line number. |
int |
getMaxOffset()
Gets the maximal offset. |
PosController |
getPosController()
Gets the position controller. |
java.lang.Object |
getSelected()
Gets the selected item. |
int |
getSelectedIndex()
Gets the selected item index. |
java.awt.Point |
getSOLocation()
Gets the scroll object location. |
java.awt.Dimension |
getSOSize()
Gets the scroll object size. |
abstract void |
insertItem(int index,
java.lang.Object o)
Inserts the given item at the specified index. |
boolean |
isComboMode()
Tests if the list works in the ombo mode. |
boolean |
isSelected(int i)
Tests if the item with the specified index is selected. |
abstract int |
itemCount()
Gets the number of items that has been added in the list. |
protected abstract 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 abstract int |
itemW(int index)
Fetches the item width. |
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. |
java.awt.Dimension |
maxItemSize()
Gets the maximal possible item size. |
void |
mouseClicked(LwMouseEvent e)
Invoked when the mouse button has been clicked on a light weight component. |
void |
mouseDragged(LwMouseEvent e)
Invoked when a mouse button is pressed on a component and then dragged.
|
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 |
mouseMoved(LwMouseEvent e)
Invoked when the mouse pointer has been moved on a light weight component
(with no buttons no down). |
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 scrolled component performs scrolling by changing its location or moving view. |
protected void |
notifyScrollMan(int index)
Notifies the scroll manager that an item component at the specified index should be fully
visible. |
protected int |
pageSize(int d)
Returns the page size for the specified direction. |
void |
paintOnTop(java.awt.Graphics g)
Paints this component. |
protected void |
perform(java.lang.Object src,
java.lang.Object data)
Creates and fires the selection event. |
void |
posChanged(java.lang.Object target,
int prevOffset,
int prevLine,
int prevCol)
Invoked when a virtual position has been changed. |
abstract void |
removeAllItems()
Removes all items from the list. |
abstract void |
removeItem(int i)
Removes an item at the specified index. |
void |
removeSelectionListener(LwActionListener l)
Removes the specified selection listener so it no longer receives selection events
from this list component. |
protected void |
repaint(int p,
int n)
Repaints the area that includes two specified list items. |
void |
select(int index)
Selects the item by the specified index. |
void |
setColor(int type,
java.awt.Color c)
Sets the specified color for the given element. |
void |
setPosController(PosController c)
Sets the specified position controller. |
void |
setScrollMan(ScrollMan m)
Sets the specified scroll manager for the scroll object. |
void |
setSOLocation(int x,
int y)
Sets the specified scroll object location. |
void |
startDragged(LwMouseEvent e)
Invoked when the mouse starts dragged. |
| Methods inherited from class org.zaval.lw.LwPanel |
add, add, calcPreferredSize, count, get, getDefaultLayout, getLayoutOffset, getLwComponentAt, getLwLayout, getPreferredSize, indexOf, insert, insert, invalidate, isInvalidatedByChild, laidout, remove, remove, removeAll, setBackground, setLwLayout, 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, recalc, 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 |
getBackground, getLwParent, getOrigin, getViewMan, getVisiblePart, isEnabled, isOpaque, paint, repaint, repaint, repaint, setEnabled, setInsets, setLwParent, setViewMan, setVisible, update |
SEL_COLOR
public static final int SEL_COLOR
- Defines the selection marker color type.
POS_COLOR
public static final int POS_COLOR
- Defines the pos marker color type.
controller
protected PosController controller
- The position controller field.
selectedIndex
protected int selectedIndex
- The selected index field.
dx
protected int dx
- The horizontal offset field.
dy
protected int dy
- The vertical offset field.
LwAList
public LwAList()
- Constructs the list component and use standard mode as the default.
LwAList
public LwAList(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.
isComboMode
public boolean isComboMode()
- Tests if the list works in the ombo mode.
- Returns:
true if the list works in combo mode.
canHaveFocus
public boolean canHaveFocus()
- Description copied from interface:
LwComponent
- Specifies if the component can have focus.
- Overrides:
canHaveFocus in class LwCanvas
- Following copied from interface:
org.zaval.lw.LwComponent
- Returns:
true if the component can have the focus.
getLines
public int getLines()
- Description copied from interface:
PosInfo
- Gets the number of lines.
- Specified by:
getLines in interface PosInfo
- Following copied from interface:
org.zaval.misc.PosInfo
- Returns:
- a number of lines.
getLineSize
public int getLineSize(int l)
- Description copied from interface:
PosInfo
- Gets the line size for the specified line number.
- Specified by:
getLineSize in interface PosInfo
- Following copied from interface:
org.zaval.misc.PosInfo
- Parameters:
line - the specified line number.- Returns:
- a size of the line.
getMaxOffset
public int getMaxOffset()
- Description copied from interface:
PosInfo
- Gets the maximal offset. The method can return -1 as the result, in this case the pos
controller that uses the pos info will try to calculate the maximal offset itself basing
on the line number and the lines sizes.
- Specified by:
getMaxOffset in interface PosInfo
- Following copied from interface:
org.zaval.misc.PosInfo
- Returns:
- a maximal offset.
setPosController
public void setPosController(PosController c)
- Sets the specified position controller. The controller manages the virtual cursor
location.
- Parameters:
c - the specified position controller.
getPosController
public PosController getPosController()
- Gets the position controller.
- Returns:
- a position controller.
getColor
public java.awt.Color getColor(int type)
- Gets the specified element color.
- Parameters:
type - the specified element type. Use the SEL_COLOR or POS_COLOR constant as the
argument value.- Returns:
- a color.
setColor
public void setColor(int type,
java.awt.Color c)
- Sets the specified color for the given element.
- Parameters:
type - the specified element type. Use the SEL_COLOR or POS_COLOR constant as the
argument value.c - the color.
select
public void select(int index)
- Selects the item by the specified index.
- Parameters:
index - the specified item index.
repaint
protected void repaint(int p,
int n)
- Repaints the area that includes two specified list items.
- Parameters:
p - the first specified list item index.n - the first specified list item index.
perform
protected void perform(java.lang.Object src,
java.lang.Object data)
- Creates and fires the selection event.
- Parameters:
src - the specified source of the event.data - the specified event related data.
getSelectedIndex
public int getSelectedIndex()
- Gets the selected item index.
- Returns:
- a selected item index.
isSelected
public boolean isSelected(int i)
- Tests if the item with the specified index is selected.
- Returns:
true if the item with the specified index is selected; otherwise
false.
addSelectionListener
public void addSelectionListener(LwActionListener l)
- Adds the specified selection listener to receive selection events from this list component.
The event data argument is selected item index that is represented as the Integer object.
The data is
null if the item has been re-selected.
- Parameters:
l - the specified listener.
removeSelectionListener
public void removeSelectionListener(LwActionListener l)
- Removes the specified selection listener so it no longer receives selection events
from this list component.
- Parameters:
l - the specified listener.
mouseClicked
public void mouseClicked(LwMouseEvent e)
- Description copied from interface:
LwMouseListener
- Invoked when the mouse button has been clicked on a light weight component.
- Specified by:
mouseClicked in interface LwMouseListener
- Following copied from interface:
org.zaval.lw.event.LwMouseListener
- Parameters:
e - the specified mouse event.
mouseExited
public void mouseExited(LwMouseEvent e)
- Description copied from interface:
LwMouseListener
- Invoked when the mouse exits a light weight component.
- Specified by:
mouseExited in interface LwMouseListener
- Following copied from interface:
org.zaval.lw.event.LwMouseListener
- Parameters:
e - the specified mouse event.
startDragged
public void startDragged(LwMouseEvent e)
- Description copied from interface:
LwMouseMotionListener
- Invoked when the mouse starts dragged.
- Specified by:
startDragged in interface LwMouseMotionListener
- Following copied from interface:
org.zaval.lw.event.LwMouseMotionListener
- Parameters:
e - the specified mouse event.
endDragged
public void endDragged(LwMouseEvent e)
- Description copied from interface:
LwMouseMotionListener
- Invoked when the mouse ends dragged.
- Specified by:
endDragged in interface LwMouseMotionListener
- Following copied from interface:
org.zaval.lw.event.LwMouseMotionListener
- Parameters:
e - the specified mouse event.
mouseDragged
public void mouseDragged(LwMouseEvent e)
- Description copied from interface:
LwMouseMotionListener
- Invoked when a mouse button is pressed on a component and then dragged.
Mouse drag events will continue to be delivered to the component where
the first originated until the mouse button is released (regardless of
whether the mouse position is within the bounds of the component).
- Specified by:
mouseDragged in interface LwMouseMotionListener
- Following copied from interface:
org.zaval.lw.event.LwMouseMotionListener
- Parameters:
e - the specified mouse event.
mouseReleased
public void mouseReleased(LwMouseEvent e)
- Description copied from interface:
LwMouseListener
- Invoked when the mouse button has been released on a light weight component.
- Specified by:
mouseReleased in interface LwMouseListener
- Following copied from interface:
org.zaval.lw.event.LwMouseListener
- Parameters:
e - the specified mouse event.
mouseMoved
public void mouseMoved(LwMouseEvent e)
- Description copied from interface:
LwMouseMotionListener
- Invoked when the mouse pointer has been moved on a light weight component
(with no buttons no down).
- Specified by:
mouseMoved in interface LwMouseMotionListener
- Following copied from interface:
org.zaval.lw.event.LwMouseMotionListener
- Parameters:
e - the specified mouse event.
mouseEntered
public void mouseEntered(LwMouseEvent e)
- Description copied from interface:
LwMouseListener
- Invoked when the mouse enters a light weight component.
- Specified by:
mouseEntered in interface LwMouseListener
- Following copied from interface:
org.zaval.lw.event.LwMouseListener
- Parameters:
e - the specified mouse event.
mousePressed
public void mousePressed(LwMouseEvent e)
- Description copied from interface:
LwMouseListener
- Invoked when the mouse button has been pressed on a light weight component.
- Specified by:
mousePressed in interface LwMouseListener
- Following copied from interface:
org.zaval.lw.event.LwMouseListener
- Parameters:
e - the specified mouse event.
keyPressed
public void keyPressed(LwKeyEvent e)
- Description copied from interface:
LwKeyListener
- Invoked when a key has been pressed.
- Specified by:
keyPressed in interface LwKeyListener
- Following copied from interface:
org.zaval.lw.event.LwKeyListener
- Parameters:
e - the specified key event.
keyReleased
public void keyReleased(LwKeyEvent e)
- Description copied from interface:
LwKeyListener
- Invoked when a key has been released.
- Specified by:
keyReleased in interface LwKeyListener
- Following copied from interface:
org.zaval.lw.event.LwKeyListener
- Parameters:
e - the specified key event.
keyTyped
public void keyTyped(LwKeyEvent e)
- Description copied from interface:
LwKeyListener
- Invoked when a key has been typed.
- Specified by:
keyTyped in interface LwKeyListener
- Following copied from interface:
org.zaval.lw.event.LwKeyListener
- Parameters:
e - the specified key event.
getSOLocation
public java.awt.Point getSOLocation()
- Description copied from interface:
ScrollObj
- Gets the scroll object location.
- Specified by:
getSOLocation in interface ScrollObj
- Following copied from interface:
org.zaval.misc.ScrollObj
- Returns:
- a scroll object location.
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.
- Specified by:
setSOLocation in interface ScrollObj
- Following copied from interface:
org.zaval.misc.ScrollObj
- Parameters:
x - the specified x coordinate.y - the specified y coordinate.
getSOSize
public java.awt.Dimension getSOSize()
- Description copied from interface:
ScrollObj
- Gets the scroll object size. The size is a size that the scroll object wants to have.
- Specified by:
getSOSize in interface ScrollObj
- Following copied from interface:
org.zaval.misc.ScrollObj
- Returns:
- a scroll object size.
setScrollMan
public void setScrollMan(ScrollMan m)
- Description copied from interface:
ScrollObj
- Sets the specified scroll manager for the scroll object. The manager reference should
be stored and used by the scrolled object to move itself inside the scrolled area.
- Specified by:
setScrollMan in interface ScrollObj
- Following copied from interface:
org.zaval.misc.ScrollObj
- Parameters:
m - the specified scroll manager.
moveContent
public boolean moveContent()
- Description copied from interface:
ScrollObj
- Tests if the scrolled component performs scrolling by changing its location or moving view.
- Specified by:
moveContent in interface ScrollObj
- Following copied from interface:
org.zaval.misc.ScrollObj
- Returns:
true if the scroll component organizes scrolling by moving
its view; otherwise false.
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.
- Specified by:
posChanged in interface PosListener
- 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.
paintOnTop
public void paintOnTop(java.awt.Graphics g)
- Paints this component. The method is overridden to paint the list item selection marker
and position marker.
- Overrides:
paintOnTop in class LwPanel
- Parameters:
g - the graphics context to be used for painting.
drawSelMarker
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.
- 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.
drawPosMarker
protected void drawPosMarker(java.awt.Graphics g,
int x,
int y,
int w,
int h)
- Invoked to paint the list position marker for the specified rectangular area.
- 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.
getItemGaps
protected int getItemGaps()
- Gets the item gaps. The gaps specify additional space that should be added arround
the list items.
- Returns:
- the item gaps.
notifyScrollMan
protected void notifyScrollMan(int index)
- Notifies the scroll manager that an item component at the specified index should be fully
visible. The scroll manager should scrolls the list view to make the component fully
visible if it is necessary.
- Parameters:
index - the specified index.
pageSize
protected int pageSize(int d)
- Returns the page size for the specified direction.
- Parameters:
d - the specified direction. Use -1 value to specify bottom-up direction and
1 value to specify up-bottom direction.- Returns:
- a page size.
correctPM
protected void correctPM(int x,
int y)
- Sets the list position to an item at the specified location.
- Parameters:
x - the x coordinate of the given location.y - the y coordinate of the given location.
getItemView
public LwView getItemView(int index)
- Gets the view for the list item at the specified position.
- Parameters:
index - the item position.- Returns:
- a view.
getSelected
public java.lang.Object getSelected()
- Gets the selected item.
- Returns:
- an selected item.
addItem
public void addItem(java.lang.Object o)
- Adds the specified item in the list.
- Parameters:
o - the specified item.
maxItemSize
public java.awt.Dimension maxItemSize()
- Gets the maximal possible item size.
- Returns:
- a maximal possible item size.
getItemW
public int getItemW(int index)
- Gets the specified item width.
- Parameters:
index - the specified item index.- Returns:
- an item width.
getItemH
public int getItemH(int index)
- Gets the specified item height.
- Parameters:
index - the specified item index.- Returns:
- an item height.
insertItem
public abstract void insertItem(int index,
java.lang.Object o)
- Inserts the given item at the specified index.
- Parameters:
index - the specified item index.o - the specified item.
removeItem
public abstract void removeItem(int i)
- Removes an item at the specified index.
- Parameters:
i - the specified item index.
getItem
public abstract java.lang.Object getItem(int i)
- Gets the item at the specified index.
- Parameters:
i - the specified item index.- Returns:
- an item.
itemCount
public abstract int itemCount()
- Gets the number of items that has been added in the list.
- Returns:
- an number of the list items.
removeAllItems
public abstract void removeAllItems()
- Removes all items from the list.
getItemIdxAt
public abstract int getItemIdxAt(int x,
int y)
- Gets an item index that is located at the given location.
- 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.
getItemX
public abstract int getItemX(int index)
- Gets the item x coordinate.
- Parameters:
index - the specified item index.- Returns:
- the item x coordinate.
getItemY
public abstract int getItemY(int index)
- Gets the item y coordinate.
- Parameters:
index - the specified item index.- Returns:
- the item y coordinate.
itemW
protected abstract int itemW(int index)
- Fetches the item width. The method should fetches the item
width from the an internal structure without performing any
list validation.
- Parameters:
index - the specified item index.- Returns:
- the item width.
itemH
protected abstract 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.
- Parameters:
index - the specified item index.- Returns:
- the item height.
|