NextApp Echo
1.0.5

nextapp.echo
Class Grid

java.lang.Object
  extended bynextapp.echo.Component
      extended bynextapp.echo.Grid
All Implemented Interfaces:
java.io.Serializable

public class Grid
extends Component

A component used to lay out child components in a grid.

See Also:
Serialized Form

Nested Class Summary
static class Grid.Cell
          A container component representing a single cell of a grid.
 class Grid.GridCellOverlapException
          An exception that is thrown when grid cells overlap (due to their column/row spans).
 
Field Summary
static java.lang.String BORDER_COLOR_CHANGED_PROPERTY
           
static java.lang.String BORDER_SIZE_CHANGED_PROPERTY
           
static java.lang.String CELL_MARGIN_CHANGED_PROPERTY
           
static java.lang.String COLUMN_DELETED_PROPERTY
           
static java.lang.String COLUMN_INSERTED_PROPERTY
           
static java.lang.String COLUMN_WIDTH_CHANGED_PROPERTY
           
static java.lang.String HEIGHT_CHANGED_PROPERTY
           
static java.lang.String HEIGHT_UNITS_CHANGED_PROPERTY
           
static int PERCENT_INDIVIDUAL_PIXEL_TOTAL_UNITS
          A constant used in the setWidthUnits() and setHeightUnits() methods.
static int PERCENT_UNITS
          A constant used in the setWidthUnits() and setHeightUnits() methods.
static int PIXEL_UNITS
          A constant used in the setWidthUnits() and setHeightUnits() methods.
static java.lang.String ROW_DELETED_PROPERTY
           
static java.lang.String ROW_HEIGHT_CHANGED_PROPERTY
           
static java.lang.String ROW_INSERTED_PROPERTY
           
static java.lang.String STYLE_BORDER_COLOR
          A style constant for the Border Color property.
static java.lang.String STYLE_BORDER_SIZE
          A style constant for the Border Size property.
static java.lang.String STYLE_CELL_MARGIN
          A style constant for the Cell Margin property.
static java.lang.String STYLE_COLUMN_WIDTHS
          A style constant for the setting column widths.
static java.lang.String STYLE_HEIGHT
          A style constant for the Height property.
static java.lang.String STYLE_HEIGHT_UNITS
          A style constant for the Height Units property.
static java.lang.String STYLE_ROW_HEIGHTS
          A style constant for the setting row heights.
static java.lang.String STYLE_WIDTH
          A style constant for the Width property.
static java.lang.String STYLE_WIDTH_UNITS
          A style constant for the Width Units property.
static int UNKNOWN_SIZE
          Deprecated. Use EchoConstants.UNDEFINED_SIZE.
static java.lang.String WIDTH_CHANGED_PROPERTY
           
static java.lang.String WIDTH_UNITS_CHANGED_PROPERTY
           
 
Fields inherited from class nextapp.echo.Component
BACKGROUND_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FONT_CHANGED_PROPERTY, FOREGROUND_CHANGED_PROPERTY, IDENTIFIER_CHANGED_PROPERTY, listenerList, LOCALE_CHANGED_PROPERTY, MODEL_CHANGED_PROPERTY, STYLE_BACKGROUND, STYLE_FONT, STYLE_FOREGROUND, UPDATE_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Constructor Summary
Grid()
          Creates a new Grid.
 
