Create a Mind Map Using Open API

Mind Map is a useful tool to visualize information, where relationships between information are drawn. In this article, you will be shown how to create a mind map using Open API.

The Mind Map going to be created

Create Blank Mind Map Diagram

First we use DiagramManager.createDiagram to create a blank diagram

//Create Blank Mind Map
DiagramManager diagramManager = ApplicationManager.instance().getDiagramManager();
IDiagramUIModel mindMap = (IDiagramUIModel) diagramManager.createDiagram(IDiagramTypeConstants.DIAGRAM_TYPE_MIND_MAP_DIAGRAM);
mindMap.setName("Sample Mind Map");

Create Nodes

We are ready to create the nodes once the diagram is created. The nodes can be created by the class IModelElementFactory.

//Create node for product launch
IMindMapNode productLaunch = IModelElementFactory.instance().createMindMapNode();
productLaunch.setName("Product Launch");
//Create the node shape on diagram
IMindMapNodeUIModel shapeProductLaunch = (IMindMapNodeUIModel) diagramManager.createDiagramElement(mindMap, productLaunch);
shapeProductLaunch.setBounds(450, 240, 250, 35);
//set the font size if you want the text larger/smaller than default
shapeProductLaunch.getElementFont().setSize(25);
//set the color for the node, you don't have to call this method if you want it to be black 
shapeProductLaunch.getLineModel().setColor(Color.black);
//Call to re-calculate caption position when render the diagram
shapeProductLaunch.resetCaption();

Now, try creating other nodes.

Create Connectors

When the nodes are created, we ca than create the connectors between nodes.

/Create connector
IMindConnector productLaunchToSales = IModelElementFactory.instance().createMindConnector();
//The connector will connect from the product launch node...
productLaunchToSales.setFrom(productLaunchToSales);
//...to the sales node
productLaunchToSales.setTo(sales);
//create the connector shape on diagram
diagramManager.createConnector(mindMap, productLaunchToSales, shapeProductLaunch, shapeSales, new Point[] {});

Try connect others nodes using this method.

Show Up the Diagram

Finally, we can show up the diagram.

//Show up diagram
diagramManager.openDiagram(mindMap);

Sample Plugin

The sample plugin demonstrate how to create mind map using Open API. After you deploy the plugin into Visual Paradigm you can then click the plugin button in the application toolbar to trigger it.

Download the Plugin

You can click this link to download the sample plugin.

Related Know-how

Related Link

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply