4
\documentclass{article}
\usepackage[shellescape]{gmp}
\begin{document}
\begin{figure}
\begin{mpost}[use]
input metauml;

Class.A("A")
       ("-instance: A")
       ("-A()",
        "+instance(): A");

drawObjects(A);
\end{mpost}
\caption{Class \texttt{A} as a singleton}
\label{fig:uml-a}
\end{figure}
\end{document}

How can I make +instance(): A underlined to mark it as a static method?

Is it possible to disable converting + and - to graphics ?

Egreg's solution below works but is there any way to draw "true" underline? For example if I add something below underlined part I would have to move line maually. I want to avoid this.

0

3 Answers 3

4
+100

You should use mpsettings={input metauml;}; then you can use Metapost for drawing a line.

\documentclass{article}
\usepackage[shellescape]{gmp}
\begin{document}
\begin{figure}
\begin{mpost}[use,mpsettings={input metauml;}]

Class.A("A")
       ("-instance: A")
       ("-A()",
        "+instance(): A");

drawObjects(A);

draw A.sw+(13,1.5) -- A.se+(-4,1.5);

\end{mpost}
\caption{Class \texttt{A} as a singleton}
\label{fig:uml-a}
\end{figure}
\end{document}

enter image description here

In order to change the + and - to something else than the default, one should study in detail the source metauml.mp

3
  • OK, thanks for the tip. But this is not an answer to my question.
    – Ichibann
    Commented Aug 22, 2012 at 6:03
  • OK, this works. It is not an underlined text but looks good :)
    – Ichibann
    Commented Aug 22, 2012 at 15:58
  • Is it possible to add "true" underline?
    – Ichibann
    Commented Aug 22, 2012 at 20:16
3

Idea in drawing line under "attribute" label. (reputation killed image)

+---------------------+
|      Singleton      |
+---------------------+
| -  static Instance  |
|   ----------------- |
+---------------------+
|                     |
+---------------------+

This is variation on egreg 's answer. It is possible that more accurate answer exist...

input metauml;

beginfig(1);
    Class.SingletonLite("Singleton")("- static Instance")();

    drawObject(SingletonLite);

    draw SingletonLite.attributeStack.pict[0].sw -- SingletonLite.attributeStack.pict[0].se ;
endfig;

end.
1
  • Welcome to TeX.sx! You now have the rep required for posting images so you could revise your answer :-) Commented Apr 29, 2013 at 8:56
0

The following suggestions work with the code in the master branch of MetaUML, but not with MetaUML 0.2.5.

It is possible to explicitly mark class features as abstract or static:

metaUML class diagram: set some methods as abstract in an abstract class

Text can be underlined as follows:

Picture.a("foo");
a.info.textDecoration := "underline";

The use of locks as visibility markers has been discontinued in favour of the standard UML notation.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .