org.eclipse.nebula.widgets.nattable.layer
Interface ILayer

All Superinterfaces:
ILayerListener, IPersistable
All Known Subinterfaces:
IUniqueIndexLayer
All Known Implementing Classes:
_001_Getting_Started.BodyLayerStack, _001_Getting_Started.ColumnHeaderLayerStack, _001_Getting_Started.RowHeaderLayerStack, _804_GlazedListsEditorExample.GlazedListsEditorColumnHeaderLayerStack, AbstractColumnHideShowLayer, AbstractIndexLayerTransform, AbstractLayer, AbstractLayerTransform, AbstractRowHideShowLayer, BaseColumnHideShowLayerFixture, BaseColumnReorderLayerFixture, BaseDataLayerFixture, BaseRowHideShowLayerFixture, BaseRowReorderLayerFixture, BlinkLayer, BodyLayerStack, BodyLayerStackFixture, ColumnGroupBodyLayerStack, ColumnGroupExpandCollapseLayer, ColumnGroupGroupHeaderLayer, ColumnGroupHeaderLayer, ColumnGroupReorderLayer, ColumnHeaderLayer, ColumnHeaderLayerFixture, ColumnHeaderLayerStack, ColumnHideShowLayer, ColumnHideShowLayerFixture, ColumnReorderLayer, ColumnReorderLayerFixture, ColumnStructureUpdatesExampleGridLayer, ComboBoxFilterRowHeaderComposite, CompositeFreezeLayer, CompositeLayer, CompositeLayerFixture, CornerLayer, CornerLayerStack, DataLayer, DataLayerFixture, DefaultBodyLayerStack, DefaultColumnHeaderDataLayer, DefaultGridLayer, DefaultRowHeaderDataLayer, DetailGlazedListsEventLayer, DimensionallyDependentIndexLayer, DimensionallyDependentLayer, DummyGridLayerStack, FilterRowDataLayer, FilterRowExampleGridLayer, FilterRowHeaderComposite, FixedSummaryRowHeaderLayer, FixedSummaryRowLayer, FreezeLayer, FullFeaturedBodyLayerStack, FullFeaturedColumnHeaderLayerStack, GenericLayerFixture, GlazedListsColumnHeaderLayerStack, GlazedListsEventLayer, GlazedListsGridLayer, GlazedListsGridLayer, GlazedListsRowHideShowLayer, GridLayer, GridLayerFixture, GroupByDataLayer, GroupByHeaderLayer, HoverLayer, InvertedLayer, NatTable, NatTableFixture, RowGroupExpandCollapseLayer, RowGroupHeaderLayer, RowHeaderLayer, RowHeaderLayerStack, RowHideShowLayer, RowHideShowLayerFixture, RowReorderLayer, RowReorderLayerFixture, SelectionExampleBodyLayerStack, SelectionExampleGridLayer, SelectionLayer, SortHeaderLayer, SpanningDataLayer, StaticFilterExampleGridLayer, SummaryRowLayer, TestLayer, TreeLayer, ViewportLayer, ViewportLayerFixture, ZoomLayer

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

See Also:
CompositeLayer

Field Summary
 
Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
 
Method Summary
 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)
           
 
Methods inherited from interface org.eclipse.nebula.widgets.nattable.layer.ILayerListener
handleLayerEvent
 
Methods inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
loadState, saveState
 

Method Detail

dispose

void dispose()

registerPersistable

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.

Parameters:
persistable - the persistable to be registered

unregisterPersistable

void unregisterPersistable(IPersistable persistable)

configure

void configure(ConfigRegistry configRegistry,
               UiBindingRegistry uiBindingRegistry)
Every layer gets this call back, starting at the top of the stack. This is triggered by the NatTable.configure() method. This is an opportunity to add any key/mouse bindings and other general configuration.

Parameters:
configRegistry - instance owned by NatTable
uiBindingRegistry - instance owned by NatTable

getRegionLabelsByXY

LabelStack getRegionLabelsByXY(int x,
                               int y)
Layer can apply its own labels to any cell it wishes.

Parameters:
x - the x pixel coordinate
y - the y pixel coordinate
Returns:
a LabelStack containing the region labels for the cell at the given pixel position

doCommand

boolean doCommand(ILayerCommand command)
Opportunity to respond to a command as it flows down the stack. If the layer is not interested in the command it should allow the command to keep traveling down the stack. Note: Before the layer can process a command it must convert the command to its local co-ordinates using ILayerCommand.convertToTargetLayer(ILayer)

Parameters:
command - the command to perform
Returns:
true if the command has been handled, false otherwise

registerCommandHandler

void registerCommandHandler(ILayerCommandHandler<?> commandHandler)

unregisterCommandHandler

void unregisterCommandHandler(Class<? extends ILayerCommand> commandClass)

fireLayerEvent

void fireLayerEvent(ILayerEvent event)
Events can be fired to notify other components of the grid. Events travel up the layer stack and may cause a repaint.

Example: When the contents of the grid change IVisualChangeEvent can be fired to notify other layers to refresh their caches etc.

Parameters:
event - the event to fire

addLayerListener

void addLayerListener(ILayerListener listener)

removeLayerListener

void removeLayerListener(ILayerListener listener)

hasLayerListener

boolean hasLayerListener(Class<? extends ILayerListener> layerListenerClass)
Parameters:
layerListenerClass - The type of ILayerListener to check for existence
Returns:
true if this ILayer has a ILayerListener registered for the specified type, false if there is no such listener registered already

