Class DefaultSaveImageFeature

    • Method Detail

      • getGraphicalViewer

        protected org.eclipse.gef.GraphicalViewer getGraphicalViewer​(ISaveImageContext context)
        Must return a GraphicalViewer that contains the diagram to be saved as an image. The default implementation returns the viewer of the DiagramEditor that started this save as image feature; this is the one associated to the feature provider of the currently opened diagram, see #getDiagramEditor().
        Parameters:
        context - Context information for saving.
        Returns:
        the viewer holding the diagram to save.
      • getSaveAsImageConfiguration

        protected ISaveAsImageConfiguration getSaveAsImageConfiguration​(org.eclipse.gef.GraphicalViewer viewer)
        Called to create a configuration object for the save as image operation that defines what to save and in which format, zoom level etc.. The default implementation returns the standard Graphiti dialog used for save as image that allows the user to define the standard Graphiti settings.
        Parameters:
        viewer - The GraphicalViewer displaying the diagram to print
        Returns:
        A newly created dialog that implements the ISaveAsImageConfiguration interface used in the save as image job.
      • getFilename

        protected java.lang.String getFilename​(org.eclipse.gef.GraphicalViewer viewer,
                                               ISaveAsImageConfiguration saveAsImageConfiguration)
        Must return the filename under which the image will be saved. The filename can (and shall be) without an extension as this will be added by a separate (outside) call to addFileExtension(String, String). The default implementation brings up a standard Eclipse file selection dialog in save mode. The dialog is configured to select between the allowed extensions for images (standard one plus the ones the registered Graphiti image exporters allow).
        Parameters:
        viewer - The GraphicalViewer displaying the diagram to print
        saveAsImageDialog - The save as image configurations as defined by getSaveAsImageConfiguration(GraphicalViewer).
        Returns:
        A string containg the absolute path of the selected file, or null if the dialog was cancelled or an error occurred.
      • addFileExtension

        protected java.lang.String addFileExtension​(java.lang.String extension,
                                                    java.lang.String filename)
        Adds the given file extension to the given filename.
        Parameters:
        extension - A string holding the extension.
        filename - A string holding the filename.
        Returns:
        A string holding the filename plus the extension.
      • getSaveAsImageOperation

        protected org.eclipse.jface.operation.IRunnableWithProgress getSaveAsImageOperation​(ISaveAsImageConfiguration saveAsImageConfiguration,
                                                                                            java.lang.String filename)
        Called to create the operation that is actually used for executing the save as image functionality. The default implementation returns the Graphiti default save as image operation that should be sufficient for almost all use cases.

        This method delegates to getSaveAsImageOperationForStandardExporter(ISaveAsImageConfiguration, String) to perform the save as image for the standard formats like GIF, JPG, BMP etc. and to getSaveAsImageOperationForNonStandardExporter(ISaveAsImageConfiguration, String) for the non standard exporters (registered via the Graphiti export image extension point) like SVG.

        Parameters:
        saveAsImageConfiguration - The ISaveAsImageConfiguration instance that was used to configure this save as image operation. In the default implementation this is the dialog to use for selecting the image format, zoom level etc.
        filename - The filename to use for saving the image
        Returns:
        The operation that will be used to actually perform the save as image.
      • getSaveAsImageOperationForNonStandardExporter

        protected org.eclipse.jface.operation.IRunnableWithProgress getSaveAsImageOperationForNonStandardExporter​(ISaveAsImageConfiguration saveAsImageConfiguration,
                                                                                                                  java.lang.String filename)
        Called to create the operation that is actually used for executing the save as image functionality for standard formats. The default implementation returns the Graphiti default save as image operation that should be sufficient for almost all use cases.
        Parameters:
        saveAsImageConfiguration - The ISaveAsImageConfiguration instance that was used to configure this save as image operation. In the default implementation this is the dialog to use for selecting the image format, zoom level etc.
        filename - The filename to use for saving the image
        Returns:
        The operation that will be used to actually perform the save as image.
      • getSaveAsImageOperationForStandardExporter

        protected org.eclipse.jface.operation.IRunnableWithProgress getSaveAsImageOperationForStandardExporter​(ISaveAsImageConfiguration saveAsImageConfiguration,
                                                                                                               java.lang.String filename)
        Called to create the operation that is actually used for executing the save as image functionality for non-standard formats. The default implementation returns the Graphiti default save as image operation that should be sufficient for almost all use cases.
        Parameters:
        saveAsImageConfiguration - The ISaveAsImageConfiguration instance that was used to configure this save as image operation. In the default implementation this is the dialog to use for selecting the image format, zoom level etc.
        filename - The filename to use for saving the image
        Returns:
        The operation that will be used to actually perform the save as image.
      • getDiagramExporters

        protected java.util.Map<java.lang.String,​java.lang.Boolean> getDiagramExporters()
        Returns all available Graphiti diagram exporters that are registered at the according Graphiti extension point. Note that the standard exporters like GIF, JPG, BMP are not part of the returned ones.
        Returns:
        A Map holding all exporters.