Diagram Class

A Diagram corresponds to a single UML diagram. It is accessed through the Package Diagrams collection and in turn contains a collection of diagram objects and diagram connectors. Adding to the DiagramObject Class adds an existing element to the diagram. When adding a new diagram, you must set the diagram type to one of the valid types:

Activity

Analysis

Component

Custom

Deployment

Logical

Sequence

Statechart

Use Case

For a Collaboration (Communication) diagram, use the Analysis type.

Associated table in .EAP file

t_diagram

Diagram Attributes

Attribute

Remarks

See also

Author

String

Notes: Read/Write

The name of the author.

CreatedDate

Date

Notes: Read/Write

The date the diagram was created.

cx

Long

Notes: Read/Write

The X dimension of the diagram (the default is 800).

cy

Long

Notes: Read/Write

The Y dimension of the diagram (the default is 1100).

DiagramGUID

Variant

Notes: Read/Write

A globally unique ID for this diagram.

DiagramID

Long

Notes: Read only

A local ID for the diagram.

DiagramLinks

Collection

Notes: Read only

A list of DiagramLink objects, each containing information about the display characteristics of a connector in a diagram.

Applies a comma-separated list of object ids (from SelectedObjects) to the currently-applied diagram filter, overriding the filter. The effect persists until another filter is applied, or the diagram is closed.

HighlightImports

Boolean

Notes: Read/Write

A flag to indicate that elements from other Packages should be highlighted. Corresponds with the 'Show Namespace' option in the diagram 'Properties' dialog.

The diagram type; see the t_diagramtypes table in the .eap file for more information.

Version

String

Notes: Read/Write

The version of the diagram.

Diagram Methods

Method

Details

See also

ApplyGroupLock (string aGroupName)

Boolean

Notes: Applies a group lock to this diagram object, for the specified group, on behalf of the current user.

Returns True if the operation is successful; returns False if the operation is unsuccessful. Use GetLastError() to retrieve error information.

Parameter:

aGroupName: String - the name of the user group for which to set the group lock

ApplyUserLock ()

Boolean

Notes: Applies a user lock to this diagram object, for the current user.

Returns True if the operation is successful; returns False if the operation is unsuccessful. Use GetLastError() to retrieve error information.

FindElementInDiagram (long ElementID)

Boolean

Notes: This function activates the Diagram View and displays the diagram with the diagram object selected. If the diagram is too large to display all of it on the screen, the portion of the diagram containing the object is displayed with the object shown in the center of the screen. Diagram objects flagged as non-selected are shown but are not selected

Returns True if the diagram object was found, the diagram displayed and the object selected (or at least displayed) in the view. Returns False if the diagram object was not found in the diagram and the diagram not displayed.

Notes: Returns a string value describing the most recent error that occurred in relation to this object.

ReadStyle (string StyleName)

String

Notes: Returns the current value of the named diagram style.

Use GetLastError() to retrieve error information.

Parameters:

StyleName: String - the name of the diagram style whose value is to be retrieved; valid StyleNames are:
- Show Element Property String
- Show Connector Property String
- Show Feature Property String

ReleaseUserLock ()

Boolean

Notes: Releases a group lock or user lock on this diagram object.

Returns True if the operation is successful; returns False if the operation is unsuccessful. Use GetLastError() to retrieve error information.

ReorderMessages ()

Void

Notes: Resets the display order of Sequence and Collaboration messages.

This is typically used after inserting or deleting messages in the diagram.

SaveAsPDF (string FileName)

Boolean

Notes: Export the diagram to a PDF document. Returns True on success.

Parameters:

FileName: String - full path to file location

SaveImagePage(long x, long y, long sizeX, long sizeY, string filename, long flags)

Boolean

Notes: Saves a page of the diagram to disk.

Returns True if the operation is successful; returns False if the operation is unsuccessful.

Use GetLastError() to retrieve error information.

Parameters:

x: Long - the horizontal page

y: Long - the vertical page

sizeX: Long - currently unused; pass a value of 0 to ensure behavior does not change in a future build

sizeY: Long - currently unused; pass a value of 0 to ensure behavior does not change in a future build

filename: String - the filename and path to save the image

flags: Long - additional options, currently unused; pass a value of 0 to ensure behavior does not change in a future build

The image type is determined by the extension of the filename. Currently only .emf, .bmp and .png formats are supported.

ShowAsElementList (bool ShowAsList, bool Persist)

Boolean

Notes: Toggles the diagram display between diagram format and Diagram List depending on the value of ShowAsList.

If Persist is set, the display format is written to the database so the diagram always opens in that format (diagram or list). Otherwise, the display format falls back to the default (diagram) once the display is closed.

Parameters:

ShowAsList: Boolean - indicates diagram or Diagram List

Persist: Boolean - indicates set (maintain ShowAsList value) or not (revert to default)

Notes: Updates this diagram object after modification or appending a new item.

If False is returned, use GetLastError() to retrieve error information.

VirtualizeConnector (int ConnectorID, int Action, int X, int Y)

Boolean

Notes: Creates a virtual copy of the source or target element on a connector, and sets its location on the diagram as a waypoint on the connector. If the source element is being virtualized, the waypoint is created as the first on the connector, and if the target element is being virtualized, the waypoint is created as the last on the connector.

If called again on the same connector, removes the virtual element. However, the waypoint remains in place.

As waypoints and therefore virtual elements can only be created on connectors with the Custom line style, if the connector does not have this line style the method sets it. So, after this method executes, an Update function should be called for the connector as well as for the diagram. All parameters are required for the function to complete successfully.

Returns True if the operation is successful; returns False if the operation is unsuccessful.

Parameters:

ConnectorID - Integer: the ID of the connector on which to create the virtual element

Action - Integer: the element to be virtualized; 1 for the source element, 2 for the target element

X - Integer: the position on the X axis that the element's center point will be aligned with

Y - Integer: the position on the Y axis that the element's centre point will be aligned with

For example, to virtualize the source element of the selected connector: