Class AutoResizeHelper
java.lang.Object
org.eclipse.nebula.widgets.nattable.resize.AutoResizeHelper
Helper class that renders a
ILayer in-memory to trigger auto-resizing
of rows and columns in case content painters are configured to calculate the
necessary dimensions.
Note that this operation is expensive in terms of memory consumption and processing time. Be careful when using this helper for huge tables.
- Since:
- 1.4
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IClientAreaProviderTheIClientAreaProviderthat is used for rendering the whole layer in-memory.protected final IConfigRegistryTheIConfigRegistryneeded for rendering.protected final ILayerTheILayerthat should be used for in-memory rendering to trigger auto-resizing.protected IClientAreaProviderThe originalIClientAreaProviderneeded to restore the original state after processing.protected org.eclipse.swt.graphics.RectangleThe total area of the previous in-memory rendering.protected booleanFlag to indicate that an automatic resize was triggered on rendering.protected ILayerListenerILayerListenerthat is added to theILayerto get informed aboutRowResizeEventandColumnResizeEventto know if an automatic resize was triggered on rendering.protected org.eclipse.swt.graphics.RectangleThe total area needed to render the whole layer at once. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidautoResize(ILayer layer, IConfigRegistry configRegistry) Executes in-memory rendering of the givenILayerto trigger content based auto-resizing.static voidautoResizeRows(NatTable natTable, ILayer rowLayer, ILayer bodyDataLayer) Trigger auto-resizing of rows based on the content of the whole row.protected voidCalculate the total area needed to render the whole layer.protected voidinit()Prepare the layer for complete in-memory rendering.protected voidPaints the layer on a temporary image GC.protected voidpaintLayer(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle printBounds) Print the part of the layer that matches the given print bounds.protected voidrestore()Restore the original state of the layer before in-memory rendering preparations.
-
Field Details
-
layer
TheILayerthat should be used for in-memory rendering to trigger auto-resizing. -
configRegistry
TheIConfigRegistryneeded for rendering. -
totalArea
protected org.eclipse.swt.graphics.Rectangle totalAreaThe total area needed to render the whole layer at once. -
prevArea
protected org.eclipse.swt.graphics.Rectangle prevAreaThe total area of the previous in-memory rendering. Needed to reduce the rendering area on consecutive calls.- Since:
- 1.5
-
originalClientAreaProvider
The originalIClientAreaProviderneeded to restore the original state after processing. -
resizedOnPrinting
protected volatile boolean resizedOnPrintingFlag to indicate that an automatic resize was triggered on rendering. -
resizeListener
ILayerListenerthat is added to theILayerto get informed aboutRowResizeEventandColumnResizeEventto know if an automatic resize was triggered on rendering. -
clientAreaProvider
TheIClientAreaProviderthat is used for rendering the whole layer in-memory.
-
-
Method Details
-
autoResize
Executes in-memory rendering of the givenILayerto trigger content based auto-resizing.- Parameters:
layer- TheILayerthat should be used for in-memory rendering to trigger auto-resizing.configRegistry- TheIConfigRegistryneeded for rendering.
-
paintInMemory
protected void paintInMemory()Paints the layer on a temporary image GC. If painters are configured for automatic size calculation, this painting will trigger the resize events. -
paintLayer
protected void paintLayer(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle printBounds) Print the part of the layer that matches the given print bounds.- Parameters:
gc- The print GC to render the layer to.printBounds- The bounds of the print page.
-
calculateTotalArea
protected void calculateTotalArea()Calculate the total area needed to render the whole layer. -
init
protected void init()Prepare the layer for complete in-memory rendering. -
restore
protected void restore()Restore the original state of the layer before in-memory rendering preparations. -
autoResizeRows
Trigger auto-resizing of rows based on the content of the whole row.- Parameters:
natTable- The NatTable on which the auto row resize should be performed. Needed to create a temporaryGCand retrieve theIConfigRegistry.rowLayer- TheILayerthat should be used to determine the rows to auto-resize. Can be theViewportLayerto ensure that the auto row resize is only triggered for visible rows or theDataLayerof the body region to auto-resize all rows.bodyDataLayer- TheDataLayerof the body region to inspect all columns in a row, even if not visible in the viewport. Can also be a higher level layer if it adds rows, e.g. the SummaryRowLayer.- Since:
- 1.6
-