|
|
Add Interfaces to Diagram |
This helper adds interfaces to a structural diagram.
|
Applicable To |
Structure
Diagram, Object Model Diagram |
|
Menu
Entry |
Power
Pack Diagram Tools Add Interfaces to Diagram |
|
Demonstration |
The helper analyzes any ports on the diagram and checks them for contracts. If a contract is already on the diagram, then it is skipped. The remaining contracts are added (each contract is only ever added once).
If the following property is set to true, then the helper removes all interfaces from the diagram before trying to add new ones:
RhapsodyPowerPack.AddInterfacesToDiagram.RemoveExistingInterfaces
Before adding any contracts to the diagram, the helper first records the show operations / show attributes properties of the diagram (this is because setting the compartments to show is not available at the graphical level).
Before adding each contract, it sets those same properties based on whether the interface has operations and attributes or not. Interfaces are then placed on the diagram in specification view and the helper sets the show operations and show values graphical display options to all (if the interface has operations/event receptions and attributes respectively).
After all contracts have been added it resets the diagram properties back to what they were before the helper ran (if they were already overridden then those values are replaced – if not then the property is reset so it does not show up as overridden)
One exception to this rule is Flow Properties. This is a huge gap in the Rhapsody API – there is no showFlowProperties property and if the showAttributes property is used then Rhapsody shows two compartments (Attributes and Flow properties) and puts the items in both. Until this is fixed in Rhapsody, the helper sets the Compartments property so that Flow Properties are shown (and does not reset it – if it does then Rhapsody hides the flow properties again).
If ports are connected by links, then the contract is placed at the center point of the link. If not, then the contract is placed relative to the port and which side of the Block/Class it is on. For ports at the top or bottom, the contract is aligned centrally with the port and then pushed up or down enough to allow for the port text to be read. For ports on the left or right hand side, the contract is placed slightly under and to the left / right of the port to allow the port text to be read. The position of the contract may result in it being represented as hashed lines –- moving the interface out of its ‘illegal’ place solves this but sadly doing so causes Rhapsody to apply its own default formatting to the element – resetting it back to blue. To avoid this, the following property (which will cause the helper to override Rhapsody’s default ‘MarkMisplacedElements’ property for this diagram) is by default set to true:
RhapsodyPowerPack.AddInterfacesToDiagram.OverrideMarkMisplacedElements

Interfaces by default are colored in green and have a width of 120 and a height of 140 but this may be controlled by setting the following properties at project / package level:
RhapsodyPowerPack.AddInterfacesToDiagram.InterfaceColor
RhapsodyPowerPack.AddInterfacesToDiagram.DefaultHeight
RhapsodyPowerPack.AddInterfacesToDiagram.DefaultWidth
RhapsodyPowerPack.AddInterfacesToDiagram.CalculateHeightBasedOnContent
If the property above is set to true, then the default height is ignored and instead the helper calculates a new height based on the content of the interface. It starts with a base height of 50 (or 60 if there are less than 4 items) and then adds 19 pixels for each event reception, operation, and attribute in the interface. If an interface has both value properties and operations/event receptions, then additional height is added to compensate for the compartment divider, but Rhapsody has no graphical API for this and so the divider may need to be manually moved.
If an interface contains many elements, then this may of course result in very large elements on the diagram.