Method Summary
 void add(Component c, int index)
          Throws an UnsupportedOperationException.
 Grid.Cell add(int column, int row, Component component)
          Creates a new Cell containing only the given component and adds it at the specified position.
 void add(int column, int row, Grid.Cell cell)
          Adds a cell at a specified coordinate.
 void applyStyle(Style style)
          Sets stylistic properties of this component based on a Style object.
 void deleteColumn(int column)
          Remove a column from the grid.
 void deleteRow(int row)
          Remove a row from the grid.
 Grid.Cell get(int column, int row)
          Returns the Cell at the specified position
 Color getBorderColor()
          Returns the border color.
 int getBorderSize()
          Returns the border size.
 int getCellMargin()
          Returns the cell margin.
 int getColumnWidth(int column)
          Returns the width of a grid column.
 int getHeight()
          Returns the overall height of the grid.
 int getHeightUnits()
          Returns the units (pixel or percent) in which column heights and overall grid height are measured.
 int getRowHeight(int row)
          Returns the height of a grid row.
 Dimension getSize()
          Returns the size of the grid.
 int getWidth()
          Returns the overall width of the grid.
 int getWidthUnits()
          Returns the units (pixel or percent) in which column widths and overall grid width are measured.
 void insertColumn(int column)
          Inserts a column into the grid.
 void insertRow(int row)
          Inserts a row into the grid.
 java.util.Iterator iterator()
          Returns a sequential (column then row) iterator over all cells in the grid.
 void remove(Component cell)
          Removes the specified Cell.
 Grid.Cell remove(int column, int row)
          Removes and returns the cell at the specified position.
 void setBorderColor(Color newValue)
          Sets the border color of the grid.
 void setBorderSize(int newValue)
          Sets the size of the grid's border.
 void setCellMargin(int newValue)
          Sets the cell interior margin.
 void setColumnWidth(int column, int newValue)
          Sets the width of a column of the grid.
 void setHeight(int newValue)
          Sets the overall height of the grid.
 void setHeightUnits(int newValue)
          Sets the units (pixel or percent) in which row heights and overall grid height are measured.
 void setRowHeight(int row, int newValue)
          Sets the height of a row of the grid.
 void setWidth(int newValue)
          Sets the overall width of the grid.
 void setWidthUnits(int newValue)
          Sets the units (pixel or percent) in which column widths and overall grid width are measured.
 void validate()
          Overrides Component.validate(), to ensure that no cells of the grid overlap.
 
Methods inherited from class nextapp.echo.Component
add, addHierarchyListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getComponent, getComponentCount, getComponents, getEchoInstance, getFont, getForeground, getIdentifier, getLocale, getParent, indexOf, init, isAncestorOf, isEnabled, isRegistered, isShowing, isVisible, remove, removeAll, removeHierarchyListener, removePropertyChangeListener, setBackground, setEnabled, setFont, setForeground, setIdentifier, setLocale, setVisible, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STYLE_BORDER_COLOR

public static final java.lang.String STYLE_BORDER_COLOR
A style constant for the Border Color property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_BORDER_SIZE

public static final java.lang.String STYLE_BORDER_SIZE
A style constant for the Border Size property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_CELL_MARGIN

public static final java.lang.String STYLE_CELL_MARGIN
A style constant for the Cell Margin property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_COLUMN_WIDTHS

public static final java.lang.String STYLE_COLUMN_WIDTHS
A style constant for the setting column widths. Values of this key must be an array of integer primitives.

See Also:
Constant Field Values

STYLE_HEIGHT

public static final java.lang.String STYLE_HEIGHT
A style constant for the Height property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_HEIGHT_UNITS

public static final java.lang.String STYLE_HEIGHT_UNITS
A style constant for the Height Units property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_ROW_HEIGHTS

public static final java.lang.String STYLE_ROW_HEIGHTS
A style constant for the setting row heights. Values of this key must be an array of integer primitives.

See Also:
Constant Field Values

STYLE_WIDTH

public static final java.lang.String STYLE_WIDTH
A style constant for the Width property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_WIDTH_UNITS

public static final java.lang.String STYLE_WIDTH_UNITS
A style constant for the Width Units property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

BORDER_COLOR_CHANGED_PROPERTY

public static final java.lang.String BORDER_COLOR_CHANGED_PROPERTY
See Also:
Constant Field Values

BORDER_SIZE_CHANGED_PROPERTY

public static final java.lang.String BORDER_SIZE_CHANGED_PROPERTY
See Also:
Constant Field Values

CELL_MARGIN_CHANGED_PROPERTY

public static final java.lang.String CELL_MARGIN_CHANGED_PROPERTY
See Also:
Constant Field Values

COLUMN_DELETED_PROPERTY

public static final java.lang.String COLUMN_DELETED_PROPERTY
See Also:
Constant Field Values

COLUMN_INSERTED_PROPERTY

public static final java.lang.String COLUMN_INSERTED_PROPERTY
See Also:
Constant Field Values

COLUMN_WIDTH_CHANGED_PROPERTY

public static final java.lang.String COLUMN_WIDTH_CHANGED_PROPERTY
See Also:
Constant Field Values

HEIGHT_CHANGED_PROPERTY

public static final java.lang.String HEIGHT_CHANGED_PROPERTY
See Also:
Constant Field Values

HEIGHT_UNITS_CHANGED_PROPERTY

public static final java.lang.String HEIGHT_UNITS_CHANGED_PROPERTY
See Also:
Constant Field Values

ROW_DELETED_PROPERTY

public static final java.lang.String ROW_DELETED_PROPERTY
See Also:
Constant Field Values

ROW_HEIGHT_CHANGED_PROPERTY

public static final java.lang.String ROW_HEIGHT_CHANGED_PROPERTY
See Also:
Constant Field Values

