org.eclipse.nebula.widgets.nattable.grid.layer
Class DimensionallyDependentIndexLayer

java.lang.Object
  extended by org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
      extended by org.eclipse.nebula.widgets.nattable.layer.AbstractIndexLayerTransform
          extended by org.eclipse.nebula.widgets.nattable.grid.layer.DimensionallyDependentIndexLayer
All Implemented Interfaces:
ILayer, ILayerListener, IUniqueIndexLayer, IPersistable

public class DimensionallyDependentIndexLayer
extends AbstractIndexLayerTransform

A DimensionallyDependentIndexLayer is a layer whose horizontal and vertical dimensions are dependent on the horizontal and vertical dimensions of other layers. A DimensionallyDependentIndexLayer takes three constructor parameters: the horizontal layer that the DimensionallyDependentIndexLayer's horizontal dimension is linked to, the vertical layer that the DimensionallyDependentIndexLayer is linked to, and a base layer to which all non-dimensionally related ILayer method calls will be delegated to (e.g. command, event methods)

Prime examples of dimensionally dependent layers are the column header and row header layers. For example, the column header layer's horizontal dimension is linked to the body layer's horizontal dimension. This means that whatever columns are shown in the body area will also be shown in the column header area, and vice versa. Note that the column header layer maintains its own vertical dimension, however, so it's vertical layer dependency would be a separate data layer. The same is true for the row header layer, only with the vertical instead of the horizontal dimension. The constructors for the column header and row header layers would therefore look something like this:

 ILayer columnHeaderLayer = new DimensionallyDependentIndexLayer(
         columnHeaderRowDataLayer, bodyLayer, columnHeaderRowDataLayer);
 ILayer rowHeaderLayer = new DimensionallyDependentIndexLayer(
         rowHeaderColumnDataLayer, bodyLayer, rowHeaderColumnDataLayer);
 

In contrast to DimensionallyDependentLayer, this class:


Field Summary
 
Fields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
commandHandlers, eventHandlers, layerPainter
 
Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
 
Constructor Summary
protected DimensionallyDependentIndexLayer(IUniqueIndexLayer baseLayer)
          Creates a new DimensionallyDependentIndexLayer.
  DimensionallyDependentIndexLayer(IUniqueIndexLayer baseLayer, IUniqueIndexLayer horizontalLayerDependency, IUniqueIndexLayer verticalLayerDependency)
          Creates a new DimensionallyDependentIndexLayer.
 
Method Summary
 boolean doCommand(ILayerCommand command)
          Opportunity to respond to a command as it flows down the stack.
 IUniqueIndexLayer getBaseLayer()
           
 int getColumnCount()
           
 int getColumnIndexByPosition(int columnPosition)
          Gets the underlying non-transformed column index for the given column position.
 int getColumnPositionByIndex(int columnIndex)
           
 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.
 int getHeight()
          Returns the total height in pixels of this layer.
 ILayer getHorizontalLayerDependency()
           
 int getPreferredColumnCount()
           
 int getPreferredHeight()
           
 int getPreferredRowCount()
           
 int getPreferredWidth()
           
 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 getRowPositionByIndex(int rowIndex)
           
 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 getVerticalLayerDependency()
           
 int getWidth()
          Returns the total width in pixels of this layer.
 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)
           
protected  void setHorizontalLayerDependency(IUniqueIndexLayer horizontalLayerDependency)
           
protected  void setVerticalLayerDependency(IUniqueIndexLayer verticalLayerDependency)
           
 int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition)
           
 int underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer, int underlyingRowPosition)
           
 
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractIndexLayerTransform
configure, dispose, getCellByPosition, getCellPainter, getConfigLabelsByPosition, getDataValueByPosition, getDisplayModeByPosition, getLayerPainter, getRegionLabelsByXY, getUnderlyingLayer, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, loadState, saveState, setClientAreaProvider, setUnderlyingLayer, underlyingToLocalColumnPositions, underlyingToLocalRowPositions
 
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
addConfiguration, addLayerListener, clearConfiguration, fireLayerEvent, getBoundsByPosition, getClientAreaProvider, getConfigLabelAccumulator, getRegionName, handleLayerEvent, hasLayerListener, registerCommandHandler, registerCommandHandlers, registerEventHandler, registerPersistable, removeLayerListener, setConfigLabelAccumulator, setLayerPainter, setRegionName, toString, unregisterCommandHandler, unregisterEventHandler, unregisterPersistable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.nebula.widgets.nattable.layer.ILayer
addLayerListener, fireLayerEvent, getBoundsByPosition, getClientAreaProvider, hasLayerListener, registerCommandHandler, registerPersistable, removeLayerListener, unregisterCommandHandler, unregisterPersistable
 
Methods inherited from interface org.eclipse.nebula.widgets.nattable.layer.ILayerListener
handleLayerEvent
 

Constructor Detail

DimensionallyDependentIndexLayer

public DimensionallyDependentIndexLayer(IUniqueIndexLayer baseLayer,
                                        IUniqueIndexLayer horizontalLayerDependency,
                                        IUniqueIndexLayer verticalLayerDependency)
Creates a new DimensionallyDependentIndexLayer.

Parameters:
baseLayer - the underlying base layer
horizontalLayerDependency - the layer, the horizontal dimension is linked to
verticalLayerDependency - the layer, the vertical dimension is linked to

DimensionallyDependentIndexLayer

protected DimensionallyDependentIndexLayer(IUniqueIndexLayer baseLayer)
Creates a new DimensionallyDependentIndexLayer.

Parameters:
baseLayer - the underlying base layer
Method Detail

setHorizontalLayerDependency

protected void setHorizontalLayerDependency(IUniqueIndexLayer horizontalLayerDependency)

