public interface ILayer extends ILayerListener, IPersistable
A Layer is a rectangular region of grid cells. A layer has methods to access its columns, rows, width and height. A layer can be stacked on top of another layer in order to expose a transformed view of its underlying layer's grid cell structure.
Columns and rows in a layer are referenced either by position or index. The position of a column/row in a layer corresponds to the physical location of the column/row in the layer. The index of a column/row in a layer corresponds to the location of the column/row in the lowest level layer in the layer stack. These concepts are illustrated by the following example:
Hide Layer C 0 1 2 3 4 <- column positions 1 0 3 4 5 <- column indexes Reorder Layer B 0 1 2 3 4 5 <- column positions 2 1 0 3 4 5 <- column indexes Data Layer A 0 1 2 3 4 5 <- column positions 0 1 2 3 4 5 <- column indexes
In the above example, Hide Layer C is stacked on top of Reorder Layer B, which is in turn stacked on top of Data Layer A. The positions in Data Layer A are the same as its indexes, because it is the lowest level layer in the stack. Reorder Layer B reorders column 0 of its underlying layer (Data Layer A) after column 2 of its underlying layer. Hide Layer C hides the first column of its underlying layer (Reorder Layer B).
Layers can also be laterally composed into larger layers. For instance, the standard grid layer is composed of a body layer, column header layer, row header layer, and corner layer:
corner | column header |
row header | body |
CompositeLayer
DOT, VALUE_SEPARATOR
Modifier and Type | Method and Description |
---|---|
void |
addLayerListener(ILayerListener listener) |
void |
configure(ConfigRegistry configRegistry,
UiBindingRegistry uiBindingRegistry)
Every layer gets this call back, starting at the top of the stack.
|
void |
dispose() |
boolean |
doCommand(ILayerCommand command)
Opportunity to respond to a command as it flows down the stack.
|
void |
fireLayerEvent(ILayerEvent event)
Events can be fired to notify other components of the grid.
|
org.eclipse.swt.graphics.Rectangle |
getBoundsByPosition(int columnPosition,
int rowPosition)
Calculates the bounds in pixel for the given cell position.
|
ILayerCell |
getCellByPosition(int columnPosition,
int rowPosition) |
ICellPainter |
getCellPainter(int columnPosition,
int rowPosition,
ILayerCell cell,
IConfigRegistry configRegistry) |
IClientAreaProvider |
getClientAreaProvider() |
int |
getColumnCount() |
int |
getColumnIndexByPosition(int columnPosition)
Gets the underlying non-transformed column index for the given column position.
|
int |
getColumnPositionByX(int x)
Returns the column position that contains the given x coordinate.
|
int |
getColumnWidthByPosition(int columnPosition)
Returns the width in pixels of the given column.
|
LabelStack |
getConfigLabelsByPosition(int columnPosition,
int rowPosition) |
Object |
getDataValueByPosition(int columnPosition,
int rowPosition) |
String |
getDisplayModeByPosition(int columnPosition,
int rowPosition) |
int |
getHeight()
Returns the total height in pixels of this layer.
|
ILayerPainter |
getLayerPainter() |
int |
getPreferredColumnCount() |
int |
getPreferredHeight() |
int |
getPreferredRowCount() |
int |
getPreferredWidth() |
LabelStack |
getRegionLabelsByXY(int x,
int y)
Layer can apply its own labels to any cell it wishes.
|
int |
getRowCount() |
int |
getRowHeightByPosition(int rowPosition)
Returns the height in pixels of the given row.
|
int |
getRowIndexByPosition(int rowPosition)
Gets the underlying non-transformed row index for the given row position.
|
int |
getRowPositionByY(int y)
Returns the row position that contains the given y coordinate.
|
int |
getStartXOfColumnPosition(int columnPosition)
Returns the x offset in pixels of the given column.
|
int |
getStartYOfRowPosition(int rowPosition)
Returns the y offset in pixels of the given row.
|
ILayer |
getUnderlyingLayerByPosition(int columnPosition,
int rowPosition) |
Collection<ILayer> |
getUnderlyingLayersByColumnPosition(int columnPosition) |
Collection<ILayer> |
getUnderlyingLayersByRowPosition(int rowPosition) |
int |
getWidth()
Returns the total width in pixels of this layer.
|
boolean |
hasLayerListener(Class<? extends ILayerListener> layerListenerClass) |
boolean |
isColumnPositionResizable(int columnPosition) |
boolean |
isRowPositionResizable(int rowPosition) |
int |
localToUnderlyingColumnPosition(int localColumnPosition)
Convert a column position to the coordinates of the underlying layer.
|
int |
localToUnderlyingRowPosition(int localRowPosition) |
void |
registerCommandHandler(ILayerCommandHandler<?> commandHandler) |
void |
registerPersistable(IPersistable persistable)
Persistables registered with a layer will have a chance to write their data out to the
Properties instance when the layer is persisted. |
void |
removeLayerListener(ILayerListener listener) |
void |
setClientAreaProvider(IClientAreaProvider clientAreaProvider) |
int |
underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer,
int underlyingColumnPosition) |
Collection<Range> |
underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer,
Collection<Range> underlyingColumnPositionRanges) |
int |
underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer,
int underlyingRowPosition) |
Collection<Range> |
underlyingToLocalRowPositions(ILayer sourceUnderlyingLayer,
Collection<Range> underlyingRowPositionRanges) |
void |
unregisterCommandHandler(Class<? extends ILayerCommand> commandClass) |
void |
unregisterPersistable(IPersistable persistable) |
handleLayerEvent
loadState, saveState
void dispose()
void registerPersistable(IPersistable persistable)
Properties
instance when the layer is persisted.persistable
- the persistable to be registeredvoid unregisterPersistable(IPersistable persistable)
void configure(ConfigRegistry configRegistry, UiBindingRegistry uiBindingRegistry)
NatTable.configure()
method. This is an opportunity to add
any key/mouse bindings and other general configuration.LabelStack getRegionLabelsByXY(int x, int y)
x
- the x pixel coordinatey
- the y pixel coordinateboolean doCommand(ILayerCommand command)
ILayerCommand.convertToTargetLayer(ILayer)
command
- the command to performvoid registerCommandHandler(ILayerCommandHandler<?> commandHandler)
void unregisterCommandHandler(Class<? extends ILayerCommand> commandClass)
void fireLayerEvent(ILayerEvent event)
Example: When the contents of the grid change IVisualChangeEvent
can be
fired to notify other layers to refresh their caches etc.
event
- the event to firevoid addLayerListener(ILayerListener listener)
void removeLayerListener(ILayerListener listener)
boolean hasLayerListener(Class<? extends ILayerListener> layerListenerClass)
layerListenerClass
- The type of ILayerListener
to check for existencetrue
if this ILayer
has a ILayerListener
registered for the specified type, false
if there is
no such listener registered alreadyILayerPainter getLayerPainter()
IClientAreaProvider getClientAreaProvider()
void setClientAreaProvider(IClientAreaProvider clientAreaProvider)
int getColumnCount()
int getPreferredColumnCount()
int getColumnIndexByPosition(int columnPosition)
columnPosition
- a column position relative to this coordinate modelint localToUnderlyingColumnPosition(int localColumnPosition)
localColumnPosition
- column position in local (the layer's own) coordinatesint underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition)
Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges)
int getWidth()
int getPreferredWidth()
int getColumnWidthByPosition(int columnPosition)
columnPosition
- the column position in this layerboolean isColumnPositionResizable(int columnPosition)
int getColumnPositionByX(int x)
x
- a horizontal pixel location relative to the pixel boundary of this layerint getStartXOfColumnPosition(int columnPosition)
columnPosition
- the column position in this layerCollection<ILayer> getUnderlyingLayersByColumnPosition(int columnPosition)
int getRowCount()
int getPreferredRowCount()
int getRowIndexByPosition(int rowPosition)
rowPosition
- a row position relative to this coordinate modelint localToUnderlyingRowPosition(int localRowPosition)
int underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer, int underlyingRowPosition)
Collection<Range> underlyingToLocalRowPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingRowPositionRanges)
int getHeight()
int getPreferredHeight()
int getRowHeightByPosition(int rowPosition)
rowPosition
- the row position in this layerboolean isRowPositionResizable(int rowPosition)
int getRowPositionByY(int y)
y
- a vertical pixel location relative to the pixel boundary of this layerint getStartYOfRowPosition(int rowPosition)
rowPosition
- the row position in this layerCollection<ILayer> getUnderlyingLayersByRowPosition(int rowPosition)
ILayerCell getCellByPosition(int columnPosition, int rowPosition)
org.eclipse.swt.graphics.Rectangle getBoundsByPosition(int columnPosition, int rowPosition)
columnPosition
- the column position of the cellrowPosition
- the row position of the cellnull
if there are no valid boundsString getDisplayModeByPosition(int columnPosition, int rowPosition)
columnPosition
- the column position of the cellrowPosition
- the row position of the cellDisplayMode
for the cell at the given position.
The DisplayMode
affects the settings out of the ConfigRegistry
.
Display mode is NORMAL by default.
Example: SelectionLayer
overrides this to return the SELECT
label for cells which are selected.
LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition)
Object getDataValueByPosition(int columnPosition, int rowPosition)
ILayer getUnderlyingLayerByPosition(int columnPosition, int rowPosition)
ICellPainter getCellPainter(int columnPosition, int rowPosition, ILayerCell cell, IConfigRegistry configRegistry)
Copyright © 2013. All Rights Reserved.