ROW_INSERTED_PROPERTY

public static final java.lang.String ROW_INSERTED_PROPERTY
See Also:
Constant Field Values

WIDTH_CHANGED_PROPERTY

public static final java.lang.String WIDTH_CHANGED_PROPERTY
See Also:
Constant Field Values

WIDTH_UNITS_CHANGED_PROPERTY

public static final java.lang.String WIDTH_UNITS_CHANGED_PROPERTY
See Also:
Constant Field Values

UNKNOWN_SIZE

public static final int UNKNOWN_SIZE
Deprecated. Use EchoConstants.UNDEFINED_SIZE.

A constant used to specify an unknown grid cell width or height.

See Also:
Constant Field Values

PIXEL_UNITS

public static final int PIXEL_UNITS
A constant used in the setWidthUnits() and setHeightUnits() methods. This value specifies that pixel-based units are used in defining the individual column or row sizes and the overall width and height of the grid.

See Also:
Constant Field Values

PERCENT_INDIVIDUAL_PIXEL_TOTAL_UNITS

public static final int PERCENT_INDIVIDUAL_PIXEL_TOTAL_UNITS
A constant used in the setWidthUnits() and setHeightUnits() methods. This value specifies that percent-based units are used in defining the individual column or row sizes, but pixel based units are used in defining the overall width or height of the grid.

See Also:
Constant Field Values

PERCENT_UNITS

public static final int PERCENT_UNITS
A constant used in the setWidthUnits() and setHeightUnits() methods. This value specifies that percent-based are used in defining both the individual column or row sizes and the overall width or height of the grid.

See Also:
Constant Field Values
Constructor Detail

Grid

public Grid()
Creates a new Grid.

Method Detail

add

public void add(Component c,
                int index)
Throws an UnsupportedOperationException.

Overrides:
add in class Component
Parameters:
c - The child component to add.
index - The index at which to add the child component, or -1 to add the component at the end.
See Also:
Component.add(Component, int)

add

public void add(int column,
                int row,
                Grid.Cell cell)
Adds a cell at a specified coordinate.

Parameters:
column - The column at which to add the component.
row - The row at which to add the component.
cell - The cell to be added.

add

public Grid.Cell add(int column,
                     int row,
                     Component component)
Creates a new Cell containing only the given component and adds it at the specified position.

Parameters:
column - The column at which to add the component.
row - The row at which to add the component.
component - The component to be added.
Returns:
The Cell object that was added to the grid at the specified coordinate, containing the specified component. This value is useful if the application needs to set additional properties on the cell.

applyStyle

public void applyStyle(Style style)
Description copied from class: Component
Sets stylistic properties of this component based on a Style object. The version of this method in Component will set foreground and background colors and the font from the style if they are present. Components should override this method if they allow more properties to be set from a style object, and should call super.applyStyle() if necessary.

Overrides:
applyStyle in class Component
Parameters:
style - The style object from which to retrieve properties for this Component.
See Also:
Component.applyStyle(Style)

deleteColumn

public void deleteColumn(int column)
Remove a column from the grid.

Parameters:
column - The column to remove from the grid.

deleteRow

public void deleteRow(int row)
Remove a row from the grid.

Parameters:
row - The row to remove from the grid.

insertColumn

public void insertColumn(int column)
Inserts a column into the grid.

Parameters:
column - The index of the inserted column.

insertRow

public void insertRow(int row)
Inserts a row into the grid.

Parameters:
row - The index of the inserted row.

iterator

public java.util.Iterator iterator()
Returns a sequential (column then row) iterator over all cells in the grid.

Returns:
An iterator over all cells in the grid.

get

public Grid.Cell get(int column,
                     int row)
Returns the Cell at the specified position

Parameters:
column - The column number of the cell to retrieve.
row - The row number of the cell to retrieve.
Returns:
The cell at the specified column and row position. If no cell was found, null is returned.

getBorderColor

public Color getBorderColor()
Returns the border color.

Returns:
The border color.

getBorderSize

public int getBorderSize()
Returns the border size.

Returns:
The border size in pixels.

getCellMargin

public int getCellMargin()
Returns the cell margin. The default cell margin is 3 pixels.

Returns:
The cell margin in pixels.

getColumnWidth

public int getColumnWidth(int column)
Returns the width of a grid column. If the width is not defined, EchoConstants.UNDEFINED_SIZE is returned. The units for this value may be pixels or percentiles, based on the value of the "WidthUnits" property.

Parameters:
column - The column index.
Returns:
The width of the grid column.

getHeight

public int getHeight()
Returns the overall height of the grid. This property is not relevant when row heights are being measured in pixels and all rows have a height value, or if the sum of all row heights (and margins) is greater than the height value.

Returns:
The height of the grid. If the height is not defined, EchoConstants.UNDEFINED_SIZE is returned.

getHeightUnits

public int getHeightUnits()
Returns the units (pixel or percent) in which column heights and overall grid height are measured.

Returns:
The unit measurement, one of the following values:
  • PIXEL_UNITS (the default)
  • PERCENT_INDIVIDUAL_PIXEL_TOTAL_UNITS
  • PERCENT_UNITS

getRowHeight

public int getRowHeight(int row)
Returns the height of a grid row. If the height is not defined, EchoConstants.UNDEFINED_SIZE is returned. The units for this value may be pixels or percentiles, based on the value of the "HeightUnits" property.

Parameters:
row - The row index.
Returns:
The height of the grid row.

getSize

public Dimension getSize()
Returns the size of the grid.

Returns:
The size of the grid in cells as a Dimension.

getWidth

public int getWidth()
Returns the overall width of the grid. This property is not relevant when column widths are being measured in pixels and all columns have a width value, or if the sum of all columns widths (and margins) is greater than the width value.

Returns:
The width of the grid. If the width is not defined, EchoConstants.UNDEFINED_SIZE is returned.

getWidthUnits

public int getWidthUnits()
Returns the units (pixel or percent) in which column widths and overall grid width are measured.

Returns:
The unit measurement, one of the following values:
  • PIXEL_UNITS (the default)
  • PERCENT_INDIVIDUAL_PIXEL_TOTAL_UNITS
  • PERCENT_UNITS

remove

public Grid.Cell remove(int column,
                        int row)
Removes and returns the cell at the specified position.

Parameters:
column - The column number of the cell to remove.
row - The row number of the cell to remove.
Returns:
The cell that was removed. If no cell was found at the specified coordinates, null is returned.

remove

public void remove(Component cell)
Removes the specified Cell.

Overrides:
remove in class Component
Parameters:
cell - The cell to be removed.

setBorderColor

public void setBorderColor(Color newValue)
Sets the border color of the grid.

Parameters:
newValue - The border color of the grid.

setBorderSize

public void setBorderSize(int newValue)
Sets the size of the grid's border.

Parameters:
newValue - The size of the grid's border, in pixels.

setCellMargin

public void setCellMargin(int newValue)
Sets the cell interior margin. The default size is 3 pixels

Parameters:
newValue - The cell margin, in pixels.

setColumnWidth

public void setColumnWidth(int column,
                           int newValue)
Sets the width of a column of the grid.

Parameters:
column - The column number.
newValue - The new width of the specified column.

setHeight

public void setHeight(int newValue)
Sets the overall height of the grid. Setting this property will have no effect in the event that all rows have a height value, or if the sum of all row heights (and margins) is greater than the height value.

Parameters:
newValue - The new height of the grid. To set the height to be undefined, use the EchoConstants.UNDEFINED_SIZE constant.

setHeightUnits

public void setHeightUnits(int newValue)
Sets the units (pixel or percent) in which row heights and overall grid height are measured.

Parameters:
newValue - The new unit measurement, one of the following values:
  • PIXEL_UNITS (the default)
  • PERCENT_INDIVIDUAL_PIXEL_TOTAL_UNITS
  • PERCENT_UNITS

setRowHeight

public void setRowHeight(int row,
                         int newValue)
Sets the height of a row of the grid.

Parameters:
row - The row number.
newValue - The new height of the specified row.

setWidth

public void setWidth(int newValue)
Sets the overall width of the grid. Setting this property will have no effect in the event that all columns have a width value, or if the sum of all columns widths (and margins) is greater than the width value.

Parameters:
newValue - The new width of the grid. To set the width to be undefined, use the EchoConstants.UNDEFINED_SIZE constant.

setWidthUnits

public void setWidthUnits(int newValue)
Sets the units (pixel or percent) in which column widths and overall grid width are measured.

Parameters:
newValue - The new unit measurement, one of the following values:
  • PIXEL_UNITS (the default)
  • PERCENT_INDIVIDUAL_PIXEL_TOTAL_UNITS
  • PERCENT_UNITS

validate

public void validate()
Overrides Component.validate(), to ensure that no cells of the grid overlap. If any cells overlap, a GridCellOverlapException is thrown.

Overrides:
validate in class Component

NextApp Echo
1.0.5