Class SummaryRowLayer
- All Implemented Interfaces:
ILayer
,ILayerListener
,IUniqueIndexLayer
,IPersistable
- Direct Known Subclasses:
FixedSummaryRowLayer
ISummaryProvider
to calculate the
summaries for all columns.
This layer also adds the following labels:
DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX
+ column indexDEFAULT_SUMMARY_ROW_CONFIG_LABEL
to all cells in the row
ISummaryProvider
can be hooked up to these labels.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Prefix of the labels that get attached to cells in the summary row.static final String
Label that gets attached to the LabelStack for every cell in the summary row.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
ConstructorDescriptionSummaryRowLayer
(IUniqueIndexLayer underlyingDataLayer, IConfigRegistry configRegistry) Creates a SummaryRowLayer on top of the given underlying layer.SummaryRowLayer
(IUniqueIndexLayer underlyingDataLayer, IConfigRegistry configRegistry, boolean autoConfigure) Creates a SummaryRowLayer on top of the given underlying layer.SummaryRowLayer
(IUniqueIndexLayer underlyingDataLayer, IConfigRegistry configRegistry, boolean smoothUpdates, boolean autoConfigure) Creates a SummaryRowLayer on top of the given underlying layer. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear the internal cache to trigger new calculations.boolean
doCommand
(ILayerCommand command) Opportunity to respond to a command as it flows down the stack.getCellByPosition
(int columnPosition, int rowPosition) Returns the cell for the given coordinates on this layer.int
getColumnPositionByIndex
(int columnIndex) getConfigLabelsByPosition
(int columnPosition, int rowPosition) Returns the config labels for the cell at the given coordinates.protected LabelStack
getConfigLabelsByPositionWithoutTransformation
(int columnPosition, int rowPosition) This method is a wrapper for callinggetConfigLabelsByPosition(int, int)
.getDataValueByPosition
(int columnPosition, int rowPosition) Calculates the summary for the column using theISummaryProvider
from theIConfigRegistry
.int
Returns the total height in pixels of this layer.int
int
int
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 on this layer.int
getRowPositionByIndex
(int rowIndex) int
getRowPositionByY
(int y) Returns the row position that contains the given y coordinate.int
Get the position of the summary row in this layer.getUnderlyingLayerByPosition
(int columnPosition, int rowPosition) Returns the layer that is directly below this layer for the given cell coordinate.getUnderlyingLayersByColumnPosition
(int columnPosition) Returns the layers that are directly below this layer for the given column position.getUnderlyingLayersByRowPosition
(int rowPosition) Returns the layers that are directly below this layer for the given row position.void
handleLayerEvent
(ILayerEvent event) Handle layer event notification.boolean
boolean
isSummaryRowPosition
(int rowPosition) Checks if the given row position is the position of the summary row.void
Clears all values in the internal cache to trigger new calculations.void
setStandalone
(boolean standalone) Configure whether the summary row should be rendered below the underlying layer (false
) or if it should be rendered standalone in a separate region of a composite (true
).void
setValueCache
(ICalculatedValueCache valueCache) Set theICalculatedValueCache
that should be used internally to calculate the summary values in a background thread and cache the results.Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
configure, dispose, getCellPainter, getColumnCount, getColumnIndexByPosition, getColumnPositionByX, getColumnWidthByPosition, getDisplayModeByPosition, getLayerPainter, getPreferredColumnCount, getPreferredWidth, getRegionLabelsByXY, getStartXOfColumnPosition, getStartYOfRowPosition, getUnderlyingLayer, getWidth, isColumnPositionResizable, isDynamicSizeLayer, isRowPositionResizable, loadState, localToUnderlyingColumnPosition, localToUnderlyingRowPosition, saveState, setClientAreaProvider, setUnderlyingLayer, underlyingToLocalColumnPosition, underlyingToLocalColumnPositions, 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, getColumnCount, getColumnIndexByPosition, getColumnPositionByX, getColumnWidthByPosition, getDisplayModeByPosition, getLayerPainter, getPreferredColumnCount, getPreferredWidth, getRegionLabelsByXY, getStartXOfColumnPosition, getStartYOfRowPosition, getWidth, hasLayerListener, isColumnPositionResizable, isDynamicSizeLayer, isRowPositionResizable, localToUnderlyingColumnPosition, localToUnderlyingRowPosition, registerCommandHandler, registerPersistable, removeLayerListener, setClientAreaProvider, underlyingToLocalColumnPosition, underlyingToLocalColumnPositions, underlyingToLocalRowPosition, underlyingToLocalRowPositions, unregisterCommandHandler, unregisterPersistable
Methods inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
loadState, saveState
-
Field Details
-
DEFAULT_SUMMARY_ROW_CONFIG_LABEL
Label that gets attached to the LabelStack for every cell in the summary row.- See Also:
-
DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX
Prefix of the labels that get attached to cells in the summary row. The complete label will consist of this prefix and the column index at the end of the label. This way every cell in the summary row can be accessed directly via label mechanism.- See Also:
-
-
Constructor Details
-
SummaryRowLayer
Creates a SummaryRowLayer on top of the given underlying layer. It uses smooth value updates as default.Note: This constructor will create the SummaryRowLayer by using the default configuration. The default configuration doesn't fit the needs so you usually will use your custom summary row configuration.
- Parameters:
underlyingDataLayer
- The underlying layer on which the SummaryRowLayer should be build.configRegistry
- The ConfigRegistry for retrieving the ISummaryProvider per column.- See Also:
-
SummaryRowLayer
public SummaryRowLayer(IUniqueIndexLayer underlyingDataLayer, IConfigRegistry configRegistry, boolean autoConfigure) Creates a SummaryRowLayer on top of the given underlying layer. It uses smooth value updates as default.Note: This constructor will create the SummaryRowLayer by using the default configuration if the autoConfig parameter is set to
true
. The default configuration doesn't fit the needs so you usually will use your custom summary row configuration. When using a custom configuration you should use this constructor setting autoConfig tofalse
. Otherwise you might get strange behaviour as the default configuration will be set additionally to your configuration.- Parameters:
underlyingDataLayer
- The underlying layer on which the SummaryRowLayer should be build.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.- See Also:
-
SummaryRowLayer
public SummaryRowLayer(IUniqueIndexLayer underlyingDataLayer, IConfigRegistry configRegistry, boolean smoothUpdates, boolean autoConfigure) Creates a SummaryRowLayer on top of the given underlying layer.Note: This constructor will create the SummaryRowLayer by using the default configuration if the autoConfig parameter is set to
true
. The default configuration doesn't fit the needs so you usually will use your custom summary row configuration. When using a custom configuration you should use this constructor setting autoConfig tofalse
. Otherwise you might get strange behaviour as the default configuration will be set additionally to your configuration.- Parameters:
underlyingDataLayer
- The underlying layer on which the SummaryRowLayer should be build.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.- See Also:
-
-
Method Details
-
getDataValueByPosition
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 classAbstractLayerTransform
- 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.
-
isSummaryRowPosition
public boolean isSummaryRowPosition(int rowPosition) Checks if the given row position is the position of the summary row.- Parameters:
rowPosition
- The row position to check.- Returns:
true
if the given row position is the summary row position.- Since:
- 1.6
-
getSummaryRowPosition
public int getSummaryRowPosition()Get the position of the summary row in this layer.- Returns:
- The position of the summary row. Typically
rowCount - 1
. - Since:
- 1.6
-
doCommand
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 classAbstractLayerTransform
- Parameters:
command
- The command to execute.- Returns:
true
if the command has been handled and was therefore consumed,false
otherwise.
-
handleLayerEvent
Description copied from class:AbstractLayer
Handle layer event notification. Convert it to your context and propagate UP. If you override this method you MUST NOT FORGET to raise the event up the layer stack by callingsuper.fireLayerEvent(event)
- unless you plan to eat the event yourself.- Specified by:
handleLayerEvent
in interfaceILayerListener
- Overrides:
handleLayerEvent
in classAbstractLayer
- Parameters:
event
- the event
-
clearCache
public void clearCache()Clear the internal cache to trigger new calculations.Usually it is not necessary to call this method manually. But for certain use cases it might be useful, e.g. changing the summary provider implementation at runtime.
- See Also:
-
killCache
public void killCache()Clears all values in the internal cache to trigger new calculations. This will also clear all values in the cache copy and will result in rendering like there was never a summary value calculated before.Usually it is not necessary to call this method manually. But for certain use cases it might be useful, e.g. changing the summary provider implementation at runtime.
- See Also:
-
getConfigLabelsByPositionWithoutTransformation
protected LabelStack getConfigLabelsByPositionWithoutTransformation(int columnPosition, int rowPosition) This method is a wrapper for callinggetConfigLabelsByPosition(int, int)
. It is needed because sub-classes of theSummaryRowLayer
might perform column position-index transformations, which would be executed again if the call for config labels is nested, e.g. incalculateNewSummaryValue(int, boolean)
. By providing and using this implementation, sub-classes that perform position-index transformations are able to implement this method by directly accessing the super implementation.- 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
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 classAbstractLayerTransform
- 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.
-
getCellByPosition
Description copied from interface:ILayer
Returns the cell for the given coordinates on this layer.- Specified by:
getCellByPosition
in interfaceILayer
- Overrides:
getCellByPosition
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position of the requested cell.rowPosition
- The row position of the requested cell.- Returns:
- The
ILayerCell
for the given coordinates in this layer ornull
if the coordinates are invalid on this layer.
-
getHeight
public int getHeight()Description copied from interface:ILayer
Returns the total height in pixels of this layer.- Specified by:
getHeight
in interfaceILayer
- Overrides:
getHeight
in classAbstractLayerTransform
- Returns:
- The total height in pixels of this layer.
-
getPreferredHeight
public int getPreferredHeight()- Specified by:
getPreferredHeight
in interfaceILayer
- Overrides:
getPreferredHeight
in classAbstractLayerTransform
-
getRowCount
public int getRowCount()- Specified by:
getRowCount
in interfaceILayer
- Overrides:
getRowCount
in classAbstractLayerTransform
- Returns:
- The number of rows in this layer.
-
getPreferredRowCount
public int getPreferredRowCount()- Specified by:
getPreferredRowCount
in interfaceILayer
- Overrides:
getPreferredRowCount
in classAbstractLayerTransform
-
getRowIndexByPosition
public int getRowIndexByPosition(int rowPosition) Description copied from interface:ILayer
Gets the underlying non-transformed row index for the given row position on this layer.- Specified by:
getRowIndexByPosition
in interfaceILayer
- Overrides:
getRowIndexByPosition
in classAbstractLayerTransform
- Parameters:
rowPosition
- The row position relative to this layer.- Returns:
- An underlying non-transformed row index, or -1 if the given row position does not exist within this coordinate system.
-
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 interfaceILayer
- Overrides:
getRowPositionByY
in classAbstractLayerTransform
- 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
-
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 interfaceILayer
- Overrides:
getRowHeightByPosition
in classAbstractLayerTransform
- Parameters:
rowPosition
- The row position in this layer.- Returns:
- The height of the row.
-
getRowPositionByIndex
public int getRowPositionByIndex(int rowIndex) - Specified by:
getRowPositionByIndex
in interfaceIUniqueIndexLayer
-
getColumnPositionByIndex
public int getColumnPositionByIndex(int columnIndex) - Specified by:
getColumnPositionByIndex
in interfaceIUniqueIndexLayer
-
isStandalone
public boolean isStandalone()- Returns:
true
if the summary row is rendered standalone,false
if it is rendered below the underlying layer.
-
setStandalone
public void setStandalone(boolean standalone) Configure whether the summary row should be rendered below the underlying layer (false
) or if it should be rendered standalone in a separate region of a composite (true
).- Parameters:
standalone
- Whether the summary row should be rendered standalone or below the underlying layer.
-
getValueCache
- Returns:
- The
ICalculatedValueCache
that contains the summary values and performs summary calculation in background processes if necessary. - Since:
- 1.3
-
setValueCache
Set theICalculatedValueCache
that should be used internally to calculate the summary values in a background thread and cache the results.Note: By default the
CalculatedValueCache
is used. Be sure you know what you are doing when you are trying to exchange the implementation.- Parameters:
valueCache
- TheICalculatedValueCache
that contains the summary values and performs summary calculation in background processes if necessary.- Since:
- 1.3
-
getUnderlyingLayersByColumnPosition
Description copied from interface:ILayer
Returns the layers that are directly below this layer for the given column position. For simple layers this collection will typically only have one entry. Layer compositions might return multiple values, e.g. in a default grid there will be 2 layers in the collection as there are two layers involved in a column.- Specified by:
getUnderlyingLayersByColumnPosition
in interfaceILayer
- Overrides:
getUnderlyingLayersByColumnPosition
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position for which the underlying layers are requested.- Returns:
- The layers that are directly below this layer for the given
column position or
null
if this layer has no underlying layers.
-
getUnderlyingLayersByRowPosition
Description copied from interface:ILayer
Returns the layers that are directly below this layer for the given row position. For simple layers this collection will typically only have one entry. Layer compositions might return multiple values, e.g. in a default grid there will be 2 layers in the collection as there are two layers involved in a row.- Specified by:
getUnderlyingLayersByRowPosition
in interfaceILayer
- Overrides:
getUnderlyingLayersByRowPosition
in classAbstractLayerTransform
- Parameters:
rowPosition
- The row position for which the underlying layers are requested.- Returns:
- The layers that are directly below this layer for the given row
position or
null
if this layer has no underlying layers.
-
getUnderlyingLayerByPosition
Description copied from interface:ILayer
Returns the layer that is directly below this layer for the given cell coordinate.- Specified by:
getUnderlyingLayerByPosition
in interfaceILayer
- Overrides:
getUnderlyingLayerByPosition
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position for which the underlying layer is requested.rowPosition
- The row position for which the underlying layer is requested.- Returns:
- The layer that is directly below this layer for the given cell
coordinates or
null
if this layer has no underlying layers.
-
getProvidedLabels
- Specified by:
getProvidedLabels
in interfaceILayer
- Overrides:
getProvidedLabels
in classAbstractLayer
- Returns:
- The collection of labels that are provided by this layer.
- Since:
- 1.4
-