|
||||||||||
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.LwPanel | +--org.zaval.lw.grid.LwGrid
This is light weight grid component. The component is a composite component that is built basing on MVC-model:
MatrixModel
. Use
setModel
and getModel
methods to set and get the
model.
setViewProvider
and getViewProvider
methods to customize
the process. Using the interface it is possible to define a background color for the
specified cell, a view to render the cell data and horizontal and vertical alignments.
The component allows to edit cells data and customizes editor components types, by
the editor provider interface. Use setEditorProvider
and
getEditorProvider
methods to set and get the editor provider interface.
Actually the interface defines two things:
The component supports two metric types:
setRowHeight
and setColWidth
methods, the painting
process uses horizontal and vertical alignments (provided by view provider interface)
to align cells views.
setRowHeight
and
setColWidth
methods have no effect. The painting process doesn't use
horizontal and vertical alignments (provided by view provider interface) to align cells
views.
usePsMetric
method.
The component sets special layout manager that should not be changed. The layout manager defines TOP_CAPTION_EL constraint that can be used to add grid caption component as it is demonstrated below:
... LwGrid grid = new LwGrid(); LwGridCaption topCaption = new LwGridCaption(grid); grid.add (LwGrid.TOP_CAPTION_EL, topCaption); ...The LEFT_CAPTION_EL constraint is reserved for the futher version of the component.
To control selection state use PosController that can be got by getPosController
method. The component suppotrts single row selection. It is possible to disable selection
any grid row, set the pos controller to null
for the purpose by
setPosController
method.
The component implements ScrollObj interface, so the grid component can be used inside LwScrollPan component.
Field Summary | |
protected int[] |
colWidths
|
static int |
DEF_COLWIDTH
The default column width. |
static int |
DEF_ROWHEIGHT
The default row height. |
static short |
DRAW_HLINES
Draw horizontal lines bit mask. |
static short |
DRAW_VLINES
Draw vertical lines bit mask. |
protected int |
dx
|
protected int |
dy
|
static java.lang.Integer |
EDITOR_EL
Cell editor component layout constraint. |
static short |
ENABLE_COLRESIZE
Enable col resizing bit mask. |
static java.lang.Integer |
LEFT_CAPTION_EL
Left caption component layout constraint. |
protected int[] |
rowHeights
|
static java.lang.Integer |
TOP_CAPTION_EL
Top caption component layout constraint. |
static short |
USE_PSMETRIC
Use preferred size metric bit mask. |
Fields inherited from class org.zaval.lw.LwPanel |
children |
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 | |
LwGrid()
Constructs the component with the default data model. |
|
LwGrid(MatrixModel data)
Constructs the component with the specified data model. |
Method Summary | |
java.awt.Dimension |
calcPreferredSize(LayoutContainer target)
Calculates the preferred size dimension for the layout container. |
boolean |
canHaveFocus()
Specifies if the component can have focus. |
protected java.awt.Point |
cellByLocation(int x,
int y)
Finds and returns grid cell row and column at the specified location. |
void |
cellModified(MatrixEvent e)
Invoked when a cell of the matrix model has been updated. |
void |
childPerformed(LwAWTEvent e)
Invoked whenever an event has been performed. |
protected int |
colWidth(int col)
Returns the specified column width. |
void |
componentAdded(java.lang.Object id,
Layoutable lw,
int index)
Invoked when the specified layoutable component is added to the layout container (that uses the layout manager). |
void |
componentRemoved(Layoutable lw,
int index)
Invoked when the specified layoutable component is removed from the layout container, that uses the layout manager. |
protected java.lang.Object |
dataToPaint(int row,
int col)
Invoked whenever the component paints the specified cell to fetch data from the grid data model. |
void |
enableColResize(boolean b)
Enables columns resizing. |
void |
focusGained(LwFocusEvent e)
Invoked when the light weight component gained focus. |
void |
focusLost(LwFocusEvent e)
Invoked when the light weight component lost focus. |
java.awt.Insets |
getCellInsets()
Gets the cells insets. |
CellsVisibility |
getCellsVisibility()
Gets the grid visibility. |
int |
getColWidth(int col)
Gets the specified column width. |
int |
getColX(int col)
Gets the x coordinate of the specified grid column. |
protected java.lang.Object |
getDataToEdit(int row,
int col)
Invoked whenever the component wants fetch data from the data model for the specified cell editing. |
protected LwLayout |
getDefaultLayout()
Gets the default layout manager that is set with the container during initialization. |
int |
getGridCols()
Gets the number of the grid columns. |
int |
getGridRows()
Gets the number of the grid rows. |
int |
getLines()
Gets the number of lines. |
int |
getLineSize(int line)
Gets the line size for the specified line number. |
int |
getMaxOffset()
Gets the maximal offset. |
MatrixModel |
getModel()
Gets the data model. |
java.awt.Color |
getNetColor()
Gets the grid lines color. |
int |
getNetGap()
Gets the gap. |
short |
getNetMask()
Gets the net mask. |
java.awt.Point |
getOrigin()
Returns an origin of the grid component. |
PosController |
getPosController()
Gets the position controller. |
int |
getRowHeight(int row)
Gets the specified row height. |
int |
getRowY(int row)
Gets the y coordinate of the specified grid row. |
java.awt.Color |
getSelectColor(boolean hasFocus)
Gets the selection marker color for the specified grid state. |
java.awt.Point |
getSOLocation()
Gets the scroll object location. |
java.awt.Dimension |
getSOSize()
Gets the scroll object size. |
LwComponent |
getTopCaption()
Gets the grid top caption component. |
protected int |
getTopCaptionHeight()
Returns the top caption size. |
LwGridViewProvider |
getViewProvider()
Gets the view provider. |
protected void |
iColVisibility()
Invalidates columns visibility properties. |
protected void |
iMetric()
Invalidates grid metric. |
void |
invalidate()
Invalidates this object. |
protected void |
iRowVisibility()
Invalidates rows visibility properties. |
protected boolean |
isMetricValid()
Checks if the grid metric is valid. |
boolean |
isUsePsMetric()
Gets the grid metric type. |
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 |
layout(LayoutContainer target)
Lays out the child layoutable components inside the layout container. |
void |
matrixResized(MatrixEvent e)
Invoked when a dimension of the matrix model (number of rows or number of columns) has been changed. |
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. |
protected int |
pageSize(int d)
Returns the page size for the specified direction. |
void |
paint(java.awt.Graphics g)
Paints this drawable component. |
protected void |
paintData(java.awt.Graphics g)
Paints the grid cells. |
protected void |
paintMarker(java.awt.Graphics g)
Paints the grid marker. |
protected void |
paintNet(java.awt.Graphics g)
Paints the grid lines. |
void |
paintOnTop(java.awt.Graphics g)
Paints additional elements (for example, marker) after the container and its child components have been rendered. |
void |
posChanged(PosEvent e)
Invoked when a virtual position has been changed. |
protected void |
rCustomMetric()
Invoked by vMetric method to calculate custom metric type. |
protected int |
rowHeight(int row)
Returns the specified row height. |
protected java.awt.Dimension |
rPs()
Calculates the preferred size of the grid component. |
protected void |
rPsMetric()
Invoked by vMetric method to calculate preferred size metric type. |
void |
setCellInsets(int t,
int l,
int b,
int r)
Sets the grid cells insets. |
void |
setColWidth(int col,
int w)
Sets the specified width for the given column. |
protected void |
setEditedData(int row,
int col,
java.lang.Object value)
Invoked whenever the component wants applies the edited value (for the specified cell) to the grid data model. |
void |
setEditorProvider(LwEditorProvider p)
Sets the editor provider. |
void |
setModel(MatrixModel d)
Sets the data model. |
void |
setNetColor(java.awt.Color c)
Sets the grid lines color. |
void |
setNetMask(short mask)
Sets the specified net mask. |
void |
setPosController(PosController p)
Sets the position controller. |
void |
setRowHeight(int row,
int h)
Sets the specified height for the given row. |
void |
setScrollMan(ScrollMan m)
Sets the specified scroll manager for the scroll object. |
void |
setSelectColor(java.awt.Color c,
boolean hasFocusVal)
Sets the selection marker color for the specified grid state. |
void |
setSOLocation(int x,
int y)
Sets the specified scroll object location. |
void |
setViewProvider(LwGridViewProvider p)
Sets the view provider. |
void |
startEditing(int row,
int col)
Starts editing of the specified grid cell. |
void |
stopEditing(boolean applyData)
Stops the cell editing. |
void |
usePsMetric(boolean b)
Sets the specified grid metric type. |
void |
validate()
Validates this object. |
protected void |
vMetric()
Validates the grid metric. |
protected void |
vVisibility()
Validates the grid visibility. |
Methods inherited from class org.zaval.lw.LwPanel |
add, add, calcPreferredSize, count, get, getLayoutOffset, getLwComponentAt, getLwLayout, indexOf, insert, insert, recalc, remove, remove, removeAll, setBackground, setLwLayout, setOpaque, toFront, updateCashedPs |
Methods inherited from class org.zaval.lw.LwCanvas |
getBackground, getBounds, getHeight, getInsets, getLocation, getLwParent, getPreferredSize, getSize, getViewMan, getVisiblePart, getWidth, getX, getY, hasFocus, isEnabled, isOpaque, isVisible, repaint, repaint, requestFocus, setEnabled, setInsets, setLocation, setLwParent, setPSSize, setSize, setViewMan, setVisible, toString, update, 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.lw.LwComponent |
getLwParent, getViewMan, getVisiblePart, setEnabled, setLwParent, setViewMan, setVisible |
Methods inherited from interface org.zaval.lw.Drawable |
getBackground, isEnabled, isOpaque, repaint, repaint, update |
Methods inherited from interface org.zaval.util.Validationable |
isValid |
Methods inherited from interface org.zaval.lw.Layoutable |
getBounds, getHeight, getInsets, getLocation, getPreferredSize, getSize, getWidth, getX, getY, isVisible, setLocation, setSize |
Field Detail |
public static final java.lang.Integer TOP_CAPTION_EL
public static final java.lang.Integer EDITOR_EL
public static final java.lang.Integer LEFT_CAPTION_EL
public static final short USE_PSMETRIC
public static final short DRAW_HLINES
public static final short DRAW_VLINES
public static final short ENABLE_COLRESIZE
public static final int DEF_COLWIDTH
public static final int DEF_ROWHEIGHT
protected int[] colWidths
protected int[] rowHeights
protected int dx
protected int dy
Constructor Detail |
public LwGrid()
public LwGrid(MatrixModel data)
data
- the specified data modelMethod Detail |
public boolean canHaveFocus()
LwComponent
canHaveFocus
in class LwCanvas
org.zaval.lw.LwComponent
true
if the component can have the focus.public void setEditorProvider(LwEditorProvider p)
p
- the specified editor provider.public short getNetMask()
public void setNetMask(short mask)
mask
- the specified net mask.public void enableColResize(boolean b)
setColWidth
method.b
- use true
to enable columns resizing; false
otherwise.public void usePsMetric(boolean b)
b
- use true
to set preferred size metric type;
false
to set custom metric type.public boolean isUsePsMetric()
true
if the preferred size metric type is used;
false
otherwise.public PosController getPosController()
public void setPosController(PosController p)
null
, in this
case it will be impossible to navigate over the grid component rows.p
- the specified position controller.public MatrixModel getModel()
public LwGridViewProvider getViewProvider()
public void setViewProvider(LwGridViewProvider p)
p
- the view provider.public void setModel(MatrixModel d)
d
- the data model.public void setSelectColor(java.awt.Color c, boolean hasFocusVal)
c
- the selection marker color.hasFocus
- the specified state. Use true
for "grid has focus"
state and false
for "grid has not focus" state.public java.awt.Color getSelectColor(boolean hasFocus)
hasFocus
- the specified state. Use true
for "grid has focus"
state and false
for "grid has not focus" state.public java.awt.Color getNetColor()
public java.awt.Insets getCellInsets()
LwGridMetrics
getCellInsets
in interface LwGridMetrics
org.zaval.lw.grid.LwGridMetrics
public void setCellInsets(int t, int l, int b, int r)
t
- the top cell indent.l
- the left cell indent.b
- the bottom cell indent.r
- the right cell indent.public void setNetColor(java.awt.Color c)
c
- the grid lines color.public void matrixResized(MatrixEvent e)
MatrixListener
matrixResized
in interface MatrixListener
org.zaval.data.event.MatrixListener
e
- the matrix event.public void cellModified(MatrixEvent e)
MatrixListener
cellModified
in interface MatrixListener
org.zaval.data.event.MatrixListener
e
- the matrix event.public void paint(java.awt.Graphics g)
Drawable
paint
in class LwCanvas
org.zaval.lw.Drawable
g
- the graphics context to be used for painting.public void paintOnTop(java.awt.Graphics g)
LwContainer
paintOnTop
in class LwPanel
org.zaval.lw.LwContainer
g
-
the graphics context.public void validate()
Validationable
validate
in class LwCanvas
public void invalidate()
Validationable
invalidate
in class LwPanel
public void setRowHeight(int row, int h)
LwGridMetrics
setRowHeight
in interface LwGridMetrics
org.zaval.lw.grid.LwGridMetrics
row
- the specified row.h
- the specified height.public void setColWidth(int col, int w)
LwGridMetrics
setColWidth
in interface LwGridMetrics
org.zaval.lw.grid.LwGridMetrics
col
- the specified column.w
- the specified width.public java.awt.Point getOrigin()
LwGridMetrics
getOrigin
in interface LwGridMetrics
getOrigin
in class LwCanvas
org.zaval.lw.grid.LwGridMetrics
public java.awt.Point getSOLocation()
ScrollObj
getSOLocation
in interface ScrollObj
org.zaval.misc.ScrollObj
public void setSOLocation(int x, int y)
ScrollObj
setSOLocation
in interface ScrollObj
org.zaval.misc.ScrollObj
x
- the specified x coordinate.y
- the specified y coordinate.public java.awt.Dimension getSOSize()
ScrollObj
getSOSize
in interface ScrollObj
org.zaval.misc.ScrollObj
public boolean moveContent()
ScrollObj
moveContent
in interface ScrollObj
org.zaval.misc.ScrollObj
true
if the scroll component organizes scrolling by moving
its view; otherwise false
.public void setScrollMan(ScrollMan m)
ScrollObj
setScrollMan
in interface ScrollObj
org.zaval.misc.ScrollObj
m
- the specified scroll manager.public void mouseClicked(LwMouseEvent e)
LwMouseListener
mouseClicked
in interface LwMouseListener
org.zaval.lw.event.LwMouseListener
e
- the specified mouse event.public void mouseEntered(LwMouseEvent e)
LwMouseListener
mouseEntered
in interface LwMouseListener
org.zaval.lw.event.LwMouseListener
e
- the specified mouse event.public void mouseExited(LwMouseEvent e)
LwMouseListener
mouseExited
in interface LwMouseListener
org.zaval.lw.event.LwMouseListener
e
- the specified mouse event.public void mouseReleased(LwMouseEvent e)
LwMouseListener
mouseReleased
in interface LwMouseListener
org.zaval.lw.event.LwMouseListener
e
- the specified mouse event.public void mousePressed(LwMouseEvent e)
LwMouseListener
mousePressed
in interface LwMouseListener
org.zaval.lw.event.LwMouseListener
e
- the specified mouse event.public int getLines()
PosInfo
getLines
in interface PosInfo
org.zaval.misc.PosInfo
public int getLineSize(int line)
PosInfo
getLineSize
in interface PosInfo
org.zaval.misc.PosInfo
line
- the specified line number.public int getMaxOffset()
PosInfo
getMaxOffset
in interface PosInfo
org.zaval.misc.PosInfo
public void posChanged(PosEvent e)
PosListener
posChanged
in interface PosListener
org.zaval.misc.event.PosListener
e
- the specified pos event.public void keyPressed(LwKeyEvent e)
LwKeyListener
keyPressed
in interface LwKeyListener
org.zaval.lw.event.LwKeyListener
e
- the specified key event.public void keyReleased(LwKeyEvent e)
LwKeyListener
keyReleased
in interface LwKeyListener
org.zaval.lw.event.LwKeyListener
e
- the specified key event.public void keyTyped(LwKeyEvent e)
LwKeyListener
keyTyped
in interface LwKeyListener
org.zaval.lw.event.LwKeyListener
e
- the specified key event.public void focusGained(LwFocusEvent e)
LwFocusListener
focusGained
in interface LwFocusListener
org.zaval.lw.event.LwFocusListener
e
- the specified focus event.public void focusLost(LwFocusEvent e)
LwFocusListener
focusLost
in interface LwFocusListener
org.zaval.lw.event.LwFocusListener
e
- the specified focus event.public void layout(LayoutContainer target)
LwLayout
layout
in interface LwLayout
org.zaval.lw.LwLayout
target
- the layout container that needs to be laid out.public void componentAdded(java.lang.Object id, Layoutable lw, int index)
LwLayout
componentAdded
in interface LwLayout
org.zaval.lw.LwLayout
id
- the layoutable component constraints.lw
- the layoutable component that has been added.index
- the child index.public void componentRemoved(Layoutable lw, int index)
LwLayout
componentRemoved
in interface LwLayout
org.zaval.lw.LwLayout
lw
- the layoutable component that has been removed.index
- the child component index.public java.awt.Dimension calcPreferredSize(LayoutContainer target)
LwLayout
calcPreferredSize
in interface LwLayout
org.zaval.lw.LwLayout
target
- the layout container.public int getGridRows()
LwGridMetrics
getGridRows
in interface LwGridMetrics
org.zaval.lw.grid.LwGridMetrics
public int getGridCols()
LwGridMetrics
getGridCols
in interface LwGridMetrics
org.zaval.lw.grid.LwGridMetrics
public int getRowHeight(int row)
LwGridMetrics
getRowHeight
in interface LwGridMetrics
org.zaval.lw.grid.LwGridMetrics
row
- the specified grid row.public int getColWidth(int col)
LwGridMetrics
getColWidth
in interface LwGridMetrics
org.zaval.lw.grid.LwGridMetrics
col
- the specified grid column.public CellsVisibility getCellsVisibility()
LwGridMetrics
getCellsVisibility
in interface LwGridMetrics
org.zaval.lw.grid.LwGridMetrics
public int getNetGap()
LwGridMetrics
getNetGap
in interface LwGridMetrics
org.zaval.lw.grid.LwGridMetrics
public int getColX(int col)
LwGridMetrics
getColX
in interface LwGridMetrics
org.zaval.lw.grid.LwGridMetrics
col
- the specified column.x
coordinate of the specified grid column.public int getRowY(int row)
LwGridMetrics
getRowY
in interface LwGridMetrics
org.zaval.lw.grid.LwGridMetrics
row
- the specified row.y
coordinate of the specified grid row.public void childPerformed(LwAWTEvent e)
LwChildrenListener
childPerformed
in interface LwChildrenListener
org.zaval.lw.event.LwChildrenListener
e
- the child event.public void startEditing(int row, int col)
row
- the specified cell row.col
- the specified cell column.public void stopEditing(boolean applyData)
applyData
- use true
value if the edited data should be
applied to data model, use false
otherwise.public LwComponent getTopCaption()
protected int colWidth(int col)
col
- the specified column.protected int rowHeight(int row)
row
- the specified row.protected java.lang.Object getDataToEdit(int row, int col)
row
- the specified row.col
- the specified column.protected void setEditedData(int row, int col, java.lang.Object value)
row
- the specified row.col
- the specified column.value
- the specified edited value.protected boolean isMetricValid()
true
if the grid metric is valid; false
otherwise.protected java.lang.Object dataToPaint(int row, int col)
row
- the specified row.col
- the specified column.protected void vMetric()
protected void vVisibility()
vMetric
method) before.protected java.awt.Dimension rPs()
colWidth
and rowHeight
to get actual columns
widths and rows heights. The method is called by vMetric
method.protected void paintNet(java.awt.Graphics g)
g
- the specified graphics context.protected void paintData(java.awt.Graphics g)
g
- the specified graphics context.protected void paintMarker(java.awt.Graphics g)
g
- the specified graphics context.protected LwLayout getDefaultLayout()
LwPanel
getDefaultLayout
in class LwPanel
org.zaval.lw.LwPanel
protected java.awt.Point cellByLocation(int x, int y)
x
field correspond to row and y
field correspond to column.x
- the specified x coordinate.y
- the specified y coordinate.protected void rPsMetric()
vMetric
method to calculate preferred size metric type.protected void rCustomMetric()
vMetric
method to calculate custom metric type.protected void iMetric()
protected int getTopCaptionHeight()
protected int pageSize(int d)
d
- the specified direction. Use -1
value to specify bottom-up direction and
1
value to specify up-bottom direction.protected void iColVisibility()
protected void iRowVisibility()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |