org.zaval.lw.grid
Class LwGrid

java.lang.Object
  |
  +--org.zaval.util.ValidationObject
        |
        +--org.zaval.lw.LwCanvas
              |
              +--org.zaval.lw.LwPanel
                    |
                    +--org.zaval.lw.grid.LwGrid
All Implemented Interfaces:
Drawable, java.util.EventListener, Layoutable, LayoutContainer, LwChildrenListener, LwComponent, LwContainer, LwFocusListener, LwGridMetrics, LwKeyListener, LwLayout, LwMouseListener, MatrixListener, PosInfo, PosListener, ScrollObj, Validationable
Direct Known Subclasses:
LwTreeGrid

public class LwGrid
extends LwPanel
implements MatrixListener, ScrollObj, LwMouseListener, LwFocusListener, LwKeyListener, PosInfo, PosListener, LwLayout, LwGridMetrics, LwChildrenListener

This is light weight grid component. The component is a composite component that is built basing on MVC-model:

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:

To set appropriate metric type use usePsMetricmethod.

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

TOP_CAPTION_EL

public static final java.lang.Integer TOP_CAPTION_EL
Top caption component layout constraint.

EDITOR_EL

public static final java.lang.Integer EDITOR_EL
Cell editor component layout constraint.

LEFT_CAPTION_EL

public static final java.lang.Integer LEFT_CAPTION_EL
Left caption component layout constraint.

USE_PSMETRIC

public static final short USE_PSMETRIC
Use preferred size metric bit mask.

DRAW_HLINES

public static final short DRAW_HLINES
Draw horizontal lines bit mask.

DRAW_VLINES

public static final short DRAW_VLINES
Draw vertical lines bit mask.

ENABLE_COLRESIZE

public static final short ENABLE_COLRESIZE
Enable col resizing bit mask.

DEF_COLWIDTH

public static final int DEF_COLWIDTH
The default column width.

DEF_ROWHEIGHT

public static final int DEF_ROWHEIGHT
The default row height.

colWidths

protected int[] colWidths

rowHeights

protected int[] rowHeights

dx

protected int dx

dy

protected int dy
Constructor Detail

LwGrid

public LwGrid()
Constructs the component with the default data model.

LwGrid

public LwGrid(MatrixModel data)
Constructs the component with the specified data model.
Parameters:
data - the specified data model
Method Detail

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.

setEditorProvider

public void setEditorProvider(LwEditorProvider p)
Sets the editor provider. The provider is used to define how the specified cell should be edited.
Parameters:
p - the specified editor provider.

getNetMask

public short getNetMask()
Gets the net mask.
Returns:
a net mask.

setNetMask

public void setNetMask(short mask)
Sets the specified net mask. The net mask is a bit mask that defines what grid lines should be painted. There are four ways to paint grid lines: The default net mask is DRAW_VLINES | DRAW_HLINES.
Parameters:
mask - the specified net mask.

enableColResize

public void enableColResize(boolean b)
Enables columns resizing. The method defines if the columns of the component can be resized or not by setColWidth method.
Parameters:
b - use true to enable columns resizing; false otherwise.

usePsMetric

public void usePsMetric(boolean b)
Sets the specified grid metric type. There are two metric types: The default metric type is custom metric type.
Parameters:
b - use true to set preferred size metric type; false to set custom metric type.

isUsePsMetric

public boolean isUsePsMetric()
Gets the grid metric type.
Returns:
true if the preferred size metric type is used; false otherwise.

getPosController

public PosController getPosController()
Gets the position controller.
Returns:
a position controller.

setPosController

public void setPosController(PosController p)
Sets the position controller. The controller can be set to null, in this case it will be impossible to navigate over the grid component rows.
Parameters:
p - the specified position controller.

getModel

public MatrixModel getModel()
Gets the data model.
Returns:
a data model.

getViewProvider

public LwGridViewProvider getViewProvider()
Gets the view provider.
Returns:
a view provider.

setViewProvider

public void setViewProvider(LwGridViewProvider p)
Sets the view provider.
Parameters:
p - the view provider.

setModel

public void setModel(MatrixModel d)
Sets the data model.
Parameters:
d - the data model.

setSelectColor

public void setSelectColor(java.awt.Color c,
                           boolean hasFocusVal)
Sets the selection marker color for the specified grid state. There are two possible states:
Parameters:
c - the selection marker color.
hasFocus - the specified state. Use true for "grid has focus" state and false for "grid has not focus" state.

getSelectColor

public java.awt.Color getSelectColor(boolean hasFocus)
Gets the selection marker color for the specified grid state. There are two possible states:
Parameters:
hasFocus - the specified state. Use true for "grid has focus" state and false for "grid has not focus" state.
Returns:
a selection marker color.

getNetColor

public java.awt.Color getNetColor()
Gets the grid lines color.
Returns:
a grid lines color.

getCellInsets

public java.awt.Insets getCellInsets()
Description copied from interface: LwGridMetrics
Gets the cells insets. The insets defines top, left, right and bottom indents inside grid cells.
Specified by:
getCellInsets in interface LwGridMetrics
Following copied from interface: org.zaval.lw.grid.LwGridMetrics
Returns:
a cells insets.

setCellInsets

public void setCellInsets(int t,
                          int l,
                          int b,
                          int r)
Sets the grid cells insets.
Parameters:
t - the top cell indent.
l - the left cell indent.
b - the bottom cell indent.
r - the right cell indent.

setNetColor

public void setNetColor(java.awt.Color c)
Sets the grid lines color.
Parameters:
c - the grid lines color.

matrixResized

public void matrixResized(MatrixEvent e)
Description copied from interface: MatrixListener
Invoked when a dimension of the matrix model (number of rows or number of columns) has been changed.
Specified by:
matrixResized in interface MatrixListener
Following copied from interface: org.zaval.data.event.MatrixListener
Parameters:
e - the matrix event.

cellModified

public void cellModified(MatrixEvent e)
Description copied from interface: MatrixListener
Invoked when a cell of the matrix model has been updated.
Specified by:
cellModified in interface MatrixListener
Following copied from interface: org.zaval.data.event.MatrixListener
Parameters:
e - the matrix event.

paint

public void paint(java.awt.Graphics g)
Description copied from interface: Drawable
Paints this drawable component.
Overrides:
paint in class LwCanvas
Following copied from interface: org.zaval.lw.Drawable
Parameters:
g - the graphics context to be used for painting.

paintOnTop

public void paintOnTop(java.awt.Graphics g)
Description copied from interface: LwContainer
Paints additional elements (for example, marker) after the container and its child components have been rendered.
Overrides:
paintOnTop in class LwPanel
Following copied from interface: org.zaval.lw.LwContainer
Parameters:
g - the graphics context.

validate

public void validate()
Description copied from interface: Validationable
Validates this object.
Overrides:
validate in class LwCanvas

invalidate

public void invalidate()
Description copied from interface: Validationable
Invalidates this object.
Overrides:
invalidate in class LwPanel

setRowHeight

public void setRowHeight(int row,
                         int h)
Description copied from interface: LwGridMetrics
Sets the specified height for the given row.
Specified by:
setRowHeight in interface LwGridMetrics
Following copied from interface: org.zaval.lw.grid.LwGridMetrics
Parameters:
row - the specified row.
h - the specified height.

setColWidth

public void setColWidth(int col,
                        int w)
Description copied from interface: LwGridMetrics
Sets the specified width for the given column.
Specified by:
setColWidth in interface LwGridMetrics
Following copied from interface: org.zaval.lw.grid.LwGridMetrics
Parameters:
col - the specified column.
w - the specified width.

getOrigin

public java.awt.Point getOrigin()
Description copied from interface: LwGridMetrics
Returns an origin of the grid component. The origin defines an offset of the component view relatively the component point of origin.
Specified by:
getOrigin in interface LwGridMetrics
Overrides:
getOrigin in class LwCanvas
Following copied from interface: org.zaval.lw.grid.LwGridMetrics
Returns:
an origin of the component.

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.

moveContent

public boolean moveContent()
Description copied from interface: ScrollObj
Tests if the scroll 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.

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 used with the scroll object to notify when the scroll object has been moved or resized.
Specified by:
setScrollMan in interface ScrollObj
Following copied from interface: org.zaval.misc.ScrollObj
Parameters:
m - the specified scroll manager.

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.

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.

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.

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.

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.

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 line)
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.

posChanged

public void posChanged(PosEvent e)
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:
e - the specified pos 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.

focusGained

public void focusGained(LwFocusEvent 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.

focusLost

public void focusLost(LwFocusEvent 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.

layout

public void layout(LayoutContainer target)
Description copied from interface: LwLayout
Lays out the child layoutable components inside the layout container.
Specified by:
layout in interface LwLayout
Following copied from interface: org.zaval.lw.LwLayout
Parameters:
target - the layout container that needs to be laid out.

componentAdded

public void componentAdded(java.lang.Object id,
                           Layoutable lw,
                           int index)
Description copied from interface: LwLayout
Invoked when the specified layoutable component is added to the layout container (that uses the layout manager). The specified constraints, layoutable component and child index are passed as arguments into the method.
Specified by:
componentAdded in interface LwLayout
Following copied from interface: org.zaval.lw.LwLayout
Parameters:
id - the layoutable component constraints.
lw - the layoutable component that has been added.
index - the child index.

componentRemoved

public void componentRemoved(Layoutable lw,
                             int index)
Description copied from interface: LwLayout
Invoked when the specified layoutable component is removed from the layout container, that uses the layout manager.
Specified by:
componentRemoved in interface LwLayout
Following copied from interface: org.zaval.lw.LwLayout
Parameters:
lw - the layoutable component that has been removed.
index - the child component index.

calcPreferredSize

public java.awt.Dimension calcPreferredSize(LayoutContainer target)
Description copied from interface: LwLayout
Calculates the preferred size dimension for the layout container. The method has to calculate "pure" preferred size, it means that an insets of the container should not be considered.
Specified by:
calcPreferredSize in interface LwLayout
Following copied from interface: org.zaval.lw.LwLayout
Parameters:
target - the layout container.
Returns:
a "pure" preferred size.

getGridRows

public int getGridRows()
Description copied from interface: LwGridMetrics
Gets the number of the grid rows.
Specified by:
getGridRows in interface LwGridMetrics
Following copied from interface: org.zaval.lw.grid.LwGridMetrics
Returns:
a number of the grid rows.

getGridCols

public int getGridCols()
Description copied from interface: LwGridMetrics
Gets the number of the grid columns.
Specified by:
getGridCols in interface LwGridMetrics
Following copied from interface: org.zaval.lw.grid.LwGridMetrics
Returns:
a number of the grid columns.

getRowHeight

public int getRowHeight(int row)
Description copied from interface: LwGridMetrics
Gets the specified row height.
Specified by:
getRowHeight in interface LwGridMetrics
Following copied from interface: org.zaval.lw.grid.LwGridMetrics
Parameters:
row - the specified grid row.
Returns:
a height of the specified row.

getColWidth

public int getColWidth(int col)
Description copied from interface: LwGridMetrics
Gets the specified column width.
Specified by:
getColWidth in interface LwGridMetrics
Following copied from interface: org.zaval.lw.grid.LwGridMetrics
Parameters:
col - the specified grid column.
Returns:
a width of the specified column.

getCellsVisibility

public CellsVisibility getCellsVisibility()
Description copied from interface: LwGridMetrics
Gets the grid visibility.
Specified by:
getCellsVisibility in interface LwGridMetrics
Following copied from interface: org.zaval.lw.grid.LwGridMetrics
Returns:
a grid visibility.

getNetGap

public int getNetGap()
Description copied from interface: LwGridMetrics
Gets the gap. The gap defines size of area that is used to paint horizontal and vertical grid lines.
Specified by:
getNetGap in interface LwGridMetrics
Following copied from interface: org.zaval.lw.grid.LwGridMetrics
Returns:
a gap.

getColX

public int getColX(int col)
Description copied from interface: LwGridMetrics
Gets the x coordinate of the specified grid column.
Specified by:
getColX in interface LwGridMetrics
Following copied from interface: org.zaval.lw.grid.LwGridMetrics
Parameters:
col - the specified column.
Returns:
a x coordinate of the specified grid column.

getRowY

public int getRowY(int row)
Description copied from interface: LwGridMetrics
Gets the y coordinate of the specified grid row.
Specified by:
getRowY in interface LwGridMetrics
Following copied from interface: org.zaval.lw.grid.LwGridMetrics
Parameters:
row - the specified row.
Returns:
an y coordinate of the specified grid row.

childPerformed

public void childPerformed(LwAWTEvent e)
Description copied from interface: LwChildrenListener
Invoked whenever an event has been performed.
Specified by:
childPerformed in interface LwChildrenListener
Following copied from interface: org.zaval.lw.event.LwChildrenListener
Parameters:
e - the child event.

startEditing

public void startEditing(int row,
                         int col)
Starts editing of the specified grid cell. The method initiates editing process if the editor provider has been defined for the grid component and the editor component exists.
Parameters:
row - the specified cell row.
col - the specified cell column.

stopEditing

public void stopEditing(boolean applyData)
Stops the cell editing. The method has effect if the editing process has been initiated before.
Parameters:
applyData - use true value if the edited data should be applied to data model, use false otherwise.

getTopCaption

public LwComponent getTopCaption()
Gets the grid top caption component.
Returns:
a grid top caption component.

colWidth

protected int colWidth(int col)
Returns the specified column width. The method is used by all other methods (except recalculation) to get the actual column width.
Parameters:
col - the specified column.
Returns:
the specified column width.

rowHeight

protected int rowHeight(int row)
Returns the specified row height. The method is used by all other methods (except recalculation) to get the actual row height.
Parameters:
row - the specified row.
Returns:
the specified row height.

getDataToEdit

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.
Parameters:
row - the specified row.
col - the specified column.
Returns:
data model value to edit.

setEditedData

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.
Parameters:
row - the specified row.
col - the specified column.
value - the specified edited value.

isMetricValid

protected boolean isMetricValid()
Checks if the grid metric is valid.
Returns:
true if the grid metric is valid; false otherwise.

dataToPaint

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.
Parameters:
row - the specified row.
col - the specified column.
Returns:
data to be painted.

vMetric

protected void vMetric()
Validates the grid metric.

vVisibility

protected void vVisibility()
Validates the grid visibility. The method validates the grid metrics (by vMetric method) before.

rPs

protected java.awt.Dimension rPs()
Calculates the preferred size of the grid component. The method calls colWidth and rowHeight to get actual columns widths and rows heights. The method is called by vMetric method.
Returns:
a calculated preferred size;

paintNet

protected void paintNet(java.awt.Graphics g)
Paints the grid lines.
Parameters:
g - the specified graphics context.

paintData

protected void paintData(java.awt.Graphics g)
Paints the grid cells.
Parameters:
g - the specified graphics context.

paintMarker

protected void paintMarker(java.awt.Graphics g)
Paints the grid marker.
Parameters:
g - the specified graphics context.

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 "layout.raster" key.
Overrides:
getDefaultLayout in class LwPanel
Following copied from class: org.zaval.lw.LwPanel
Returns:
a layout manager.

cellByLocation

protected java.awt.Point cellByLocation(int x,
                                        int y)
Finds and returns grid cell row and column at the specified location. The result is presented with java.awt.Point class where x field correspond to row and y field correspond to column.
Parameters:
x - the specified x coordinate.
y - the specified y coordinate.
Returns:
a cell at the specified location.

rPsMetric

protected void rPsMetric()
Invoked by vMetric method to calculate preferred size metric type.

rCustomMetric

protected void rCustomMetric()
Invoked by vMetric method to calculate custom metric type.

iMetric

protected void iMetric()
Invalidates grid metric.

getTopCaptionHeight

protected int getTopCaptionHeight()
Returns the top caption size.
Returns:
a top caption size.

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.

iColVisibility

protected void iColVisibility()
Invalidates columns visibility properties.

iRowVisibility

protected void iRowVisibility()
Invalidates rows visibility properties.


Copyright © Zaval Creative Engineering Group, 2000-2005.
http://www.zaval.org