如何在 tikz 中绘制元模型?

如何在 tikz 中绘制元模型?

我需要在 tikz 中创建一个绘图来表示某个元模型。创建它的理想方法是什么?

XES 元模型

答案1

在此处输入图片描述

这应该足以让你开始:

\documentclass[tikz, border=20]{standalone}
\usetikzlibrary{arrows,calc,shapes}
\begin{document}        
    \begin{tikzpicture}
        \tikzset{dark box/.style={draw,fill=gray!80,rounded corners, minimum height=0.5cm, minimum width=2cm}}
        \tikzset{oval/.style={draw,fill=gray!80,ellipse,minimum height=0.5cm, minimum width=2cm}}
        
        % Main nodes
        \node[dark box] (string) {String};
        \node[dark box, below=0.4cm] (date) at (string) {Date};
        \node[dark box, below=0.4cm] (int) at (date) {Int};
        \node[dark box, below=0.4cm] (float) at (int) {Float};
        \node[dark box, below=0.4cm] (boolean) at (float) {Boolean};
        
        % Left arrows
        \draw[<->, >=open diamond] (string.east) --++(0.5, 0) -- ++(0, -0.65) -- (date.east);
        \draw[->, >=open diamond] (date.east) ++(0.5, 0) -- ++(0, -0.65) -- (int.east);
        \draw[->, >=open diamond] (int.east) ++(0.5, 0) -- ++(0, -0.65) -- (float.east);
        \draw[->, >=open diamond] (float.east) ++(0.5, 0) -- ++(0, -0.65) -- (boolean.east);
        % Right arrows
        \draw[->, >=open triangle 90] (string.west) -- ++(-0.5, 0) -- ++(0, 0.5);
        \draw (boolean.west) -- ++(-0.5, 0) -- ++(0, 2.7);
        \draw (date.west) -- ++(-0.5, 0);
        \draw (int.west) -- ++(-0.5, 0);
        \draw (float.west) -- ++(-0.5, 0);
        
        % Value node
        \node[oval] (value) at ($(float) + (3,0)$) {Value};
        \draw (value.west) -- ($(float.east) + (0.5, 0)$);
        
        % Attribute node
        \node[draw, dashed, fill=gray!80, rounded corners, minimum width=2cm, minimum height=1cm]  (attribute) at ($(string) + (-1.5, 1)$) {Attribute};
    \end{tikzpicture}
\end{document}

相关内容