We provide an API to layout presentation elements in a diagram using different strategies (layouter), see:
- com.nomagic.magicdraw.uml.symbols.layout.Layouting
//layout using the default diagram layouter AbstractDiagramPresentationElement diagramView = ...; diagramView.open(); Layouting.layout(diagramView);
//layout the selected symbols in the diagram using the default diagram layouter AbstractDiagramPresentationElement diagramView = ...; diagramView.open(); List<PresentationElement> symbolsToLayout = ...; diagramView.setSelected(symbolsToLayout); Layouting.layout(diagramView);
//layout using any of the available layouters AbstractDiagramPresentationElement diagram = ...; diagram.open() Layouting.layout(diagram, Layouting.HIERARCHIC_DIAGRAM_LAYOUTER);
Make sure the diagram is opened and the session is closed before doing a diagram layout. These are the current limitation of layout API
You can find more code examples in
- <installation_directory>\openapi\examples\testframework, com.nomagic.magicdraw.examples.testframework.DiagramLayoutTest class
Related pages