diff options
author | Karl Berry <karl@freefriends.org> | 2006-07-15 21:07:44 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-07-15 21:07:44 +0000 |
commit | addfc6cb8f4f70fdc76a72cb6338bd0c69c4c4c3 (patch) | |
tree | 9df3d1ec788caf8f5a848d259f44cfbafa7ad717 /Master/texmf-dist/metapost | |
parent | 9599b464aebb35b4a1bc3bf70a4cd2740f3765f7 (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')
31 files changed, 4302 insertions, 0 deletions
diff --git a/Master/texmf-dist/metapost/metauml/metauml.mp b/Master/texmf-dist/metapost/metauml/metauml.mp new file mode 100644 index 00000000000..6d0b29c86c8 --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml.mp @@ -0,0 +1,60 @@ +% 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. + +if known _metauml_mp: + expandafter endinput +fi; +_metauml_mp:=1; + +input boxes; + +input util_infrastructure; +input util_object; +input util_commons; +input util_margins; +input util_picture; +input util_group; +input util_picture_stack; +input util_positioning; +input util_shade; + +input metauml_base; + +input metauml_links; +input metauml_paths; + +input metauml_note; + +input metauml_stereotype; + +input metauml_class_clipart; +input metauml_class; +input metauml_instance; +input metauml_class_relations; +input metauml_class_assoc; + +input metauml_package; +input metauml_package_relations; + +input metauml_behavioral_common; +input metauml_activity; +input metauml_state; + +input metauml_usecase_clipart; +input metauml_usecase; + +input metauml_templates; diff --git a/Master/texmf-dist/metapost/metauml/metauml_activity.mp b/Master/texmf-dist/metapost/metauml/metauml_activity.mp new file mode 100644 index 00000000000..b5b99f16e86 --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_activity.mp @@ -0,0 +1,231 @@ +% 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. + +if known _metauml_activity_mp: + expandafter endinput +fi; +_metauml_activity_mp:=1; + +input metauml_defaults; +input util_log; + +vardef ActivityInfo@#= + attributes(@#); + var(color) foreColor, borderColor; + + FontInfo.@#iFont(metauml_defaultFont, defaultscale); + @#iFont.ignoreNegativeBase := 1; + + PictureInfo.@#iText (2, 2, 2, 2)(@#iFont); + PictureStackInfo.@#iStack (2, 2, 2, 2)(9)(@#iText); + + @#iStack.iPict.ignoreNegativeBase := 1; + + Margins.@#(2,2,2,2); + + @#fat := 5; + + ShadeInfo.@#iShade; + @#foreColor := .9white; + @#borderColor := black; +enddef; + +vardef ActivityInfoCopy@#(text src)= + log "ActivityInfoCopy: Copying activity info"; + + attributes(@#); + var(color) foreColor, borderColor; + + PictureStackInfoCopy.@#iStack (src.iStack); + MarginsCopy.@#(src); + @#fat := src.fat; + + ShadeInfoCopy.@#iShade(src.iShade); + + @#foreColor := src.foreColor; + @#borderColor := src.borderColor; +enddef; + +ActivityInfo.iActivity; + +vardef Activity@#(text contents)= + EActivity.@#(iActivity)(contents); +enddef; + +vardef EActivity@#(text _info)(text contents)= + ObjectEquations(@#); + @#className := "Activity"; + + ActivityInfoCopy.@#info(_info); + + numeric @#nLines; @#nLines := 0; + string @#lines[]; + for l=contents: + @#lines[@#nLines] := l; + @#nLines := @#nLines + 1; + endfor; + + EPictureStack.@#stack(@#info.iStack)(scantokens listArray(@#lines)(@#nLines))("vcenterbase"); +enddef; + +vardef Activity_layout@#= + if @#layedout = 1: + log "Activity " & (str @#) & " has already been layed out"; + else: + @#layedout := 1; + + PictureStack_layout.@#stack; + + @#width = @#stack.width + @#info.left + @#info.right + 2 * @#info.fat; + @#height = @#stack.height + @#info.top + @#info.bottom; + + @#c = @#stack.c; + + pair @#urt, @#lrt, @#ulft, @#llft; + + @#urt := @#ne - (@#info.fat, 0); + @#lrt := @#se - (@#info.fat, 0); + @#ulft := @#nw + (@#info.fat, 0); + @#llft := @#sw + (@#info.fat, 0); + fi; +enddef; + +vardef Activity_draw@#= + Activity_layout@#; + objectEnsurePositioning.@#; + + attributes(@#); + var(path) border; + @#border := @#ulft -- @#urt .. @#e .. @#lrt -- @#llft .. @#w .. cycle; + + drawObjectShade(@#); + fill @#border withcolor @#info.foreColor; + draw @#border withcolor @#info.borderColor; + + drawObject(@#stack); +enddef; + +vardef Activity_border@#= + @#border +enddef; + + +vardef BranchInfo@#= + @#width := 10; + @#height := 10; + + numeric @#shade; + color @#shadeColor, @#foreColor; + @#shade := .3; + @#shadeColor := .6white; + @#foreColor := white; +enddef; + +BranchInfo.iBranch; + +vardef Branch@#= + ObjectEquations(@#); + @#className := "Branch"; + + @#width = iBranch.width; + @#height = iBranch.height; +enddef; + +vardef Branch_layout@#= + % nothing to do +enddef; + +vardef Branch_draw@#= + objectEnsurePositioning.@#; + + path @#border; + @#border := @#n -- @#e -- @#s -- @#w -- cycle; + + fill @#border shifted (iBranch.shade, -iBranch.shade) withcolor iBranch.shadeColor; + fill @#border withcolor iBranch.foreColor; + draw @#border; +enddef; + +vardef Branch_border@#= + @#border +enddef; + +vardef ForkInfo@#= + @#thickness := 3; + + numeric @#shade; + color @#shadeColor, @#foreColor; + @#shade := .3; + @#shadeColor := .6white; + @#foreColor := black; +enddef; + +ForkInfo.iFork; + +vardef Fork@#(expr orientation, length)= + ObjectEquations(@#); + @#className := "Fork"; + + if (orientation="h") or (orientation="horiz") or (orientation="horizontal"): + @#width = length; + @#height = iFork.thickness; + else: + @#height = length; + @#width = iFork.thickness; + fi; +enddef; + +vardef Fork_layout@#= + % nothing to do +enddef; + +vardef Fork_draw@#= + objectEnsurePositioning.@#; + + path @#border; + @#border := @#nw -- @#ne -- @#se -- @#sw -- cycle; + + fill @#border shifted (iFork.shade, -iFork.shade) withcolor iFork.shadeColor; + fill @#border withcolor iFork.foreColor; +enddef; + +vardef Fork_border@#= + @#border +enddef; + +defaultTransitionHeadWidth := 15; +defaultTransitionHeadHeight := 5; + +vardef TransitionInfo@# = + LinkInfo@#; + + @#widthA = 0; + @#heightA = 0; + @#drawMethodA = "drawNothing"; + + @#widthB = defaultTransitionHeadWidth; + @#heightB = defaultTransitionHeadHeight; + @#drawMethodB = "drawArrow"; + + @#drawMethod = "drawLine"; +enddef; + +TransitionInfo.transition; + +FontInfo.guardFont(metauml_defaultFont, .7); +PictureInfo.iGuard(2, 2, 2, 2)(guardFont); +iGuard.ignoreNegativeBase := 1; diff --git a/Master/texmf-dist/metapost/metauml/metauml_base.mp b/Master/texmf-dist/metapost/metauml/metauml_base.mp new file mode 100644 index 00000000000..c44947ad43f --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_base.mp @@ -0,0 +1,147 @@ +% 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. + +if known _metauml_base_mp: + expandafter endinput +fi; +_metauml_base_mp:=1; + +input util_log; + +vardef markPoint(text p)(text color) = + draw p withpen pencircle scaled 1 withcolor color; +enddef; + +vardef drawLine(text pA)(text pB)(text base) = + draw pA--pB; +enddef; + +vardef drawArrow(text pA)(text pB)(text base) = + numeric dx, dy; + dx = xpart(pB - pA); + dy = ypart(pB - pA); + + numeric alfa; + alfa = angle(dx, dy); + + pair pC, pD; + pC := (0, base/2); + pC := pC rotated (alfa) shifted pA; + pD := (0, base/2); + pD := pD rotated (180+alfa) shifted pA; + + %fill pA--pC--pB--pD--cycle withcolor .8white; + + draw pA--pB; + draw pB--pC; + draw pB--pD; +enddef; + +vardef drawTriangle(text pA)(text pB)(text base) = + numeric dx, dy; + dx = xpart(pB - pA); + dy = ypart(pB - pA); + + numeric alfa; + alfa = angle(dx, dy); + pair pC, pD; + pC := (0, base/2); + pC := pC rotated (alfa) shifted pA; + pD := (0, base/2); + pD := pD rotated (180+alfa) shifted pA; + + fill pA--pC--pB--pD--cycle withcolor white; + + draw pA--pC;% withcolor red; + draw pA--pD;% withcolor green; + draw pB--pC;% withcolor blue; + draw pB--pD; +enddef; + +vardef drawDiamond(text pA)(text pB)(text height) = + numeric dx, dy; + dx = xpart(pB - pA); + dy = ypart(pB - pA); + + numeric alfa; + alfa = angle(dx, dy); + + numeric width; + width = _length(pA)(pB); + + path diamond; + diamond = (0,0)--(width/2, height/2)--(width, 0)--(width/2, -height/2)--cycle; + + fill diamond rotated alfa shifted pA withcolor white; + draw diamond rotated alfa shifted pA; +enddef; + +vardef drawDiamondBlack(text pA)(text pB)(text height) = + numeric dx, dy; + dx = xpart(pB - pA); + dy = ypart(pB - pA); + + numeric alfa; + alfa = angle(dx, dy); + + numeric width; + width = _length(pA)(pB); + + path diamond; + diamond = (0,0)--(width/2, height/2)--(width, 0)--(width/2, -height/2)--cycle; + + fill diamond rotated alfa shifted pA; +enddef; + +vardef drawCrossedCircle(text pA)(text pB)(text height) = + numeric dx, dy; + dx = xpart(pB - pA); + dy = ypart(pB - pA); + + numeric alfa; + alfa = angle(dx, dy); + + numeric width; + width = _length(pA)(pB); + + pair pC, pD; + pC := (width/2, height/2 + 1); + pC := pC rotated (alfa) shifted pA; + pD := (width/2, -height/2 - 1); + pD := pD rotated (alfa) shifted pA; + + fill pA..pB..pA -- cycle withcolor white; + + draw pA -- pB; + draw pC -- pD; + draw pA .. pB .. pA; +enddef; + +vardef drawLine(expr my_path) = + draw my_path; +enddef; + +vardef drawLineDashed(expr my_path) = + draw my_path dashed evenly; +enddef; + +vardef drawNothing(text pA)(text pB)(text base) = +enddef; + +def shorterLineEndPoint(text pA)(text pB)(text delta) = + (xpart(pA) + _dx(pA)(pB)*(1 - delta/_length(pA)(pB)), ypart(pA) + _dy(pA)(pB) * (1 - delta/_length(pA)(pB)) ) +enddef; diff --git a/Master/texmf-dist/metapost/metauml/metauml_behavioral_common.mp b/Master/texmf-dist/metapost/metauml/metauml_behavioral_common.mp new file mode 100644 index 00000000000..0f52d206777 --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_behavioral_common.mp @@ -0,0 +1,216 @@ +% 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. + +if known _metauml_behavioral_common_mp: + expandafter endinput +fi; +_metauml_behavioral_common_mp:=1; + +input util_log; + +vardef SpecialStateInfo@#= + numeric @#diameter; + color @#discColor; + + numeric @#shade; + color @#shadeColor, @#foreColor; + + @#diameter := 0.4cm; + @#discColor := black; + @#foreColor := black; + + ShadeInfo.@#iShade; +enddef; + +vardef SpecialStateInfoCopy@#(text src)= + SpecialStateInfo.@#; + ShadeInfo_copy.@#iShade(src.iShade); + + @#diameter := src.diameter; + @#discColor := src.discColor; + @#foreColor := src.foreColor; +enddef; + +%%%%%%%%%%%%%%%%%% +% BEGIN % +%%%%%%%%%%%%%%%%%% + +SpecialStateInfo.iBegin; + +vardef Begin@#= + ObjectEquations(@#); + @#className := "Begin"; + + SpecialStateInfoCopy.@#info(iBegin); +enddef; + +vardef Begin_layout@#= + if @#layedout = 1: + log "Begin " & (str @#) & " has already been layed out"; + else: + @#layedout := 1; + + @#width = @#info.diameter; + @#height = @#info.diameter; + fi; +enddef; + +vardef Begin_draw@#= + Begin_layout@#; + objectEnsurePositioning.@#; + + path @#border; + @#border := @#n..@#e..@#s..@#w..cycle; + + drawObjectShade(@#); + + fill @#border withcolor @#info.discColor; + draw @#border withcolor @#info.foreColor; +enddef; + +vardef Begin_border@#= + @#border +enddef; + +%%%%%%%%%%%%%%%%%% +% END % +%%%%%%%%%%%%%%%%%% + +SpecialStateInfo.iEnd; +iEnd.innerSpacing := 2; +iEnd.discColor := white; + +vardef End@#= + ObjectEquations(@#); + @#className := "End"; + SpecialStateInfoCopy.@#info(iEnd); + @#info.innerSpacing := iEnd.innerSpacing; +enddef; + +vardef End_layout@#= + Begin_layout@#; +enddef; + +vardef End_draw@#= + Begin_draw.@#; + + path @#innerDisc; + @#innerDisc := @#n - (0, @#info.innerSpacing) .. + @#e - (@#info.innerSpacing, 0) .. + @#s + (0, @#info.innerSpacing) .. + @#w + (@#info.innerSpacing, 0) ..cycle; + + fill @#innerDisc withcolor @#info.foreColor; +enddef; + +vardef End_border@#= + @#border +enddef; + +%%%%%%%%%%%%%%%%%% +% ENTRY POINT % +%%%%%%%%%%%%%%%%%% + +SpecialStateInfo.iEntryPoint; +iEntryPoint.discColor := white; +iEntryPoint.innerSpacing := 2; + +vardef EntryPoint@#= + ObjectEquations(@#); + @#className := "EntryPoint"; + SpecialStateInfoCopy.@#info(iEntryPoint); + @#info.innerSpacing := iEntryPoint.innerSpacing; +enddef; + +vardef EntryPoint_layout@#= + Begin_layout@#; +enddef; + +vardef EntryPoint_draw@#= + Begin_draw.@#; +enddef; + +vardef EntryPoint_border@#= + @#border +enddef; + +%%%%%%%%%%%%%%%%%% +% EXIT POINT % +%%%%%%%%%%%%%%%%%% + +SpecialStateInfo.iExitPoint; +iExitPoint.discColor := white; +iExitPoint.innerSpacing := 2; + +vardef ExitPoint@#= + ObjectEquations(@#); + @#className := "ExitPoint"; + SpecialStateInfoCopy.@#info(iExitPoint); + @#info.innerSpacing := iExitPoint.innerSpacing; + @#info.iShade.shift := 0; +enddef; + +vardef ExitPoint_layout@#= + Begin_layout@#; +enddef; + +vardef ExitPoint_draw@#= + Begin_draw.@#; + + _n_ := str @#; + generic_declare(pair) _n.urt, _n.lrt, _n.llft, _n.ulft; + + @#urt := @#c + @#info.diameter/2 * (sind(45), cosd(45)); + @#lrt := @#c + @#info.diameter/2 * (sind(135), cosd(135)); + @#llft := @#c + @#info.diameter/2 * (sind(225), cosd(225)); + @#ulft := @#c + @#info.diameter/2 * (sind(315), cosd(315)); + + draw @#urt -- @#llft; + draw @#ulft -- @#lrt; +enddef; + +vardef ExitPoint_border@#= + @#border +enddef; + +%%%%%%%%%%%%%%%%%% +% FlowFinal % +%%%%%%%%%%%%%%%%%% + +SpecialStateInfo.iFlowFinal; +iFlowFinal.discColor := white; +iFlowFinal.innerSpacing := 2; + +vardef FlowFinal@#= + ObjectEquations(@#); + @#className := "FlowFinal"; + SpecialStateInfoCopy.@#info(iFlowFinal); + @#info.innerSpacing := iFlowFinal.innerSpacing; + %@#info.iShade.shift := 0; +enddef; + +vardef FlowFinal_layout@#= + Begin_layout@#; +enddef; + +vardef FlowFinal_draw@#= + ExitPoint_draw@# +enddef; + +vardef FlowFinal_border@#= + @#border +enddef; diff --git a/Master/texmf-dist/metapost/metauml/metauml_class.mp b/Master/texmf-dist/metapost/metauml/metauml_class.mp new file mode 100644 index 00000000000..6e8e4330e3b --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_class.mp @@ -0,0 +1,351 @@ +% 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. + +if known _metauml_class_mp: + expandafter endinput +fi; +_metauml_class_mp:=1; + +input metauml_defaults; +input util_log; + +input util_picture; +input util_picture_stack; +input util_shade; + +string accessPublic, accessProtected, accessPrivate; +accessPublic:="+"; +accessProtected:="#"; +accessPrivate:="-"; + +vardef ClassInfo@#= + attributes(@#); + var(numeric) featureAccessSpacing, accessWidth, accessHeight; + var(color) foreColor, borderColor; + + FontInfo.@#nameFont(metauml_defaultFont, defaultscale); + + FontInfo.@#attributeFont (metauml_defaultFont, defaultscale); + FontInfo.@#methodFont (metauml_defaultFont, defaultscale); + FontInfo.@#stereotypeFont(metauml_defaultFont, .7); + + ShadeInfo.@#iShade; + + @#featureAccessSpacing := 2; + @#accessWidth := 7; + @#accessHeight := 6.75; + + @#foreColor := .9white; + @#borderColor := black; + + PictureInfo.@#iName (2, 2, 1, 3)(@#nameFont); + + PictureInfo.@#iStereotype(2, -5, 2, 2)(@#stereotypeFont); + PictureInfo.@#iAttribute (2, 2, 1.25, 0)(@#attributeFont); + PictureInfo.@#iMethod (2, 2, 1.25, 0)(@#methodFont); + + PictureStackInfo.@#iStereotypeStack(2, 2, 1, 1)(5.5)(@#iStereotype); + PictureStackInfo.@#iAttributeStack (2, 2, 2.5, 2)(10.5)(@#iAttribute); % 8.5 + PictureStackInfo.@#iMethodStack (2, 2, 2.5, 2)(10.5)(@#iMethod); + @#iAttributeStack.iPict.bottom := 2; + %@#iAttributeStack.iPict.boxed := 1; + @#iMethodStack.iPict.bottom := 2; + %@#iMethodStack.iPict.boxed := 1; + + LockInfo.@#iLock(@#accessWidth, @#accessHeight, .6, .15, .55, .4white, .6white, .7white, .3white); + + @#iName.ignoreNegativeBase := 1; + @#iAttributeStack.iPict.ignoreNegativeBase := 1; + @#iMethodStack.iPict.ignoreNegativeBase := 1; + @#iStereotypeStack.iPict.ignoreNegativeBase := 1; +enddef; + +vardef ClassInfoCopy@#(text src)= + log "ClassInfoCopy: Copying class"; + + attributes(@#); + var(numeric) featureAccessSpacing, accessWidth, accessHeight; + var(color) foreColor, borderColor; + + FontInfoCopy.@#nameFont(src.nameFont); + + FontInfoCopy.@#attributeFont(src.attributeFont); + FontInfoCopy.@#methodFont(src.methodFont); + FontInfoCopy.@#stereotypeFont(src.stereotypeFont); + + ShadeInfoCopy.@#iShade(src.iShade); + + @#featureAccessSpacing := src.featureAccessSpacing; + @#accessWidth := src.accessWidth; + @#accessHeight := src.accessHeight; + + @#foreColor := src.foreColor; + @#borderColor := src.borderColor; + + PictureInfoCopy.@#iName (src.iName); + + PictureInfoCopy.@#iStereotype(src.iStereotype); + PictureInfoCopy.@#iAttribute (src.iAttribute); + PictureInfoCopy.@#iMethod (src.iMethod); + + PictureStackInfoCopy.@#iStereotypeStack(src.iStereotypeStack); + PictureStackInfoCopy.@#iAttributeStack (src.iAttributeStack); + PictureStackInfoCopy.@#iMethodStack (src.iMethodStack); + + LockInfoCopy.@#iLock(src.iLock); +enddef; + +ClassInfo.iClass; + +ClassInfoCopy.iInterface(iClass); +iInterface.iName.iFont.name := metauml_defaultFontOblique; + +ClassInfoCopy.iAbstractClass(iInterface); + +% +% CLASS +% +vardef defClass@#(expr pname) = + ObjectEquations(@#); + @#className := "Class"; + + string @#name; + @#name = pname; + + numeric @#nStereotypes; + string @#stereotypes[]; + + string @#attributes[]; + string @#attributesAccess[]; + + string @#methods[]; + string @#methodsAccess[]; + + numeric @#nAttrs; + numeric @#nMethods; + + @#nStereotypes := 0; + @#nAttrs := 0; + @#nMethods := 0; +enddef; + +vardef addAttribute@#(expr pcontent) = + string access; + access := substring(0,1) of pcontent; + if (not (access = accessPublic)) and + (not (access = accessPrivate)) and + (not (access = accessProtected)): + + @#.attributes[@#.nAttrs] := pcontent; + @#.attributesAccess[@#.nAttrs] := accessProtected; + else: + save from; + from := 1; + if (substring(1,2) of pcontent) = " ": from := 2; fi; + + @#.attributes[@#.nAttrs] := substring(from, infinity) of pcontent; + @#.attributesAccess[@#.nAttrs] := access; + fi; + + @#.nAttrs := @#.nAttrs + 1; +enddef; + +vardef addMethod@#(expr pcontent) = + string access; + access := substring(0,1) of pcontent; + if (not (access = accessPublic)) and + (not (access = accessPrivate)) and + (not (access = accessProtected)): + + @#.methods[@#.nMethods] := pcontent; + @#.methodsAccess[@#.nMethods] := accessProtected; + else: + @#.methods[@#.nMethods] := substring(1, 999) of pcontent; + @#.methodsAccess[@#.nMethods] := access; + fi; + + @#.nMethods := @#.nMethods + 1; +enddef; + +vardef classStereotype@#(expr pcontent) = + @#stereotypes[@#nStereotypes] := pcontent; + @#nStereotypes := @#nStereotypes + 1; +enddef; + +vardef classStereotypes@#(text stereotypes)= + for stereotype = stereotypes: + classStereotype@#(stereotype); + endfor; +enddef; + +vardef EClass@#(text _info)(expr name)(text attributes)(text methods)= + log "EClass begin: " & str @#; + defClass@#(name); + + log "Copying class info"; + ClassInfoCopy.@#info(_info); + + for a=attributes: + log "Adding attribute ", a; + addAttribute@#(a); + endfor; + for m=methods: + log "Adding method ", m; + addMethod@#(m); + endfor; +enddef; + +vardef Class@#(expr name)(text attributes)(text methods)= + EClass@#(iClass)(name)(attributes)(methods); +enddef; + +vardef Interface@#(expr name)(text methods)= + EClass@#(iInterface)(name)()(methods); +enddef; + +vardef EInterface@#(text _info)(expr name)(text methods)= + EClass@#(_info)(name)()(methods); +enddef; + +vardef AbstractClass@#(expr name)(text attributes)(text methods)= + EClass@#(iAbstractClass)(name)(attributes)(methods); +enddef; + +vardef EAbstractClass@#(text _info)(expr name)(text methods)= + EClass@#(_info)(name)()(methods); +enddef; + +vardef Class_border@#= + objectBox(@#) +enddef; + +vardef Class_layout@# = + if @#layedout = 1: + log "Class " & (str @#) & " has already been layed out"; + else: + @#layedout := 1; + log "Class layout: " & (str @#); + + @#maxFeatureWidth := 0; + + EPictureStack.@#stereotypeStack(@#info.iStereotypeStack) + (scantokens listArray(@#stereotypes)(@#nStereotypes))("vcenterbase"); + + EPicture.@#namePict(@#info.iName)(@#name); + EPictureStack.@#attributeStack(@#info.iAttributeStack) + (scantokens listArray(@#attributes)(@#nAttrs))("vleftbase"); + EPictureStack.@#methodStack(@#info.iMethodStack) + (scantokens listArray(@#methods)(@#nMethods))("vleftbase"); + + layoutObjects(@#stereotypeStack, @#namePict, @#attributeStack, @#methodStack); + + log "Computing maxFeatureWidth"; + log @#stereotypeStack.width; + log @#namePict.width; + log @#attributeStack.width; + log @#methodStack.width; + log "..."; + @#maxFeatureWidth := lmax(@#stereotypeStack.width, @#namePict.width, + @#attributeStack.width, @#methodStack.width); + log "Done computing maxFeatureWidth"; + + log "max feature width: " & decimal @#maxFeatureWidth; + + @#namePict.midx = @#midx; + @#stereotypeStack.midx = @#namePict.midx; + + @#stereotypeStack.top = @#top; + @#namePict.top = @#stereotypeStack.bottom; + @#attributeStack.top = @#namePict.bottom; + @#methodStack.top = @#attributeStack.bottom; + + @#attributeStack.left = @#methodStack.left = + @#left + @#info.accessWidth + @#info.featureAccessSpacing; + + @#width = @#maxFeatureWidth + @#info.accessWidth + @#info.featureAccessSpacing; + @#bottom = @#methodStack.bottom; + + log "Class layout done..."; + fi; +enddef; + +vardef Class_paintAccess@#(expr _access, _se) = + save lock; + ELock.lock(@#info.iLock)(_access); + lock.se = _se; + drawObject(lock); +enddef; + +vardef Class_drawFeatures@#= + log "Drawing stereotypes"; + drawObject(@#stereotypeStack); + + log "Drawing name"; + drawObject(@#namePict); + log "Drawing attribute stack"; + drawObject(@#attributeStack); + + log "Drawing method stack"; + drawObject(@#methodStack); + + log "********************************** Drawing access locks"; + for i = 0 upto @#nAttrs-1: + log @#attributesAccess[i]; + Class_paintAccess@#(@#attributesAccess[i], + @#attributeStack.pict[i].sw + (-@#info.featureAccessSpacing, @#info.iAttributeStack.iPict.bottom)); + endfor; + + for i = 0 upto @#nMethods-1: + log @#methodsAccess[i]; + Class_paintAccess@#(@#methodsAccess[i], + @#methodStack.pict[i].sw + (-@#info.featureAccessSpacing, @#info.iMethodStack.iPict.bottom)); + endfor; +enddef; + +vardef Class_paintSkin@# = + log "Painting class skin..."; + nameAttributeY := @#attributeStack.top; + attributeMethodY := @#methodStack.top; + + %fill Class_border.@# shifted (@#info.shade,-@#info.shade) + % withcolor .7white withpen currentpen scaled 1; + drawObjectShade(@#); + + fill Class_border.@# withcolor @#info.foreColor; + draw Class_border.@# withcolor @#info.borderColor; + + draw (xpart @#nw, nameAttributeY)--(xpart @#se, nameAttributeY) withcolor @#info.borderColor; + draw (xpart @#nw, attributeMethodY)--(xpart @#se, attributeMethodY) withcolor @#info.borderColor; +enddef; + +vardef Class_draw@#= + log "draw class begin..."; + Class_layout.@#; + objectEnsurePositioning.@#; + Class_paintSkin.@#; + Class_drawFeatures.@#; +enddef; + +vardef Class_setDebugMode@#= + @#.info.iName.boxed := 1; + @#.info.iStereotypeStack.boxed := 1; + @#.info.iStereotypeStack.iPict.boxed := 1; + @#.info.iAttributeStack.boxed := 1; + @#.info.iAttributeStack.iPict.boxed := 1; + @#.info.iMethodStack.boxed := 1; + @#.info.iMethodStack.iPict.boxed := 1; +enddef; diff --git a/Master/texmf-dist/metapost/metauml/metauml_class_assoc.mp b/Master/texmf-dist/metapost/metauml/metauml_class_assoc.mp new file mode 100644 index 00000000000..457e3015d3a --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_class_assoc.mp @@ -0,0 +1,95 @@ +% 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. + +if known _metauml_class_assoc_mp: + expandafter endinput +fi; +_metauml_class_assoc_mp:=1; + +input util_log; +input metauml_defaults; + +FontInfo.assocFont(metauml_defaultFont, .7); +PictureInfo.iAssoc(2, 2, 2, 2)(assocFont); +iAssoc.ignoreNegativeBase := 1; + +vardef QualifiedAssociationInfo@#= + color @#background; + color @#borderColor; + numeric @#borderScale; + + @#background := .9white; + @#borderColor := black; + @#borderScale := .5; + + FontInfo.@#iFont(metauml_defaultFont, .9); + PictureInfo.@#iPict(2, 2, 2, 2)(@#iFont); + PictureStackInfo.@#iStack(2, 2, 1, 1)(7)(@#iPict); + + @#iStack.iPict.ignoreNegativeBase := 1; +enddef; + +vardef QualifiedAssociationInfoCopy@#(text src)= + color @#background; + color @#borderColor; + numeric @#borderScale; + + @#background := src.background; + @#borderColor := src.borderColor; + @#borderScale := src.borderScale; + + FontInfoCopy.@#iFont(src.iFont); + PictureInfoCopy.@#iPict(src.iPict); + PictureStackInfoCopy.@#iStack(src.iStack); +enddef; + +QualifiedAssociationInfo.iQualifiedAssociation; + +% +% QualifiedAssociation +% +vardef EQualifiedAssociation@#(text _info)(text qualifiedAssociations) = + ObjectEquations(@#); + @#className := "QualifiedAssociation"; + + QualifiedAssociationInfoCopy.@#info(_info); + + EPictureStack.@#elementsStack(@#info.iStack)(qualifiedAssociations)("vleftbase"); + + @#nw = @#elementsStack.nw; + @#se = @#elementsStack.se; +enddef; + +vardef QualifiedAssociation@#(text qualifiedAssociations)= + EQualifiedAssociation@#(iQualifiedAssociation)(qualifiedAssociations); +enddef; + +vardef QualifiedAssociation_paintSkin@# = + log "Painting qualifiedAssociation skin..."; + + fill objectBox(@#) withcolor @#info.background; + + draw objectBox(@#) + withpen pencircle scaled @#info.borderScale withcolor @#info.borderColor; +enddef; + +vardef QualifiedAssociation_draw@# = + PictureStack_layout.@#elementsStack; + + QualifiedAssociation_paintSkin.@#; + drawObject(@#elementsStack); +enddef; diff --git a/Master/texmf-dist/metapost/metauml/metauml_class_clipart.mp b/Master/texmf-dist/metapost/metauml/metauml_class_clipart.mp new file mode 100644 index 00000000000..72bae5b93e3 --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_class_clipart.mp @@ -0,0 +1,151 @@ +% 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. + +if known _metauml_class_clipart_mp: + expandafter endinput +fi; +_metauml_class_clipart_mp:=1; + +input util_log; + +%% +%% This file contains various drawing which can be used in +%% UML class diagrams +%% + +vardef LockInfo@#(expr _width, _height, _y, _d, _span, _faceColor, _topColor, _rightColor, _lockColor)= + numeric @#y, @#d, @#span, @#width, @#height; + color @#faceColor, @#topColor, @#rightColor, @#lockColor; + + @#width := _width; + @#height := _height; + + @#heightRatio := _y; + @#depthRatio := _d; + @#span := _span; + + @#faceColor := _faceColor; + @#topColor := _topColor; + @#rightColor := _rightColor; + @#lockColor := _lockColor; +enddef; + +vardef LockInfoCopy@#(text src)= + LockInfo@#(src.width, src.height, src.heightRatio, src.depthRatio, src.span, + src.faceColor, src.topColor, src.rightColor, src.lockColor); +enddef; + +LockInfo.iLock(8, 8, .55, .15, .55, .4white, .6white, .7white, .3white); + +def lockLockPen=pencircle scaled .8pt enddef; +def lockLockTension=tension(1) enddef; + +vardef ELock@#(text lockInfo)(expr how)= + ObjectEquations(@#); + @#className := "Lock"; + + generic_declare(path) _n.pFace, _n.pRight, _n.pTop; + generic_declare(path) _n.pLock; + generic_declare(string) _n.mode; + + LockInfoCopy.@#info(lockInfo); + + @#height = @#info.height; + @#width = @#info.width; + + @#mode := how; + + log "ELock completed"; +enddef; + +vardef Lock@#(expr how)= + ELock@#(iLock)(how); +enddef; + +vardef Lock_draw@#= + log "Drawing lock"; + log @#nw; + log @#se; + generic_declare(numeric) _n.depth,_n.ya, _n.xa; + + @#depth = @#info.width * @#info.depthRatio; + @#ya = ypart @#nw - @#height * @#info.heightRatio; + @#xa = xpart @#se - @#depth; + + @#pFace = (xpart @#nw, @#ya) -- (@#xa, @#ya) -- (@#xa, ypart @#se) -- (xpart @#nw, ypart @#se) -- cycle; + @#pRight = (@#xa, ypart @#se) -- (xpart @#se, ypart @#se + @#depth) -- + (xpart @#se, @#ya + @#depth) -- (@#xa, @#ya) -- cycle; + @#pTop = (@#xa, @#ya) -- (xpart @#se, @#ya + @#depth) -- + (xpart @#nw + @#depth, @#ya + @#depth) -- (xpart @#nw, @#ya) -- cycle; + + save myMode; string myMode; + myMode = "base"; + if ((@#mode="private") or (@#mode="-")): + myMode := "closed"; + elseif ((@#mode="protected") or (@#mode="#")): + myMode := "opened"; + fi; + + if myMode="closed": + log "Closed!"; + generic_declare(pair) _n.A, _n.B, _n.C, _n.M; + generic_declare(numeric) _n.span; + @#span = @#info.span * @#width; + + @#M = ((xpart @#se + xpart @#nw) / 2, @#ya + @#depth/2); + log @#M; + @#A = (xpart @#M - (@#span / 2), ypart @#M); + log @#A; + @#B = (xpart @#M + (@#span / 2), ypart @#M); + log @#B; + @#C = (xpart @#M, ypart @#nw); + log @#C; + linecap:=butt; + + @#pLock = @#A {curl 0}..lockLockTension .. @#C .. lockLockTension .. {curl 0} @#B; + %withcolor @#info.lockColor withpen lockLockPen; + elseif myMode="opened": + log "Opened!"; + + generic_declare(pair) _n.A, _n.B, _n.C, _n.M; + generic_declare(numeric) _n.span; + @#span = @#info.span * @#width; + + @#M = ((xpart @#se + xpart @#nw) / 2, @#ya + @#depth/2); + @#A = (xpart @#M - (@#span / 2), ypart @#M) + (0, @#height/3); + @#B = (xpart @#M + (@#span / 2), ypart @#M); + @#C = (xpart @#M, ypart @#nw); + log @#M, @#A, @#B, @#C; + + linecap:=butt; + + @#pLock = @#A {curl 0}..lockLockTension .. @#C .. lockLockTension .. {curl 0} @#B; + %withcolor @#info.lockColor withpen lockLockPen; + fi; + + fill @#pFace withcolor @#info.faceColor; + fill @#pRight withcolor @#info.rightColor; + fill @#pTop withcolor @#info.topColor; + + if not ((myMode = "opened") or (myMode="closed")): + log "No lock to draw..."; + else: + draw @#pLock withcolor @#info.lockColor withpen lockLockPen; + fi; +enddef; + + diff --git a/Master/texmf-dist/metapost/metauml/metauml_class_relations.mp b/Master/texmf-dist/metapost/metauml/metauml_class_relations.mp new file mode 100644 index 00000000000..bcc4997b049 --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_class_relations.mp @@ -0,0 +1,171 @@ +% 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. + +if known _metauml_class_relations_mp: + expandafter endinput +fi; +_metauml_class_relations_mp:=1; + +defaultRelationHeadWidth := 25; +defaultRelationHeadHeight := 10; + +vardef AssociationInfo@# = + LinkInfo@#; + + @#widthA = 0; + @#heightA = 0; + @#drawMethodA = "drawNothing"; + + @#widthB = 0; + @#heightB = 0; + @#drawMethodB = "drawNothing"; + + @#drawMethod = "drawLine"; +enddef; + +vardef AssociationUniInfo@# = + LinkInfo@#; + + @#widthA = 0; + @#heightA = 0; + @#drawMethodA = "drawNothing"; + + @#widthB = defaultRelationHeadWidth; + @#heightB = defaultRelationHeadHeight; + @#drawMethodB = "drawArrow"; + + @#drawMethod = "drawLine"; +enddef; + +vardef InheritanceInfo@# = + LinkInfo@#; + + @#widthA = 0; + @#heightA = 0; + @#drawMethodA = "drawNothing"; + + @#widthB = defaultRelationHeadWidth; + @#heightB = defaultRelationHeadHeight; + @#drawMethodB = "drawTriangle"; + + @#drawMethod = "drawLine"; +enddef; + +vardef AggregationInfo@# = + LinkInfo@#; + + @#widthA = 0; + @#heightA = 0; + @#drawMethodA = "drawNothing"; + + @#widthB = defaultRelationHeadWidth; + @#heightB = defaultRelationHeadHeight; + @#drawMethodB = "drawDiamond"; + + @#drawMethod = "drawLine"; +enddef; + +vardef AggregationUniInfo@# = + LinkInfo@#; + + @#widthA = defaultRelationHeadWidth; + @#heightA = defaultRelationHeadHeight; + @#drawMethodA = "drawArrow"; + + @#widthB = defaultRelationHeadWidth; + @#heightB = defaultRelationHeadHeight; + @#drawMethodB = "drawDiamond"; + + @#drawMethod = "drawLine"; +enddef; + +vardef CompositionInfo@# = + LinkInfo@#; + + @#widthA = 0; + @#heightA = 0; + @#drawMethodA = "drawNothing"; + + @#widthB = defaultRelationHeadWidth; + @#heightB = defaultRelationHeadHeight; + @#drawMethodB = "drawDiamondBlack"; + + @#drawMethod = "drawLine"; +enddef; + +vardef CompositionUniInfo@# = + LinkInfo@#; + + @#widthA = defaultRelationHeadWidth; + @#heightA = defaultRelationHeadHeight; + @#drawMethodA = "drawArrow"; + + @#widthB = defaultRelationHeadWidth; + @#heightB = defaultRelationHeadHeight; + @#drawMethodB = "drawDiamondBlack"; + + @#drawMethod = "drawLine"; +enddef; + +vardef DashedLinkInfo@# = + LinkInfo@#; + + @#widthA = 0; + @#heightA = 0; + @#drawMethodA = "drawNothing"; + + @#widthB = 0; + @#heightB = 0; + @#drawMethodB = "drawNothing"; + + @#drawMethod = "drawLineDashed"; +enddef; + +vardef DependencyInfo@# = + LinkInfo@#; + + @#widthA = 0; + @#heightA = 0; + @#drawMethodA = "drawNothing"; + + @#widthB = defaultRelationHeadWidth; + @#heightB = defaultRelationHeadHeight; + @#drawMethodB = "drawArrow"; + + @#drawMethod = "drawLineDashed"; +enddef; + +AssociationInfo.association; +AssociationUniInfo.associationUni; +InheritanceInfo.inheritance; +AggregationInfo.aggregation; +AggregationUniInfo.aggregationUni; +CompositionInfo.composition; +CompositionUniInfo.compositionUni; +DashedLinkInfo.dashedLink; +DependencyInfo.dependency; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Deprecated, kept to support code using the older API. +% Using the generic formulation involving link, e.g. +% link(association)(A.n--B.s) is preferable. +% link and clink are defined in metauml_links +% +vardef drawRelation(text iLink)(expr myPath)= + link(iLink)(myPath); +enddef; diff --git a/Master/texmf-dist/metapost/metauml/metauml_defaults.mp b/Master/texmf-dist/metapost/metauml/metauml_defaults.mp new file mode 100644 index 00000000000..db1183a52bf --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_defaults.mp @@ -0,0 +1,45 @@ +% 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. + +if known _metauml_defaults_mp: + expandafter endinput +fi; +_metauml_defaults_mp:=1; + +% txbtt + +if not known metauml_defaultFont: + string metauml_defaultFont; + metauml_defaultFont := "ptmr8r"; +fi; + +if not known metauml_defaultFontOblique: + string metauml_defaultFontOblique; + metauml_defaultFontOblique := "ptmro8r"; +fi; + +if not known metauml_defaultFontBold: + string metauml_defaultFontBold; + metauml_defaultFontBold := "ptmb8r"; +fi; + +if not known metauml_defaultFontBoldOblique: + string metauml_defaultFontBoldOblique; + metauml_defaultFontBoldOblique := "ptmbo8r"; +fi; + + diff --git a/Master/texmf-dist/metapost/metauml/metauml_instance.mp b/Master/texmf-dist/metapost/metauml/metauml_instance.mp new file mode 100644 index 00000000000..3732d600d4f --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_instance.mp @@ -0,0 +1,188 @@ +% MetaUML, a MetaPost library for typesetting exquisite UML diagrams. +% Copyright (C) 2005 Radu-George Radulescu +% +% 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_instance_mp: + expandafter endinput +fi; +_metauml_instance_mp:=1; + +input metauml_defaults; +input util_log; + +input util_picture; +input util_picture_stack; +input util_shade; + +vardef InstanceInfo@#= + attributes(@#); + var(color) foreColor, borderColor; + + FontInfo.@#nameFont(metauml_defaultFont, defaultscale); + + FontInfo.@#attributeFont(metauml_defaultFont, defaultscale); + + ShadeInfo.@#iShade; + + @#foreColor := .9white; + @#borderColor := black; + + PictureInfo.@#iName (2, 2, 1, 3)(@#nameFont); + + PictureInfo.@#iAttribute (2, 2, 1.25, 0)(@#attributeFont); + + PictureStackInfo.@#iAttributeStack (2, 2, 2.5, 2)(10.5)(@#iAttribute); % 8.5 + @#iAttributeStack.iPict.bottom := 2; + + @#iName.ignoreNegativeBase := 1; + @#iAttributeStack.iPict.ignoreNegativeBase := 1; +enddef; + +vardef InstanceInfoCopy@#(text src)= + log "InstanceInfoCopy: Copying Instance"; + + attributes(@#); + var(color) foreColor, borderColor; + + FontInfoCopy.@#nameFont(src.nameFont); + + FontInfoCopy.@#attributeFont(src.attributeFont); + + ShadeInfoCopy.@#iShade(src.iShade); + + @#foreColor := src.foreColor; + @#borderColor := src.borderColor; + + PictureInfoCopy.@#iName (src.iName); + + PictureInfoCopy.@#iAttribute (src.iAttribute); + PictureStackInfoCopy.@#iAttributeStack (src.iAttributeStack); + +enddef; + +InstanceInfo.iInstance; + +% +% Instance +% +vardef defInstance@#(expr pname) = + ObjectEquations(@#); + @#className := "Instance"; + + string @#name; + @#name = pname; + + string @#attributes[]; + numeric @#nAttrs; + @#nAttrs := 0; +enddef; + +vardef Instance_addAttribute@#(expr pcontent) = + + @#.attributes[@#.nAttrs] := pcontent; + @#.nAttrs := @#.nAttrs + 1; + +enddef; + +vardef EInstance@#(text _info)(expr name)(text attributes)= + log "EInstance begin"; + defInstance@#(name); + + log "Copying Instance info"; + InstanceInfoCopy.@#info(_info); + + for a = attributes: + log "Adding attribute ", a; + Instance_addAttribute@#(a); + endfor; +enddef; + +vardef Instance@#(expr name)(text attributes)= + EInstance@#(iInstance)(name)(attributes); +enddef; + +vardef Instance_border@#= + objectBox(@#) +enddef; + +vardef Instance_layout@# = + if @#layedout = 1: + log "Instance " & (str @#) & " has already been layed out"; + else: + @#layedout := 1; + log "Instance layout: " & (str @#); + + @#maxFeatureWidth := 0; + + EPicture.@#namePict(@#info.iName)(@#name); + EPictureStack.@#attributeStack(@#info.iAttributeStack) + (scantokens listArray(@#attributes)(@#nAttrs))("vleftbase"); + + layoutObjects(@#namePict, @#attributeStack); + + @#maxFeatureWidth := lmax(@#namePict.width, @#attributeStack.width) + 1; + + @#namePict.midx = @#midx; + + @#namePict.top = @#top - 1; + @#attributeStack.top = @#namePict.bottom - 1; + + @#attributeStack.left = @#left; + + @#width = @#maxFeatureWidth; + @#bottom = @#attributeStack.bottom; + + log "Layout done..."; + fi; +enddef; + +vardef Instance_drawFeatures@#= + log "Drawing name"; + drawObject(@#namePict); + log "Underlining name"; + pair A, B; + A := @#namePict.se + (-@#namePict.info.left, @#namePict.info.bottom-1); + B := @#namePict.sw + (@#namePict.info.right, @#namePict.info.bottom-1); + draw A--B; + log "Drawing attribute stack"; + drawObject(@#attributeStack); + +enddef; + +vardef Instance_paintSkin@# = + log "Painting Instance skin..."; + + drawObjectShade(@#); + + fill Instance_border.@# withcolor @#info.foreColor; + draw Instance_border.@# withcolor @#info.borderColor; + + draw (xpart @#nw, @#attributeStack.top)--(xpart @#se, @#attributeStack.top) withcolor @#info.borderColor; +enddef; + +vardef Instance_draw@#= + log "draw Instance begin..."; + Instance_layout.@#; + objectEnsurePositioning.@#; + Instance_paintSkin.@#; + Instance_drawFeatures.@#; +enddef; + +vardef Instance_setDebugMode@#= + @#.info.iName.boxed := 1; + @#.info.iAttributeStack.boxed := 1; + @#.info.iAttributeStack.iPict.boxed := 1; +enddef; 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; diff --git a/Master/texmf-dist/metapost/metauml/metauml_note.mp b/Master/texmf-dist/metapost/metauml/metauml_note.mp new file mode 100644 index 00000000000..92d0aac93b9 --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_note.mp @@ -0,0 +1,137 @@ +% 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. + +if known _metauml_note_mp: + expandafter endinput +fi; +_metauml_note_mp:=1; + +% def metauml_note_debug text txt=log txt enddef; +def metauml_note_debug text txt= enddef; + +input metauml_defaults; +input util_log; + +input util_object; +input util_picture_stack; +input util_shade; +input util_margins; + +vardef NoteInfo@#= + attributes(@#); + var(color) foreColor, borderColor; + var(numeric) horizontalFolding, verticalFolding; + + FontInfo.@#iFont(metauml_defaultFont, defaultscale); + @#iFont.ignoreNegativeBase := 1; + + PictureInfo.@#iText (2, 2, 2, 2)(@#iFont); + PictureStackInfo.@#iStack (0, 0, 0, 0)(9)(@#iText); + + @#iStack.iPict.ignoreNegativeBase := 1; + + ShadeInfo.@#iShade; + Margins.@#(2,2,2,2); + + @#foreColor := .9white; + @#borderColor := black; + @#horizontalFolding := 10; + @#verticalFolding := 10; +enddef; + +vardef NoteInfoCopy@#(text src)= + attributes(@#); + var(color) foreColor, borderColor; + + log "NoteInfoCopy: Copying usecase info"; + + PictureStackInfoCopy.@#iStack (src.iStack); + MarginsCopy.@#(src); + ShadeInfoCopy.@#iShade(src.iShade); + + @#foreColor := src.foreColor; + @#borderColor := src.borderColor; + @#horizontalFolding := src.horizontalFolding; + @#verticalFolding := src.verticalFolding; +enddef; + +NoteInfo.iNote; + +vardef Note@#(text contents)= + ENote.@#(iNote)(contents); +enddef; + +vardef ENote@#(text _info)(text contents)= + ObjectEquations(@#); + @#className := "Note"; + + NoteInfoCopy.@#info(_info); + + numeric @#nLines; @#nLines := 0; + string @#lines[]; + for l=contents: + @#lines[@#nLines] := l; + @#nLines := @#nLines + 1; + endfor; + + EPictureStack.@#stack(@#info.iStack)(scantokens listArray(@#lines)(@#nLines))("vleftbase"); +enddef; + +vardef Note_layout@#= + if @#layedout = 1: + log "Note " & (str @#) & " has already been layed out"; + else: + @#layedout := 1; + log "Note layout: " & (str @#); + + PictureStack_layout.@#stack; + + @#width = @#stack.width + @#info.left + @#info.right + @#info.horizontalFolding; + @#height = @#stack.height + @#info.top + @#info.bottom; + + @#top = @#stack.top + @#info.top; + @#left = @#stack.left - @#info.left; + fi; +enddef; + +vardef Note_draw@#= + Note_layout@#; + objectEnsurePositioning.@#; + + attributes(@#); + var(path) border, corner; + + @#border := @#nw -- (@#ne - (@#info.horizontalFolding, 0)) -- + (@#ne - (0, @#info.verticalFolding) ) -- @#se -- @#sw -- cycle; + + @#corner := (@#ne - (@#info.horizontalFolding, 0)) -- + (@#ne - (@#info.horizontalFolding, @#info.verticalFolding)) -- + (@#ne - (0, @#info.verticalFolding)); + + drawObjectShade(@#); + + fill Note_border.@# withcolor @#info.foreColor; + draw Note_border.@# withcolor @#info.borderColor; + + draw @#corner withcolor @#info.borderColor; + drawObject(@#stack); +enddef; + +vardef Note_border@#= + @#border +enddef; + 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; diff --git a/Master/texmf-dist/metapost/metauml/metauml_package_relations.mp b/Master/texmf-dist/metapost/metauml/metauml_package_relations.mp new file mode 100644 index 00000000000..5b740c0557f --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_package_relations.mp @@ -0,0 +1,51 @@ +% MetaUML, a MetaPost library for typesetting exquisite UML diagrams. +% Copyright (C) 2006 Radu-George Radulescu +% +% 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_relations_mp: + expandafter endinput +fi; +_metauml_package_relations_mp:=1; + +defaultRelationHeadWidth := 25; +defaultRelationHeadHeight := 10; + +vardef NestInfo@# = + LinkInfo@#; + + @#widthA = 0; + @#heightA = 0; + @#drawMethodA = "drawNothing"; + + @#widthB = defaultRelationHeadWidth; + @#heightB = defaultRelationHeadHeight; + @#drawMethodB = "drawCrossedCircle"; + + @#drawMethod = "drawLine"; +enddef; + +NestInfo.nest; + +vardef drawRelation(text iLink)(expr myPath)= + link(iLink)(myPath); +enddef; + +vardef drawLine(expr my_path) = + draw my_path; +enddef; + +vardef drawNothing(text pA)(text pB)(text base) = +enddef; diff --git a/Master/texmf-dist/metapost/metauml/metauml_paths.mp b/Master/texmf-dist/metapost/metauml/metauml_paths.mp new file mode 100644 index 00000000000..cb307f8df00 --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_paths.mp @@ -0,0 +1,86 @@ +% 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. + +if known _metauml_paths_mp: + expandafter endinput +fi; +_metauml_paths_mp:=1; + +def pathDirect(expr pA,pB) = + pA--pB +enddef; + +vardef pathManhattanX(expr pA,pB) = + pA--(xpart(pB), ypart(pA))--pB +enddef; + +vardef rpathManhattanX(expr pA,pB) = + pB--(xpart(pB), ypart(pA))--pA +enddef; + +vardef pathManhattanY(expr pA,pB) = + pA--(xpart(pA), ypart(pB))--pB +enddef; + +vardef rpathManhattanY(expr pA,pB) = + pB--(xpart(pA), ypart(pB))--pA +enddef; + +vardef pathStepX(expr pA,pB, deltax) = + pA--(pA+(deltax, 0))--(((xpart pA)+deltax), ypart(pB))--pB +enddef; + +vardef rpathStepX(expr pA,pB, deltax) = + pB--(((xpart pA)+deltax), ypart(pB))--(pA+(deltax, 0))--pA +enddef; + +vardef pathStepY(expr pA,pB, deltay) = + pA--(pA+(0, deltay))--(xpart(pB), ((ypart pA)+deltay))--pB +enddef; + +vardef rpathStepY(expr pA,pB, deltay) = + pB--(xpart(pB), ((ypart pA)+deltay))--(pA+(0, deltay))--pA +enddef; + +vardef pathHorizontal(expr pA, untilX) = + pA--(untilX,ypart(pA)) +enddef; + +vardef rpathHorizontal(expr pA, untilX) = + (untilX,ypart(pA))--pA +enddef; + +vardef pathVertical(expr pA, untilY) = + pA--(xpart(pA), untilY) +enddef; + +vardef rpathVertical(expr pA, untilY) = + (xpart(pA), untilY)--pA +enddef; + +% Cuts path thePath so that it won't intersect the objects +% objectA and objectB. The border of the objects is obtained +% by invoking the method "_border". +% +vardef pathCut(suffix objectA, objectB)(expr thePath)= + save timeA, timeB; + + timeA = xpart (thePath intersectiontimes objectBorder(objectA)); + timeB = xpart (thePath intersectiontimes objectBorder(objectB)); + + subpath (timeA, timeB) of thePath +enddef; diff --git a/Master/texmf-dist/metapost/metauml/metauml_skin_simple.mp b/Master/texmf-dist/metapost/metauml/metauml_skin_simple.mp new file mode 100644 index 00000000000..afafe88fab8 --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_skin_simple.mp @@ -0,0 +1,42 @@ +% 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. + +%% Usage of skins +%% +%% Skins are configuration files that, in geneal, customize the settings of +%% MetaUML *Info objects. You most likely want to include the skin file after +%% all other MetaUML files have been included: +%% +%% input metauml +%% input metauml_skin_simple +%% +%% % normal usage of MetaUML follows here +%% +%% More advanced skin files might customize fonts for specific elements +%% (eg for Class and Note), and also colors (eg foreground, shade, line etc.) + +if known _metauml_skin_simple_mp: + expandafter endinput +fi; +_metauml_skin_simple_mp:=1; + +iClass.foreColor := blue; +iClass.iName.iFont.name := "cmr12"; +iClass.iAttributeStack.iPict.iFont.name := "cmr10"; +iClass.iMethodStack.iPict.iFont.name := "cmr10"; + + diff --git a/Master/texmf-dist/metapost/metauml/metauml_state.mp b/Master/texmf-dist/metapost/metauml/metauml_state.mp new file mode 100644 index 00000000000..7d4b348afad --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_state.mp @@ -0,0 +1,203 @@ +% 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. + +if known _metauml_state_mp: + expandafter endinput +fi; +_metauml_state_mp:=1; + +input metauml_defaults; +input util_log; + +vardef StateInfo@#= + attributes(@#); + var(color) foreColor, borderColor; + var(numeric) round; + + FontInfo.@#iFont(metauml_defaultFont, defaultscale); + @#iFont.ignoreNegativeBase := 1; + + PictureInfo.@#iText (2, 2, 2, 2)(@#iFont); + PictureStackInfo.@#iStack (2, 2, 2, 2)(9)(@#iText); + + @#iStack.iPict.ignoreNegativeBase := 1; + + Margins.@#(2,2,0,6); + + GroupInfo.@#iGroupSubstates(2, 2, 4, 2); + + @#round := 5; + @#drawNameLine := 0; + + ShadeInfo.@#iShade; + @#foreColor := .9white; + @#borderColor := black; +enddef; + +vardef StateInfoCopy@#(text src)= + log "StateInfoCopy: Copying state info"; + attributes(@#); + var(color) foreColor, borderColor; + var(numeric) round; + + PictureStackInfoCopy.@#iStack (src.iStack); + MarginsCopy.@#(src); + @#round := src.round; + @#drawNameLine := src.drawNameLine; + + GroupInfoCopy.@#iGroupSubstates(src.iGroupSubstates); + + ShadeInfoCopy.@#iShade(src.iShade); + @#foreColor := src.foreColor; + @#borderColor := src.borderColor; +enddef; + +StateInfo.iState; + +vardef State@#(text contents)(text _substates)= + EState.@#(iState)(contents)(_substates); +enddef; + +vardef EState@#(text _info)(text contents)(text _substates)= + ObjectEquations(@#); + @#className := "State"; + + StateInfoCopy.@#info(_info); + + numeric @#nLines; @#nLines := 0; + string @#lines[]; + + numeric @#nInternalTransitions; @#nInternalTransitions := 0; + string @#internalTransitions[]; + + for l=contents: + @#lines[@#nLines] := l; + @#nLines := @#nLines + 1; + endfor; + + EGroup.@#substates(@#info.iGroupSubstates)(_substates); + %@#substates.info.boxed := 1; + + EPictureStack.@#stack(@#info.iStack)(scantokens listArray(@#lines)(@#nLines))("vcenterbase"); +enddef; + +vardef stateTransitions@#(text transitions)= + State_internalTransitions@#(transitions); +enddef; + +vardef State_internalTransitions@#(text transitions)= + for transition=transitions: + @#internalTransitions[@#nInternalTransitions] := transition; + @#nInternalTransitions := @#nInternalTransitions + 1; + endfor; +enddef; + +vardef State_layout@#= + if @#layedout = 1: + log "State '" & (str @#) & "' has already been layed out"; + else: + @#layedout := 1; + log "State layout: '" & (str @#) & "'"; + + EPictureStack.@#internalTransitionsStack(@#info.iStack) + (scantokens listArray(@#internalTransitions)(@#nInternalTransitions))("vleftbase"); + + log "State name layout '" & (str @#) & "'..."; + PictureStack_layout.@#stack; + log "Internal transitions layout '" & (str @#) & "'..."; + PictureStack_layout.@#internalTransitionsStack; + log "Substates layout '" & (str @#) & "'..."; + Group_layout.@#substates; + + log "All elements in state '" & (str @#) & "' successfully layed out, integrating..."; + +% @#internalTransitionsStack.info.boxed := 1; + + @#contentWidth = lmax(@#stack.width, @#internalTransitionsStack.width, @#substates.width); + + @#width = @#contentWidth + @#info.left + @#info.right + 2 * @#info.round; + @#height = @#stack.height + @#info.top + @#info.bottom + + @#internalTransitionsStack.height + @#substates.height; + + @#stack.n = @#n + (0, -@#info.top); + @#substates.n = @#stack.s; + + @#internalTransitionsStack.sw = @#sw + (@#info.round, @#info.round); + + attributes(@#); + var(pair) urt, lrt, ulft, llft; + var(pair) urta, lrta, ulfta, llfta; + var(pair) urtb, lrtb, ulftb, llftb; + + @#urta := @#ne - (@#info.round, 0); + @#urtb := @#ne - (0, @#info.round); + + @#lrta := @#se + (0, @#info.round); + @#lrtb := @#se - (@#info.round, 0); + + @#ulfta := @#nw - (0, @#info.round); + @#ulftb := @#nw + (@#info.round, 0); + + @#llfta := @#sw + (@#info.round, 0); + @#llftb := @#sw + (0, @#info.round); + + @#urt := @#ne - (@#info.round, @#info.round) + @#info.round * (sind(45),cosd(45)); + @#lrt := @#se + (-@#info.round, @#info.round) + @#info.round * (sind(135),cosd(135)); + @#llft := @#sw + (@#info.round, @#info.round) + @#info.round * (sind(225),cosd(225)); + @#ulft := @#nw + (@#info.round, -@#info.round) + @#info.round * (sind(315),cosd(315)); + + var(pair) nameLineLeft, nameLineRight; + ypart @#nameLineLeft = ypart @#nameLineRight = @#stack.bottom; + xpart @#nameLineLeft = xpart @#nw; + xpart @#nameLineRight = xpart @#ne; + + log "State layout for " & (str @#) & " ended."; + fi; +enddef; + +vardef State_draw@#= + State_layout.@#; + objectEnsurePositioning.@#; + + attributes(@#); + var(path) border; + + @#border := @#urta .. @#urt .. @#urtb -- % + @#lrta .. @#lrt .. @#lrtb -- % + @#llfta .. @#llft .. @#llftb -- % + @#ulfta .. @#ulft .. @#ulftb -- cycle; + + %fill @#border shifted (@#info.shade, -@#info.shade) withcolor .7white; + drawObjectShade(@#); + + fill @#border withcolor @#info.foreColor; + draw @#border withcolor @#info.borderColor; + + + drawObject(@#internalTransitionsStack); + drawObject(@#stack); + drawObject(@#substates); + + if @#info.drawNameLine = 1: + draw @#nameLineLeft -- @#nameLineRight; + fi; +enddef; + +vardef State_border@#= + @#border +enddef; + diff --git a/Master/texmf-dist/metapost/metauml/metauml_stereotype.mp b/Master/texmf-dist/metapost/metauml/metauml_stereotype.mp new file mode 100644 index 00000000000..afc4ef14a8a --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_stereotype.mp @@ -0,0 +1,27 @@ +% 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. + +if known _metauml_stereotype_mp: + expandafter endinput +fi; +_metauml_stereotype_mp:=1; + +input metauml_defaults; + +FontInfo.assocFont(metauml_defaultFont, .7); +PictureInfo.iStereo(2, 2, 2, 2)(assocFont); +iStereo.ignoreNegativeBase := 1; diff --git a/Master/texmf-dist/metapost/metauml/metauml_templates.mp b/Master/texmf-dist/metapost/metauml/metauml_templates.mp new file mode 100644 index 00000000000..f4125097108 --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_templates.mp @@ -0,0 +1,134 @@ +% 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. + +if known _metauml_templates_mp: + expandafter endinput +fi; +_metauml_templates_mp:=1; + +input metauml_defaults; +input util_log; + +vardef TemplateInfo@#= + color @#background; + color @#borderColor; + numeric @#borderScale; + + @#background := .9white; + @#borderColor := black; + @#borderScale := 1; + + FontInfo.@#iFont(metauml_defaultFont, .9); + PictureInfo.@#iPict(2, 2, 2, 2)(@#iFont); + PictureStackInfo.@#iStack(2, 2, 1, 1)(7)(@#iPict); + + @#iStack.iPict.ignoreNegativeBase := 1; +enddef; + +vardef TemplateInfoCopy@#(text src)= + color @#background; + color @#borderColor; + numeric @#borderScale; + + @#background := src.background; + @#borderColor := src.borderColor; + @#borderScale := src.borderScale; + + FontInfoCopy.@#iFont(src.iFont); + PictureInfoCopy.@#iPict(src.iPict); + PictureStackInfoCopy.@#iStack(src.iStack); +enddef; + +TemplateInfo.iTemplate; + +% +% Template +% +vardef ETemplate@#(text _info)(text templates) = + ObjectEquations(@#); + @#className := "Template"; + + TemplateInfoCopy.@#info(_info); + + EPictureStack.@#elementsStack(@#info.iStack)(templates)("vleftbase"); + + @#nw = @#elementsStack.nw; + @#se = @#elementsStack.se; +enddef; + +vardef Template@#(text templates) = + ETemplate@#(iTemplate)(templates); +enddef; + +vardef EClassTemplate@#(text _info)(text templates)(text theClass)= + ETemplate.@#(_info)(templates); + Template_attachToClass.@#(theClass); +enddef; + +vardef ClassTemplate@#(text templates)(text theClass)= + EClassTemplate.@#(iTemplate)(templates)(theClass); +enddef; + +vardef Template_layout@#= + if @#layedout = 1: + log "Template " & (str @#) & " has already been layed out"; + else: + @#layedout := 1; + log "Template layout: " & (str @#); + PictureStack_layout.@#elementsStack; + fi; +enddef; + +vardef Template_paintSkin@# = + log "Painting template skin..."; + + fill objectBox(@#) withcolor @#info.background; + + draw objectBox(@#) dashed evenly scaled .8 + withpen pencircle scaled @#info.borderScale withcolor @#info.borderColor; +enddef; + +vardef Template_draw@# = + Template_layout.@#; + + Template_paintSkin.@#; + drawObject(@#elementsStack); +enddef; + +vardef Template_attachToClass@#(text theClass)= + Template_layout.@#; + Class_layout.theClass; + + log "--- Attaching template " & (str @#) & " to class " & (str theClass); + + save __nItems, __nameToRight; + + __nItems := @#elementsStack.nItems; + __nameToRight := theClass.right - theClass.namePict.right; + + @#elementsStack.pict[__nItems-1].midy = theClass.top; + + if __nameToRight > @#width/2: + @#midx = theClass.right; + log "X"; + else: + @#midx = theClass.right + (@#width/2 - __nameToRight) + 2; + log "Y"; + fi; + + %@#elementsStack.pict[__nItems-1].info.boxed:=1; +enddef; diff --git a/Master/texmf-dist/metapost/metauml/metauml_usecase.mp b/Master/texmf-dist/metapost/metauml/metauml_usecase.mp new file mode 100644 index 00000000000..1fc98b5879e --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_usecase.mp @@ -0,0 +1,217 @@ +% 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. + +if known _metauml_usecase_mp: + expandafter endinput +fi; +_metauml_usecase_mp:=1; + +input metauml_defaults; +input util_log; + +vardef ActorInfo@#= + FontInfo.@#iFont(metauml_defaultFont, defaultscale); + @#iFont.ignoreNegativeBase := 1; + + PictureInfo.@#iName (2, 2, 2, 2)(@#iFont); + PictureStackInfo.@#iNameStack (1pt, 1pt, 1pt, 1pt)(9)(@#iName); + + @#iNameStack.iPict.ignoreNegativeBase := 1; + + HumanInfo.@#iHuman(25, 35, .3, .35, .5, 1, 1); +enddef; + +vardef ActorInfoCopy@#(text src)= + log "ActorInfoCopy: Copying actor info"; + + PictureStackInfoCopy.@#iNameStack (src.iNameStack); + + HumanInfoCopy.@#iHuman(src.iHuman); +enddef; + +ActorInfo.iActor; + +vardef Actor@#(text contents)= + EActor.@#(iActor)(contents); +enddef; + +vardef EActor@#(text _info)(text contents)= + ObjectEquations(@#); + @#className := "Actor"; + + ActorInfoCopy.@#info(_info); + + numeric @#nLines; @#nLines := 0; + string @#lines[]; + for l=contents: + @#lines[@#nLines] := l; + @#nLines := @#nLines + 1; + endfor; + EHuman.@#human(@#info.iHuman); + EPictureStack.@#nameStack(@#info.iNameStack)(scantokens listArray(@#lines)(@#nLines))("vcenterbase"); +enddef; + +vardef Actor_setDebugMode@#= + @#.nameStack.info.boxed := 1; +enddef; + +vardef Actor_layout@#= + if @#layedout = 1: + log "Actor " & (str @#) & " has already been layed out"; + else: + @#layedout := 1; + log "Actor layout: " & (str @#); + Human_layout.@#human; + PictureStack_layout.@#nameStack; + + @#width = max(@#nameStack.width)(@#human.width); + @#height = @#nameStack.height + @#human.height; + + @#n = @#human.n; + @#nameStack.n=@#human.s; + @#s = @#nameStack.s; + fi; +enddef; + +vardef Actor_draw@#= + Actor_layout.@#; + + objectEnsurePositioning.@#; + + drawObjects(@#nameStack, @#human); +enddef; + +vardef Actor_border@#= + objectBox(@#); +enddef; + +vardef UsecaseInfo@#= + attributes(@#); + var(color) foreColor, borderColor; + + FontInfo.@#iFont(metauml_defaultFont, defaultscale); + @#iFont.ignoreNegativeBase := 1; + + PictureInfo.@#iName (2, 2, 2, 2)(@#iFont); + PictureStackInfo.@#iNameStack (0, 0, 0, 0)(9)(@#iName); + + @#iNameStack.iPict.ignoreNegativeBase := 1; + + Margins.@#(2,2,2,2); + + @#hFatRatio := .1; + @#vFatRatio := .15; + + ShadeInfo.@#iShade; + @#foreColor := .9white; + @#borderColor := black; +enddef; + +vardef UsecaseInfoCopy@#(text src)= + log "UsecaseInfoCopy: Copying usecase info"; + attributes(@#); + var(color) foreColor, borderColor; + + PictureStackInfoCopy.@#iNameStack (src.iNameStack); + MarginsCopy.@#(src); + @#hFatRatio := src.hFatRatio; + @#vFatRatio := src.vFatRatio; + + ShadeInfoCopy.@#iShade(src.iShade); + @#foreColor := src.foreColor; + @#borderColor := src.borderColor; +enddef; + +UsecaseInfo.iUsecase; + +vardef Usecase@#(text contents)= + EUsecase.@#(iUsecase)(contents); +enddef; + +vardef EUsecase@#(text _info)(text contents)= + ObjectEquations(@#); + @#className := "Usecase"; + + UsecaseInfoCopy.@#info(_info); + + attributes(@#); + var(numeric) nLines; + @#nLines := 0; + + string @#lines[]; + for l=contents: + @#lines[@#nLines] := l; + @#nLines := @#nLines + 1; + endfor; +enddef; + +vardef Usecase_layout@#= + if @#layedout = 1: + log "Usecase " & (str @#) & " has already been layed out"; + else: + @#layedout := 1; + + EPictureStack.@#nameStack(@#info.iNameStack)(scantokens listArray(@#lines)(@#nLines))("vcenterbase"); + PictureStack_layout.@#nameStack; + + numeric @#vFat, @#hFat; + + @#hFat = 0; + @#vFat = 10; + + @#width = @#nameStack.width + @#info.left + @#info.right + 2 * @#hFat; + @#height = @#nameStack.height + @#info.top + @#info.bottom + 2 * @#vFat; + + log "UC w,h"; + log @#hFat; + log @#vFat; + log @#nameStack.width; + log @#nameStack.height; + log @#width; + log @#height; + + @#c = @#nameStack.c; + fi; +enddef; + +vardef Usecase_draw@#= + Usecase_layout@#; + + pair @#urt, @#lrt, @#ulft, @#llft; + + @#urt = @#nameStack.ne; + @#lrt = @#nameStack.se; + @#ulft = @#nameStack.nw; + @#llft = @#nameStack.sw; + + objectEnsurePositioning.@#; + + path @#border; + %@#border := @#w .. @#ulft .. @#n .. @#urt .. @#e .. @#lrt .. @#s .. @#llft .. cycle; + @#border := @#w .. @#n .. @#e .. @#s .. cycle; + + drawObjectShade(@#); + + fill Usecase_border.@# withcolor @#info.foreColor; + draw Usecase_border.@# withcolor @#info.borderColor; + + drawObject(@#nameStack); +enddef; + +vardef Usecase_border@#= + @#border +enddef; diff --git a/Master/texmf-dist/metapost/metauml/metauml_usecase_clipart.mp b/Master/texmf-dist/metapost/metauml/metauml_usecase_clipart.mp new file mode 100644 index 00000000000..4e573fae3be --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_usecase_clipart.mp @@ -0,0 +1,160 @@ +% 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. + +%% +%% This file contains various drawings which can be used in +%% UML usecase diagrams +%% + +if known _metauml_usecase_clipart_mp: + expandafter endinput +fi; +_metauml_usecase_clipart_mp:=1; + +input util_log; + +vardef HumanInfo@#(expr _width, _height, _yHeadRatio, _yBodyRatio, _yHandsRatio, _xHandsRatio, _xLegsRatio)= + attributes(@#); + + var(numeric) width, height, yHeadRatio, yBodyRatio, + yHandsRatio, xHandsRatio, xLegsRatip; + var(color) foreColor, shadeColor; + var(numeric) shade; + + @#width := _width; + @#height := _height; + @#yHeadRatio := _yHeadRatio; + @#yBodyRatio := _yBodyRatio; + @#yHandsRatio := _yHandsRatio; + @#xHandsRatio := _xHandsRatio; + @#xLegsRatio := _xLegsRatio; + + @#foreColor := black; + @#shadeColor := .7white; + @#shade := .5; + + Margins.@#(2,2,1,0); +enddef; + +vardef HumanInfoCopy@#(text src)= + HumanInfo@#(src.width, src.height, src.yHeadRatio, src.yBodyRatio, src.yHandsRatio, src.xHandsRatio, src.xLegsRatio); + + _n_ := str @#; + var(color) foreColor, shadeColor; + var(numeric) shade; + + @#foreColor := src.foreColor; + @#shadeColor := src.shadeColor; + @#shade := src.shade; + + MarginsCopy.@#(src); +enddef; + +HumanInfo.iHuman(25, 25, .3, .35, .55, 1, 1); + +vardef EHuman@#(text _info)= + ObjectEquations(@#); + @#className := "Human"; + + var(path) pHead, pBody, pHands, pLegs; + + HumanInfoCopy.@#info(_info); +enddef; + +vardef Human@#= + EHuman@#(iHuman); +enddef; + +vardef Human_layout@#= + if @#layedout = 1: + log "Human " & (str @#) & " has already been layed out"; + else: + @#layedout := 1; + log "Human layout: " & (str @#); + + attributes(@#); + + @#height = @#info.height; + @#width = @#info.width; + + log "(W, H) MUST BE SET. Their values are: " & (decimal @#height) &" "& (decimal @#width); + + var(numeric) actualHeight, actualWidth; + @#actualHeight = @#height - @#info.top - @#info.bottom; + @#actualWidth = @#width - @#info.left - @#info.right; + + % HEAD + var(pair) headS, headE, headW; + + ypart @#headW = ypart @#headE; + .5[@#n - (0, @#info.top), @#headS] = .5[@#headE, @#headW]; + (ypart @#n - @#info.top) - (ypart @#headS) = + (xpart @#headE) - (xpart @#headW) = + @#actualHeight * @#info.yHeadRatio; + (xpart @#headS) = (xpart @#n); + + % BODY + var(pair) bodyS; + xpart @#bodyS = xpart @#headS; + ypart @#headS - ypart @#bodyS = @#actualHeight * @#info.yBodyRatio; + + % HANDS + var(pair) handsW, handsE; + ypart @#handsW = ypart @#handsE = ypart @#n - (@#actualHeight * @#info.yHandsRatio); + .5[xpart @#handsE, xpart @#handsW] = @#midx; + xpart @#handsE - xpart @#handsW = @#actualWidth * @#info.xHandsRatio; + + % LEGS + var(pair) footW, footE; + ypart @#footW = ypart @#footE = ypart @#s + @#info.bottom; + .5[xpart @#footW, xpart @#footE] = @#midx; + xpart @#footE - xpart @#footW = @#actualWidth * @#info.xLegsRatio; + + log "Human layout completed"; + fi; +enddef; + +vardef Human_draw@#= + log "Drawing human"; + + Human_layout.@#; + objectEnsurePositioning.@#; + + % all coordinates must be set to known values in order to compute the paths + @#pHead := (@#n - (0, @#info.top)) .. @#headE .. @#headS .. @#headW .. cycle; + @#pBody := @#headS -- @#bodyS; + @#pHands := @#handsW -- @#handsE; + @#pLegs := @#footW -- @#bodyS -- @#footE; + + attributes(@#); + var(pair) shadeShift; + @#shadeShift = (@#info.shade, -@#info.shade); + + draw @#pHead shifted @#shadeShift withcolor @#info.shadeColor; + draw @#pBody shifted @#shadeShift withcolor @#info.shadeColor; + draw @#pHands shifted @#shadeShift withcolor @#info.shadeColor; + draw @#pLegs shifted @#shadeShift withcolor @#info.shadeColor; + + draw @#pHead withcolor @#info.foreColor; + draw @#pBody withcolor @#info.foreColor; + draw @#pHands withcolor @#info.foreColor; + draw @#pLegs withcolor @#info.foreColor; +enddef; + +vardef Human_border@#= + objectBox(@#) +enddef; diff --git a/Master/texmf-dist/metapost/metauml/util_commons.mp b/Master/texmf-dist/metapost/metauml/util_commons.mp new file mode 100644 index 00000000000..b333ee57a5a --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/util_commons.mp @@ -0,0 +1,139 @@ +% MetaUtil, an easier MetaPost life +% 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. + +if known _util_commons_mp: + expandafter endinput +fi; +_util_commons_mp:=1; + +input util_log; + +vardef lmax(text items)= + log "finding lmax of items " & str items; + save current, nItems; + numeric current, nItems; + nItems := 0; + current:= 0; + + for item = items: + log nItems; + log item; + + if nItems = 0: + current := item; + else: + current := max(current)(item); + fi; + nItems := nItems + 1; + endfor; + + current +enddef; + +vardef lmin(text items)= + save current, nItems; + numeric current, nItems; + nItems := 0; + current:= 0; + + for item = items: + if nItems = 0: + current := item; + else: + current := min(current)(item); + fi; + nItems := nItems + 1; + endfor; + + current +enddef; + +def max(text a)(text b)= + if (a > b): a% + else:b% + fi; +enddef; + +def min(text a)(text b)= + if (a < b): a% + else:b% + fi; +enddef; + +vardef ensurePict(text pictOrText)(expr font, scale) = + save p; picture p; + if picture pictOrText: p=pictOrText + else: p = pictOrText infont font scaled scale + fi; + p +enddef; + +def pictHeight(text obj) = + (ypart (urcorner obj) - ypart (llcorner obj)) +enddef; + +def pictWidth(text obj) = + (xpart (urcorner obj) - xpart (llcorner obj)) +enddef; + +vardef listArray(text array)(text nElements)= + save objEnum; + string objEnum; + objEnum := ""; + + for i = 0 upto nElements-1: + if i>0: + objEnum := objEnum & ", "; + fi; + objEnum := objEnum & (str array) & (decimal i); + endfor; + + objEnum +enddef; + +vardef enumToString(text enumeration)(expr prefix)= + save ret, firstVar; + string ret; + ret := ""; + + numeric firstVar; + firstVar := 1; + + forsuffixes v = enumeration: + if firstVar = 0: + ret := ret & ","; + else: + firstVar := 0; + fi; + + ret := ret & prefix & (str v); + endfor; + + ret +enddef; + +def _dx(text pA)(text pB) = + (xpart(pB)-xpart(pA)) +enddef; + +def _dy(text pA, pB) = + (ypart(pB)-ypart(pA)) +enddef; + +def _length(text pA)(text pB) = + sqrt (_dx(pA)(pB)*_dx(pA)(pB) + _dy(pA)(pB)*_dy(pA)(pB)) +enddef; diff --git a/Master/texmf-dist/metapost/metauml/util_group.mp b/Master/texmf-dist/metapost/metauml/util_group.mp new file mode 100644 index 00000000000..732deba4bdf --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/util_group.mp @@ -0,0 +1,173 @@ +% MetaUtil, an easier MetaPost life +% 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. + +if known _util_group_mp: + expandafter endinput +fi; +_util_group_mp:=1; + +input util_object; +input util_commons; +input util_margins; +input util_log; + +vardef GroupInfo@#(expr pleft, pright, ptop, pbottom)= + attributes(@#); + var(color) borderColor; + var(numeric) boxed; + + @#boxed := 0; + @#borderColor := red; + + Margins.@#(pleft, pright, ptop, pbottom); +enddef; + +vardef GroupInfoCopy@#(text src)= + GroupInfo@#(src.left, src.right, src.top, src.bottom); + + @#boxed := src.boxed; + @#borderColor := src.borderColor; + +enddef; + +GroupInfo.iGroup(2, 2, 2, 2); + +GroupInfoCopy.iGroupBoxed(iGroup); +iGroupBoxed.boxed := 1; + +vardef EGroup@#(text groupInfo)(text objects)= + ObjectEquations(@#); + @#className := "Group"; + + var(numeric) minx, maxx, miny, maxy; + var(numeric) nObjects; + var(string) objectsAsString; + + GroupInfoCopy.@#info(groupInfo); + + @#objectsAsString := enumToString(objects)(""); + log @#objectsAsString; + + @#nObjects := 0; + if @#objectsAsString <> "": + forsuffixes obj = scantokens @#objectsAsString: + @#nObjects := @#nObjects + 1; + endfor; + fi; + +enddef; + +vardef Group@#(text objects)= + EGroup@#(iGroup)(objects); +enddef; + +vardef Group_layout@#= + if @#layedout = 0: + log "Needing layout for group " & (str @#); + @#layedout := 1; + + if (@#objectsAsString = ""): + @#width = @#info.left + @#info.right; + @#height = @#info.top + @#info.bottom; + else: + log "Calling layout for objects group '" & (str @#) & "' ..."; + log " object are: '" & @#objectsAsString & "'."; + + layoutObjects(scantokens @#objectsAsString); + log "All objects in group '" & (str @#) & "' are now layed out."; + + % As already tested, @#objectsAsString must be <> "". + % See page 53, User's manual for MetaPost + % "if some of the suffixes are empty, the loop gets + % executed, with the loop index parameter set to + % the empty suffix" (!) + + log "Proceeding to finding min/max x/y of objects:"; + log " " & @#objectsAsString; + + __objectIndex := 0; + forsuffixes obj__ = scantokens @#objectsAsString: + if __objectIndex = 0: + log "First object " & str obj__; + @#minx := obj__.left; + log @#maxx; + log obj__.right; + @#maxx := obj__.right; + log @#maxx; + @#miny := obj__.bottom; + @#maxy := obj__.top; + + __objectIndex := __objectIndex + 1; + else: + log "Current object " & str obj__; + + log "comparing(min)"; + log @#minx; + log @#obj__.left; + @#minx := min(@#minx)(obj__.left); + + log "comparing(max)"; + log @#maxx; + log @#obj__.right; + @#maxx := max(@#maxx)(obj__.right); + + log "comparing(min)"; + log @#miny; + log @#obj__.bottom; + @#miny := min(@#miny)(obj__.bottom); + + log "comparing(max)"; + log @#maxy; + log @#obj__.top; + @#maxy := max(@#maxy)(obj__.top); + + __objectIndex := __objectIndex + 1; + fi; + endfor; + log "... done iterating"; + log "maxx = "; + log @#maxx; + + @#nw = (@#minx - @#info.left, @#maxy + @#info.top); + @#se = (@#maxx + @#info.right, @#miny - @#info.bottom); + + log "Done performing actual layout for group " & str @#; + fi; + else: + log "NOT needing layout for group " & (str @#); + fi; +enddef; + +vardef Group_draw@#= + log "Drawing group...."; + Group_layout@#; + objectEnsurePositioning.@#; + + if @#objectsAsString <> "": + drawObjects(scantokens @#objectsAsString); + fi; + + if (@#info.boxed = 1): + draw objectBox(@#) withcolor @#info.borderColor; + fi; +enddef; + +vardef Group_border@#= + objectBox(@#) +enddef; + + diff --git a/Master/texmf-dist/metapost/metauml/util_infrastructure.mp b/Master/texmf-dist/metapost/metauml/util_infrastructure.mp new file mode 100644 index 00000000000..26dc421cdb9 --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/util_infrastructure.mp @@ -0,0 +1,58 @@ +% MetaUtil, an easier MetaPost life +% 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. + +if known _util_infrastructure_mp: + expandafter endinput +fi; +_util_infrastructure_mp:=1; + +input util_log; + +vardef attributes(text objectName)= + _n_ := str objectName +enddef; + +vardef variables_ext text variables= + save ret, firstVar; + string ret; + ret := ""; + + numeric firstVar; + firstVar := 1; + + forsuffixes v = variables: + if firstVar = 0: + ret := ret & ","; + else: + firstVar := 0; + fi; + + ret := ret & " _n." & (str v); + endfor; + + ret +enddef; + +vardef var(text type) text variables = + save _variables; + string _variables; + _variables := variables_ext variables; + + generic_declare(type) scantokens _variables; +enddef; + + diff --git a/Master/texmf-dist/metapost/metauml/util_log.mp b/Master/texmf-dist/metapost/metauml/util_log.mp new file mode 100644 index 00000000000..20efc47fe08 --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/util_log.mp @@ -0,0 +1,45 @@ +% MetaUtil, an easier MetaPost life +% 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. + +if known _util_log_mp: + expandafter endinput +fi; +_util_log_mp:=1; + +util_loglevel_PARANOIA:=1; +util_loglevel_DEBUG:=2; +util_loglevel_RELEASE:=3; +util_loglevel_SILENT:=4; + +util_log_thresholdlevel := util_loglevel_DEBUG; +util_log_defaultlevel := util_loglevel_RELEASE; + +def elog(expr loglevel) text txt= + if (loglevel <= util_log_thresholdlevel): + show txt + else: + % do nothing + fi; +enddef; + +def log text txt= + if (util_log_defaultlevel <= util_log_thresholdlevel): + show txt + else: + % do nothing + fi; +enddef; diff --git a/Master/texmf-dist/metapost/metauml/util_margins.mp b/Master/texmf-dist/metapost/metauml/util_margins.mp new file mode 100644 index 00000000000..7b6b0446cfb --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/util_margins.mp @@ -0,0 +1,35 @@ +% MetaUtil, an easier MetaPost life +% 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. + +if known _util_margins_mp: + expandafter endinput +fi; +_util_margins_mp:=1; + +vardef Margins@#(expr pleft, pright, ptop, pbottom)= + attributes(@#); + var(numeric) left, right, top, bottom; + + @#left := pleft; + @#right := pright; + @#top := ptop; + @#bottom := pbottom; +enddef; + +vardef MarginsCopy@#(text src)= + Margins@#(src.left, src.right, src.top, src.bottom); +enddef; diff --git a/Master/texmf-dist/metapost/metauml/util_object.mp b/Master/texmf-dist/metapost/metauml/util_object.mp new file mode 100644 index 00000000000..7cd6c0404c6 --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/util_object.mp @@ -0,0 +1,217 @@ +% MetaUtil, an easier MetaPost life +% 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. + +if known _util_object_mp: + expandafter endinput +fi; +_util_object_mp:=1; + +input util_infrastructure; +input util_log; + +def ObjectEquations(suffix $)= + attributes($); + var(pair) n, ne, e, se, s, sw, w, nw, c; + var(pair) dim; + var(numeric) width, height; + + var(numeric) left, right; + var(numeric) top, bottom; + var(numeric) midx, midy; + + var(picture) pict; + var(string) className; + + var(numeric) layedout, drawn; + + $.layedout := 0; + $.drawn := 0; + + $.left = xpart $.nw = xpart $.sw; + $.right = xpart $.ne = xpart $.se; + + $.top = ypart $.ne = ypart $.nw; + $.bottom = ypart $.se = ypart $.sw; + + $.w = .5[$.nw,$.sw]; + $.s = .5[$.sw,$.se]; + $.e = .5[$.ne,$.se]; + $.n = .5[$.ne,$.nw]; + + $.c = .5[$.nw, $.se]; + + $.width = $.right - $.left; + $.height = $.top - $.bottom; + + $.midx = xpart($.c); + $.midy = ypart($.c); + + xpart $.dim = $.width; + ypart $.dim = $.height; + + $.className := "Object"; +enddef; + +def objectBox(text obj)= + obj.nw -- obj.ne -- obj.se -- obj.sw -- cycle +enddef; + +vardef objectBorder(suffix @#)= + save methodName; + string methodName; + methodName := @#className & "_border"; + log "invoking " & methodName & " arg=" & str @#; + + scantokens (methodName).@# +enddef; + +vardef Object_toString(text obj)= + save ret; string ret; + ret := "Generic object"; + ret +enddef; + +vardef toString(suffix @#)= + scantokens (@#className & "_toString").@# +enddef; + +vardef layoutObject(suffix @#)= + save methodName; + string methodName; + methodName := @#className & "_layout"; + log "invoking " & methodName & " arg=" & str @#; + + scantokens (methodName).@#; +enddef; + +vardef drawObject(suffix @#)= + save methodName; + string methodName; + methodName := @#className & "_draw"; + log "invoking " & methodName & " arg=" & str @#; + + scantokens (methodName).@#; +enddef; + +vardef drawObjectShade(suffix @#)= + fill objectBorder(@#) shifted + (@#.info.iShade.shift, -@#.info.iShade.shift) withcolor @#.info.iShade.background; +enddef; + +vardef objectEnsurePositioning@#= + if unknown (xpart @#nw): + log "*** WARNING: DEFAULTING OBJECT'S (" & (str @#) & ") x TO 0"; + xpart @#nw = 0; + fi; + if unknown (ypart @#nw): + log "*** WARNING: DEFAULTING OBJECT'S (" & (str @#) & ") y TO 0"; + ypart @#nw = 0; + fi; +enddef; + +vardef drawObjectAt(suffix @#)(text eq)= + eq; + drawObject(@#); +enddef; + +vardef layoutObjects(text objects)= + log "Layout objects..."; + forsuffixes o = objects: + if (str o) <> "": + layoutObject(o); + fi; + endfor; +enddef; + +vardef drawObjects(text objects)= + % This needs to be done first in order to allow for equations which define + % relative positioning to be appropiately solved. Otherwise, for example, + % object0 may be positioned somewhere by default, and object1 also, leading + % to inconsitent equations. Inconsistency would have been caused by the fact that the + % positioning equations become meaningful only after object layout is performed + % --- but that would have been too late, since the positioning would have been + % done already to inappropriate values. + % + layoutObjects(objects); + + forsuffixes o = objects: + if (str o) <> "": + drawObject(o); + fi; + endfor; +enddef; + +%% +%% Joins the given pictures according to the equation given +%% by the pictureDoJoin macro. Note: the pictureDoJoin macro +%% can be conveniently set by calling setPicutureJoin macro. +%% +%% Usage example: +%% joinObjects (p, q, r); +%% +def joinObjects(text pictures)= + save skipFirstPicture; + skipFirstPicture := 1; + forsuffixes p=pictures: + if skipFirstPicture=0: + objectDoJoin(previousPic, p); + else: + % first picture is skipped + skipFirstPicture := 0; + fi; + def previousPic=p enddef; + endfor; +enddef; + +%% +%% Sets the macro pictureDoJoin, which is used by joinObjects to join +%% one picture into another. +%% +%% The pictureDoJoin macro has two arguments: pa and pb. +%% pa represents the first picture and pb the second picture. +%% The second picture is positioned relatively to pa as specified +%% by the given equation. +%% +%% Usage examples: +%% +%% % place the second picture at the bottom of the first +%% setPictureJoin(pa.sw = pb.nw); +%% +%% % place the second picture at the right of the first +%% setPictureJoin(pa.ne = pb.nw); +%% +def setObjectJoin(text eq)= + def objectDoJoin(suffix pa, pb)=eq enddef; +enddef; + +%% +%% A shortcut for setting the join equation and actually performing the join. +% +def joinObjectsEq(text objects)(text eq)= + setObjectJoin(eq); + joinObjects(objects); +enddef; + + +%% +%% Joins the pictures and draws them. A shorthand for +%% the corresponding two macro invocations. +%% +def joinDrawObjects(text pictures)= + joinObjects(pictures); + drawObjects(pictures); +enddef; diff --git a/Master/texmf-dist/metapost/metauml/util_picture.mp b/Master/texmf-dist/metapost/metauml/util_picture.mp new file mode 100644 index 00000000000..fc9133392d9 --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/util_picture.mp @@ -0,0 +1,217 @@ +% MetaUtil, an easier MetaPost life +% 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. + +if known _util_picture_mp: + expandafter endinput +fi; +_util_picture_mp:=1; + +input util_log; + +input util_margins; +if not known _n_cur_:input boxes;fi; + +vardef FontInfo@#(expr tname, tscale)= + attributes(@#); + var(string) className; + var(string) name; + var(numeric) scale; + + @#className := "FontInfo"; + + @#name := tname; + @#scale := tscale; +enddef; + +vardef FontInfoCopy@#(text fontInfo)= + FontInfo@#(fontInfo.name, fontInfo.scale); + @#ignoreNegativeBase := fontInfo.ignoreNegativeBase; +enddef; + +vardef FontInfo_toString@#= + save ret; string ret; + ret := "FontInfo(" & (str @#) & "): {" & (@#name) & ", " & (decimal @#scale) & "}"; + ret +enddef; + +log "()()() Creating iFont"; +FontInfo.iFont(defaultfont, defaultscale); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% PICTURE % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +vardef PictureInfo@#(expr pleft, pright, ptop, pbottom)(text pfont)= + attributes(@#); + var(string) className; + @#className := "PictureInfo"; + + var(color) borderColor; + var(numeric) boxed; + + var(numeric) ignoreNegativeBase; + + @#boxed := 0; + @#borderColor := blue; + + @#ignoreNegativeBase := 0; + + Margins.@#(pleft, pright, ptop, pbottom); + + FontInfoCopy.@#iFont(pfont); +enddef; + +vardef PictureInfoCopy@#(text src)= + PictureInfo@#(src.left, src.right, src.top, src.bottom)(src.iFont); + + @#boxed := src.boxed; + @#borderColor := src.borderColor; + @#ignoreNegativeBase := src.ignoreNegativeBase; +enddef; + +vardef PictureInfo_toString@#= + save ret; string ret; + ret := "PictureInfo(" & (str @#) & "): {" & (decimal @#left) & ", " & (decimal @#right) & ", " & (decimal @#top) & ", " & (decimal @#bottom) & "}" & " boxed: " & (decimal @#boxed); + ret := ret & " Font: " & toString(@#iFont); + ret +enddef; + +PictureInfo.iPict(2, 2, 2, 2)(iFont); + +PictureInfoCopy.iPictBoxed(iPict); +iPictBoxed.boxed := 1; + +%% +%% Contructs a Picture object by wrapping around the +%% low-level picture thePict. +%% +vardef EPicture@#(text iPict)(expr thePict) = + ObjectEquations(@#); + @#className := "Picture"; + + var(pair) contentShift; + var(picture) pict; + var(numeric) negativeBase; + var(string) contentAsString; + var(picture) contentAsPicture; + + PictureInfoCopy.@#info(iPict); + + if string thePict: + log "Picture " & (str @#) & " is a text"; + @#contentAsString := thePict; + log @#contentAsString; + elseif picture thePict: + log "Picture " & (str @#) & " is a native pict"; + @#contentAsPicture := thePict; + log @#contentAsPicture; + else: + log "Picture " & (str @#) & " [error]"; + fi; + +enddef; + +%% +%% Contructs a Picture object by wrapping around the +%% low-level picture thePict. +%% +vardef Picture@#(expr thePict) = + EPicture@#(iPict)(thePict); +enddef; + +%% +%% Lays out the Picture. +%% +vardef Picture_layout@# = + if @#layedout = 0: + log "Laying out " & (str @#); + + @#layedout := 1; + + if known @#contentAsPicture: + log "Content is known to be a picture"; + @#pict = @#contentAsPicture; + elseif known @#contentAsString: + log "Content is known to be a string"; + log @#contentAsString; + @#pict = @#contentAsString infont @#info.iFont.name scaled @#info.iFont.scale; + else: + log "Show unknown parameter type in picture layout"; + 2 = 3; + fi; + + @#negativeBase = ypart llcorner @#pict; + + @#width = pictWidth(@#pict) + @#info.left + @#info.right; + + if @#info.ignoreNegativeBase = 0: + @#height = pictHeight(@#pict) + @#info.top + @#info.bottom; + @#contentShift = @#sw + (@#info.left, @#info.bottom - @#negativeBase) ; + else: + @#height = pictHeight(@#pict) + @#info.top + @#info.bottom + @#negativeBase; + @#contentShift = @#sw + (@#info.left, @#info.bottom); + fi; + + else: + log "Picture " & str @# & " already layed out."; + fi; +enddef; + +%% +%% Draws the Picture. +%% +vardef Picture_draw@# = + Picture_layout@#; + objectEnsurePositioning.@#; + + draw @#pict shifted @#contentShift; + + if (@#info.boxed = 1): + draw objectBox(@#) withcolor @#info.borderColor; + fi; +enddef; + +vardef Picture_border@#= + objectBox(@#) +enddef; + +vardef aitem(text pictInfo)(text thePict)(text equation)= + save obj; + EPicture.obj(pictInfo)(thePict); + equation; + drawObject(obj); +enddef; + +vardef item@#(text iPict)(text thePict)(text equation)= + save itemName; + string itemName; + itemName := str @#; + + log "Creating an item with name: '" & itemName & "'"; + + if itemName = "": + log "Name is empty, creating an anonymous item!"; + aitem(iPict)(thePict)(equation); + else: + EPicture@#(iPict)(thePict); + equation; + drawObject(@#); + fi; +enddef; + diff --git a/Master/texmf-dist/metapost/metauml/util_picture_stack.mp b/Master/texmf-dist/metapost/metauml/util_picture_stack.mp new file mode 100644 index 00000000000..11b6b7a16fa --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/util_picture_stack.mp @@ -0,0 +1,137 @@ +% MetaUtil, an easier MetaPost life +% 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. + +if known _util_picture_stack_mp: + expandafter endinput +fi; +_util_picture_stack_mp:=1; + +input util_picture; +input util_commons; +input util_group; + +input util_log; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% PICTURE STACK % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +vardef PictureStackInfo@#(expr pleft, pright, ptop, pbottom)(text pspacing)(text ppictInfo)= + attributes(@#); + var(numeric) boxed; + var(color) borderColor; + + var(numeric) left, right, top, bottom; + var(numeric) spacing; + + Margins@#(pleft, pright, ptop, pbottom); + + @#spacing := pspacing; + + @#boxed := 0; + @#borderColor := green; + + PictureInfoCopy.@#iPict(ppictInfo); +enddef; + +vardef PictureStackInfoCopy@#(text src)= + PictureStackInfo@#(src.left, src.right, src.top, src.bottom)(src.spacing)(src.iPict); + + @#boxed := src.boxed; + @#borderColor := src.borderColor; +enddef; + +log "*** Creating iStack..."; +PictureStackInfo.iStack(2, 2, 2, 2)(2)(iPict); + +vardef EPictureStack@#(text pictStackInfo)(text thePictures)(text how)= + ObjectEquations(@#); + @#className := "PictureStack"; + + PictureStackInfoCopy.@#info(pictStackInfo); + + attributes(@#); + var(numeric) nItems; + var(numeric) minx, miny, maxx, maxy; + var(string) picturesAsString; + var(string) joinMethod; + + @#joinMethod := how; + + @#nItems := 0; + for p=thePictures: + EPicture.@#pict[@#nItems](@#info.iPict)(p); + @#nItems := @#nItems + 1; + endfor; + + @#picturesAsString := listArray(@#pict)(@#nItems); + + EGroup.@#group(@#info)(scantokens @#picturesAsString); + + @#nw = @#group.nw; + @#se = @#group.se; +enddef; + +vardef PictureStack@#(text thePictures)(text how)= + EPictureStack@#(iStack)(thePictures)(how); +enddef; + +vardef PictureStack_layout@#= + if @#layedout = 1: + log "PictureStack " & (str @#) & " has already been layed out"; + else: + @#layedout := 1; + + layoutObjects(scantokens @#picturesAsString); + + if @#joinMethod = "vleft": + setObjectJoin(pa.left=pb.left; pa.bottom = pb.top + @#info.spacing); + elseif @#joinMethod = "vcenter": + setObjectJoin(pa.midx=pb.midx; pa.bottom = pb.top + @#info.spacing); + elseif @#joinMethod = "vright": + setObjectJoin(pa.right=pb.right; pa.bottom = pb.top + @#info.spacing); + elseif @#joinMethod = "vleftbase": + setObjectJoin(pa.left=pb.left; pa.bottom = pb.bottom + @#info.spacing); + elseif @#joinMethod = "vcenterbase": + setObjectJoin(pa.midx=pb.midx; pa.bottom = pb.bottom + @#info.spacing); + fi; + + joinObjects(scantokens @#picturesAsString); + + Group_layout.@#group; + fi; +enddef; + +vardef PictureStack_draw@#= + PictureStack_layout.@#; + objectEnsurePositioning.@#; + + for i=0 upto @#nItems-1: + Picture_draw.@#pict[i]; + endfor; + + if (@#info.boxed = 1): + draw objectBox(@#) withcolor @#info.borderColor; + fi; +enddef; + +vardef PictureStack_border@#= + objectBox(@#) +enddef; + diff --git a/Master/texmf-dist/metapost/metauml/util_positioning.mp b/Master/texmf-dist/metapost/metauml/util_positioning.mp new file mode 100644 index 00000000000..442fc534d55 --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/util_positioning.mp @@ -0,0 +1,236 @@ +% MetaUtil, an easier MetaPost life +% 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. + +if known _util_positioning_mp: + expandafter endinput +fi; +_util_positioning_mp:=1; + +input util_log; + +%% Gives a point which is below the given @point with the given @value. +%% +def below(expr point, value) = + (point - (0, value)) +enddef; + +%% Gives a point which is above the given @point with the given @value. +%% +def above(expr point, value) = + (point + (0, value)) +enddef; + +%% Gives a point which is at the right of the given @point with the given @value. +%% +def atright(expr point, value) = + (point + (value, 0)) +enddef; + +%% Gives a point which is at the left of the given @point with the given @value. +%% +def atleft(expr point, value) = + (point - (value, 0)) +enddef; + +%% Positions the given objects so that they: +%% * have their tops alligned +%% * the distance between the objects is @distance +%% * the center of gravity of the objects (taken on the top line) is at @middlePoint +%% +%% @distance +%% |---------------------------| +%% | | +%% | @middlePoint | +%% __________|_____________._____________|____________ the same top +%% [objectA] | [objectB] +%% +vardef centered_allign_top(suffix objectA, objectB)(expr distance, middlePoint)= + log middlePoint; + objectA.top = objectB.top; + objectB.left - objectA.right = distance; + middlePoint = .5[objectB.nw, objectA.ne]; +enddef; + + +%% theString means here not a sequence of characters but +%% the horizontal or vertical line on which objects are placed. +%% For example, if theString is top, then the objects are +%% "hanging" on a horizontal line, like freshly washed +%% clothes on a string. + +vardef allign(suffix theString, extremityNew, extremityOld) + (text distanceBetweenObjects)(expr sign)(text objects)= + string objectsAsString__; + objectsAsString__ := enumToString(objects)(""); + + log "Alligning '" & objectsAsString__ & "' at " & str theString; + log sign; + + if (objectsAsString__ = ""): + log "Nothing to do, bailing out."; + else: + string previousObject__; + previousObject__ := ""; + objectIndex__ := 0; + + forsuffixes obj = objects: + log "object: " & str obj; + if objectIndex__ = 0: + objectIndex__ := objectIndex__ + 1; + previousObject__ := str obj; + else: + objectIndex__ := objectIndex__ + 1; + + log str theString; + log str extremityOld; + log str extremityNew; + log distanceBetweenObjects; + + string eqA__, eqB__; + eqA__ := previousObject__ & "." & str theString & " = " & str obj & "." & str theString; + + if (sign = "+"): + eqB__ := previousObject__ & "." & str extremityOld & " + " & (str distanceBetweenObjects) & " = " & str obj & "." & str extremityNew; + %eqB__ := previousObject__ & "." & str extremityOld & " + distanceBetweenObjects = " & str obj & "." & str extremityNew; + else: + eqB__ := previousObject__ & "." & str extremityOld & " - " & (str distanceBetweenObjects) & " = " & str obj & "." & str extremityNew; + fi; + + log eqA__, eqB__; + scantokens eqA__; + scantokens eqB__; + + previousObject__ := str obj; + fi; + endfor; + fi; +enddef; + +vardef leftToRight@#(text distanceBetweenObjects)(text objects)= + if str @# = "": + log "String is empty, alligning to midy"; + allign(midy, left, right)(distanceBetweenObjects)("+")(objects); + else: + allign(@#, left, right)(distanceBetweenObjects)("+")(objects); + fi; +enddef; + +vardef rightToLeft@#(text distanceBetweenObjects)(text objects)= + if str @# = "": + log "String is empty, alligning to midy"; + allign(midy, right, left)(distanceBetweenObjects)("-")(objects); + else: + allign(@#, right, left)(distanceBetweenObjects)("-")(objects); + fi; +enddef; + +vardef topToBottom@#(text distanceBetweenObjects)(text objects)= + if str @# = "": + log "String is empty, alligning to midx"; + allign(midx, top, bottom)(distanceBetweenObjects)("-")(objects); + else: + allign(@#, top, bottom)(distanceBetweenObjects)("-")(objects); + fi; +enddef; + +vardef bottomToTop@#(text distanceBetweenObjects)(text objects)= + if str @# = "": + log "String is empty, alligning to midx"; + allign(midx, bottom, top)(distanceBetweenObjects)("+")(objects); + else: + allign(@#, bottom, top)(distanceBetweenObjects)("+")(objects); + fi; +enddef; + +%% +%% Defines an equation which sets the given prefix to be equal for all the given objects. +%% For example: +%% +%% same.top(a, b, c); +%% +%% is equivalent to +%% a.top = b.top = c.top; +%% +vardef same@#(text objects)= + log "begin macro: same@#(text objects)="; + + string equation__, property__; + equation__ := ""; + property__ := str @#; + + objectIndex__ := 0; + forsuffixes obj = objects: + log "object: " & str obj; + + if objectIndex__ = 0: + objectIndex__ := objectIndex__ + 1; + equation__ := equation__ & str obj & "." & property__; + else: + objectIndex__ := objectIndex__ + 1; + equation__ := equation__ & "=" & str obj & "." & property__; + fi; + endfor; + + equation__ := equation__ & ";"; + + log "Equation is: '" & equation__ & "'"; + + if objectIndex__ <= 1: + log "One or no objects, nothing to do!"; + else: + scantokens equation__; + fi; +enddef; + +%% this macro is NOT usable (yet) +vardef leftToRightCentered@#(expr distanceBetweenObjects, middlePoint)(text objects)= + string objectsAsString__; + objectsAsString__ := enumToString(objects)(""); + + if (objectsAsString__ = ""): + log "Nothing to do, bailing out."; + else: + log "ASDFGHJ"; + leftToRight@#(distanceBetweenObjects)(objects); + + string firstObject__, lastObject__; + objectIndex__ := 0; + forsuffixes obj = objects: + if objectIndex__ = 0: + objectIndex__ := objectIndex__ + 1; + firstObject__ := str obj; + else: + objectIndex__ := objectIndex__ + 1; + lastObject__ := str obj; + fi; + endfor; + + log "___"; + .5[authA.nw,authB.ne] = middlePoint; + log "___"; + + string eqCenter__; + eqCenter__ := ".5[" & firstObject__ & ".nw," & lastObject__ & ".ne] = middlePoint"; + + log eqCenter__; + log middlePoint; + + log "XXX"; + scantokens eqCenter__; + log "XXX"; + fi; +enddef; diff --git a/Master/texmf-dist/metapost/metauml/util_shade.mp b/Master/texmf-dist/metapost/metauml/util_shade.mp new file mode 100644 index 00000000000..2cc6f99af91 --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/util_shade.mp @@ -0,0 +1,55 @@ +% MetaUtil, an easier MetaPost life +% 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. + +if known _metauml_shade_mp: + expandafter endinput +fi; +_metauml_shade_mp:=1; + +input util_log; + +vardef ShadeInfo@#= + _n_ := str @#; + generic_declare(numeric) _n.shift; + generic_declare(color) _n.background; + + @#shift := 1; + @#background := .7white; +enddef; + +vardef ShadeInfoCopy@#(text src)= + ShadeInfo.@#; + ShadeInfo_copy@#(src); +enddef; + +vardef ShadeInfo_copy@#(text src)= + @#shift := src.shift; + @#background := src.background; +enddef; + +vardef ShadeInfo_toString@#= + save @#ret; + string @#ret; + @#ret := "Shade (shift: " & (decimal @#shift) & " back: (" & + (decimal redpart @#background) & ", " & + (decimal greenpart @#background) & ", " & + (decimal bluepart @#background) & ")"; + + @#ret +enddef; + + |