DRAKON Editor relies on SQLite to work with files. A .drn file is an SQLite 3.6 database.
DRAKON files are guaranteed to be backward and forward compatible within the major version. For example, DRAKON Editor 1.4 can use files created with DRAKON Editor 1.5 and vice-versa.
No conversion is needed when a new version of DRAKON Editor comes out.
There are free tools that can be used to read and edit SQLite database files, for example SQLite Database Browser.
The SQL script that creates the database is located in scripts/schema.sql. This script does not create the info table (which serves like a file signature).
General information related to the whole file. A record in this table is a property consisting of a key-value pair.
Field | Data type | Description |
key | text, unique | The name of the property. |
value | text | The value of the property. |
Typical content of the info table:
key field | value field | Comment |
type | drakon | This is a DRAKON Editor diagram file. |
version | 5 | The minor version number: 1.5 |
start_version | 1 | The major version number: 1.5 |
language | c++ | The diagrams in this file can be used to generate C++ code. |
The list of diagrams.
The diagram coordinate space:
Field | Data type | Description |
diagram_id | integer, unique | The primary key. |
name | text, unique | The name of the diagram. |
origin | text | The position of the left top corner of the diagram viewport in the diagram coordinate space. Used for scrolling. The origin is stored as a tcl list with two elements. The first element is X, the second element is Y. |
description | text | An optional text description of the diagram. |
zoom | double | The visible scale of the diagram in percents. 100 means a one-to-one mapping between the screen space and the diagram space. 200 means the coordinate (10, 20) in the diagram transforms to (20, 40) on the screen. |
Miscellaneous global information.
This table always contains only one row with the field "row" equal to 1.
Field | Data type | Description |
row | integer, unique | Must be equal 1. |
current_dia | integer | The currently visible diagram. A reference to the diagrams table. |
description | text | An optional text description of the whole file. |
Each diagram owns a list of properties in the form of key-value pairs.
Export parameters are stored as diagram properties.
Field | Data type | Description |
diagram_id | integer | References the diagram that owns the property. |
name | text | The name of the property. |
value | text | The value of the property. |
diagram_info table has a composite primary key: diagram_id, name.
Each diagram owns a list of items. An item is an object on the diagram, like an icon or a connector.
Field | Data type | Description |
item_id | integer, unique | The primary key of the item. |
diagram_id | integer | References the diagram that owns the item. |
type | text | The type of the item. For example, action or beginend. |
text | text | The text on the icon. Lines and arrows do not have text. Not all items can have text. |
text2 | text | The secondary text on the icon. For example, the upper text in a shelf item. |
selected | integer | 1 if the item is selectd, 0 otherwise. |
x | integer | The meaning depends on the item type. Usually, it is the X coordinate of the geometric center of the item. |
y | integer | The meaning depends on the item type. Usually, it is the Y coordinate of the geometric center of the item. |
w | integer | The meaning depends on the item type. Usually, it is a half of the width of the item. |
h | integer | The meaning depends on the item type. Usually, it is a half of the height of the item. |
a | integer | The meaning depends on the item type. |
b | integer | The meaning depends on the item type. |
color | text | The color of the item. Format: "fg #000000 bg #aaaa00". fg - foreground and text color bg - background color If empty, the color is set based on the global Editor settings. (See File / Global settings...) |
aux_value | text | Reserved. |
format | text | Reserved. |
Each node in the main tree view control of DRAKON Editor is stored as a record in the tree_nodes table.
There are two kinds of nodes: folder nodes and diagram nodes.
There is a one-to-one link between diagram nodes and diagrams.
Field | Data type | Description |
node_id | integer, unique | The primary key of the node. |
parent | integer | References the node_id of the parent of this node. |
type | text | The type of the node. Can be either folder or item. |
name | text | For folder nodes, this field contains the text of the tree node. For diagram nodes, the text of the node is taken from diagram name. |
diagram_id | integer | For diagram nodes, references the related diagram. |
Items of these types have a similar form based on rectangle:
Field | Data type | Description |
x | integer | The X coordinate of the geometric center of the item. |
y | integer | The Y coordinate of the geometric center of the item. |
w | integer | A half of the width of the item. |
h | integer | A half of the height of the item. |
a | integer | Ignored. |
b | integer | Ignored. |
Items of these types have two text fields:
Field | Data type | Description |
text2 | text | The secondary text. Placed at the upper text field. |
x | integer | The X coordinate of the geometric center of the item. |
y | integer | The Y coordinate of the geometric center of the item. |
w | integer | A half of the width of the item. |
h | integer | A half of the height of the item. |
a | integer | The distance between the top edge and the horizontal line in the middle. |
b | integer | Ignored. |
Horizontal line segments:
Field | Data type | Description |
x | integer | The X coordinate of the left end. |
y | integer | The Y coordinate of the left end. |
w | integer | The distance between the left and right ends. |
h | integer | Ignored. |
a | integer | Line type. See the type codes below. |
b | integer | Ignored. |
The line type is encoded in the a field:
Line type | a |
---|---|
Plain horizontal line | 0 |
Left arrow | 40100 |
Right arrow | 20100 |
Left "transparent" arrow | 40200 |
Right "transparent" arrow | 20200 |
Left paw | 40300 |
Right paw | 20300 |
Parallel | 50100 |
The vertical line.
Vertical line segments:
Field | Data type | Description |
x | integer | The X coordinate of the top end. |
y | integer | The Y coordinate of the top end. |
w | integer | Ignored. |
h | integer | The distance between the top and bottom ends. |
a | integer | Line type. See the type codes below. |
b | integer | Ignored. |
The line type is encoded in the a field:
Line type | a |
---|---|
Plain vertical line | 0 |
Up arrow | 10100 |
Down arrow | 30100 |
Up "transparent" arrow | 10200 |
Down "transparent" arrow | 30200 |
Up paw | 10300 |
Down paw | 30300 |
The arrow with two angles.
Field | Data type | Description |
x | integer | The X coordinate of the top end of the vertical segment. |
y | integer | The Y coordinate of the top end of the vertical segment. |
w | integer | The length of the upper horizontal segment. |
h | integer | The height of the vertical segment. |
a | integer | The length of the lower horizontal segment. |
b | integer | 0 if the arrow points to the left, 1 if to the right. |
The if icon.
Field | Data type | Description |
x | integer | The X coordinate of the geometric center of the item. |
y | integer | The Y coordinate of the geometric center of the item. |
w | integer | A half of the width of the item. |
h | integer | A half of the height of the item. |
a | integer | The length of the horizontal line at the right side. |
b | integer | 0 means the right exit is YES. 1 means the right exit is NO. |
A standalone comment icon.
Field | Data type | Description |
x | integer | The X coordinate of the geometric center of the item. |
y | integer | The Y coordinate of the geometric center of the item. |
w | integer | A half of the width of the item. |
h | integer | A half of the height of the item. |
a | integer | The length of the horizontal line at the side. |
b | integer | 0 if the horizontal line goes out of the left side, 1 if out of the right side. |
The header of a branch.
Field | Data type | Description |
x | integer | The X coordinate of the geometric center of the item. |
y | integer | The Y coordinate of the geometric center of the item. |
w | integer | A half of the width of the item. |
h | integer | A half of the height of the item. |
a | integer | Ignored |
b | integer | 1 if the icon has a cycle mark,
0 if the icon does not have a cycle mark. |
The footer of a branch.
Field | Data type | Description |
x | integer | The X coordinate of the geometric center of the item. |
y | integer | The Y coordinate of the geometric center of the item. |
w | integer | A half of the width of the item. |
h | integer | A half of the height of the item. |
a | integer | Ignored |
b | integer | 1 if the icon has a cycle mark,
0 if the icon does not have a cycle mark. |
Contact: drakon.editor@gmail.com