Package org.eclipse.graphiti.ui.services
Interface IImageService
- All Known Implementing Classes:
ImageService
public interface IImageService
This interface provides services for the creation of images.
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
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 givenImage
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
(String diagramTypeProviderId, String imageId) Gets an image descriptor for the given image id.org.eclipse.swt.graphics.Image
getImageForId
(String diagramTypeProviderId, String imageId) Gets an image for the given image id.org.eclipse.jface.resource.ImageDescriptor
getPlatformImageDescriptorForId
(String imageId) Gets an image descriptor for the given image id.org.eclipse.swt.graphics.Image
getPlatformImageForId
(String imageId) Gets an image for the given image id.void
removeImageFromRegistry
(String imageId) Removes the corresponding image entry from the image registry and disposes the corresponding image (if existent).
-
Method Details
-
getImageDescriptorForId
org.eclipse.jface.resource.ImageDescriptor getImageDescriptorForId(String diagramTypeProviderId, String imageId) 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 pluginorg.eclipse.graphiti.ui
is used. This ensures that the image descriptor will only created once.- Parameters:
imageId
- the image id which is supported by an graphiti image providerdiagramTypeProviderId
-- Returns:
- the image descriptor for the id
- Since:
- 0.10
- See Also:
-
ImageDescriptor
-
getImageForId
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 pluginorg.eclipse.graphiti.ui
is used. This ensures that the image will only created once. The image returned must not be disposed by the caller.- Parameters:
imageId
- the image id which is supported by an graphiti image provider- Returns:
- the image for the id
- Since:
- 0.10
- See Also:
-
Image
-
removeImageFromRegistry
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 pluginorg.eclipse.graphiti.ui
is used. Only call this method if you can guarantee that the image/image descriptor is no longer in use.- Parameters:
imageId
- the image id which is supported by an graphiti image provider- Since:
- 0.9
- See Also:
-
Image
-
getPlatformImageDescriptorForId
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 pluginorg.eclipse.graphiti.ui
is used. This ensures that the image descriptor will only created once.- Parameters:
imageId
- the image id which is supported by the graphiti platform image provider- Returns:
- the image descriptor for the id
- Since:
- 0.10
- See Also:
-
ImageDescriptor
-
getPlatformImageForId
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 pluginorg.eclipse.graphiti.ui
is used. This ensures that the image will only created once. The image returned must not be disposed by the caller.- Parameters:
imageId
- the image id which is supported by the graphiti platform image provider- Returns:
- the image for the id
- Since:
- 0.10
- See Also:
-
Image
-
convertImageToBytes
byte[] convertImageToBytes(org.eclipse.swt.graphics.Image image, int format) Converts the givenImage
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, seeImageLoader
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 anIllegalStateException
.- Parameters:
image
- The image to convert to a byte arrayformat
- The format to use seeImageLoader
- Returns:
- A byte array containing the image
- Throws:
In
- case of GIF format and the image having more than 256 colors.- Since:
- 0.11
-
convertDiagramToBytes
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.- Parameters:
diagram
- The diagram to convert to a byte arrayformat
- The format to use seeImageLoader
- Returns:
- A byte array containing the diagram image
- Since:
- 0.13
-