getLayerPainter

ILayerPainter getLayerPainter()

getClientAreaProvider

IClientAreaProvider getClientAreaProvider()

setClientAreaProvider

void setClientAreaProvider(IClientAreaProvider clientAreaProvider)

getColumnCount

int getColumnCount()
Returns:
the number of columns in this coordinate model

getPreferredColumnCount

int getPreferredColumnCount()

getColumnIndexByPosition

int getColumnIndexByPosition(int columnPosition)
Gets the underlying non-transformed column index for the given column position.

Parameters:
columnPosition - a column position relative to this coordinate model
Returns:
an underlying non-transformed column index, or -1 if the given column position does not exist within this coordinate system

localToUnderlyingColumnPosition

int localToUnderlyingColumnPosition(int localColumnPosition)
Convert a column position to the coordinates of the underlying layer. This is possible since each layer is aware of its underlying layer.

Parameters:
localColumnPosition - column position in local (the layer's own) coordinates
Returns:
column position in the underlying layer's coordinates

underlyingToLocalColumnPosition

int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer,
                                    int underlyingColumnPosition)

underlyingToLocalColumnPositions

Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer,
                                                   Collection<Range> underlyingColumnPositionRanges)

getWidth

int getWidth()
Returns the total width in pixels of this layer.

Returns:
the width of this layer

getPreferredWidth

int getPreferredWidth()

getColumnWidthByPosition

int getColumnWidthByPosition(int columnPosition)
Returns the width in pixels of the given column. The width of invisible and non-existing columns is 0.

Parameters:
columnPosition - the column position in this layer
Returns:
the width of the column

isColumnPositionResizable

boolean isColumnPositionResizable(int columnPosition)

getColumnPositionByX

int getColumnPositionByX(int x)
Returns the column position that contains the given x coordinate.

Parameters:
x - a horizontal pixel location relative to the pixel boundary of this layer
Returns:
a column position relative to the associated coordinate system, or -1 if there is no column that contains x

getStartXOfColumnPosition

int getStartXOfColumnPosition(int columnPosition)
Returns the x offset in pixels of the given column.

Parameters:
columnPosition - the column position in this layer
Returns:
the x offset of the column, or -1

getUnderlyingLayersByColumnPosition

Collection<ILayer> getUnderlyingLayersByColumnPosition(int columnPosition)

getRowCount

int getRowCount()
Returns:
the number of rows in this coordinate model

getPreferredRowCount

int getPreferredRowCount()

getRowIndexByPosition

int getRowIndexByPosition(int rowPosition)
Gets the underlying non-transformed row index for the given row position.

Parameters:
rowPosition - a row position relative to this coordinate model
Returns:
an underlying non-transformed row index, or -1 if the given row position does not exist within this coordinate system

localToUnderlyingRowPosition

int localToUnderlyingRowPosition(int localRowPosition)

underlyingToLocalRowPosition

int underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer,
                                 int underlyingRowPosition)

underlyingToLocalRowPositions

Collection<Range> underlyingToLocalRowPositions(ILayer sourceUnderlyingLayer,
                                                Collection<Range> underlyingRowPositionRanges)

getHeight

int getHeight()
Returns the total height in pixels of this layer.

Returns:
the height of this layer

getPreferredHeight

int getPreferredHeight()

getRowHeightByPosition

int getRowHeightByPosition(int rowPosition)
Returns the height in pixels of the given row. The height of invisible and non-existing rows is 0.

Parameters:
rowPosition - the row position in this layer
Returns:
the height of the row

isRowPositionResizable

boolean isRowPositionResizable(int rowPosition)

getRowPositionByY

int getRowPositionByY(int y)
Returns the row position that contains the given y coordinate.

Parameters:
y - a vertical pixel location relative to the pixel boundary of this layer
Returns:
a row position relative to the associated coordinate system, or -1 if there is no row that contains y

getStartYOfRowPosition

int getStartYOfRowPosition(int rowPosition)
Returns the y offset in pixels of the given row.

Parameters:
rowPosition - the row position in this layer
Returns:
the y offset of the row, or -1

getUnderlyingLayersByRowPosition

Collection<ILayer> getUnderlyingLayersByRowPosition(int rowPosition)

getCellByPosition

ILayerCell getCellByPosition(int columnPosition,
                             int rowPosition)

getBoundsByPosition

org.eclipse.swt.graphics.Rectangle getBoundsByPosition(int columnPosition,
                                                       int rowPosition)
Calculates the bounds in pixel for the given cell position.

Parameters:
columnPosition - the column position of the cell
rowPosition - the row position of the cell
Returns:
the bounds, or null if there are no valid bounds

getDisplayModeByPosition

String getDisplayModeByPosition(int columnPosition,
                                int rowPosition)
Parameters:
columnPosition - the column position of the cell
rowPosition - the row position of the cell
Returns:
DisplayMode 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.


getConfigLabelsByPosition

LabelStack getConfigLabelsByPosition(int columnPosition,
                                     int rowPosition)

getDataValueByPosition

Object getDataValueByPosition(int columnPosition,
                              int rowPosition)

getUnderlyingLayerByPosition

ILayer getUnderlyingLayerByPosition(int columnPosition,
                                    int rowPosition)

getCellPainter

ICellPainter getCellPainter(int columnPosition,
                            int rowPosition,
                            ILayerCell cell,
                            IConfigRegistry configRegistry)


Copyright © 2015. All rights reserved.