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.

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

  • OK, thanks for the tip. But this is not an answer to my question. – Ichibann Aug 22 '12 at 6:03
  • OK, this works. It is not an underlined text but looks good :) – Ichibann Aug 22 '12 at 15:58
  • Is it possible to add "true" underline? – Ichibann Aug 22 '12 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.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.