Diagram Info box- Turning on/off, moving using API

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Diagram Info box- Turning on/off, moving using API

Postby stephen.r.foster@jpmorgan.com » Fri Feb 17, 2023 11:27 am

I'm using the API to generate a diagram, but having issues with accessing the Diagram Info box.

The Diagram Info box is added to the diagram by default when I first create the diagram, but as I add shapes, the diagram gets bigger and the Diagram Info box ends up not in the right place.

I want to put the Diagram Info box back in the top right corner - either by moving to a specified location (preferred) or by turning it off then back on again.

Can anyone provide a solution?

Thanks
stephen.r.foster@jpmorgan.com
Forum Newbie
Forum Newbie
 
Posts: 5
Posts Rating:0
Joined: Thu Dec 08, 2016 11:38 am

Re: Diagram Info box- Turning on/off, moving using API

Postby anyonearomatic@gmail.com » Tue Feb 28, 2023 9:14 pm

I am having the same problem and need a practical solution
anyonearomatic@gmail.com
Forum Newbie
Forum Newbie
 
Posts: 2
Posts Rating:0
Joined: Tue Feb 28, 2023 9:09 pm

Re: Diagram Info box- Turning on/off, moving using API

Postby yu3333 » Fri Apr 07, 2023 9:19 am

I usually use layout function to make sure Diagram Info box ends up in the acceptable position, for example:
Code: Select all
Diagram diagram = ...;
DiagramPresentationElement diagramSymbol = project.getDiagram(diagram);
..............
diagramSymbol.open();
diagramSymbol.layout(false);


Alternatively, if you feel like moving the info box manually, do it this way:

Code: Select all
DiagramPresentationElement diagram = ...;

java.awt.Rectangle rect;      // this is the diagram frame's bound rectangle
DiagramPropertiesShape view;  // this is the diagram info box
for(PresentationElement e : diagram.getPresentationElements()) { 
    if (e instanceof DiagramFrameView){
        print(e.getBounds().getHeight()); 
        rect = e.getBounds();
    } 
   
    if (e instanceof DiagramPropertiesShape){
        view = e;     
    }
}     

// move the info box
PresentationElementsManager.getInstance().movePresentationElement(view, new java.awt.Point((Integer)rect.getWidth() -100, 10));


Hope it helps!
yu3333
Forum Newbie
Forum Newbie
 
Posts: 7
Posts Rating:0
Joined: Wed Mar 29, 2023 1:09 am

Re: Diagram Info box- Turning on/off, moving using API

Postby stephen.r.foster@jpmorgan.com » Wed Apr 19, 2023 8:58 am

That solution works - thanks
stephen.r.foster@jpmorgan.com
Forum Newbie
Forum Newbie
 
Posts: 5
Posts Rating:0
Joined: Thu Dec 08, 2016 11:38 am


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 0 guests