Class AutoResizeHelper
- java.lang.Object
-
- org.eclipse.nebula.widgets.nattable.resize.AutoResizeHelper
-
public class AutoResizeHelper extends Object
Helper class that renders aILayer
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
Fields Modifier and Type Field Description protected IClientAreaProvider
clientAreaProvider
TheIClientAreaProvider
that is used for rendering the whole layer in-memory.protected IConfigRegistry
configRegistry
TheIConfigRegistry
needed for rendering.protected ILayer
layer
TheILayer
that should be used for in-memory rendering to trigger auto-resizing.protected IClientAreaProvider
originalClientAreaProvider
The originalIClientAreaProvider
needed to restore the original state after processing.protected org.eclipse.swt.graphics.Rectangle
prevArea
The total area of the previous in-memory rendering.protected boolean
resizedOnPrinting
Flag to indicate that an automatic resize was triggered on rendering.protected ILayerListener
resizeListener
ILayerListener
that is added to theILayer
to get informed aboutRowResizeEvent
andColumnResizeEvent
to know if an automatic resize was triggered on rendering.protected org.eclipse.swt.graphics.Rectangle
totalArea
The total area needed to render the whole layer at once.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
autoResize(ILayer layer, IConfigRegistry configRegistry)
Executes in-memory rendering of the givenILayer
to trigger content based auto-resizing.static void
autoResizeRows(NatTable natTable, ILayer rowLayer, ILayer bodyDataLayer)
Trigger auto-resizing of rows based on the content of the whole row.protected void
calculateTotalArea()
Calculate the total area needed to render the whole layer.protected void
init()
Prepare the layer for complete in-memory rendering.protected void
paintInMemory()
Paints the layer on a temporary image GC.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.protected void
restore()
Restore the original state of the layer before in-memory rendering preparations.
-
-
-
Field Detail
-
layer
protected final ILayer layer
TheILayer
that should be used for in-memory rendering to trigger auto-resizing.
-
configRegistry
protected final IConfigRegistry configRegistry
TheIConfigRegistry
needed for rendering.
-
totalArea
protected org.eclipse.swt.graphics.Rectangle totalArea
The total area needed to render the whole layer at once.
-
prevArea
protected org.eclipse.swt.graphics.Rectangle prevArea
The total area of the previous in-memory rendering. Needed to reduce the rendering area on consecutive calls.- Since:
- 1.5
-
originalClientAreaProvider
protected IClientAreaProvider originalClientAreaProvider
The originalIClientAreaProvider
needed to restore the original state after processing.
-
resizedOnPrinting
protected volatile boolean resizedOnPrinting
Flag to indicate that an automatic resize was triggered on rendering.
-
resizeListener
protected ILayerListener resizeListener
ILayerListener
that is added to theILayer
to get informed aboutRowResizeEvent
andColumnResizeEvent
to know if an automatic resize was triggered on rendering.
-
clientAreaProvider
protected IClientAreaProvider clientAreaProvider
TheIClientAreaProvider
that is used for rendering the whole layer in-memory.
-
-
Method Detail
-
autoResize
public static void autoResize(ILayer layer, IConfigRegistry configRegistry)
Executes in-memory rendering of the givenILayer
to trigger content based auto-resizing.- Parameters:
layer
- TheILayer
that should be used for in-memory rendering to trigger auto-resizing.configRegistry
- TheIConfigRegistry
needed 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
public static void autoResizeRows(NatTable natTable, ILayer rowLayer, ILayer bodyDataLayer)
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 temporaryGC
and retrieve theIConfigRegistry
.rowLayer
- TheILayer
that should be used to determine the rows to auto-resize. Can be theViewportLayer
to ensure that the auto row resize is only triggered for visible rows or theDataLayer
of the body region to auto-resize all rows.bodyDataLayer
- TheDataLayer
of 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
-
-