|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.graphiti.features.impl.AbstractFeature
org.eclipse.graphiti.features.impl.AbstractSaveImageFeature
org.eclipse.graphiti.ui.features.DefaultSaveImageFeature
public class DefaultSaveImageFeature
The default feature implementation for saving a diagram as an image. This
feature is used to trigger saving from inside an open and initialized
DiagramEditor
. It relies on an existing GraphicalViewer
showing the diagram to save.
Constructor Summary | |
---|---|
DefaultSaveImageFeature(IFeatureProvider fp)
Creates a new DefaultSaveImageFeature . |
Method Summary | |
---|---|
protected String |
addFileExtension(String extension,
String filename)
Adds the given file extension to the given filename. |
private byte[] |
convertImageToBytes(Image image,
int format)
|
private ImageData |
create8BitIndexedPaletteImage(Image image)
|
protected Map<String,Boolean> |
getDiagramExporters()
Returns all available Graphiti diagram exporters that are registered at the according Graphiti extension point. |
protected String |
getFilename(GraphicalViewer viewer,
ISaveAsImageConfiguration saveAsImageConfiguration)
Must return the filename under which the image will be saved. |
protected GraphicalViewer |
getGraphicalViewer(ISaveImageContext context)
Must return a GraphicalViewer that contains the diagram to be
saved as an image. |
protected ISaveAsImageConfiguration |
getSaveAsImageConfiguration(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.. |
protected IRunnableWithProgress |
getSaveAsImageOperation(ISaveAsImageConfiguration saveAsImageConfiguration,
String filename)
Called to create the operation that is actually used for executing the save as image functionality. |
protected IRunnableWithProgress |
getSaveAsImageOperationForNonStandardExporter(ISaveAsImageConfiguration saveAsImageConfiguration,
String filename)
Called to create the operation that is actually used for executing the save as image functionality for standard formats. |
protected IRunnableWithProgress |
getSaveAsImageOperationForStandardExporter(ISaveAsImageConfiguration saveAsImageConfiguration,
String filename)
Called to create the operation that is actually used for executing the save as image functionality for non-standard formats. |
void |
save(ISaveImageContext context)
Performs the save as image operation. |
Methods inherited from class org.eclipse.graphiti.features.impl.AbstractSaveImageFeature |
---|
canExecute, canSave, execute, getName, hasDoneChanges, postSave, preSave |
Methods inherited from class org.eclipse.graphiti.features.impl.AbstractFeature |
---|
addGraphicalRepresentation, canUndo, getAllBusinessObjectsForPictogramElement, getBusinessObjectForPictogramElement, getDescription, getDiagram, getDiagramBehavior, getDiagramEditor, getFeatureProvider, getProgressCallback, getUserDecision, isAvailable, layoutPictogramElement, link, link, manageColor, manageColor, manageDefaultFont, manageFont, manageFont, setProgressCallback, toString, updatePictogramElement |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.eclipse.graphiti.features.ISaveImageFeature |
---|
canSave, postSave, preSave |
Methods inherited from interface org.eclipse.graphiti.features.IFeature |
---|
canExecute, canUndo, execute, hasDoneChanges, isAvailable |
Methods inherited from interface org.eclipse.graphiti.IName |
---|
getName |
Methods inherited from interface org.eclipse.graphiti.IDescription |
---|
getDescription |
Methods inherited from interface org.eclipse.graphiti.features.IFeatureProviderHolder |
---|
getFeatureProvider |
Constructor Detail |
---|
public DefaultSaveImageFeature(IFeatureProvider fp)
DefaultSaveImageFeature
.
fp
- The feature provider providing this featureMethod Detail |
---|
public void save(ISaveImageContext context)
#getGraphicalViewer(IPrintContext)
to retrieve the
GraphicalViewer
that already displays the diagram, queries for
ISaveAsImageConfiguration
to use by calling
getSaveAsImageConfiguration(GraphicalViewer)
, queries for the
filename by delegating to
getFilename(GraphicalViewer, ISaveAsImageConfiguration)
and
finally uses
getSaveAsImageOperation(ISaveAsImageConfiguration, String)
to
create an operation to perform the save as image operation. All those
methods may be overridden to change the default behavior, so normally one
would not need to override this method unless the complete sequence needs
to changed or the save as image is performed in a completely different
scenario.
save
in interface ISaveImageFeature
context
- Context information for saving as an image.protected GraphicalViewer getGraphicalViewer(ISaveImageContext context)
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 AbstractFeature.getDiagramEditor()
.
context
- Context information for saving.
protected ISaveAsImageConfiguration getSaveAsImageConfiguration(GraphicalViewer viewer)
viewer
- The GraphicalViewer
displaying the diagram to print
ISaveAsImageConfiguration
interface used in the save as
image job.protected String getFilename(GraphicalViewer viewer, ISaveAsImageConfiguration saveAsImageConfiguration)
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).
viewer
- The GraphicalViewer
displaying the diagram to printsaveAsImageDialog
- The save as image configurations as defined by
getSaveAsImageConfiguration(GraphicalViewer)
.
protected String addFileExtension(String extension, String filename)
extension
- A string holding the extension.filename
- A string holding the filename.
protected IRunnableWithProgress getSaveAsImageOperation(ISaveAsImageConfiguration saveAsImageConfiguration, String filename)
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.
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
protected IRunnableWithProgress getSaveAsImageOperationForNonStandardExporter(ISaveAsImageConfiguration saveAsImageConfiguration, String filename)
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
protected IRunnableWithProgress getSaveAsImageOperationForStandardExporter(ISaveAsImageConfiguration saveAsImageConfiguration, String filename)
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
protected Map<String,Boolean> getDiagramExporters()
Map
holding all exporters.private byte[] convertImageToBytes(Image image, int format)
private ImageData create8BitIndexedPaletteImage(Image image)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |