1

I need to draw the red arrow in the figure but I'm not able to.

enter image description here

Here's my code

\documentclass[10pt,a4paper]{toptesi}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{tikz}
\usetikzlibrary{shapes, positioning}
\author{Antonio Santoro}
\begin{document}
\begin{tikzpicture}[ball/.style={ellipse, minimum width=3cm, minimum height=1.5cm, draw},>=latex]

\node[ball] (classeA) {classe A};
\node[ball, right=2.5cm of classeA] (classeB) {classe B};
\node[ball, above right=2cm of classeA] (loaderL) {loader L};
\node[rectangle,draw,minimum width=2cm,minimum height=1cm, right=4cm of loaderL] (bytecode) {bytecode};

\draw[-] (bytecode) -- node[above] {caricamento} (loaderL);
\draw[->] (loaderL) -- (classeB);
\draw[->] (loaderL) -- (classeA);
\draw[->] (classeA) -- node[above] {intercetta} (loaderL-classeB);

\end{tikzpicture}


\end{document}

but it gives me errors.

4

Maybe not the most smart solution, but you can add an empty node to the path between loader L and classe B and then draw the arrow to that node:

enter image description here

\documentclass[10pt,a4paper]{toptesi}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{tikz}
\usetikzlibrary{shapes, positioning}
\author{Antonio Santoro}
\begin{document}

\begin{tikzpicture}[ball/.style={ellipse, minimum width=3cm, minimum height=1.5cm, draw},>=latex]

\node[ball] (classeA) {classe A};
\node[ball, right=2.5cm of classeA] (classeB) {classe B};
\node[ball, above right=2cm of classeA] (loaderL) {loader L};
\node[rectangle,draw,minimum width=2cm,minimum height=1cm, right=4cm of loaderL] (bytecode) {bytecode};

\draw[-] (bytecode) -- node[above] {caricamento} (loaderL);
\draw[->] (loaderL) -- node [midway](LtoB){} (classeB);
\draw[->] (loaderL) -- (classeA);
\draw[->] (classeA) -- node [above,sloped] {intercetta} (LtoB);

\end{tikzpicture}

\end{document}
0

You can define a node in a path like in the visual tikz manual section 7.9. and then draw an arrow usig that point, in this case named M.

enter image description here

\documentclass[border=10pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes, positioning}
\begin{document}
\begin{tikzpicture}[
    ball/.style={
        ellipse,
        minimum width=3cm,
        minimum height=1.5cm,
        draw
    },
    >=latex
]

\node[ball] (classeA) {classe A};
\node[ball, right=2.5cm of classeA] (classeB) {classe B};
\node[ball, above right=2cm of classeA] (loaderL) {loader L};
\node[rectangle,draw,minimum width=2cm,minimum height=1cm, right=4cm of loaderL] (bytecode) {bytecode};

\draw[-] (bytecode) -- node[above] {caricamento} (loaderL);
\draw[->] (loaderL) -- (classeB) node [sloped,midway](M){}; % Declare node in the middle of the path named M
\draw[->] (loaderL) -- (classeA);
\draw[->,red] (classeA) -- (M.center) node[midway,sloped,above]{\sf Label}; %Draw arrow, and put text in a node, declared in the midle again.

\end{tikzpicture}


\end{document}

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.