All Implemented Interfaces:
IExporter, ITableExporter

public class ImageExporter extends Object implements ITableExporter
This class is used to export a NatTable to different types of image. Currently, 4 types of image are supported: BMP, JPEG, JPG, PNG. GIF is not supported due to its limitation on image depth described in the bug 38232.

Warning: Using this class is risky as it could cause severe damage to NatTables that show huge data sets (for example: a table with more than 20k rows).

  • Constructor Details

    • ImageExporter

      public ImageExporter()
      Default constructor to create a new image exporter.
    • ImageExporter

      public ImageExporter(IOutputStreamProvider outputStreamProvider)
      Create a new ImageExporter that uses the given IOutputStreamProvider for retrieving the OutputStream.
      outputStreamProvider - The IOutputStreamProvider used to retrieve the OutputStream to write the export to.
  • Method Details

    • getResult

      public Object getResult()
      Specified by:
      getResult in interface IExporter
      The result that is produced by this ITableExporter. Usually the file that is created or written by this exporter.
    • exportTable

      public void exportTable(org.eclipse.swt.widgets.Shell shell, org.eclipse.swt.widgets.ProgressBar progressBar, OutputStream outputStream, ILayer layer, IConfigRegistry configRegistry) throws IOException
      Export the given layer of the nattable to image. This method must be called after the execution of the getOutputStream(Shell) method.
      Specified by:
      exportTable in interface ITableExporter
      shell - The parent shell
      layer - The layer to be exported
      configRegistry - The configure registry of the nattable
      progressBar - The ProgressBar that can be used to report the export progress to the user.
      outputStream - The OutputStream to write the export to. Typically previously retrieved by calling IExporter.getOutputStream(Shell).
      IOException - If an error occurs while exporting.
    • getImageFormatIndex

      protected int getImageFormatIndex(String selectedFilterExt)
      Get the image format index by the filter extension.
      selectedFilterExt - The selected filter extension
      The image index or -1 if not found
    • getOutputStream

      public OutputStream getOutputStream(org.eclipse.swt.widgets.Shell shell)
      Description copied from interface: IExporter
      Get the OutputStream to which the export should be written to.
      Specified by:
      getOutputStream in interface IExporter
      shell - The Shell to which the ILayer to export is connected to. Necessary to support user interactions via dialogs on configuring the output location.
      The OutputStream to write the export to.