Diagrams & views
Everything in the Creating a model chapter was abstract syntax — the model's meaning, independent of how it's drawn. This chapter is about concrete syntax: the boxes, lines, and positions that depict a model on a canvas.
A model and its diagrams are deliberately decoupled. The same Person class
can appear in three diagrams, at three positions, or in none at all — its
meaning doesn't change. A diagram never owns model elements; it only holds
views that point at them. This separation is why you can build a complete,
valid, serializable model without ever creating a diagram.
The object model
Three kinds of object make up the concrete syntax:
- Diagram — a named canvas. Diagrams belong to the project (not to a package), and a project may have any number of them.
- View — a depiction of one model element on a diagram: a
ClassViewfor a class, aBinaryRelationViewfor a relation, aGeneralizationView, aNoteView, and so on. A view wraps itselementand carries the shapes that draw it. - Shape — the geometry: a
Rectangle(with position, width, height) for a class or package box, aPath(a list ofPoints) for a connector, aTextbox for a note, aDiamondfor an n-ary relation's hub.
So a diagram has views, and each view has one or more shapes. You lay out a diagram by adding views and then positioning their shapes.
How this chapter is organized
- Creating a diagram — make a canvas and drop class views onto it.
- Positioning views — move and size the shapes behind those views.
- Connecting elements — relation and generalization views, and the paths that route them.
- Notes & packages — the views that aren't created for you.
- A complete diagram — lay out a whole model end to end, then serialize it.
Because views only refer to model elements, deleting a view removes the depiction and leaves the element untouched. Deleting the element, on the other hand, cleans up every view of it across all diagrams.
Start with Creating a diagram →.