Create a Cause and Effect Diagram Using Open API

Cause and Effect diagram, also known as Fishbone Diagram, is useful for recording potential factors that may cause a problem or effect. This article will show you how to create a cause and effect diagram using Open API.

The cause and effect diagram will be created by the diagram.

Create Blank Cause and Effect Diagram

We can first create a blank cause and effect diagram using DiagramManager.createDiagram.

//Create blank diagram
DiagramManager diagramManager = ApplicationManager.instance().getDiagramManager();
IFishboneDiagramUIModel causeAndEffectDiagram = (IFishboneDiagramUIModel) diagramManager.createDiagram(IDiagramTypeConstants.DIAGRAM_TYPE_FISHBONE_DIAGRAM);
causeAndEffectDiagram.setName("Sample Cause and Effect Diagram");

Create Cause and Effect Diagram model

Unlike other charts and diagrams, which elements’ shapes have to be manually rendered, the elements’ shapes of cause and effect diagram are rendered automatically by an IFishboneDiagramModel object. The object can be created using IModelElementFactory.instance().createFishboneDiagramModel().

//Create diagram model and problem
IFishboneDiagramModel causeAndEffect = IModelElementFactory.instance().createFishboneDiagramModel();
causeAndEffectDiagram.setFishboneDiagramModelAddress(causeAndEffect.getAddress());
//Specify the potential problem
causeAndEffect.setProblem("Difficulty on Locating a Drawing");

Create Categories

Once the model is created, we are ready to create some categories using IModelElementFactory. You will need to use IFishboneCategory.setPosition() to place the category either on the top or on the bottom of the diagram, or it will be placed on the top by default.

//Create Categories
IFishboneCategory man = causeAndEffect.createFishboneCategory();
man.setName("Man");
//Place the category on the top
man.setPosition(IFishboneCategory.POSITION_TOP);
//Add the category to the diagram
causeAndEffect.addCategory(man);

Create Primary Causes

After the categories are added, you can then create the primary causes using IModelElementFactory.

//Create primary causes for category man
IFishboneCause notAdequatelyInformed = IModelElementFactory.instance().createFishboneCause();
notAdequatelyInformed.setName("Library workers aren't \nadequately informed");
//Add the primary cause to the category
man.addCause(notAdequatelyInformed);

Create Secondary Causes

Every secondary causes is treated as a child of a primary cause, so it can be created using method IFishboneCause.createFishboneCause().

//Create secondary causes for filling cabinets
IFishboneCause drawingToHigh = fillingCabinets.createFishboneCause();
drawingToHigh.setName("Drawings are put too \nhigh on cabinets");
//Add secondary cause to the primary cause
fillingCabinets.addSubCause(drawingToHigh);

Show up Diagram

Finally, show up the diagram.

//Show up the diagram
diagramManager.openDiagram(causeAndEffectDiagram);

Sample Plugin

The sample plugin demonstrate how to create cause and effect diagram 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.

Sample Plugin Download

You can download the sample plugin here.

Related Know-how

Related Link

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply