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_LABELto all cells in the row
ISummaryProvider can be hooked up to these labels.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringPrefix of the labels that get attached to cells in the summary row.static final StringLabel that gets attached to the LabelStack for every cell in the summary row.Fields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
underlyingLayerFields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
commandHandlers, eventHandlers, eventHelperLock, layerPainterFields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR -
Constructor Summary
ConstructorsConstructorDescriptionSummaryRowLayer(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 TypeMethodDescriptionvoidClear the internal cache to trigger new calculations.booleandoCommand(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.intgetColumnPositionByIndex(int columnIndex) getConfigLabelsByPosition(int columnPosition, int rowPosition) Returns the config labels for the cell at the given coordinates.protected LabelStackgetConfigLabelsByPositionWithoutTransformation(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 theISummaryProviderfrom theIConfigRegistry.intReturns the total height in pixels of this layer.intintintintgetRowHeightByPosition(int rowPosition) Returns the height in pixels of the given row.intgetRowIndexByPosition(int rowPosition) Gets the underlying non-transformed row index for the given row position on this layer.intgetRowPositionByIndex(int rowIndex) intgetRowPositionByY(int y) Returns the row position that contains the given y coordinate.intGet 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.voidhandleLayerEvent(ILayerEvent event) Handle layer event notification.booleanbooleanisSummaryRowPosition(int rowPosition) Checks if the given row position is the position of the summary row.voidClears all values in the internal cache to trigger new calculations.voidsetStandalone(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).voidsetValueCache(ICalculatedValueCache valueCache) Set theICalculatedValueCachethat 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, underlyingToLocalRowPositionsMethods 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, unregisterPersistableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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, unregisterPersistableMethods 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-trueto use the DefaultSummaryRowConfiguration,falseif 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-trueif the summary value updates should be performed smoothly,falseif on re-calculation the value should be immediately shown as not calculated.autoConfigure-trueto use the DefaultSummaryRowConfiguration,falseif a custom configuration will be set after the creation.- See Also:
-
-
Method Details
-
getDataValueByPosition
Calculates the summary for the column using theISummaryProviderfrom 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_VALUEis returned.NOTE: Since this is a
IUniqueIndexLayersitting close to theDataLayer, columnPosition == columnIndex- Specified by:
getDataValueByPositionin interfaceILayer- Overrides:
getDataValueByPositionin 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:
trueif 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:ILayerOpportunity 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:
doCommandin interfaceILayer- Overrides:
doCommandin classAbstractLayerTransform- Parameters:
command- The command to execute.- Returns:
trueif the command has been handled and was therefore consumed,falseotherwise.
-
handleLayerEvent
Description copied from class:AbstractLayerHandle 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:
handleLayerEventin interfaceILayerListener- Overrides:
handleLayerEventin 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 theSummaryRowLayermight 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
LabelStackfor the cell at the given coordinates.
-
getConfigLabelsByPosition
Description copied from interface:ILayerReturns the config labels for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of theIConfigRegistry.- Specified by:
getConfigLabelsByPositionin interfaceILayer- Overrides:
getConfigLabelsByPositionin classAbstractLayerTransform- Parameters:
columnPosition- The column position of the cell.rowPosition- The row position of the cell.- Returns:
- The
LabelStackwith the config labels for the cell at the given coordinates.
-
getCellByPosition
Description copied from interface:ILayerReturns the cell for the given coordinates on this layer.- Specified by:
getCellByPositionin interfaceILayer- Overrides:
getCellByPositionin classAbstractLayerTransform- Parameters:
columnPosition- The column position of the requested cell.rowPosition- The row position of the requested cell.- Returns:
- The
ILayerCellfor the given coordinates in this layer ornullif the coordinates are invalid on this layer.
-
getHeight
public int getHeight()Description copied from interface:ILayerReturns the total height in pixels of this layer.- Specified by:
getHeightin interfaceILayer- Overrides:
getHeightin classAbstractLayerTransform- Returns:
- The total height in pixels of this layer.
-
getPreferredHeight
public int getPreferredHeight()- Specified by:
getPreferredHeightin interfaceILayer- Overrides:
getPreferredHeightin classAbstractLayerTransform
-
getRowCount
public int getRowCount()- Specified by:
getRowCountin interfaceILayer- Overrides:
getRowCountin classAbstractLayerTransform- Returns:
- The number of rows in this layer.
-
getPreferredRowCount
public int getPreferredRowCount()- Specified by:
getPreferredRowCountin interfaceILayer- Overrides:
getPreferredRowCountin classAbstractLayerTransform
-
getRowIndexByPosition
public int getRowIndexByPosition(int rowPosition) Description copied from interface:ILayerGets the underlying non-transformed row index for the given row position on this layer.- Specified by:
getRowIndexByPositionin interfaceILayer- Overrides:
getRowIndexByPositionin 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:ILayerReturns the row position that contains the given y coordinate.- Specified by:
getRowPositionByYin interfaceILayer- Overrides:
getRowPositionByYin 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:ILayerReturns the height in pixels of the given row. The height of invisible and non-existing rows is 0.- Specified by:
getRowHeightByPositionin interfaceILayer- Overrides:
getRowHeightByPositionin classAbstractLayerTransform- Parameters:
rowPosition- The row position in this layer.- Returns:
- The height of the row.
-
getRowPositionByIndex
public int getRowPositionByIndex(int rowIndex) - Specified by:
getRowPositionByIndexin interfaceIUniqueIndexLayer
-
getColumnPositionByIndex
public int getColumnPositionByIndex(int columnIndex) - Specified by:
getColumnPositionByIndexin interfaceIUniqueIndexLayer
-
isStandalone
public boolean isStandalone()- Returns:
trueif the summary row is rendered standalone,falseif 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
ICalculatedValueCachethat contains the summary values and performs summary calculation in background processes if necessary. - Since:
- 1.3
-
setValueCache
Set theICalculatedValueCachethat should be used internally to calculate the summary values in a background thread and cache the results.Note: By default the
CalculatedValueCacheis used. Be sure you know what you are doing when you are trying to exchange the implementation.- Parameters:
valueCache- TheICalculatedValueCachethat contains the summary values and performs summary calculation in background processes if necessary.- Since:
- 1.3
-
getUnderlyingLayersByColumnPosition
Description copied from interface:ILayerReturns 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:
getUnderlyingLayersByColumnPositionin interfaceILayer- Overrides:
getUnderlyingLayersByColumnPositionin 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
nullif this layer has no underlying layers.
-
getUnderlyingLayersByRowPosition
Description copied from interface:ILayerReturns 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:
getUnderlyingLayersByRowPositionin interfaceILayer- Overrides:
getUnderlyingLayersByRowPositionin 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
nullif this layer has no underlying layers.
-
getUnderlyingLayerByPosition
Description copied from interface:ILayerReturns the layer that is directly below this layer for the given cell coordinate.- Specified by:
getUnderlyingLayerByPositionin interfaceILayer- Overrides:
getUnderlyingLayerByPositionin 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
nullif this layer has no underlying layers.
-
getProvidedLabels
- Specified by:
getProvidedLabelsin interfaceILayer- Overrides:
getProvidedLabelsin classAbstractLayer- Returns:
- The collection of labels that are provided by this layer.
- Since:
- 1.4
-