IBM Rational Software Modeler
Release 6.0

com.ibm.xtools.uml.diagram
Interface IUMLDiagramHelper


public interface IUMLDiagramHelper

Provides miscellaneous UML diagram utilities


Method Summary
 boolean canCreateViews(Diagram diagram, List objects)
          Returns whether views can be created for the objects specified by objects in the diagram specified by diagram
 Diagram createDiagram(Namespace container, UMLDiagramKind kind)
          Creates a UML diagram with a given kind and inserts it into a given container
 Diagram createDiagram(Namespace container, UMLDiagramKind kind, Element context)
          Creates a UML diagram with a given context and kind and inserts it into a given container
 Edge createEdge(View source, View target, Element element)
          Creates an edge for a given element and connects it between a given source and a given target
 Edge createEdge(View source, View target, String type)
          Creates an edge with a given type and connects it between a given source and a given target
 List createEdges(Diagram diagram, Relationship element)
          Creates diagram edges between the related elements of a relationship
 Node createNode(View container, Element element)
          Creates a node for a given element and inserts it into a given container
 Node createNode(View container, String type)
          Creates a node with a given type and inserts it into a given container
 List createViews(Diagram diagram, List objects)
          Creates views for the objects specified by objects in the diagram specified by diagram.
 void destroyView(View view)
          Destroys a given view
 View getChildView(View container, String type)
          Gets the child view with a given type from a given view
 List getDiagrams(Namespace element)
          Gets a list of diagrams for a given element
 List getDiagrams(Namespace element, UMLDiagramKind kind)
          Gets a list of diagrams of a given kind for a given element
 ILayoutNode getLayoutNode(Node node)
          getLayoutNode Gets the ILayoutNode in order to retrieve the actual size of the Node object irrespective of the autosize properties.
 Diagram getMainDiagram(Namespace element)
          Gets the main diagram of an element
 UMLDiagramKind getUmlDiagramKind(Diagram diagram)
          Retrieves the UMLDiagramKind of the specified diagram
 void layout(View view, String hint)
          layout Utility method to layout the children of a view container.
 void layoutNodes(List nodes, String hint)
          layoutNodes Utility method to layout a list of Node children on a diagram.
 void openDiagramEditor(Diagram diagram)
          Opens an editor for a given diagram
 Image renderToAWTImage(Diagram diagram)
          renderToAWTImage Utility api to generate an AWT based image representation of the diagram contents.
 void renderToImageFile(Diagram diagram, String file, ImageFileFormat format)
          renderToImageFile Utility api to render the diagram to a specified image formatation of the diagram contents.
 Image renderToSWTImage(Diagram diagram)
          renderToSWTImage Utility api to generate an SWT based image representation of the diagram contents.
 void setMainDiagram(Namespace element, Diagram diagram)
          Sets the main diagram of an element
 

Method Detail

createDiagram

public Diagram createDiagram(Namespace container,
                             UMLDiagramKind kind)
Creates a UML diagram with a given kind and inserts it into a given container

Parameters:
container - The container namespace for the diagram
kind - The UML diagram kind
Returns:
a newly created Diagram

createDiagram

public Diagram createDiagram(Namespace container,
                             UMLDiagramKind kind,
                             Element context)
Creates a UML diagram with a given context and kind and inserts it into a given container

Parameters:
container - The container namespace for the diagram
context - The UML diagram element context
kind - The UML diagram kind
Returns:
A newly created Diagram

createNode

public Node createNode(View container,
                       Element element)
Creates a node for a given element and inserts it into a given container

Parameters:
container - The node view container
element - The node view element context
Returns:
A newly created Node

createNode

public Node createNode(View container,
                       String type)
Creates a node with a given type and inserts it into a given container

Parameters:
container - The node view container
type - The node view type
Returns:
A newly created Node

createEdge

public Edge createEdge(View source,
                       View target,
                       Element element)
Creates an edge for a given element and connects it between a given source and a given target

Parameters:
source - The edge's source view
target - The edge's target view
element - The edge view element context
Returns:
A newly created Edge

createEdge

public Edge createEdge(View source,
                       View target,
                       String type)
Creates an edge with a given type and connects it between a given source and a given target

Parameters:
source - The edge's source view
target - The edge's target view
type - The edge view type
Returns:
A newly created Edge

destroyView

public void destroyView(View view)
Destroys a given view

Parameters:
view - The view to be destroyed

openDiagramEditor

public void openDiagramEditor(Diagram diagram)
Opens an editor for a given diagram

Parameters:
diagram - The diagram to be opened
Returns:
a newly opened IEditorPart for the diagram

getDiagrams

public List getDiagrams(Namespace element)
Gets a list of diagrams for a given element

Parameters:
element - The namespace element
Returns:
A list of Diagram s

getDiagrams

