Class FixedSummaryRowLayer
- java.lang.Object
-
- org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
-
- org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
-
- org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer
-
- org.eclipse.nebula.widgets.nattable.summaryrow.FixedSummaryRowLayer
-
- All Implemented Interfaces:
ILayer
,ILayerListener
,IUniqueIndexLayer
,IPersistable
public class FixedSummaryRowLayer extends SummaryRowLayer
This layer is a specialization of theSummaryRowLayer
and is intended to be used in a composition below aGridLayer
or a vertical composition like one with a column header and a body. It is horizontal dependent to the layer above and configured as a standalone summary row, which means that only the summary row is rendered.A typical composition to use this layer could look like this:
+---------------+---------------+
| CompositeLayer |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
| +---------------------------+ |
| | GridLayer | |
| +~~~~~~~~~~~~~~~~~~~~~~~~~~~+ |
| | Corner | ColHeader | |
| +-----------+---------------+ |
| | RowHeader | Body | |
| +-----------+---------------+ |
+-------------------------------+
| FixedSummaryRowLayer |
+-------------------------------+
It would be created by the following code:
GridLayer gridLayer = new GridLayer(...); FixedSummaryRowLayer summaryRowLayer = new FixedSummaryRowLayer(bodyDataLayer, gridLayer, configRegistry); CompositeLayer composite = new CompositeLayer(1, 2); composite.setChildLayer("GRID", gridLayer, 0, 0); composite.setChildLayer(SUMMARY_REGION, summaryRowLayer, 0, 1); NatTable natTable = new NatTable(panel, composite);
Note that the bodyDataLayer needs to be accessible somehow and the creation of the
GridLayer
is not specified in detail in the above example.Using this layer in a composition as shown above will result in a fixed summary row that doesn't scroll if the viewport is scrolled. This is different to the typical approach of adding the
SummaryRowLayer
on top of the bodyDataLayer
where the summary row will scroll as part of the body region.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_SUMMARY_ROW_LABEL
protected ILayer
horizontalLayerDependency
The layer to which fixed summary row should be horizontally dependent.protected String
summaryRowLabel
-
Fields inherited from class org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer
DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX, DEFAULT_SUMMARY_ROW_CONFIG_LABEL
-
Fields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
underlyingLayer
-
Fields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
commandHandlers, eventHandlers, eventHelperLock, layerPainter
-
Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description FixedSummaryRowLayer(IUniqueIndexLayer bodyDataLayer, ILayer horizontalLayerDependency, IConfigRegistry configRegistry)
Creates a standaloneFixedSummaryRowLayer
that is horizontal dependent to the given layer and calculates the summary values from the given bodyDataLayer.FixedSummaryRowLayer(IUniqueIndexLayer bodyDataLayer, ILayer horizontalLayerDependency, IConfigRegistry configRegistry, boolean autoConfigure)
Creates a standaloneFixedSummaryRowLayer
that is horizontal dependent to the given layer and calculates the summary values from the given bodyDataLayer.FixedSummaryRowLayer(IUniqueIndexLayer bodyDataLayer, ILayer horizontalLayerDependency, IConfigRegistry configRegistry, boolean smoothUpdates, boolean autoConfigure)
Creates a standaloneFixedSummaryRowLayer
that is horizontal dependent to the given layer and calculates the summary values from the given bodyDataLayer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
doCommand(ILayerCommand command)
Opportunity to respond to a command as it flows down the stack.int
getColumnCount()
int
getColumnIndexByPosition(int columnPosition)
Gets the underlying non-transformed column index for the given column position on this layer.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)
Returns the config labels for the cell at the given coordinates.protected LabelStack
getConfigLabelsByPositionWithoutTransformation(int columnPosition, int rowPosition)
This implementation directly calls the super implementation.Object
getDataValueByPosition(int columnPosition, int rowPosition)
Calculates the summary for the column using theISummaryProvider
from theIConfigRegistry
.int
getPreferredColumnCount()
int
getPreferredWidth()
int
getStartXOfColumnPosition(int columnPosition)
Returns the x offset in pixels of the given column.String
getSummaryRowLabel()
int
getWidth()
Returns the total width in pixels of this layer.boolean
hasHorizontalCompositeDependency()
protected boolean
isBodyColumn(int columnPosition)
boolean
isColumnPositionResizable(int columnPosition)
Check if the column at the given position is resizable.int
localToUnderlyingColumnPosition(int localColumnPosition)
Convert a column position to the coordinates of the underlying layer.void
setHorizontalCompositeDependency(boolean compositeDependency)
Specify if the horizontal dependency is aCompositeLayer
that adds additional columns.void
setSummaryRowLabel(String summaryRowLabel)
int
underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition)
Transforms the column position relative to the given underlying layer to this layer coordinates.Collection<Range>
underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges)
Transforms the column position ranges relative to the given underlying layer to this layer coordinates.-
Methods inherited from class org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer
clearCache, getCellByPosition, getColumnPositionByIndex, getHeight, getPreferredHeight, getPreferredRowCount, getProvidedLabels, getRowCount, getRowHeightByPosition, getRowIndexByPosition, getRowPositionByIndex, getRowPositionByY, getSummaryRowPosition, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, getValueCache, handleLayerEvent, isStandalone, isSummaryRowPosition, killCache, setStandalone, setValueCache
-
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
configure, dispose, getCellPainter, getDisplayModeByPosition, getLayerPainter, getRegionLabelsByXY, getStartYOfRowPosition, getUnderlyingLayer, isDynamicSizeLayer, isRowPositionResizable, loadState, localToUnderlyingRowPosition, saveState, setClientAreaProvider, setUnderlyingLayer, underlyingToLocalRowPosition, underlyingToLocalRowPositions
-
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
addConfiguration, addLayerListener, clearConfiguration, fireLayerEvent, getBoundsByPosition, getClientAreaProvider, getConfigLabelAccumulator, getRegionName, 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, configure, dispose, fireLayerEvent, getBoundsByPosition, getCellPainter, getClientAreaProvider, getDisplayModeByPosition, getLayerPainter, getRegionLabelsByXY, getStartYOfRowPosition, hasLayerListener, isDynamicSizeLayer, isRowPositionResizable, localToUnderlyingRowPosition, registerCommandHandler, registerPersistable, removeLayerListener, setClientAreaProvider, underlyingToLocalRowPosition, underlyingToLocalRowPositions, unregisterCommandHandler, unregisterPersistable
-
Methods inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
loadState, saveState
-
-
-
-
Field Detail
-
DEFAULT_SUMMARY_ROW_LABEL
public static final String DEFAULT_SUMMARY_ROW_LABEL
- See Also:
- Constant Field Values
-
summaryRowLabel
protected String summaryRowLabel
-
-
Constructor Detail
-
FixedSummaryRowLayer
public FixedSummaryRowLayer(IUniqueIndexLayer bodyDataLayer, ILayer horizontalLayerDependency, IConfigRegistry configRegistry)
Creates a standaloneFixedSummaryRowLayer
that is horizontal dependent to the given layer and calculates the summary values from the given bodyDataLayer. It will register the default configurations and perform smooth value updates.Note:
TheFixedSummaryRowLayer
constructor is setting aGridLineCellLayerPainter
that is configured for clipTop to the given bodyDataLayer. This is necessary as otherwise the body region would paint over the summary row. In case you want to use a differentILayerPainter
ensure to set it AFTER creating theFixedSummaryRowLayer
.- Parameters:
bodyDataLayer
- The underlying layer on which this layer should be build. Typically theDataLayer
of the body region.horizontalLayerDependency
- The layer that is above this layer in the surrounding composition. Typically aGridLayer
.configRegistry
- The ConfigRegistry for retrieving the ISummaryProvider per column.
-
FixedSummaryRowLayer
public FixedSummaryRowLayer(IUniqueIndexLayer bodyDataLayer, ILayer horizontalLayerDependency, IConfigRegistry configRegistry, boolean autoConfigure)
Creates a standaloneFixedSummaryRowLayer
that is horizontal dependent to the given layer and calculates the summary values from the given bodyDataLayer. It will perform smooth value updates.Note:
TheFixedSummaryRowLayer
constructor is setting aGridLineCellLayerPainter
that is configured for clipTop to the given bodyDataLayer. This is necessary as otherwise the body region would paint over the summary row. In case you want to use a differentILayerPainter
ensure to set it AFTER creating theFixedSummaryRowLayer
.- Parameters:
bodyDataLayer
- The underlying layer on which this layer should be build. Typically theDataLayer
of the body region.horizontalLayerDependency
- The layer that is above this layer in the surrounding composition. Typically aGridLayer
.configRegistry
- The ConfigRegistry for retrieving the ISummaryProvider per column.autoConfigure
-true
to use the DefaultSummaryRowConfiguration,false
if a custom configuration will be set after the creation.
-
FixedSummaryRowLayer
public FixedSummaryRowLayer(IUniqueIndexLayer bodyDataLayer, ILayer horizontalLayerDependency, IConfigRegistry configRegistry, boolean smoothUpdates, boolean autoConfigure)
Creates a standaloneFixedSummaryRowLayer
that is horizontal dependent to the given layer and calculates the summary values from the given bodyDataLayer.Note:
TheFixedSummaryRowLayer
constructor is setting aGridLineCellLayerPainter
that is configured for clipTop to the given bodyDataLayer. This is necessary as otherwise the body region would paint over the summary row. In case you want to use a differentILayerPainter
ensure to set it AFTER creating theFixedSummaryRowLayer
.- Parameters:
bodyDataLayer
- The underlying layer on which this layer should be build. Typically theDataLayer
of the body region.Note: When using a different layer than the DataLayer, e.g. the GlazedListsEventLayer to receive automatic updates, you need to ensure that the GridLineCellLayerPainter configured for clipping on top is set to the DataLayer for correct rendering of the fixed summary row.
horizontalLayerDependency
- The layer that is above this layer in the surrounding composition. Typically aGridLayer
.configRegistry
- The ConfigRegistry for retrieving the ISummaryProvider per column.smoothUpdates
-true
if the summary value updates should be performed smoothly,false
if on re-calculation the value should be immediately shown as not calculated.autoConfigure
-true
to use the DefaultSummaryRowConfiguration,false
if a custom configuration will be set after the creation.
-
-
Method Detail
-
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 coordinates using
ILayerCommand.convertToTargetLayer(ILayer)
- Specified by:
doCommand
in interfaceILayer
- Overrides:
doCommand
in classSummaryRowLayer
- Parameters:
command
- The command to execute.- Returns:
true
if the command has been handled and was therefore consumed,false
otherwise.
-
getDataValueByPosition
public Object getDataValueByPosition(int columnPosition, int rowPosition)
Description copied from class:SummaryRowLayer
Calculates the summary for the column using theISummaryProvider
from theIConfigRegistry
. In order to prevent the table from freezing (for large data sets), the summary is calculated in a separate Thread. While summary is being calculatedISummaryProvider.DEFAULT_SUMMARY_VALUE
is returned.NOTE: Since this is a
IUniqueIndexLayer
sitting close to theDataLayer
, columnPosition == columnIndex- Specified by:
getDataValueByPosition
in interfaceILayer
- Overrides:
getDataValueByPosition
in classSummaryRowLayer
- Parameters:
columnPosition
- The column position of the cell.rowPosition
- The row position of the cell.- Returns:
- The data value for the cell at the given coordinates.
-
isBodyColumn
protected boolean isBodyColumn(int columnPosition)
- Parameters:
columnPosition
- The column position that should be checked.- Returns:
true
if the column at the given position is a column of the body,false
if it is a column of another region, e.g. the row header in a grid.
-
hasHorizontalCompositeDependency
public boolean hasHorizontalCompositeDependency()
- Returns:
true
if the horizontal dependency is itself a composite that has an additional column, e.g. aGridLayer
with a row header.false
if the horizontal dependency is not a composite, e.g. the body layer stack.
-
setHorizontalCompositeDependency
public void setHorizontalCompositeDependency(boolean compositeDependency)
Specify if the horizontal dependency is aCompositeLayer
that adds additional columns.- Parameters:
compositeDependency
-true
to specify that the horizontal dependency is itself a composite that has an additional column, e.g. aGridLayer
with a row header.false
if the horizontal dependency is not a composite, e.g. the body layer stack.
-
getSummaryRowLabel
public String getSummaryRowLabel()
- Returns:
- The label that is used as data value for the horizontal dependent cell to the row header column.
-
setSummaryRowLabel
public void setSummaryRowLabel(String summaryRowLabel)
- Parameters:
summaryRowLabel
- The label that should be used as data value for the horizontal dependent cell to the row header column.
-
getConfigLabelsByPositionWithoutTransformation
protected LabelStack getConfigLabelsByPositionWithoutTransformation(int columnPosition, int rowPosition)
This implementation directly calls the super implementation. This is done to skip the column position-index transformation since it was done already.- Overrides:
getConfigLabelsByPositionWithoutTransformation
in classSummaryRowLayer
- Parameters:
columnPosition
- The column position of the cell for which the config labels are requested. If transformations are necessary, this value should be already transformed.rowPosition
- The row position of the cell for which the config labels are requested. If transformations are necessary, this value should be already transformed.- Returns:
- The
LabelStack
for the cell at the given coordinates.
-
getConfigLabelsByPosition
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition)
Description copied from interface:ILayer
Returns the config labels for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of theIConfigRegistry
.- Specified by:
getConfigLabelsByPosition
in interfaceILayer
- Overrides:
getConfigLabelsByPosition
in classSummaryRowLayer
- Parameters:
columnPosition
- The column position of the cell.rowPosition
- The row position of the cell.- Returns:
- The
LabelStack
with the config labels for the cell at the given coordinates.
-
getColumnCount
public int getColumnCount()
- Specified by:
getColumnCount
in interfaceILayer
- Overrides:
getColumnCount
in classAbstractLayerTransform
- Returns:
- The number of columns in this layer.
-
getPreferredColumnCount
public int getPreferredColumnCount()
- Specified by:
getPreferredColumnCount
in interfaceILayer
- Overrides:
getPreferredColumnCount
in classAbstractLayerTransform
-
getColumnIndexByPosition
public int getColumnIndexByPosition(int columnPosition)
Description copied from interface:ILayer
Gets the underlying non-transformed column index for the given column position on this layer.- Specified by:
getColumnIndexByPosition
in interfaceILayer
- Overrides:
getColumnIndexByPosition
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position relative to this layer.- Returns:
- An underlying non-transformed column index, or -1 if the given column position does not exist within this coordinate system.
-
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 interfaceILayer
- Overrides:
localToUnderlyingColumnPosition
in classAbstractLayerTransform
- 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)
Description copied from interface:ILayer
Transforms the column position relative to the given underlying layer to this layer coordinates.- Specified by:
underlyingToLocalColumnPosition
in interfaceILayer
- Overrides:
underlyingToLocalColumnPosition
in classAbstractLayerTransform
- Parameters:
sourceUnderlyingLayer
- The underlying layer to which the given column position matches.underlyingColumnPosition
- The column position in the given underlying layer that should be converted to a local column position.- Returns:
- The given column position transformed to be local to this layer.
-
underlyingToLocalColumnPositions
public Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges)
Description copied from interface:ILayer
Transforms the column position ranges relative to the given underlying layer to this layer coordinates.- Specified by:
underlyingToLocalColumnPositions
in interfaceILayer
- Overrides:
underlyingToLocalColumnPositions
in classAbstractLayerTransform
- Parameters:
sourceUnderlyingLayer
- The underlying layer to which the given column positions match.underlyingColumnPositionRanges
- The column position ranges relative to the given underlying layer that should be converted to local column positions.- Returns:
- The given column position ranges transformed to this layer.
-
getWidth
public int getWidth()
Description copied from interface:ILayer
Returns the total width in pixels of this layer.- Specified by:
getWidth
in interfaceILayer
- Overrides:
getWidth
in classAbstractLayerTransform
- Returns:
- The total width in pixels of this layer.
-
getPreferredWidth
public int getPreferredWidth()
- Specified by:
getPreferredWidth
in interfaceILayer
- Overrides:
getPreferredWidth
in classAbstractLayerTransform
-
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 interfaceILayer
- Overrides:
getColumnWidthByPosition
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position in this layer.- Returns:
- The width of the column.
-
isColumnPositionResizable
public boolean isColumnPositionResizable(int columnPosition)
Description copied from interface:ILayer
Check if the column at the given position is resizable.- Specified by:
isColumnPositionResizable
in interfaceILayer
- Overrides:
isColumnPositionResizable
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position to check.- Returns:
true
if the column is resizable,false
if not.
-
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 interfaceILayer
- Overrides:
getColumnPositionByX
in classAbstractLayerTransform
- 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 interfaceILayer
- Overrides:
getStartXOfColumnPosition
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position in this layer.- Returns:
- The x offset of the column, or -1.
-
-