ModSL
Text-to-diagram UML sketching tool
The goal of the project is to build a platform-independent UML modeling library for text-to-diagram translation. The domain-specific scripting language used by the core library is designed for simplicity of diagram sketching. The rendering engine produces an image object which can be saved or returned as a PNG or JPEG file.
Philosophy behind declarative diagram sketching
ModSL addresses several shortcomings in the conventional mouse-click-to-diagram approach:
- Existing visual tools do not allow proper version control/change management for diagrams. Yes, you can store the binary document as a blob in repository but there's no way to find the differences between versions of that document. Even if you happen to use a tool which stores the diagrams in a text format, the text files generated by those tools are usually too cryptic to allow any meaningful diff analysis or merge process.
- Difficulty of embedding diagrams into documents, especially if you happen to use wiki as your document repository. Create/update diagram in an external tool, convert to image, upload, replace old version, rinse, repeat. Too much hassle, especially for the initial stages of your project life cycle, when your understanding of the problem area, as well as documentation, change very quickly.
- There are several aspects of the visual diagram layout which could be automated, but the existing visual tools rarely provide an adequate set of controls around it. For instance, detecting the natural "flow" of the diagram ("sources"/superclasses bubbling up and "sinks"/subclasses sinking down) or laying out related elements closely together (clustering).
ModSL library is trying to address these issues by being able to process a simple scripting language and automatically lay out and render the resulting diagram image.
ModSL allows you to add diagramming capabilities to any inherently "text-only" environment, such as wiki or a text editor (as a plugin). This allows you to edit your diagrams inline in wiki pages and have complete access to their change history.
Samples
| Class Diagram | Collaboration Diagram |
| |
Class diagram input:
class diagram Sample {
abstract class AbstractElement {
name; parent; type;
abstract accept(AbstractVisitor);
}
abstract class AbstractBox extends AbstractElement {
pos; disp; size;
}
class Edge extends AbstractElement {
labels; bends; node1; node2;
}
class Bend extends AbstractBox {}
class Graph extends AbstractBox {
reqSize; labels;
1->*(Edge);
1->*(Node);
}
class Node extends AbstractBox {
connectedEdges; labels;
}
}Collaboration diagram input:
collaboration diagram Sample {
Main->Lexer.tokenize();
Main->Parser.parse();
Main->GraphLayout.apply();
GraphLayout->SugiyamaLayout.apply();
GraphLayout->NodeLabelLayout.apply();
GraphLayout->EdgeLabelLayout.apply();
Main->RenderVisitor.apply(graph);
RenderVisitor->Graph.visit();
}