org.eclipse.nebula.widgets.nattable.layer
Class CompositeLayer

java.lang.Object
  extended by org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
      extended by org.eclipse.nebula.widgets.nattable.layer.CompositeLayer
All Implemented Interfaces:
ILayer, ILayerListener, IPersistable
Direct Known Subclasses:
ComboBoxFilterRowHeaderComposite, CompositeFreezeLayer, CompositeLayerFixture, FilterRowHeaderComposite, GridLayer

public class CompositeLayer
extends AbstractLayer

A composite layer is a layer that is made up of a number of underlying child layers. This class assumes that the child layers are laid out in a regular grid pattern where the child layers in each composite row all have the same number of rows and the same height, and the child layers in each composite column each have the same number of columns and the same width.


Nested Class Summary
protected  class CompositeLayer.CompositeLayerPainter
           
 
Field Summary
 
Fields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
layerPainter
 
Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
 
Constructor Summary
CompositeLayer(int layoutXCount, int layoutYCount)
           
 
Method Summary
 void addConfigLabelAccumulatorForRegion(String regionName, IConfigLabelAccumulator configLabelAccumulator)
          Adds the configLabelAccumulator to the existing label accumulators.
 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.
protected  boolean doCommandOnChildLayers(ILayerCommand command)
           
 org.eclipse.swt.graphics.Rectangle getBoundsByPosition(int compositeColumnPosition, int compositeRowPosition)
          Calculates the bounds in pixel for the given cell position.
 ILayerCell getCellByPosition(int compositeColumnPosition, int compositeRowPosition)
           
 ICellPainter getCellPainter(int compositeColumnPosition, int compositeRowPosition, ILayerCell cell, IConfigRegistry configRegistry)
           
 ILayer getChildLayerByLayoutCoordinate(int layoutX, int layoutY)
           
 ILayer getChildLayerByRegionName(String regionName)
           
 int getColumnCount()
           
 int getColumnIndexByPosition(int compositeColumnPosition)
          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.
protected  int getColumnPositionOffset(int layoutX)
           
 int getColumnWidthByPosition(int column)
          Returns the width in pixels of the given column.
 IConfigLabelAccumulator getConfigLabelAccumulatorByRegionName(String regionName)
           
 LabelStack getConfigLabelsByPosition(int compositeColumnPosition, int compositeRowPosition)
           
 Object getDataValueByPosition(int compositeColumnPosition, int compositeRowPosition)
           
 String getDisplayModeByPosition(int compositeColumnPosition, int compositeRowPosition)
           
 int getHeight()
          Returns the total height in pixels of this layer.
protected  int getHeightOffset(int layoutY)
           
protected  int getLayoutXByColumnPosition(int compositeColumnPosition)
           
protected  int getLayoutXByPixelX(int x)
           
 int getLayoutXCount()
           
protected  org.eclipse.swt.graphics.Point getLayoutXYByChildLayer(ILayer childLayer)
           
protected  org.eclipse.swt.graphics.Point getLayoutXYByPixelXY(int x, int y)
           
protected  org.eclipse.swt.graphics.Point getLayoutXYByPosition(int compositeColumnPosition, int compositeRowPosition)
           
protected  int getLayoutYByPixelY(int y)
           
protected  int getLayoutYByRowPosition(int compositeRowPosition)
           
 int getLayoutYCount()
           
 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 row)
          Returns the height in pixels of the given row.
 int getRowIndexByPosition(int compositeRowPosition)
          Gets the underlying non-transformed row index for the given row position.
 int getRowPositionByY(int y)
          Get the row position relative to the layer the containing coordinate y.
protected  int getRowPositionOffset(int layoutY)
           
 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.
protected  int getWidthOffset(int layoutX)
           
 boolean isColumnPositionResizable(int compositeColumnPosition)
           
 boolean isRowPositionResizable(int compositeRowPosition)
           
 void loadState(String prefix, Properties properties)
          Restore the state out of the given Properties identified by the specified prefix.
 int localToUnderlyingColumnPosition(int localColumnPosition)
          Convert a column position to the coordinates of the underlying layer.
 int localToUnderlyingRowPosition(int localRowPosition)
           
 void saveState(String prefix, Properties properties)
          Saves the state to the given Properties using the specified prefix.
 void setChildLayer(String regionName, ILayer childLayer, int layoutX, int layoutY)
           
 void setConfigLabelAccumulatorForRegion(String regionName, IConfigLabelAccumulator configLabelAccumulator)
          Sets the IConfigLabelAccumulator for the given named region.
 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)
           
 
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
addConfiguration, addLayerListener, clearConfiguration, fireLayerEvent, getClientAreaProvider, getConfigLabelAccumulator, getLayerPainter, getRegionName, handleLayerEvent, hasLayerListener, registerCommandHandler, registerCommandHandlers, registerEventHandler, registerPersistable, removeLayerListener, setClientAreaProvider, setConfigLabelAccumulator, setLayerPainter, setRegionName, toString, unregisterCommandHandler, unregisterEventHandler, unregisterPersistable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompositeLayer

