========================================================================== Our ``uml.py`` diagram tool basics for dummies ========================================================================== :Author: Asko Soukka :Date: 2002-12-03 Some basics to create diagrams with ``uml.py`` tool. General ======= There should be two different files for every diagram. One with ``.uml`` and an another with ``.mp`` extension. Although, both of the files should have a same name (*prefix*). The ``.uml`` file is for the semantics of the diagram and the ``.mp`` file is for the layout. When running ``uml.py`` the prefix of the diagram files is the only argument given. Filename examples:: diagram.uml diagram.mp The ``MPINPUT`` environment variable must be set, when running ``uml.py``. ``MPINPUT`` should point from the current directory to the directory, where ``umlhelper.py`` is located. Running example:: MPINPUTS=../../metacode python ../../metacode/uml.py diagram Finally, the font file ``Helvetica.tfm`` must exist in the current directory. Examples ======== **NOTE:** Following diagrams probably don't make semantically any sence :) Their only meaning is to show how to use many features of ``uml.py``. --------------- Package example --------------- ``packages.uml`` ---------------- :: bigpackage Package #big package object package First #normal package object inside the big package jlink #links object to classes.html containing more detailed classes.html #diagram of this package, linked objedct is #colored blue package Second use First #association: Second uses First ``packages.mp`` --------------- :: horizontally(50, h, First, Second); # draws packages First and Second # horizontally next to each other # using 50px padding # # 'h' is key to indentify this draw pad = 30; # resizes the big package object Package.nw = First.nw + (-pad,pad); # to cover both inner packages with Package.se = Second.se + (pad,-pad);# 30px padding on edges Output ------ .. image:: packages.png ------------- Class example ------------- ``classes.uml`` --------------- :: jlinkpackage Package.First # Defines where the following classes # belong to. Jlink uses this information # to link right (java)doc files into class # objects. class Interface "interface" # Discriminates interface class from # other classes jlink # Bare jlink links class to its # documentation (javadoc). methods # Defines methods for this class. void first() class Derived "interface" jlink inherit Interface # Inheritance. methods void second() class Abstract "abstract" jlink methods void third() void fourth() class Implementation jlink realize Derived # Realization ~ implements # an abstract class or interface. realize Abstract # The ollowing creates a composite association with a role # description, association can be created also without # 'compos', 'role' or even without 'multi' attributes. assoc compos multi(1) - multi(*) role(part_of) Component class Component jlink ``classes.mp`` -------------- :: Derived.c = (100, 100) horizontally(50, interface_h, Interface, Derived, Abstract); vertically(50, interface_v, Derived, Implementation); Component.c = (300, 17); horizontally(50, component_h, Component); Output ------ .. image:: classes.png ---------------- Sequence example ---------------- ``sequence.uml`` ---------------- :: seqobject First seqobject Second seqobject Third sequence example call First "call(...)" call Second "call (...)" call Third "call (...)" call Second "callbac(...)" call First "callback(...)" return return return return return ``sequence.mp`` --------------- :: horizontally(100, h, First, Second, Third); Output ------ .. image:: sequence.png