summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/metauml/metauml_links.mp
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-07-15 21:07:44 +0000
committerKarl Berry <karl@freefriends.org>2006-07-15 21:07:44 +0000
commitaddfc6cb8f4f70fdc76a72cb6338bd0c69c4c4c3 (patch)
tree9df3d1ec788caf8f5a848d259f44cfbafa7ad717 /Master/texmf-dist/metapost/metauml/metauml_links.mp
parent9599b464aebb35b4a1bc3bf70a4cd2740f3765f7 (diff)
new metapost package metauml (21mar06)
git-svn-id: svn://tug.org/texlive/trunk@1851 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost/metauml/metauml_links.mp')
-rw-r--r--Master/texmf-dist/metapost/metauml/metauml_links.mp100
1 files changed, 100 insertions, 0 deletions
diff --git a/Master/texmf-dist/metapost/metauml/metauml_links.mp b/Master/texmf-dist/metapost/metauml/metauml_links.mp
new file mode 100644
index 00000000000..3b54368012b
--- /dev/null
+++ b/Master/texmf-dist/metapost/metauml/metauml_links.mp
@@ -0,0 +1,100 @@
+% MetaUML, a MetaPost library for typesetting exquisite UML diagrams.
+% Copyright (C) 2005 Ovidiu Gheorghies
+%
+% This program is free software; you can redistribute it and/or
+% modify it under the terms of the GNU General Public License
+% as published by the Free Software Foundation; either version 2
+% of the License, or (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program; if not, write to the Free Software
+% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+% A LinkStructure is used to compute the relevant elements
+% of a link, such as what is the main path of the link and
+% where the link ends are to be drawn.
+%
+% For example, for a unidirectional aggregation between points
+% A and B one must reserve some space for one diamond to the left and one arrow
+% to the right, and draw the continous line on a segment shorter than AB.
+%
+
+if known _metauml_links_mp:
+ expandafter endinput
+fi;
+_metauml_links_mp:=1;
+
+vardef LinkStructure@#(expr my_path, widthA, widthB) =
+ pair @#pointA, @#pointB, @#pointAc, @#pointBc;
+ path @#circleA, @#circleB;
+ numeric @#timeA, @#timeB;
+ path @#actualPath;
+
+ @#pointA = point 0 of my_path;
+ @#pointB = point infinity of my_path;
+
+ @#circleA = fullcircle scaled widthA shifted @#pointA;
+ @#circleB = fullcircle scaled widthB shifted @#pointB;
+
+ @#timeA = xpart (my_path intersectiontimes @#circleA);
+ @#timeB = xpart (my_path intersectiontimes @#circleB);
+ @#pointAc = point @#timeA of my_path;
+ @#pointBc = point @#timeB of my_path;
+
+ @#actualPath = subpath (@#timeA, @#timeB) of my_path;
+enddef;
+
+% Used for visual debugging purposes
+%
+vardef describeLinkStructure(text linkStruct)=
+ %draw linkStruct.pointA -- linkStruct.pointB withpen pencircle scaled 2 withcolor green;
+
+ draw linkStruct.circleA;
+ draw linkStruct.circleB;
+
+ dotlabel.lft("A", linkStruct.pointA);
+ dotlabel.rt ("B", linkStruct.pointB);
+
+ dotlabel.urt("A1", linkStruct.pointAc);
+ dotlabel.ulft("B1", linkStruct.pointBc);
+
+ draw linkStruct.actualPath withcolor red;
+enddef;
+
+% Draws the path using graphical elements specified by iLink
+% using the landmark points computed in the LinkStructure
+% linkStruct.
+%
+vardef drawLinkStructure(text linkStruct)(text iLink) =
+ scantokens(iLink.drawMethod)(linkStruct.actualPath);
+
+ scantokens(iLink.drawMethodA)(linkStruct.pointAc)(linkStruct.pointA)(iLink.heightA);
+ scantokens(iLink.drawMethodB)(linkStruct.pointBc)(linkStruct.pointB)(iLink.heightB);
+enddef;
+
+vardef LinkInfo@# =
+ numeric @#widthA, @#heightA;
+ string @#drawMethodA;
+
+ numeric @#widthB, @#heightB;
+ string @#drawMethodB;
+
+ string @#drawMethod;
+enddef;
+
+% Draws a link using the given path as support.
+%
+vardef link(text iLink)(expr myPath)=
+ LinkStructure.ls(myPath, iLink.widthA, iLink.widthB);
+ drawLinkStructure(ls)(iLink);
+enddef;
+
+% Draws a direct link between the center of the objects.
+vardef clink(text iLink)(suffix objectA, objectB)=
+ link(iLink)(pathCut(objectA, objectB)(objectA.c--objectB.c));
+enddef;