public List getDiagrams(Namespace element,
                        UMLDiagramKind kind)
Gets a list of diagrams of a given kind for a given element

Parameters:
element - The namespace element
kind - The diagram kind
Returns:
A list of Diagram s

getMainDiagram

public Diagram getMainDiagram(Namespace element)
Gets the main diagram of an element

Parameters:
element - The namespace element
Returns:
The main Diagram

setMainDiagram

public void setMainDiagram(Namespace element,
                           Diagram diagram)
Sets the main diagram of an element

Parameters:
element - The namespace element
diagram - The main diagram

getChildView

public View getChildView(View container,
                         String type)
Gets the child view with a given type from a given view

Parameters:
container - The container view
type - The type of the child view
Returns:
a child View

getUmlDiagramKind

public UMLDiagramKind getUmlDiagramKind(Diagram diagram)
Retrieves the UMLDiagramKind of the specified diagram

Parameters:
diagram - The diagram to retrieve the UMLDiagramKind for
Returns:
The UMLDiagramKind

renderToImageFile

public void renderToImageFile(Diagram diagram,
                              String file,
                              ImageFileFormat format)
renderToImageFile Utility api to render the diagram to a specified image formatation of the diagram contents.

Parameters:
diagram - The Diagram to render the image from.
file - String that is the image file path to write to.
format - ImageFileFormat enumeration of valid file formats
Throws:
NullPointerException - diagram is null
NullPointerException - file is null
NullPointerException - format is null
IllegalArgumentException - file is an empty string
UnsupportedOperationException - Unable to render diagram to format

renderToAWTImage

public Image renderToAWTImage(Diagram diagram)
renderToAWTImage Utility api to generate an AWT based image representation of the diagram contents.

Parameters:
diagram - The Diagram to render the image from.
Returns:
java.awt.Image that is the bitmap representation of the diagram contents.
Throws:
NullPointerException - diagram is null

renderToSWTImage

public Image renderToSWTImage(Diagram diagram)
renderToSWTImage Utility api to generate an SWT based image representation of the diagram contents.

Parameters:
diagram - The Diagram to render the image from.
Returns:
org.eclipse.swt.graphics.Image that is the bitmap representation of the diagram contents. Caller is responsible for calling dispose() on the return image.
Throws:
NullPointerException - diagram is null

getLayoutNode

public ILayoutNode getLayoutNode(Node node)
getLayoutNode Gets the ILayoutNode in order to retrieve the actual size of the Node object irrespective of the autosize properties.

Parameters:
node - Node to get the layout node equivalent from
Returns:
ILayoutNode object
Throws:
NullPointerException - node is null

layout

public void layout(View view,
                   String hint)
layout Utility method to layout the children of a view container.

Parameters:
view - View object that is the container whose children will be laid out. Typically this would be the Diagram notation element.
hint - String representing a hint for what kind of layout will be applied. Value can be one of
Throws:
NullPointerException - view is null
NullPointerException - hint is null
See Also:
ILayoutNodesProvider.DEFAULT_LAYOUT, Other values would have to understand by custom providers., ILayoutNodesProvider

layoutNodes

public void layoutNodes(List nodes,
                        String hint)
layoutNodes Utility method to layout a list of Node children on a diagram.

Parameters:
nodes - List of Node objects
hint - String representing a hint for what kind of layout will be applied. Value can be one of
Throws:
NullPointerException - nodes is null
IllegalArgumentException - nodes is an empty list
NullPointerException - hint is null
IllegalArgumentException - Argument nodes contains objects which aren't of type Node
IllegalArgumentException - Argument nodes contains objects which have a different parent containment
See Also:
ILayoutNodesProvider.DEFAULT_LAYOUT, Other values would have to understand by custom providers., ILayoutNodesProvider

createViews

public List createViews(Diagram diagram,
                        List objects)
Creates views for the objects specified by objects in the diagram specified by diagram.

Parameters:
diagram - The diagram where to add views to
objects - The objects to add views for
Returns:
The notation elements added to the diagram
Throws:
NullPointerException - diagram or object is null
IllegalArgumentException - diagram has no associated edit part (internal error)

canCreateViews

public boolean canCreateViews(Diagram diagram,
                              List objects)
Returns whether views can be created for the objects specified by objects in the diagram specified by diagram

Parameters:
diagram - The diagram where to add a views to
objects - The objects to add views for
Returns:
true if at least one object can be viewed in the specified diagram
Throws:
NullPointerException - diagram or objects is null

createEdges

public List createEdges(Diagram diagram,
                        Relationship element)
Creates diagram edges between the related elements of a relationship

Parameters:
diagram - The diagram to created edges in
element - The relationship element
Returns:
The list of created Edge s

IBM Rational Software Modeler
Release 6.0


Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2004. All rights reserved.