Class AutoResizeHelper


  • public class AutoResizeHelper
    extends Object
    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 Detail

      • layer

        protected final ILayer layer
        The ILayer that should be used for in-memory rendering to trigger auto-resizing.
      • 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
      • resizedOnPrinting

        protected volatile boolean resizedOnPrinting
        Flag to indicate that an automatic resize was triggered on rendering.
    • Method Detail

      • autoResize

        public static void autoResize​(ILayer layer,
                                      IConfigRegistry configRegistry)
        Executes in-memory rendering of the given ILayer to trigger content based auto-resizing.
        Parameters:
        layer - The ILayer that should be used for in-memory rendering to trigger auto-resizing.
        configRegistry - The IConfigRegistry 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 temporary GC and retrieve the IConfigRegistry.
        rowLayer - The ILayer that should be used to determine the rows to auto-resize. Can be the ViewportLayer to ensure that the auto row resize is only triggered for visible rows or the DataLayer of the body region to auto-resize all rows.
        bodyDataLayer - The DataLayer 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