org.eclipse.nebula.widgets.nattable.summaryrow
Class FixedSummaryRowLayer

java.lang.Object
  extended by org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
      extended by org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
          extended by org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer
              extended by 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 the 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
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, layerPainter
 
Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
 
Constructor Summary
FixedSummaryRowLayer(IUniqueIndexLayer bodyDataLayer, ILayer horizontalLayerDependency, IConfigRegistry configRegistry)
          Creates a standalone FixedSummaryRowLayer 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 standalone FixedSummaryRowLayer 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 standalone FixedSummaryRowLayer that is horizontal dependent to the given layer and calculates the summary values from the given bodyDataLayer.
 
Method Summary
 int getColumnCount()
           
 int getColumnIndexByPosition(int columnPosition)
          Gets the underlying non-transformed column index for the given column position.
 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)
           
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 the ISummaryProvider from the IConfigRegistry.
 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)
           
 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 a CompositeLayer that adds additional columns.
 void setSummaryRowLabel(String summaryRowLabel)
           
 int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition)
           
 Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges)
           
 
Methods inherited from class org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer
clearCache, doCommand, getCellByPosition, getColumnPositionByIndex, getHeight, getPreferredHeight, getPreferredRowCount, getRowCount, getRowHeightByPosition, getRowIndexByPosition, getRowPositionByIndex, getRowPositionByY, handleLayerEvent, isStandalone, killCache, setStandalone
 
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
configure, dispose, getCellPainter, getDisplayModeByPosition, getLayerPainter, getRegionLabelsByXY, getStartYOfRowPosition, getUnderlyingLayer, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, 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, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, hasLayerListener, 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

horizontalLayerDependency

protected ILayer horizontalLayerDependency
The layer to which fixed summary row should be horizontally dependent. Typically a GridLayer or the body layer stack in case of a simple vertical composition.

Constructor Detail

FixedSummaryRowLayer

public FixedSummaryRowLayer(IUniqueIndexLayer bodyDataLayer,
                            ILayer horizontalLayerDependency,
                            IConfigRegistry configRegistry)
Creates a standalone FixedSummaryRowLayer 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:
The FixedSummaryRowLayer constructor is setting a GridLineCellLayerPainter 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 different ILayerPainter ensure to set it AFTER creating the FixedSummaryRowLayer.

Parameters:
bodyDataLayer - The underlying layer on which this layer should be build. Typically the DataLayer of the body region.
horizontalLayerDependency - The layer that is above this layer in the surrounding composition. Typically a GridLayer.
configRegistry - The ConfigRegistry for retrieving the ISummaryProvider per column.

FixedSummaryRowLayer

public FixedSummaryRowLayer(IUniqueIndexLayer bodyDataLayer,
                            ILayer horizontalLayerDependency,
                            IConfigRegistry configRegistry,
                            boolean autoConfigure)
Creates a standalone FixedSummaryRowLayer that is horizontal dependent to the given layer and calculates the summary values from the given bodyDataLayer. It will perform smooth value updates.

Note:
The FixedSummaryRowLayer constructor is setting a GridLineCellLayerPainter 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 different ILayerPainter ensure to set it AFTER creating the FixedSummaryRowLayer.

Parameters:
bodyDataLayer - The underlying layer on which this layer should be build. Typically the DataLayer of the body region.
horizontalLayerDependency - The layer that is above this layer in the surrounding composition. Typically a GridLayer.
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 standalone FixedSummaryRowLayer that is horizontal dependent to the given layer and calculates the summary values from the given bodyDataLayer.

Note:
The FixedSummaryRowLayer constructor is setting a GridLineCellLayerPainter 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 different ILayerPainter ensure to set it AFTER creating the FixedSummaryRowLayer.

Parameters:
bodyDataLayer - The underlying layer on which this layer should be build. Typically the DataLayer 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 a GridLayer.
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

getDataValueByPosition

public Object getDataValueByPosition(int columnPosition,
                                     int rowPosition)
Description copied from class: SummaryRowLayer
Calculates the summary for the column using the ISummaryProvider from the IConfigRegistry. In order to prevent the table from freezing (for large data sets), the summary is calculated in a separate Thread. While summary is being calculated ISummaryProvider.DEFAULT_SUMMARY_VALUE is returned.

NOTE: Since this is a IUniqueIndexLayer sitting close to the DataLayer, columnPosition == columnIndex

Specified by:
getDataValueByPosition in interface ILayer
Overrides:
getDataValueByPosition in class SummaryRowLayer

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. a GridLayer 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 a CompositeLayer that adds additional columns.

Parameters:
compositeDependency - true to specify that the horizontal dependency is itself a composite that has an additional column, e.g. a GridLayer 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 class SummaryRowLayer
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)
Specified by:
getConfigLabelsByPosition in interface ILayer
Overrides:
getConfigLabelsByPosition in class SummaryRowLayer

getColumnCount

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

getPreferredColumnCount

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

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 AbstractLayerTransform
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

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 AbstractLayerTransform
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 AbstractLayerTransform

underlyingToLocalColumnPositions

public Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer,
                                                          Collection<Range> underlyingColumnPositionRanges)
Specified by:
underlyingToLocalColumnPositions in interface ILayer
Overrides:
underlyingToLocalColumnPositions in class AbstractLayerTransform

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 AbstractLayerTransform
Returns:
the width of this layer

getPreferredWidth

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

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 AbstractLayerTransform
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 AbstractLayerTransform

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 AbstractLayerTransform
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 AbstractLayerTransform
Parameters:
columnPosition - the column position in this layer
Returns:
the x offset of the column, or -1


Copyright © 2015. All rights reserved.