metauml:实现链接不起作用

metauml:实现链接不起作用
\documentclass{article}
\usepackage[shellescape]{gmp}
\begin{document}
\begin{figure}
\begin{mpost}[use]
input metauml;

Interface.A("Interface")
       ();

A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;

Class.B("Class")
       ()
       ();       

A.w = B.e + (50, 0);

drawObjects(A, B);

clink(association)(B, A);
\end{mpost}
\caption{association}
\end{figure}

\begin{figure}
\begin{mpost}[use]
input metauml;

Interface.A("Interface")
       ();

A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;

Class.B("Class")
       ()
       ();       

A.w = B.e + (50, 0);

drawObjects(A, B);

clink(associationUni)(B, A);
\end{mpost}
\caption{associationUni}
\end{figure}

\begin{figure}
\begin{mpost}[use]
input metauml;

Interface.A("Interface")
       ();

A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;

Class.B("Class")
       ()
       ();       

A.w = B.e + (50, 0);

drawObjects(A, B);

clink(inheritance)(B, A);
\end{mpost}
\caption{inheritance}
\end{figure}

\begin{figure}
\begin{mpost}[use]
input metauml;

Interface.A("Interface")
       ();

A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;

Class.B("Class")
       ()
       ();       

A.w = B.e + (50, 0);

drawObjects(A, B);

clink(realization)(B, A);
\end{mpost}
\caption{realization}
\end{figure}

\begin{figure}
\begin{mpost}[use]
input metauml;

Interface.A("Interface")
       ();

A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;

Class.B("Class")
       ()
       ();       

A.w = B.e + (50, 0);

drawObjects(A, B);

clink(aggregation)(B, A);
\end{mpost}
\caption{aggregation}
\end{figure}

\begin{figure}
\begin{mpost}[use]
input metauml;

Interface.A("Interface")
       ();

A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;

Class.B("Class")
       ()
       ();       

A.w = B.e + (50, 0);

drawObjects(A, B);

clink(aggregationUni)(B, A);
\end{mpost}
\caption{aggregationUni}
\end{figure}

\begin{figure}
\begin{mpost}[use]
input metauml;

Interface.A("Interface")
       ();

A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;

Class.B("Class")
       ()
       ();       

A.w = B.e + (50, 0);

drawObjects(A, B);

clink(composition)(B, A);
\end{mpost}
\caption{composition}
\end{figure}

\begin{figure}
\begin{mpost}[use]
input metauml;

Interface.A("Interface")
       ();

A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;

Class.B("Class")
       ()
       ();       

A.w = B.e + (50, 0);

drawObjects(A, B);

clink(compositionUni)(B, A);
\end{mpost}
\caption{compositionUni}
\end{figure}

\begin{figure}
\begin{mpost}[use]
input metauml;

Interface.A("Interface")
       ();

A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;

Class.B("Class")
       ()
       ();       

A.w = B.e + (50, 0);

drawObjects(A, B);

clink(dependency)(B, A);
\end{mpost}
\caption{dependency}
\end{figure}
\end{document}

此示例显示了类/接口之间的所有可能链接,如 metauml 第 9 页所述文档

所有链接均正确显示,除了一个。它是“实现”。该链接未显示。

现在看起来像这样:

类

如何修复?

我使用 MetaPost,版本 1.504(MiKTeX 2.9)

这是我编译 egreg 的解决方案时得到的结果:

在此处输入图片描述

这里您可以从 metapost 中找到尝试生成实现链接的日志。

编辑:

我发现我的版本早于 0.2.4,因为该文件C:\Program Files (x86)\MiKTeX 2.9\metapost\generic\metauml\metauml_class_relations.mp不包含 的定义realization。实现支持是在 0.2.4 中添加的。

我只做了一件事。我下载了最新版本并替换了 中的每个文件C:\Program Files (x86)\MiKTeX 2.9\metapost\generic\metauml。这造成了“一点”麻烦。
日志 ( tmp+mp000X.log) 表示:

! I can't open file `metauml_component'.
l.77 input metauml_component
                            ;
Please type another input file name
! Emergency stop.
l.77 input metauml_component
                            ;
*** (job aborted, file error in nonstop mode)

我检查后发现文件确实存在。我下一步该怎么做?

答案1

这是输入 Metapost 片段的正确方法:

\documentclass{article}
\usepackage[shellescape]{gmp}
\begin{document}

\begin{mpost}[use,mpsettings={input metauml;}]
Interface.A("Interface")
       ();
A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;
Class.B("Class")
       ()
       ();       
A.w = B.e + (50, 0);
drawObjects(A, B);
clink(association)(B, A);
\end{mpost}

\begin{mpost}[use,mpsettings={input metauml;}]

Interface.A("Interface")
       ();

A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;

Class.B("Class")
       ()
       ();       

A.w = B.e + (50, 0);

drawObjects(A, B);

clink(associationUni)(B, A);
\end{mpost}

\begin{mpost}[use,mpsettings={input metauml;}]

Interface.A("Interface")
       ();

A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;

Class.B("Class")
       ()
       ();       

A.w = B.e + (50, 0);

drawObjects(A, B);

clink(inheritance)(B, A);
\end{mpost}

\begin{mpost}[use,mpsettings={input metauml;}]

Interface.A("Interface")
       ();

A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;

Class.B("Class")
       ()
       ();       

A.w = B.e + (50, 0);

drawObjects(A, B);

clink(realization)(B, A);
\end{mpost}

\begin{mpost}[use,mpsettings={input metauml;}]

Interface.A("Interface")
       ();

A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;

Class.B("Class")
       ()
       ();       

A.w = B.e + (50, 0);

drawObjects(A, B);

clink(aggregation)(B, A);
\end{mpost}

\begin{mpost}[use,mpsettings={input metauml;}]

Interface.A("Interface")
       ();

A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;

Class.B("Class")
       ()
       ();       

A.w = B.e + (50, 0);

drawObjects(A, B);

clink(aggregationUni)(B, A);
\end{mpost}

\begin{mpost}[use,mpsettings={input metauml;}]

Interface.A("Interface")
       ();

A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;

Class.B("Class")
       ()
       ();       

A.w = B.e + (50, 0);

drawObjects(A, B);

clink(composition)(B, A);
\end{mpost}

\begin{mpost}[use,mpsettings={input metauml;}]

Interface.A("Interface")
       ();

A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;

Class.B("Class")
       ()
       ();       

A.w = B.e + (50, 0);

drawObjects(A, B);

clink(compositionUni)(B, A);
\end{mpost}

\begin{mpost}[use,mpsettings={input metauml;}]

Interface.A("Interface")
       ();

A.info.iAttributeStack.top := 0;
A.info.iAttributeStack.bottom := 0;

Class.B("Class")
       ()
       ();       

A.w = B.e + (50, 0);

drawObjects(A, B);

clink(dependency)(B, A);
\end{mpost}

\end{document}

我省略了不必要的标题和figure环境。这就是结果。

在此处输入图片描述

检查 MetaUML 包的版本。版本 0.2.5 可用:参见

<texroot>/doc/metapost/metauml/README

检查版本号。使用您的包管理器(MiKTeX 或tlmgrTeX Live)进行更新。

相关内容