Runtime

org.eclipse.gmf.runtime.diagram.ui.render.util
Class CopyToImageUtil

java.lang.Object
  extended byorg.eclipse.gmf.runtime.diagram.ui.render.util.CopyToImageUtil

public class CopyToImageUtil
extends java.lang.Object

Utility class to render a diagram to an image file.


Constructor Summary
CopyToImageUtil()
           
 
Method Summary
 DiagramGenerator copyToImage(DiagramEditPart diagramEP, IPath destination, ImageFileFormat format, IProgressMonitor monitor)
          Copies the diagram to an image file in the specified format.
 void copyToImage(DiagramEditPart diagramEP, java.util.List selection, IPath destination, ImageFileFormat format, IProgressMonitor monitor)
          Copies the diagram to an image file in the specified format.
 java.util.List copyToImage(Diagram diagram, IPath destination, ImageFileFormat format, IProgressMonitor monitor, PreferencesHint preferencesHint)
          Copies the diagram to an image file in the specified format.
 DiagramEditPart createDiagramEditPart(Diagram diagram, Shell shell, PreferencesHint preferencesHint)
          Creates a DiagramEditPart given the Diagram without opening an editor.
protected  void saveSVGToFile(IPath destination, DiagramSVGGenerator generator, IProgressMonitor monitor)
          Saves an SVG DOM to a file.
protected  void saveToFile(IPath destination, Image image, ImageFileFormat imageFormat, IProgressMonitor monitor)
          Saves the image to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CopyToImageUtil

public CopyToImageUtil()
Method Detail

createDiagramEditPart

public DiagramEditPart createDiagramEditPart(Diagram diagram,
                                             Shell shell,
                                             PreferencesHint preferencesHint)
Creates a DiagramEditPart given the Diagram without opening an editor.

Parameters:
diagram - the Diagram
shell - An out parameter for the shell that must be disposed after the copy to image operation has completed.
preferencesHint - The preference hint that is to be used to find the appropriate preference store from which to retrieve diagram preference values. The preference hint is mapped to a preference store in the preference registry <@link DiagramPreferencesRegistry>.
Returns:
the new populated DiagramEditPart

copyToImage

public java.util.List copyToImage(Diagram diagram,
                                  IPath destination,
                                  ImageFileFormat format,
                                  IProgressMonitor monitor,
                                  PreferencesHint preferencesHint)
                           throws CoreException
Copies the diagram to an image file in the specified format.

Parameters:
diagram - the diagram to be copied
destination - the destination file, including path and file name
format - the image file format
monitor - progress monitor.
preferencesHint - The preference hint that is to be used to find the appropriate preference store from which to retrieve diagram preference values. The preference hint is mapped to a preference store in the preference registry <@link DiagramPreferencesRegistry>.
Returns:
A list of PartPositionInfo objects with details regarding each top-level editpart on the diagram represented in the image.
Throws:
CoreException - if this method fails

copyToImage

public DiagramGenerator copyToImage(DiagramEditPart diagramEP,
                                    IPath destination,
                                    ImageFileFormat format,
                                    IProgressMonitor monitor)
                             throws CoreException
Copies the diagram to an image file in the specified format.

Parameters:
diagramEP - the diagram editpart
destination - the destination file, including path and file name
format - the image format to create.
monitor - progress monitor.
Returns:
The diagram generator used to copy the image.
Throws:
CoreException - if this method fails

copyToImage

public void copyToImage(DiagramEditPart diagramEP,
                        java.util.List selection,
                        IPath destination,
                        ImageFileFormat format,
                        IProgressMonitor monitor)
                 throws CoreException
Copies the diagram to an image file in the specified format.

Parameters:
diagramEP - the diagram edit part
selection - selected shapes in the diagram.
destination - the destination file, including path and file name
format - the image format to create.
monitor - progress monitor.
Throws:
CoreException - if this method fails

saveToFile

protected void saveToFile(IPath destination,
                          Image image,
                          ImageFileFormat imageFormat,
                          IProgressMonitor monitor)
                   throws CoreException
Saves the image to a file.

Parameters:
destination - the destination file, including path and file name
image - the SWT image
imageFormat - the selected image format
monitor - progress monitor
Throws:
CoreException - if this method fails

saveSVGToFile

protected void saveSVGToFile(IPath destination,
                             DiagramSVGGenerator generator,
                             IProgressMonitor monitor)
                      throws CoreException
Saves an SVG DOM to a file.

Parameters:
destination - the destination file, including path and file name
generator - the svg generator for a diagram, used to write
monitor - the progress monitor
Throws:
CoreException - if this method fails

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.