Class ImageService

    • Constructor Summary

      Constructors 
      Constructor Description
      ImageService()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] convertDiagramToBytes​(Diagram diagram, int format)
      Converts the given diagram into an image byte array in the given format.
      This allows end users to export diagrams without having to run the associated GEF editor.
      byte[] convertImageToBytes​(org.eclipse.swt.graphics.Image image, int format)
      Converts the given Image into a byte array in the given format that could be directly saved to a file in that format.
      org.eclipse.jface.resource.ImageDescriptor getImageDescriptorForId​(java.lang.String providerId, java.lang.String imageId)
      Gets an image descriptor for the given image id.
      org.eclipse.swt.graphics.Image getImageForId​(java.lang.String providerId, java.lang.String imageId)
      Gets an image for the given image id.
      org.eclipse.jface.resource.ImageDescriptor getPlatformImageDescriptorForId​(java.lang.String imageId)
      Gets an image descriptor for the given image id.
      org.eclipse.swt.graphics.Image getPlatformImageForId​(java.lang.String imageId)
      Gets an image for the given image id.
      void removeImageFromRegistry​(java.lang.String key)
      Removes the corresponding image entry from the image registry and disposes the corresponding image (if existent).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ImageService

        public ImageService()
    • Method Detail

      • getImageDescriptorForId

        public org.eclipse.jface.resource.ImageDescriptor getImageDescriptorForId​(java.lang.String providerId,
                                                                                  java.lang.String imageId)
        Description copied from interface: IImageService
        Gets an image descriptor for the given image id. This image id must be supported by an graphiti image provider, and available to the given DiagramTypeProvider. The image registry of the plugin org.eclipse.graphiti.ui is used. This ensures that the image descriptor will only created once.
        Specified by:
        getImageDescriptorForId in interface IImageService
        imageId - the image id which is supported by an graphiti image provider
        Returns:
        the image descriptor for the id
        See Also:
        ImageDescriptor
      • getImageForId

        public org.eclipse.swt.graphics.Image getImageForId​(java.lang.String providerId,
                                                            java.lang.String imageId)
        Description copied from interface: IImageService
        Gets an image for the given image id. This image id must be supported by an graphiti image provider, and available to the given DiagramTypeProvider. The image registry of the plugin org.eclipse.graphiti.ui is used. This ensures that the image will only created once. The image returned must not be disposed by the caller.
        Specified by:
        getImageForId in interface IImageService
        imageId - the image id which is supported by an graphiti image provider
        Returns:
        the image for the id
        See Also:
        Image
      • removeImageFromRegistry

        public void removeImageFromRegistry​(java.lang.String key)
        Description copied from interface: IImageService
        Removes the corresponding image entry from the image registry and disposes the corresponding image (if existent). The passed image id must be supported by an graphiti image provider. The image registry of the plugin org.eclipse.graphiti.ui is used. Only call this method if you can guarantee that the image/image descriptor is no longer in use.
        Specified by:
        removeImageFromRegistry in interface IImageService
        Parameters:
        key - the image id which is supported by an graphiti image provider
        See Also:
        Image
      • getPlatformImageDescriptorForId

        public org.eclipse.jface.resource.ImageDescriptor getPlatformImageDescriptorForId​(java.lang.String imageId)
        Description copied from interface: IImageService
        Gets an image descriptor for the given image id. This image id must be supported by the graphiti platform image provider. The image registry of the plugin org.eclipse.graphiti.ui is used. This ensures that the image descriptor will only created once.
        Specified by:
        getPlatformImageDescriptorForId in interface IImageService
        Parameters:
        imageId - the image id which is supported by the graphiti platform image provider
        Returns:
        the image descriptor for the id
        See Also:
        ImageDescriptor
      • getPlatformImageForId

        public org.eclipse.swt.graphics.Image getPlatformImageForId​(java.lang.String imageId)
        Description copied from interface: IImageService
        Gets an image for the given image id. This image id must be supported by the graphiti platform image provider. The image registry of the plugin org.eclipse.graphiti.ui is used. This ensures that the image will only created once. The image returned must not be disposed by the caller.
        Specified by:
        getPlatformImageForId in interface IImageService
        Parameters:
        imageId - the image id which is supported by the graphiti platform image provider
        Returns:
        the image for the id
        See Also:
        Image
      • convertImageToBytes

        public byte[] convertImageToBytes​(org.eclipse.swt.graphics.Image image,
                                          int format)
        Description copied from interface: IImageService
        Converts the given Image into a byte array in the given format that could be directly saved to a file in that format. Supported formats are BMP (Windows or OS/2 Bitmap), ICO (Windows Icon), JPEG, GIF, PNG and TIFF, see ImageLoader for details.
        In case GIF is the target format this method will check that the image does not contain more than 256 colors (limit for GIF format). In case there are more colors this method will throw an IllegalStateException.
        Specified by:
        convertImageToBytes in interface IImageService
        Parameters:
        image - The image to convert to a byte array
        format - The format to use see ImageLoader
        Returns:
        A byte array containing the image
      • convertDiagramToBytes

        public byte[] convertDiagramToBytes​(Diagram diagram,
                                            int format)
        Description copied from interface: IImageService
        Converts the given diagram into an image byte array in the given format.
        This allows end users to export diagrams without having to run the associated GEF editor.
        Specified by:
        convertDiagramToBytes in interface IImageService
        Parameters:
        diagram - The diagram to convert to a byte array
        format - The format to use see ImageLoader
        Returns:
        A byte array containing the diagram image