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.

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.