Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\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.

share|improve this question

2 Answers 2

up vote 4 down vote accepted
+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

share|improve this answer
    
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

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.
share|improve this answer
    
Welcome to TeX.sx! You now have the rep required for posting images so you could revise your answer :-) –  Peter Jansson Apr 29 '13 at 8:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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