Uml.Sty, a Package for Writing UML Diagrams in LATEX
Total Page:16
File Type:pdf, Size:1020Kb
uml.sty, a package for writing UML diagrams in LATEX Ellef Fange Gjelstad March 17, 2010 Contents 1 Syntax for all the commands 5 1.1 Lengths ........................................ 5 1.2 Angles......................................... 5 1.3 Nodenames...................................... 6 1.4 Referencepoints ................................. 6 1.5 Colors ......................................... 6 1.6 Linestyles...................................... 6 2 uml.sty options 6 2.1 debug ......................................... 6 2.2 index.......................................... 6 3 Object-oriented approach 7 3.1 Colors ......................................... 10 3.2 Positions....................................... 10 4 Drawable 12 4.1 Namedoptions .................................... 12 4.1.1 import..................................... 12 5 Element 12 5.1 Namedoptions .................................... 12 5.1.1 Reference ................................... 12 5.1.2 Stereotype................................... 12 5.1.3 Subof ..................................... 13 5.1.4 ImportedFrom ................................ 13 5.1.5 Comment ................................... 13 6 Box 13 6.1 Namedoptionsconcerninglocation . ....... 13 6.2 Boxesintext ..................................... 14 6.3 Named options concerning visual appearance . ......... 14 6.3.1 grayness.................................... 14 6.3.2 border..................................... 14 1 6.3.3 borderLine .................................. 14 6.3.4 innerBorder.................................. 14 6.4 Namedoptionsconcerningsize . ..... 14 7 Diagram 15 7.1 Example........................................ 15 8 Stretchbox 15 8.1 Name,graphicalNameandreference . ...... 16 9 Classifier 16 10 Compartment 16 10.1Suppression .................................... 16 10.2Name ......................................... 17 11 Compartmentline 17 12 Feature 17 12.0.1 visibility................................... 17 12.0.2 type ...................................... 17 12.0.3 propertyString ............................... 17 13 Method 17 14 Attribute 18 15 Argument 18 16 Class 18 17 Schema 18 17.1Example(Stack) ................................. 20 18 Relation 20 18.1 Appearanceoftheconnector . ..... 22 18.2 Geometryoftheconnector. ..... 22 18.3 Referenceandplacementofnodes. ....... 22 19 AssociationEnd 23 19.1 Placingofthesymbol ............................. 23 20 Label 24 21 Symbol 24 22 Navigability 24 2 23 The different relations 24 23.0.1 Association .................................. 25 23.0.2 Subclass(generalization). ...... 25 23.0.3 Innerclass................................... 25 23.0.4 Instance.................................... 25 23.0.5 Aggregation.................................. 25 23.0.6 Composition ................................. 25 23.0.7 Application .................................. 25 23.1 RelationstoRelations . ..... 26 23.1.1 AssociationClass . 26 23.1.2 ArgumentRelation . 26 24 Package 28 24.1Example........................................ 29 24.2 Connectingpackages . .... 30 25 Colors 30 25.1Colorset....................................... 30 25.2 Usingthecolorsets.............................. .... 31 26 Positions 31 26.1PlaceNode...................................... 31 26.2Coordinates.................................... 32 26.2.1 Coordinatecommands . 32 27 A large example (Abstract Data Structures) 33 28 Typesetting the implementation 38 28.1 Thedocumentationdriverfile . ...... 39 29 Introductory code 39 29.1Identification .................................. 39 29.2 Processingofoptions. ..... 39 29.2.1 debug ..................................... 39 29.2.2 index ..................................... 39 29.2.3 Processingtheoptions . 40 29.3 Usingotherpackages. .... 40 30 General syntax 40 30.1Lengths ........................................ 40 30.2Angles......................................... 40 31 Drawable 40 31.1Namedoptions ................................... 41 31.2Colors ......................................... 41 31.3Thecommand..................................... 41 32 Element 42 3 33 Box 42 33.1Positioning .................................... 42 33.2Boxesintext .................................... 44 33.3 Thevisualappeareance . .... 44 33.4Size .......................................... 45 33.5 Holding together all the named options . ......... 45 33.6Thecommand..................................... 45 34 Diagram 46 34.1Thecommand..................................... 46 35 Stretchbox 47 36 Package 47 37 Classifier 48 38 Class 49 39 Schema 49 40 Compartment 50 40.1Suppression .................................... 50 40.2 Compartmentnames ............................... 51 40.3 Theimplementation . .. .. .. .. .. .. .. .. .. .. .. .. 51 41 Compartmentline 52 42 Feature 52 42.1Attribute ...................................... 53 42.2Method ........................................ 54 42.3Argument ....................................... 54 43 Relation 55 43.1 Nodeconnectionpoints . .... 55 43.2Armgeometry .................................... 55 43.3 Visualappeareance.. .. .. .. .. .. .. .. .. .. .. .. .. .... 56 43.4Themacro....................................... 56 43.5 Aboutthespesificrelations . ...... 57 43.6Association .................................... 58 43.7 Subclass(generalization). ........ 58 43.8Innerclass..................................... 58 43.9Instance....................................... 60 43.10Aggregation................................... 60 43.11Composition................................... 60 43.12Application ................................... 61 43.13ToRelation .................................... 61 43.14AssociationClass and AssociationSchema . ............ 61 4 43.15ArgumentRelation . .... 62 44 AssociationEnd 62 44.1Fraction....................................... 63 44.2Thecommand..................................... 64 44.3Label ......................................... 64 44.4Symbol ........................................ 64 44.5Navigability................................... 65 45 Colors 65 45.1Colorset....................................... 65 45.2Usingcolorsets................................. 66 46 Positions 67 46.1PlaceNode...................................... 67 1 Syntax for all the commands Most of the commands in uml.sty have the syntax \umlhConstructi[hNamed optionsi]hArgumentsi. hConstructi can be Diagram, Class, Method or other things. hNamed optionsi is a comma-separated list of hkeyi=hvaluei pairs. This is implemented by keyval.sty. The entire [hNamed optionsi] part is optional. In this documentation, the = often is replaced with a . This is due to an error in the index generation process, which does not accept. hArgumentsi a number of arguments, typically enclosed in brackets ({}). Typical arguments are a name and some interior of a box. 1.1 Lengths Legal lengths are all PSTricks lengths, including TEX lengths. In PSTricks lengths, the unit is optional; if no unit is present, the current PSTricks unit is used. 1.2 Angles We distinguish between angles and rotations. An angle should be a number giving the angle in degrees, by default. You can also change the units used for angles with the PSTricks \degrees[num] command. A rotation also expresses a direction, but can have different syntax forms: An angle i.e. a number An angle preceded by an asterisk This means the angle is to be interpreted absolute (rel- ative to the page) and not to the underling text direction. This is useful when getting a relation label right up, not in the direction of the relation 5 A letter One of letter Short for Equiv. to letter Short for Equiv. to U Up 0 N North *0 L Left 90 W West *90 D Down 180 S South *180 R Right 270 E East *270 When rotating along lines e.g. relations, you can precede an angle or one of ULDR with a colon. This is to orientate the text relative to the line. This is useful when getting a relation along the relation, not right up. 1.3 Node names A node name is a name of a location on the page. Such a name must contain only letters and numbers, and must begin with a letter. Also, the node names should be unique (at least, to the page). Node names are typically placed by means of the reference named option, but could be placed using any PSTricks node command. 1.4 Reference points A reference point is the point in a box which is to be placed. E.g., if the reference point is tl, meaning top left, the top left corner is placed relative to whatever. A reference point can be any of l (left), r (right), t (top), b (bottom) or B (baseline) or reasonable combinations of them. 1.5 Colors This is as in PSTricks. E.g., you can say \red Red gives Red and use the color red as linecolor or fillcolor. See also section 25 on page 30. 1.6 Line styles As in PSTricks, e.g., solid, dashed, dotted or none. 2 uml.sty options 2.1 debug 2.2 index By default, every named uml.sty construct (e.g., each Class and Attribute) makes an en- try in the index of the form hnamei!htypei. This feature can be turned off with the option \umlIndexOn noindex or on with index. The feature can also be turned on with \umlIndexOn and off with \umlIndexOff \umlIndexOff. Tip: It is possible to change the index entry format by changing \umlIndex. \umlIndex should take two arguments: The name and the type. E.g., \renewcommand\umlIndex[2]{\index{#1 (#2)}}. 6 3 Object-oriented approach A When making an uml package for LTEX, it seems natural to do the programming object- A oriented. While LTEX has no direct support for object-oriented programming, it can be simulated