public CompositeLayer(int layoutXCount,
                      int layoutYCount)
Method Detail

dispose

public void dispose()
Specified by:
dispose in interface ILayer
Overrides:
dispose in class AbstractLayer

saveState

public void saveState(String prefix,
                      Properties properties)
Description copied from interface: IPersistable
Saves the state to the given Properties using the specified prefix. Note: The prefix must be prepended to the property key to support multiple states within one Properties instance.

Specified by:
saveState in interface IPersistable
Overrides:
saveState in class AbstractLayer
Parameters:
prefix - The prefix to use for the state keys. Is also used as the state configuration name.
properties - The Properties instance to save the state to.

loadState

public void loadState(String prefix,
                      Properties properties)
Description copied from interface: IPersistable
Restore the state out of the given Properties identified by the specified prefix. Note: The prefix must be prepended to the property key to support multiple states within one Properties instance.

Specified by:
loadState in interface IPersistable
Overrides:
loadState in class AbstractLayer
Parameters:
prefix - The prefix to use for the state keys. Is also used as the state configuration name.
properties - The Properties instance to load the state from.

configure

public void configure(ConfigRegistry configRegistry,
                      UiBindingRegistry uiBindingRegistry)
Description copied from interface: ILayer
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.

Specified by:
configure in interface ILayer
Overrides:
configure in class AbstractLayer
Parameters:
configRegistry - instance owned by NatTable
uiBindingRegistry - instance owned by NatTable

doCommand

public 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) Handle commands

Specified by:
doCommand in interface ILayer
Overrides:
doCommand in class AbstractLayer
Parameters:
command - the command to perform
Returns:
true if the command has been handled, false otherwise

doCommandOnChildLayers

protected boolean doCommandOnChildLayers(ILayerCommand command)

getColumnCount

public int getColumnCount()
Returns:
total number of columns being displayed Note: Works off the header layers.

getPreferredColumnCount

public int getPreferredColumnCount()

getColumnIndexByPosition

public int getColumnIndexByPosition(int compositeColumnPosition)
Description copied from interface: ILayer
Gets the underlying non-transformed column index for the given column position.

Parameters:
compositeColumnPosition - Column position in the CompositeLayer
Returns:
column index in the underlying layer.

localToUnderlyingColumnPosition

public int localToUnderlyingColumnPosition(int localColumnPosition)
Description copied from interface: ILayer
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

public int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer,
                                           int underlyingColumnPosition)

underlyingToLocalColumnPositions

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

getWidth

public int getWidth()
Description copied from interface: ILayer
Returns the total width in pixels of this layer.

Returns:
the width of this layer

getPreferredWidth

public int getPreferredWidth()

getColumnWidthByPosition

public int getColumnWidthByPosition(int column)
Description copied from interface: ILayer
Returns the width in pixels of the given column. The width of invisible and non-existing columns is 0.

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

isColumnPositionResizable

public boolean isColumnPositionResizable(int compositeColumnPosition)

getColumnPositionByX

public int getColumnPositionByX(int x)
Description copied from interface: ILayer
Returns the column position that contains the given x coordinate.

Parameters:
x - pixel position - starts from 0
Returns:
a column position relative to the associated coordinate system, or -1 if there is no column that contains x

getStartXOfColumnPosition

public int getStartXOfColumnPosition(int columnPosition)
Description copied from interface: ILayer
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

public Collection<ILayer> getUnderlyingLayersByColumnPosition(int columnPosition)

getRowCount

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

getPreferredRowCount

public int getPreferredRowCount()

getRowIndexByPosition

public int getRowIndexByPosition(int compositeRowPosition)
Description copied from interface: ILayer
Gets the underlying non-transformed row index for the given row position.

Parameters:
compositeRowPosition - 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

public int localToUnderlyingRowPosition(int localRowPosition)

underlyingToLocalRowPosition

public int underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer,
                                        int underlyingRowPosition)

underlyingToLocalRowPositions

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

getHeight

public int getHeight()
Description copied from interface: ILayer
Returns the total height in pixels of this layer.

Returns:
the height of this layer

getPreferredHeight

public int getPreferredHeight()

getRowHeightByPosition

public int getRowHeightByPosition(int row)
Description copied from interface: ILayer
Returns the height in pixels of the given row. The height of invisible and non-existing rows is 0.

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

isRowPositionResizable

public boolean isRowPositionResizable(int compositeRowPosition)
Returns:
false if the row position is out of bounds

getRowPositionByY

public int getRowPositionByY(int y)
Get the row position relative to the layer the containing coordinate y.

Parameters:
y - Mouse event Y position.
Returns:
a row position relative to the associated coordinate system, or -1 if there is no row that contains y

getStartYOfRowPosition

public int getStartYOfRowPosition(int rowPosition)
Description copied from interface: ILayer
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

public Collection<ILayer> getUnderlyingLayersByRowPosition(int rowPosition)

getCellByPosition

public ILayerCell getCellByPosition(int compositeColumnPosition,
                                    int compositeRowPosition)
Specified by:
getCellByPosition in interface ILayer
Overrides:
getCellByPosition in class AbstractLayer

getBoundsByPosition

public org.eclipse.swt.graphics.Rectangle getBoundsByPosition(int compositeColumnPosition,
                                                              int compositeRowPosition)
Description copied from interface: ILayer
Calculates the bounds in pixel for the given cell position.

Specified by:
getBoundsByPosition in interface ILayer
Overrides:
getBoundsByPosition in class AbstractLayer
Parameters:
compositeColumnPosition - the column position of the cell
compositeRowPosition - the row position of the cell
Returns:
the bounds, or null if there are no valid bounds

getDisplayModeByPosition

public String getDisplayModeByPosition(int compositeColumnPosition,
                                       int compositeRowPosition)
Specified by:
getDisplayModeByPosition in interface ILayer
Overrides:
getDisplayModeByPosition in class AbstractLayer
Parameters:
compositeColumnPosition - the column position of the cell
compositeRowPosition - 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

public LabelStack getConfigLabelsByPosition(int compositeColumnPosition,
                                            int compositeRowPosition)
Specified by:
getConfigLabelsByPosition in interface ILayer
Overrides:
getConfigLabelsByPosition in class AbstractLayer

getDataValueByPosition

public Object getDataValueByPosition(int compositeColumnPosition,
                                     int compositeRowPosition)

getCellPainter

public ICellPainter getCellPainter(int compositeColumnPosition,
                                   int compositeRowPosition,
                                   ILayerCell cell,
                                   IConfigRegistry configRegistry)
Specified by:
getCellPainter in interface ILayer
Overrides:
getCellPainter in class AbstractLayer

setChildLayer

public void setChildLayer(String regionName,
                          ILayer childLayer,
                          int layoutX,
                          int layoutY)

getConfigLabelAccumulatorByRegionName

public IConfigLabelAccumulator getConfigLabelAccumulatorByRegionName(String regionName)

setConfigLabelAccumulatorForRegion

public void setConfigLabelAccumulatorForRegion(String regionName,
                                               IConfigLabelAccumulator configLabelAccumulator)
Sets the IConfigLabelAccumulator for the given named region. Replaces any existing IConfigLabelAccumulator.


addConfigLabelAccumulatorForRegion

public void addConfigLabelAccumulatorForRegion(String regionName,
                                               IConfigLabelAccumulator configLabelAccumulator)
Adds the configLabelAccumulator to the existing label accumulators.


getChildLayerByLayoutCoordinate

public ILayer getChildLayerByLayoutCoordinate(int layoutX,
                                              int layoutY)
Parameters:
layoutX - col position in the CompositeLayer
layoutY - row position in the CompositeLayer
Returns:
child layer according to the Composite Layer Layout

getChildLayerByRegionName

public ILayer getChildLayerByRegionName(String regionName)
Parameters:
regionName - The region name for which the child layer is requested.
Returns:
The child layer that is registered for the given region name.

getRegionLabelsByXY

public LabelStack getRegionLabelsByXY(int x,
                                      int y)
Description copied from interface: ILayer
Layer can apply its own labels to any cell it wishes.

Specified by:
getRegionLabelsByXY in interface ILayer
Overrides:
getRegionLabelsByXY in class AbstractLayer
Parameters:
x - pixel position
y - pixel position
Returns:
Region which the given position is in

getUnderlyingLayerByPosition

public ILayer getUnderlyingLayerByPosition(int columnPosition,
                                           int rowPosition)

getLayoutXYByChildLayer

protected org.eclipse.swt.graphics.Point getLayoutXYByChildLayer(ILayer childLayer)

getLayoutXByPixelX

protected int getLayoutXByPixelX(int x)

getLayoutYByPixelY

protected int getLayoutYByPixelY(int y)

getLayoutXYByPixelXY

protected org.eclipse.swt.graphics.Point getLayoutXYByPixelXY(int x,
                                                              int y)

getLayoutXByColumnPosition

protected int getLayoutXByColumnPosition(int compositeColumnPosition)

getLayoutYByRowPosition

protected int getLayoutYByRowPosition(int compositeRowPosition)

getLayoutXYByPosition

protected org.eclipse.swt.graphics.Point getLayoutXYByPosition(int compositeColumnPosition,
                                                               int compositeRowPosition)

getColumnPositionOffset

protected int getColumnPositionOffset(int layoutX)

getWidthOffset

protected int getWidthOffset(int layoutX)

getRowPositionOffset

protected int getRowPositionOffset(int layoutY)

getHeightOffset

protected int getHeightOffset(int layoutY)

getLayoutXCount

public int getLayoutXCount()
Returns:
The number of column regions in this CompositeLayer.

getLayoutYCount

public int getLayoutYCount()
Returns:
The number of row regions in this CompositeLayer.


Copyright © 2014. All rights reserved.