![Tkiz:绘制属性语法的依赖图](https://linux22.com/image/464611/Tkiz%EF%BC%9A%E7%BB%98%E5%88%B6%E5%B1%9E%E6%80%A7%E8%AF%AD%E6%B3%95%E7%9A%84%E4%BE%9D%E8%B5%96%E5%9B%BE.png)
我正在尝试绘制这个,但我不确定它是否可在 Tkiz 中完成,因为它太复杂了而且我失败了。
该图的理念是,顶部的三角形是至少一个“增强依赖关系图”的开始,底部是子“增强依赖关系图”。正方形或圆圈是至少两个继承(左下正方形)和合成(右上正方形)属性。值从继承属性传到子属性,然后回到合成属性。然后我添加了一个“摘要”边(蓝色),表示我们不需要传到子属性然后再回来,因为我们可以使用摘要边来总结子属性的依赖关系。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
calc, chains,
positioning}
\usetikzlibrary{ext.paths.ortho}
\usetikzlibrary{ext.node-families}
\usetikzlibrary{arrows.meta,
decorations.markings,
positioning
}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[
->-/.style={decoration={markings,% switch on markings
mark=between positions 0 and 1 step 0.4
with {\arrow[thick]{Straight Barb}}
},
postaction={decorate}
}
]
\draw[fill=gray!10] (0,0.0) -- ++ (10, 0) -- ++ (-5,5) -- cycle;
\draw[fill=gray!20, semitransparent]
(0,2) coordinate (A) node[]{}
-- ++ (2,-1) -- ++ (-4,0) -- cycle;
\end{tikzpicture}
\end{figure}
\end{document}
答案1
这里有一种方法可以做到,想想就简单。
尝试模仿你的第一幅草图。不知道这是否是你想要的。还有很多调整和微调的空间。
\documentclass[10pt,border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta} % for shape or arrow tips
\begin{document}
\begin{tikzpicture}
[arr/.style={> = {Stealth}}]% replace standard arrow tip
% ~~~ coordinates for the triangles ~~~~~~~~~~
\coordinate (A) at (0,0);
\coordinate (B) at (3,0);
\coordinate (C) at (1,2.5);
\coordinate (c) at (1,1.5);
\coordinate (a) at (-.2,-1);
\coordinate (b) at (2.5, -1);
% ~~~ triangles ~~~~~~~~~
\draw (A) -- (B) -- (C) -- cycle;
\draw (a) -- (c) -- (b);
% ~~~ rectangles ~~~~~~~~~~
\node [draw] (R) at (.8,.4) {};
\node [draw] (S) at (1.12,.6) {};
% ~~~ blue arrow ~~~~~~
% with nicer arrow tip
% using nodes anchors
% bending the blue line
\draw [blue, ->, arr]
(R.south) to [out=290, in=250] (S.south);
% ~~~ red line ~~~~~~~~~~
% use rounded corners, radius 7mm
% draw a path, which runs through the rectangles
\draw [red, ->, arr, rounded corners=7mm]
(1,2) -- (R) -- (.3,-.5) -- (1.7,-.5) -- (S) -- ((1.5, 1.5);
\end{tikzpicture}
\end{document}