IBM Support

Programmatically rearrange layout on Class Diagrams

Troubleshooting


Problem

In IBM Rational Software Architect and IBM Rational Software Modeler, when a class diagram is automatically arranged using the “Arrange all” diagram context menu item, sometimes the resulting diagram can contain overlapping elements and text. This is particularly the case when the names on the ends of associations are long.

Symptom

Steps to reproduce:

1. Create a class Diagram in a model.
2. Drag four Class types from Palette to create four classes (named Class1, Class2, Class3 and Class4).
3. Create associations between the classes in the following order Class2 Class1, Class2 Class3, Class3 Class1, Class3 Class4.
4. Left click on the diagram background then right click and select Arrange All. The diagram rearranges but the labels on the Class3 ends of the associations overlap the Class symbol as in the following screenshot:

Cause

The reason for this is that the “Arrange all” does not take into consideration the sizes of labels.

Resolving The Problem


Disclaimer

All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.



IBM Rational Client Support developed a pluglet to show how to relocate elements programmatically. The pluglet will scale the spacing between nodes so that the association labels are then less likely to overlap the nodes. This pluglet performs a scaling of the diagram and not a zoom, the size of each of the elements does not change. The only change is the relative distance between the nodes which is doubled.

To install and run this pluglet, download the attached pluglet project and follow the instructions in the link in the Related information section.

RelocateDiagram.zip

Applying this pluglet to the above diagram results in the following layout:

Related Information

[{"Product":{"code":"SSCLKU","label":"Rational Software Modeler"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Modeling: Diagrams","Platform":[{"code":"PF033","label":"Windows"},{"code":"PF016","label":"Linux"}],"Version":"7.5;7.5.1;7.5.2","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SS4JE2","label":"Rational Software Architect Standard Edition"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":" ","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"7.5;7.5.1;7.5.2","Edition":"","Line of Business":{"code":"LOB36","label":"IBM Automation"}},{"Product":{"code":"SS4JCV","label":"Rational Software Architect for WebSphere Software"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":" ","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"7.5;7.5.1;7.5.2","Edition":"","Line of Business":{"code":"LOB15","label":"Integration"}}]

Document Information

Modified date:
29 September 2018

UID

swg21385255