Runtime

## org.eclipse.gmf.runtime.diagram.ui.render.clipboard
Class DiagramGenerator

    java.lang.Object
      org.eclipse.gmf.runtime.diagram.ui.render.clipboard.DiagramGenerator

Direct Known Subclasses:
  DiagramImageGenerator, DiagramSVGGenerator

public abstract class DiagramGenerator
extends java.lang.Object

Provides the framework to generate SWT and AWT images of a diagram or a subset of editparts on a diagram.

Constructor Summary
`DiagramGenerator(DiagramEditPart dgrmEP)` Creates a new instance.

Method Summary
`protected Rectangle` `calculateImageRectangle(java.util.List editparts)` Determine the minimal rectangle required to bound the list of editparts.
`java.awt.Image` `createAWTImageForDiagram()` Creates an AWT image for the contents of the diagram editpart.
`abstract java.awt.Image` `createAWTImageForParts(java.util.List editparts)` Creates an AWT image for the list of editparts passed in.
`ImageDescriptor` `createSWTImageDescriptorForDiagram()` Creates an SWT image descriptor for the contents of the diagram editpart.
`ImageDescriptor` `createSWTImageDescriptorForParts(java.util.List editparts)` Creates an SWT image descriptor for the list of editparts passed in.Any connections where both the source and target editparts are passed in are also drawn.
`protected void` `disposeGraphics(Graphics g)` Allows hook to dispose of any artifacts around the creation of the `Graphics` object used for rendering.
`protected DiagramEditPart` `getDiagramEditPart()`
`java.util.List` `getDiagramPartInfo(DiagramEditPart diagramEditPart)` Get the positional data and the semantic elements for each `ShapeEditPart`, `ShapeCompartmentEditPart`, and `ConnectionEditPart` on the diagram.
`protected abstract ImageDescriptor` `getImageDescriptor(Graphics g)` Creates an image descriptor representing the image rendered from the diagram.
`protected int` `getImageMargin()`
`protected org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode` `getMapMode()`
`protected void` `renderToGraphics(Graphics graphics, Point translateOffset, java.util.List editparts)` Renders the list of editparts to the graphics object.
`protected abstract Graphics` `setUpGraphics(int width, int height)` Allows hook for the creation of a `Graphics` object that is used for the rendering of the diagram.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DiagramGenerator

    public DiagramGenerator(DiagramEditPart dgrmEP)

  Creates a new instance.

Parameters:
  `dgrmEP` - the diagram editpart

Method Detail

### getDiagramEditPart

    protected DiagramEditPart getDiagramEditPart()

  Returns:
    DiagramEditPart

### setUpGraphics

    protected abstract Graphics setUpGraphics(int width,
                                              int height)

  Allows hook for the creation of a `Graphics` object that is used for the rendering of the diagram.

  Parameters:
    `width` - of the clipping area
    `height` - of the clipping area
  Returns:
    Graphics element that is the target for rendering.

### disposeGraphics

    protected void disposeGraphics(Graphics g)

  Allows hook to dispose of any artifacts around the creation of the `Graphics` object used for rendering.

  Parameters:
    `g` - Graphics element that is to be disposed.

### getImageDescriptor

    protected abstract ImageDescriptor getImageDescriptor(Graphics g)

  Creates an image descriptor representing the image rendered from the diagram.

  Parameters:
    `g` - Graphics object where information to form the image descriptor can be retrieved from.
  Returns:
    ImageDescriptor representing the image rendered from the diagram.

### createAWTImageForDiagram

    public final java.awt.Image createAWTImageForDiagram()

  Creates an AWT image for the contents of the diagram editpart.

  Returns:
    an image in AWT format

### createAWTImageForParts

    public abstract java.awt.Image createAWTImageForParts(java.util.List editparts)

  Creates an AWT image for the list of editparts passed in.

  Parameters:
    `editparts` - the list of `IGraphicalEditParts` that will be rendered to the Image
  Returns:
    an image in AWT format

### createSWTImageDescriptorForDiagram

    public final ImageDescriptor createSWTImageDescriptorForDiagram()

  Creates an SWT image descriptor for the contents of the diagram editpart.

  Returns:
    an image descriptor for an SWT image

### createSWTImageDescriptorForParts

    public final ImageDescriptor createSWTImageDescriptorForParts(java.util.List editparts)

  Creates an SWT image descriptor for the list of editparts passed in.Any connections where both the source and target editparts are passed in are also drawn.

  Parameters:
    `editparts` - the list of `IGraphicalEditParts` that will be rendered to the Image
  Returns:
    an image descriptor for an SWT image

### getMapMode

    protected org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode getMapMode()

  Returns:

### renderToGraphics

    protected final void renderToGraphics(Graphics graphics,
                                          Point translateOffset,
                                          java.util.List editparts)

  Renders the list of editparts to the graphics object. Any connections where both the source and target editparts are passed in are also drawn.

  Parameters:
    `graphics` - the graphics object on which to draw
    `translateOffset` - a `Point` that the value the `graphics` object will be translated by in relative coordinates.
    `editparts` - the list of `IGraphicalEditParts` that will be rendered to the graphics object

### calculateImageRectangle

    protected Rectangle calculateImageRectangle(java.util.List editparts)

  Determine the minimal rectangle required to bound the list of editparts. A margin is used around each of the editpart's figures when calculating the size.

  Parameters:
    `editparts` - the list of `IGraphicalEditParts` from which their figure bounds will be used
  Returns:
    Rectangle the minimal rectangle that can bound the figures of the list of editparts

### getDiagramPartInfo

    public java.util.List getDiagramPartInfo(DiagramEditPart diagramEditPart)

  Get the positional data and the semantic elements for each `ShapeEditPart`, `ShapeCompartmentEditPart`, and `ConnectionEditPart` on the diagram.

  Parameters:
    `diagramEditPart` - The diagram edit part.
  Returns:
    A list of `PartPositionInfo`objects with positional data and the semantic element for the relevant editparts on the diagram.

### getImageMargin

    protected int getImageMargin()

  Returns:
    `int` value that is the margin around the generated image in logical coordinates.

Runtime

Guidelines for using Eclipse APIs.

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