Class FixedSummaryRowLayer
- All Implemented Interfaces:
ILayer,ILayerListener,IUniqueIndexLayer,IPersistable
SummaryRowLayer and is intended
to be used in a composition below a GridLayer 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 body DataLayer where the summary row will scroll as part
of the body region.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected ILayerThe layer to which fixed summary row should be horizontally dependent.protected StringFields inherited from class org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer
DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX, DEFAULT_SUMMARY_ROW_CONFIG_LABELFields 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
ConstructorsConstructorDescriptionFixedSummaryRowLayer(IUniqueIndexLayer bodyDataLayer, ILayer horizontalLayerDependency, IConfigRegistry configRegistry) Creates a standaloneFixedSummaryRowLayerthat 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 standaloneFixedSummaryRowLayerthat 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 standaloneFixedSummaryRowLayerthat is horizontal dependent to the given layer and calculates the summary values from the given bodyDataLayer. -
Method Summary
Modifier and TypeMethodDescriptionbooleandoCommand(ILayerCommand command) Opportunity to respond to a command as it flows down the stack.intintgetColumnIndexByPosition(int columnPosition) Gets the underlying non-transformed column index for the given column position on this layer.intgetColumnPositionByX(int x) Returns the column position that contains the given x coordinate.intgetColumnWidthByPosition(int columnPosition) Returns the width in pixels of the given column.getConfigLabelsByPosition(int columnPosition, int rowPosition) Returns the config labels for the cell at the given coordinates.protected LabelStackgetConfigLabelsByPositionWithoutTransformation(int columnPosition, int rowPosition) This implementation directly calls the super implementation.getDataValueByPosition(int columnPosition, int rowPosition) Calculates the summary for the column using theISummaryProviderfrom theIConfigRegistry.intintintgetStartXOfColumnPosition(int columnPosition) Returns the x offset in pixels of the given column.intgetWidth()Returns the total width in pixels of this layer.booleanprotected booleanisBodyColumn(int columnPosition) booleanisColumnPositionResizable(int columnPosition) Check if the column at the given position is resizable.intlocalToUnderlyingColumnPosition(int localColumnPosition) Convert a column position to the coordinates of the underlying layer.voidsetHorizontalCompositeDependency(boolean compositeDependency) Specify if the horizontal dependency is aCompositeLayerthat adds additional columns.voidsetSummaryRowLabel(String summaryRowLabel) intunderlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition) Transforms the column position relative to the given underlying layer to this layer coordinates.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, setValueCacheMethods 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, 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, getDisplayModeByPosition, getLayerPainter, getRegionLabelsByXY, getStartYOfRowPosition, hasLayerListener, isDynamicSizeLayer, isRowPositionResizable, localToUnderlyingRowPosition, registerCommandHandler, registerPersistable, removeLayerListener, setClientAreaProvider, underlyingToLocalRowPosition, underlyingToLocalRowPositions, unregisterCommandHandler, unregisterPersistableMethods inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
loadState, saveState
-
Field Details
-
DEFAULT_SUMMARY_ROW_LABEL
- See Also:
-
summaryRowLabel
-
horizontalLayerDependency
The layer to which fixed summary row should be horizontally dependent. Typically aGridLayeror the body layer stack in case of a simple vertical composition.
-
-
Constructor Details
-
FixedSummaryRowLayer
public FixedSummaryRowLayer(IUniqueIndexLayer bodyDataLayer, ILayer horizontalLayerDependency, IConfigRegistry configRegistry) Creates a standaloneFixedSummaryRowLayerthat 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:
TheFixedSummaryRowLayerconstructor is setting aGridLineCellLayerPainterthat 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 differentILayerPainterensure to set it AFTER creating theFixedSummaryRowLayer.- Parameters:
bodyDataLayer- The underlying layer on which this layer should be build. Typically theDataLayerof 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 standaloneFixedSummaryRowLayerthat is horizontal dependent to the given layer and calculates the summary values from the given bodyDataLayer. It will perform smooth value updates.Note:
TheFixedSummaryRowLayerconstructor is setting aGridLineCellLayerPainterthat 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 differentILayerPainterensure to set it AFTER creating theFixedSummaryRowLayer.- Parameters:
bodyDataLayer- The underlying layer on which this layer should be build. Typically theDataLayerof 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-trueto use the DefaultSummaryRowConfiguration,falseif a custom configuration will be set after the creation.
-
FixedSummaryRowLayer
public FixedSummaryRowLayer(IUniqueIndexLayer bodyDataLayer, ILayer horizontalLayerDependency, IConfigRegistry configRegistry, boolean smoothUpdates, boolean autoConfigure) Creates a standaloneFixedSummaryRowLayerthat is horizontal dependent to the given layer and calculates the summary values from the given bodyDataLayer.Note:
TheFixedSummaryRowLayerconstructor is setting aGridLineCellLayerPainterthat 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 differentILayerPainterensure to set it AFTER creating theFixedSummaryRowLayer.- Parameters:
bodyDataLayer- The underlying layer on which this layer should be build. Typically theDataLayerof 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-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.
-
-
Method Details
-
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 classSummaryRowLayer- Parameters:
command- The command to execute.- Returns:
trueif the command has been handled and was therefore consumed,falseotherwise.
-
getDataValueByPosition
Description copied from class:SummaryRowLayerCalculates 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 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:
trueif the column at the given position is a column of the body,falseif it is a column of another region, e.g. the row header in a grid.
-
hasHorizontalCompositeDependency
public boolean hasHorizontalCompositeDependency()- Returns:
trueif the horizontal dependency is itself a composite that has an additional column, e.g. aGridLayerwith a row header.falseif 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 aCompositeLayerthat adds additional columns.- Parameters:
compositeDependency-trueto specify that the horizontal dependency is itself a composite that has an additional column, e.g. aGridLayerwith a row header.falseif the horizontal dependency is not a composite, e.g. the body layer stack.
-
getSummaryRowLabel
- Returns:
- The label that is used as data value for the horizontal dependent cell to the row header column.
-
setSummaryRowLabel
- 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:
getConfigLabelsByPositionWithoutTransformationin 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
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 classSummaryRowLayer- 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.
-
getColumnCount
public int getColumnCount()- Specified by:
getColumnCountin interfaceILayer- Overrides:
getColumnCountin classAbstractLayerTransform- Returns:
- The number of columns in this layer.
-
getPreferredColumnCount
public int getPreferredColumnCount()- Specified by:
getPreferredColumnCountin interfaceILayer- Overrides:
getPreferredColumnCountin classAbstractLayerTransform
-
getColumnIndexByPosition
public int getColumnIndexByPosition(int columnPosition) Description copied from interface:ILayerGets the underlying non-transformed column index for the given column position on this layer.- Specified by:
getColumnIndexByPositionin interfaceILayer- Overrides:
getColumnIndexByPositionin 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:ILayerConvert a column position to the coordinates of the underlying layer. This is possible since each layer is aware of its underlying layer.- Specified by:
localToUnderlyingColumnPositionin interfaceILayer- Overrides:
localToUnderlyingColumnPositionin 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:ILayerTransforms the column position relative to the given underlying layer to this layer coordinates.- Specified by:
underlyingToLocalColumnPositionin interfaceILayer- Overrides:
underlyingToLocalColumnPositionin 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:ILayerTransforms the column position ranges relative to the given underlying layer to this layer coordinates.- Specified by:
underlyingToLocalColumnPositionsin interfaceILayer- Overrides:
underlyingToLocalColumnPositionsin 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:ILayerReturns the total width in pixels of this layer.- Specified by:
getWidthin interfaceILayer- Overrides:
getWidthin classAbstractLayerTransform- Returns:
- The total width in pixels of this layer.
-
getPreferredWidth
public int getPreferredWidth()- Specified by:
getPreferredWidthin interfaceILayer- Overrides:
getPreferredWidthin classAbstractLayerTransform
-
getColumnWidthByPosition
public int getColumnWidthByPosition(int columnPosition) Description copied from interface:ILayerReturns the width in pixels of the given column. The width of invisible and non-existing columns is 0.- Specified by:
getColumnWidthByPositionin interfaceILayer- Overrides:
getColumnWidthByPositionin 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:ILayerCheck if the column at the given position is resizable.- Specified by:
isColumnPositionResizablein interfaceILayer- Overrides:
isColumnPositionResizablein classAbstractLayerTransform- Parameters:
columnPosition- The column position to check.- Returns:
trueif the column is resizable,falseif not.
-
getColumnPositionByX
public int getColumnPositionByX(int x) Description copied from interface:ILayerReturns the column position that contains the given x coordinate.- Specified by:
getColumnPositionByXin interfaceILayer- Overrides:
getColumnPositionByXin 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:ILayerReturns the x offset in pixels of the given column.- Specified by:
getStartXOfColumnPositionin interfaceILayer- Overrides:
getStartXOfColumnPositionin classAbstractLayerTransform- Parameters:
columnPosition- The column position in this layer.- Returns:
- The x offset of the column, or -1.
-