setVerticalLayerDependency

protected void setVerticalLayerDependency(IUniqueIndexLayer verticalLayerDependency)

getHorizontalLayerDependency

public ILayer getHorizontalLayerDependency()

getVerticalLayerDependency

public ILayer getVerticalLayerDependency()

getBaseLayer

public IUniqueIndexLayer getBaseLayer()

doCommand

public boolean doCommand(ILayerCommand command)
Description copied from interface: ILayer
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)

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

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface ILayer
Overrides:
getColumnCount in class AbstractIndexLayerTransform
Returns:
the number of columns in this coordinate model

getPreferredColumnCount

public int getPreferredColumnCount()
Specified by:
getPreferredColumnCount in interface ILayer
Overrides:
getPreferredColumnCount in class AbstractIndexLayerTransform

getColumnIndexByPosition

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

Specified by:
getColumnIndexByPosition in interface ILayer
Overrides:
getColumnIndexByPosition in class AbstractIndexLayerTransform
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

getColumnPositionByIndex

public int getColumnPositionByIndex(int columnIndex)
Specified by:
getColumnPositionByIndex in interface IUniqueIndexLayer
Overrides:
getColumnPositionByIndex in class AbstractIndexLayerTransform

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.

Specified by:
localToUnderlyingColumnPosition in interface ILayer
Overrides:
localToUnderlyingColumnPosition in class AbstractIndexLayerTransform
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)
Specified by:
underlyingToLocalColumnPosition in interface ILayer
Overrides:
underlyingToLocalColumnPosition in class AbstractIndexLayerTransform

getWidth

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

Specified by:
getWidth in interface ILayer
Overrides:
getWidth in class AbstractIndexLayerTransform
Returns:
the width of this layer

getPreferredWidth

public int getPreferredWidth()
Specified by:
getPreferredWidth in interface ILayer
Overrides:
getPreferredWidth in class AbstractIndexLayerTransform

getColumnWidthByPosition

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

Specified by:
getColumnWidthByPosition in interface ILayer
Overrides:
getColumnWidthByPosition in class AbstractIndexLayerTransform
Parameters:
columnPosition - the column position in this layer
Returns:
the width of the column

isColumnPositionResizable

public boolean isColumnPositionResizable(int columnPosition)
Specified by:
isColumnPositionResizable in interface ILayer
Overrides:
isColumnPositionResizable in class AbstractIndexLayerTransform

getColumnPositionByX

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

Specified by:
getColumnPositionByX in interface ILayer
Overrides:
getColumnPositionByX in class AbstractIndexLayerTransform
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

public int getStartXOfColumnPosition(int columnPosition)
Description copied from interface: ILayer
Returns the x offset in pixels of the given column.

Specified by:
getStartXOfColumnPosition in interface ILayer
Overrides:
getStartXOfColumnPosition in class AbstractIndexLayerTransform
Parameters:
columnPosition - the column position in this layer
Returns:
the x offset of the column, or -1

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface ILayer
Overrides:
getRowCount in class AbstractIndexLayerTransform
Returns:
the number of rows in this coordinate model

getPreferredRowCount

public int getPreferredRowCount()
Specified by:
getPreferredRowCount in interface ILayer
Overrides:
getPreferredRowCount in class AbstractIndexLayerTransform

getRowIndexByPosition

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

Specified by:
getRowIndexByPosition in interface ILayer
Overrides:
getRowIndexByPosition in class AbstractIndexLayerTransform
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

getRowPositionByIndex

public int getRowPositionByIndex(int rowIndex)
Specified by:
getRowPositionByIndex in interface IUniqueIndexLayer
Overrides:
getRowPositionByIndex in class AbstractIndexLayerTransform

localToUnderlyingRowPosition

public int localToUnderlyingRowPosition(int localRowPosition)
Specified by:
localToUnderlyingRowPosition in interface ILayer
Overrides:
localToUnderlyingRowPosition in class AbstractIndexLayerTransform

underlyingToLocalRowPosition

public int underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer,
                                        int underlyingRowPosition)
Specified by:
underlyingToLocalRowPosition in interface ILayer
Overrides:
underlyingToLocalRowPosition in class AbstractIndexLayerTransform

getHeight

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

Specified by:
getHeight in interface ILayer
Overrides:
getHeight in class AbstractIndexLayerTransform
Returns:
the height of this layer

getPreferredHeight

public int getPreferredHeight()
Specified by:
getPreferredHeight in interface ILayer
Overrides:
getPreferredHeight in class AbstractIndexLayerTransform

getRowHeightByPosition

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

Specified by:
getRowHeightByPosition in interface ILayer
Overrides:
getRowHeightByPosition in class AbstractIndexLayerTransform
Parameters:
rowPosition - the row position in this layer
Returns:
the height of the row

isRowPositionResizable

public boolean isRowPositionResizable(int rowPosition)
Specified by:
isRowPositionResizable in interface ILayer
Overrides:
isRowPositionResizable in class AbstractIndexLayerTransform

getRowPositionByY

public int getRowPositionByY(int y)
Description copied from interface: ILayer
Returns the row position that contains the given y coordinate.

Specified by:
getRowPositionByY in interface ILayer
Overrides:
getRowPositionByY in class AbstractIndexLayerTransform
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

public int getStartYOfRowPosition(int rowPosition)
Description copied from interface: ILayer
Returns the y offset in pixels of the given row.

Specified by:
getStartYOfRowPosition in interface ILayer
Overrides:
getStartYOfRowPosition in class AbstractIndexLayerTransform
Parameters:
rowPosition - the row position in this layer
Returns:
the y offset of the row, or -1


Copyright © 2015. All rights reserved.