summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/metauml/metauml_package.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_package.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_package.mp')
-rw-r--r--Master/texmf-dist/metapost/metauml/metauml_package.mp178
1 files changed, 178 insertions, 0 deletions
diff --git a/Master/texmf-dist/metapost/metauml/metauml_package.mp b/Master/texmf-dist/metapost/metauml/metauml_package.mp
new file mode 100644
index 00000000000..a2be4e920c0
--- /dev/null
+++ b/Master/texmf-dist/metapost/metauml/metauml_package.mp
@@ -0,0 +1,178 @@
+% MetaUML, a MetaPost library for typesetting exquisite UML diagrams.
+% Copyright (C) 2006 Radu-George Radulescu, 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.
+
+if known _metauml_package_mp:
+ expandafter endinput
+fi;
+_metauml_package_mp:=1;
+
+input metauml_defaults;
+input util_log;
+
+vardef PackageInfo@#=
+ attributes(@#);
+ var(color) foreColor, borderColor;
+ var(numeric) forceEmptyContent;
+ var(numeric) minimumNameContentsDifference;
+
+ FontInfo.@#iFont(metauml_defaultFont, defaultscale);
+ @#iFont.ignoreNegativeBase := 1;
+
+ PictureInfo.@#iText (2, 2, 2, 2)(@#iFont);
+ PictureStackInfo.@#iNameStack (2, 2, 2, 2)(9)(@#iText);
+ @#iNameStack.iPict.ignoreNegativeBase := 1;
+
+ Margins.@#(2,2,2,2);
+
+ ShadeInfo.@#iShade;
+ @#foreColor := .9white;
+ @#borderColor := black;
+
+ @#forceEmptyContent := 0;
+
+ @#minimumNameContentsDifference := 20;
+
+ GroupInfo.@#iContentsGroup(2, 2, 10, 2);
+enddef;
+
+vardef PackageInfoCopy@#(text src)=
+ log "PackageInfoCopy: Copying package info";
+
+ attributes(@#);
+ var(color) foreColor, borderColor;
+ var(numeric) forceEmptyContent;
+ var(numeric) minimumNameContentsDifference;
+
+ PictureStackInfoCopy.@#iNameStack (src.iNameStack);
+ MarginsCopy.@#(src);
+
+ ShadeInfoCopy.@#iShade(src.iShade);
+ @#foreColor := src.foreColor;
+ @#borderColor := src.borderColor;
+
+ @#forceEmptyContent := src.forceEmptyContent;
+
+ @#minimumNameContentsDifference := src.minimumNameContentsDifference;
+
+ GroupInfoCopy.@#iContentsGroup(src.iContentsGroup);
+enddef;
+
+PackageInfo.iPackage;
+
+vardef Package@#(text contents)(text _subItems)=
+ EPackage.@#(iPackage)(contents)(_subItems);
+enddef;
+
+vardef EPackage@#(text _info)(text contents)(text _subItems)=
+ ObjectEquations(@#);
+ @#className := "Package";
+
+ PackageInfoCopy.@#info(_info);
+
+ numeric @#nLines; @#nLines := 0;
+ string @#lines[];
+% numeric @#nSubItems; @#nSubItems := 0;
+ numeric @#nameInCenter; @#nameInCenter := 0;
+
+ for l=contents:
+ @#lines[@#nLines] := l;
+ @#nLines := @#nLines + 1;
+ endfor;
+
+% for s=_subItems:
+% @#nSubItems := @#nSubItems + 1;
+% endfor;
+
+ EGroup.@#subItems(@#info.iContentsGroup)(_subItems);
+
+ EPictureStack.@#nameStack(@#info.iNameStack)(scantokens listArray(@#lines)(@#nLines))("vcenterbase");
+enddef;
+
+vardef Package_layout@#=
+ if @#layedout = 1:
+ log "Package '" & (str @#) & "' has already been layed out";
+ else:
+ @#layedout := 1;
+ log "Package layout: '" & (str @#) & "'";
+
+ log "Package name layout '" & (str @#) & "'...";
+ PictureStack_layout.@#nameStack;
+ log "SubItems for package layout '" & (str @#) & "'...";
+ Group_layout.@#subItems;
+
+ log "All elements in package '" & (str @#) & "' successfully layed out, integrating...";
+
+ if @#subItems.nObjects = 0:
+ if @#info.forceEmptyContent = 0:
+ @#nameInCenter := 1;
+ fi;
+ fi;
+
+ if @#subItems.width < @#nameStack.width + @#info.minimumNameContentsDifference:
+ @#contentWidth = @#nameStack.width + @#info.minimumNameContentsDifference;
+ else:
+ @#contentWidth = lmax(@#nameStack.width, @#subItems.width);
+ fi;
+
+ if @#nameInCenter = 1:
+ @#height = @#info.top + @#info.bottom + @#nameStack.height;
+ @#width = @#info.left + @#info.right + @#nameStack.width;
+ @#nameStack.sw = @#sw + (@#info.left, @#info.bottom);
+ else:
+ @#nameStack.sw = @#nw;
+ @#width = @#contentWidth + @#info.left + @#info.right;
+ @#height = @#info.top + @#info.bottom + @#subItems.height;
+ fi;
+
+ @#subItems.n = @#n + (0, -((@#height - @#subItems.height)/2));
+
+ log "Package layout for " & (str @#) & " ended.";
+ fi;
+enddef;
+
+vardef Package_draw@#=
+ Package_layout.@#;
+ objectEnsurePositioning.@#;
+
+ attributes(@#);
+ var(path) border, nameStackBorder, emptyNameBorder;
+
+ @#border := @#ne -- @#nw -- @#sw -- @#se -- cycle;
+ @#nameStackBorder := @#nameStack.ne -- @#nameStack.nw -- @#nameStack.sw -- @#nameStack.se -- cycle;
+ @#emptyNameBorder := @#nw -- @#nw + (0, 10) -- @#n + (0, 10) -- @#n -- cycle;
+
+ drawObjectShade(@#);
+
+ fill @#border withcolor @#info.foreColor;
+ draw @#border withcolor @#info.borderColor;
+ if @#nameInCenter = 0:
+ fill @#nameStackBorder withcolor @#info.foreColor;
+ draw @#nameStackBorder withcolor @#info.borderColor;
+ else:
+ fill @#emptyNameBorder withcolor @#info.foreColor;
+ draw @#emptyNameBorder withcolor @#info.borderColor;
+ fi;
+
+
+ drawObject(@#nameStack);
+ drawObject(@#subItems);
+
+enddef;
+
+vardef Package_border@#=
+ @#border
+enddef;