Drawio

Nasdankia provides two Maven modules for working with Drawio diagrams - API and Model. The modules require Java 17 or above.

API

Drawio module provides Java API for reading and manipulating Drawio diagrams. It is built on top of Graph.

The module provides the following interfaces representing elements of a diagram file:

  • Document - the root object of the API representing a file/resource which contains one or more pages.
  • Page - a page containing a diagram (Model).
  • Model - a diagram model containing the diagram root.
  • Root - the root of the model containing layers.
  • Layer - a diagram may have one or more layers. Layers contain Nodes and Connections.
  • Node - a node can be connected to other nodes with connections. A node may contain other nodes and connections.
  • Connection - a connection between two nodes.

The below diagram shows relationships between the above interfaces including their super-interfaces:

Util provides utility methods such as layout() and methods to navigate and query documents and their elements.

Executable diagrams

With Nasdanika Drawio API and other products you can make your diagrams executable. There are two primary methods:

  • Creating graph element processors for diagram elements
  • Mapping diagrams to a semantic model and then making the model executable, possibly using graph processors

The first option requires less coding, the second is more flexible.

Executable (computational) graphs & diagrams story provides a high level overview of executable graphs and diagrams. Graph documentation features more technical details and code samples. Beyond Diagrams book explains the mapping approach. And Compute Graph Demo provides examples of the both approaches using the compute graph from the “Executable (computational) graphs & diagrams” story.

Model

Drawio Model module provides an EMF Ecore model for diagrams. A model instance can be obtained from the API document by calling Document.toModelDocument() method.

The model makes it more convenient to work with the diagram elements by:

  • Making a reference between pages and model elements bi-directional.
  • Introducing Tag class as opposed to a string in the API. Tag is contained by Page and has bi-directional reference with tagged elements.
  • Sources

  • JavaDoc