diff options
author | Karl Berry <karl@freefriends.org> | 2010-09-12 23:03:48 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-09-12 23:03:48 +0000 |
commit | 14889c6d7bd31fd163f9cb123c8ba772769d176b (patch) | |
tree | 87daf844b7fc365e2a328b7f6b39632e5aa68f94 /Master/texmf-dist/metapost/metauml | |
parent | 2468fdd0a97481e170ef878e0839faf948be681a (diff) |
metauml 0.2.5 (31jul10)
git-svn-id: svn://tug.org/texlive/trunk@19692 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost/metauml')
29 files changed, 903 insertions, 119 deletions
diff --git a/Master/texmf-dist/metapost/metauml/metauml.mp b/Master/texmf-dist/metapost/metauml/metauml.mp index 6d0b29c86c8..997728450b2 100644 --- a/Master/texmf-dist/metapost/metauml/metauml.mp +++ b/Master/texmf-dist/metapost/metauml/metauml.mp @@ -20,35 +20,52 @@ if known _metauml_mp: fi; _metauml_mp:=1; -input boxes; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; -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; +inputonce util_infrastructure; +inputonce util_object; +inputonce util_commons; +inputonce util_margins; +inputonce util_picture; +inputonce util_group; +inputonce util_picture_stack; +inputonce util_positioning; +inputonce util_shade; -input metauml_base; +inputonce metauml_base; -input metauml_links; -input metauml_paths; +inputonce metauml_links; +inputonce metauml_paths; -input metauml_note; +inputonce metauml_note; -input metauml_stereotype; +inputonce metauml_stereotype; -input metauml_class_clipart; -input metauml_class; -input metauml_instance; -input metauml_class_relations; -input metauml_class_assoc; +inputonce metauml_class_clipart; +inputonce metauml_class; +inputonce metauml_instance; +inputonce metauml_class_relations; +inputonce metauml_class_assoc; -input metauml_package; -input metauml_package_relations; +inputonce metauml_package; +inputonce metauml_package_relations; + +inputonce metauml_behavioral_common; +inputonce metauml_activity; +inputonce metauml_state; + +inputonce metauml_usecase_clipart; +inputonce metauml_usecase; input metauml_behavioral_common; input metauml_activity; @@ -57,4 +74,8 @@ input metauml_state; input metauml_usecase_clipart; input metauml_usecase; +input metauml_component; +input metauml_component_relations; + input metauml_templates; + diff --git a/Master/texmf-dist/metapost/metauml/metauml_activity.mp b/Master/texmf-dist/metapost/metauml/metauml_activity.mp index b5b99f16e86..7843b1da91c 100644 --- a/Master/texmf-dist/metapost/metauml/metauml_activity.mp +++ b/Master/texmf-dist/metapost/metauml/metauml_activity.mp @@ -20,8 +20,20 @@ if known _metauml_activity_mp: fi; _metauml_activity_mp:=1; -input metauml_defaults; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce metauml_defaults; +inputonce util_log; vardef ActivityInfo@#= attributes(@#); diff --git a/Master/texmf-dist/metapost/metauml/metauml_base.mp b/Master/texmf-dist/metapost/metauml/metauml_base.mp index c44947ad43f..e269fb34ec9 100644 --- a/Master/texmf-dist/metapost/metauml/metauml_base.mp +++ b/Master/texmf-dist/metapost/metauml/metauml_base.mp @@ -1,5 +1,5 @@ % MetaUML, a MetaPost library for typesetting exquisite UML diagrams. -% Copyright (C) 2005 Ovidiu Gheorghies +% Copyright (C) 2006 Ovidiu Gheorghies, 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 @@ -20,7 +20,19 @@ if known _metauml_base_mp: fi; _metauml_base_mp:=1; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce util_log; vardef markPoint(text p)(text color) = draw p withpen pencircle scaled 1 withcolor color; @@ -131,6 +143,32 @@ vardef drawCrossedCircle(text pA)(text pB)(text height) = draw pA .. pB .. pA; enddef; +vardef drawSemiCircle(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 + 5, height/2 + 1); + pC := pC rotated (alfa) shifted pB; + pD := (width/2 + 5, -height/2 - 1); + pD := pD rotated (alfa) shifted pB; + + draw pC .. pA .. pD; +enddef; + +vardef drawCircle(text pA)(text pB)(text height) = + fill pA..pB..pA -- cycle withcolor white; + + draw pA .. pB .. pA; +enddef; + vardef drawLine(expr my_path) = draw my_path; enddef; diff --git a/Master/texmf-dist/metapost/metauml/metauml_behavioral_common.mp b/Master/texmf-dist/metapost/metauml/metauml_behavioral_common.mp index 0f52d206777..271597027b3 100644 --- a/Master/texmf-dist/metapost/metauml/metauml_behavioral_common.mp +++ b/Master/texmf-dist/metapost/metauml/metauml_behavioral_common.mp @@ -20,7 +20,19 @@ if known _metauml_behavioral_common_mp: fi; _metauml_behavioral_common_mp:=1; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce util_log; vardef SpecialStateInfo@#= numeric @#diameter; diff --git a/Master/texmf-dist/metapost/metauml/metauml_class.mp b/Master/texmf-dist/metapost/metauml/metauml_class.mp index 6e8e4330e3b..f99b134c0d4 100644 --- a/Master/texmf-dist/metapost/metauml/metauml_class.mp +++ b/Master/texmf-dist/metapost/metauml/metauml_class.mp @@ -20,12 +20,24 @@ if known _metauml_class_mp: fi; _metauml_class_mp:=1; -input metauml_defaults; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce metauml_defaults; +inputonce util_log; -input util_picture; -input util_picture_stack; -input util_shade; +inputonce util_picture; +inputonce util_picture_stack; +inputonce util_shade; string accessPublic, accessProtected, accessPrivate; accessPublic:="+"; @@ -111,7 +123,17 @@ enddef; ClassInfo.iClass; +ClassInfoCopy.iClassNameOnly(iClass); +iClassNameOnly.iName.top := 10; +iClassNameOnly.iName.bottom := 10; +iClassNameOnly.iAttributeStack.top := 0; +iClassNameOnly.iAttributeStack.bottom := 0; +iClassNameOnly.iMethodStack.top := 0; +iClassNameOnly.iMethodStack.bottom := 0; + ClassInfoCopy.iInterface(iClass); +iInterface.iAttributeStack.top := 0; +iInterface.iAttributeStack.bottom := 0; iInterface.iName.iFont.name := metauml_defaultFontOblique; ClassInfoCopy.iAbstractClass(iInterface); @@ -221,6 +243,14 @@ vardef EInterface@#(text _info)(expr name)(text methods)= EClass@#(_info)(name)()(methods); enddef; +vardef ClassName@#(expr name)= + EClass@#(iClassNameOnly)(name)()(); +enddef; + +vardef EClassName@#(text _info)(expr name)= + EClass@#(_info)(name)()(); +enddef; + vardef AbstractClass@#(expr name)(text attributes)(text methods)= EClass@#(iAbstractClass)(name)(attributes)(methods); enddef; diff --git a/Master/texmf-dist/metapost/metauml/metauml_class_assoc.mp b/Master/texmf-dist/metapost/metauml/metauml_class_assoc.mp index 457e3015d3a..fb7786b8794 100644 --- a/Master/texmf-dist/metapost/metauml/metauml_class_assoc.mp +++ b/Master/texmf-dist/metapost/metauml/metauml_class_assoc.mp @@ -20,8 +20,20 @@ if known _metauml_class_assoc_mp: fi; _metauml_class_assoc_mp:=1; -input util_log; -input metauml_defaults; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce util_log; +inputonce metauml_defaults; FontInfo.assocFont(metauml_defaultFont, .7); PictureInfo.iAssoc(2, 2, 2, 2)(assocFont); diff --git a/Master/texmf-dist/metapost/metauml/metauml_class_clipart.mp b/Master/texmf-dist/metapost/metauml/metauml_class_clipart.mp index 72bae5b93e3..faa175494e8 100644 --- a/Master/texmf-dist/metapost/metauml/metauml_class_clipart.mp +++ b/Master/texmf-dist/metapost/metauml/metauml_class_clipart.mp @@ -20,7 +20,19 @@ if known _metauml_class_clipart_mp: fi; _metauml_class_clipart_mp:=1; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce util_log; %% %% This file contains various drawing which can be used in diff --git a/Master/texmf-dist/metapost/metauml/metauml_class_relations.mp b/Master/texmf-dist/metapost/metauml/metauml_class_relations.mp index bcc4997b049..00306bd3882 100644 --- a/Master/texmf-dist/metapost/metauml/metauml_class_relations.mp +++ b/Master/texmf-dist/metapost/metauml/metauml_class_relations.mp @@ -149,6 +149,20 @@ vardef DependencyInfo@# = @#drawMethod = "drawLineDashed"; enddef; +vardef RealizationInfo@# = + LinkInfo@#; + + @#widthA = 0; + @#heightA = 0; + @#drawMethodA = "drawNothing"; + + @#widthB = defaultRelationHeadWidth; + @#heightB = defaultRelationHeadHeight; + @#drawMethodB = "drawTriangle"; + + @#drawMethod = "drawLineDashed"; +enddef; + AssociationInfo.association; AssociationUniInfo.associationUni; InheritanceInfo.inheritance; @@ -158,6 +172,7 @@ CompositionInfo.composition; CompositionUniInfo.compositionUni; DashedLinkInfo.dashedLink; DependencyInfo.dependency; +RealizationInfo.realization; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/Master/texmf-dist/metapost/metauml/metauml_component.mp b/Master/texmf-dist/metapost/metauml/metauml_component.mp new file mode 100644 index 00000000000..d0d531d872c --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_component.mp @@ -0,0 +1,200 @@ +% 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_component_mp: + expandafter endinput +fi; +_metauml_component_mp:=1; + +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce metauml_defaults; +inputonce util_log; + +vardef ComponentInfo@#= + attributes(@#); + var(color) foreColor, borderColor; + 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; + + @#minimumNameContentsDifference := 20; + + GroupInfo.@#iContentsGroup(2, 2, 10, 2); +enddef; + +vardef ComponentInfoCopy@#(text src)= + log "ComponentInfoCopy: Copying component info"; + + attributes(@#); + var(color) foreColor, borderColor; + var(numeric) minimumNameContentsDifference; + + PictureStackInfoCopy.@#iNameStack (src.iNameStack); + MarginsCopy.@#(src); + + ShadeInfoCopy.@#iShade(src.iShade); + @#foreColor := src.foreColor; + @#borderColor := src.borderColor; + + @#minimumNameContentsDifference := src.minimumNameContentsDifference; + + GroupInfoCopy.@#iContentsGroup(src.iContentsGroup); +enddef; + +ComponentInfo.iComponent; + +vardef Component@#(text contents)(text _subItems)= + EComponent.@#(iComponent)(contents)(_subItems); +enddef; + +vardef EComponent@#(text _info)(text contents)(text _subItems)= + ObjectEquations(@#); + @#className := "Component"; + + ComponentInfoCopy.@#info(_info); + + numeric @#nLines; @#nLines := 0; + string @#lines[]; + numeric @#nSubItems; @#nSubItems := 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 Component_layout@#= + if @#layedout = 1: + log "Component '" & (str @#) & "' has already been layed out"; + else: + @#layedout := 1; + log "Component layout: '" & (str @#) & "'"; + + log "Component name layout '" & (str @#) & "'..."; + PictureStack_layout.@#nameStack; + log "SubItems for component layout '" & (str @#) & "'..."; + Group_layout.@#subItems; + + log "All elements in component '" & (str @#) & "' successfully layed out, integrating..."; + + + if @#subItems.width < @#nameStack.width + @#info.minimumNameContentsDifference: + @#contentWidth = @#nameStack.width + @#info.minimumNameContentsDifference; + else: + @#contentWidth = lmax(@#nameStack.width, @#subItems.width); + fi; + + @#width = @#contentWidth + @#info.left + @#info.right + 15; + + if @#nSubItems = 0: + @#height = @#info.top + @#info.bottom + @#subItems.height + 15; + @#nameStack.n = @#n - (0, 7); + else: + @#height = @#info.top + @#info.bottom + @#subItems.height + 30; + @#nameStack.n = @#n + (0, @#info.top) - (0, 5); + fi; + + @#subItems.n = @#n + (0, -((@#height - @#subItems.height)/2)) - (0, 5); + + log "Component layout for " & (str @#) & " ended."; + fi; +enddef; + +vardef Component_draw@#= + Component_layout.@#; + objectEnsurePositioning.@#; + + attributes(@#); + var(path) border; + + @#border := @#ne -- @#nw -- @#sw -- @#se -- cycle; + + drawObjectShade(@#); + + fill @#border withcolor @#info.foreColor; + draw @#border withcolor @#info.borderColor; + + drawComponentVisualStereotype(@#ne); + + drawObject(@#nameStack); + drawObject(@#subItems); + +enddef; + +vardef drawComponentVisualStereotype(text ne)= + % lud = left-up-down of the top-right rectangle; luu = left-up-up of the top-right rectangle etc. + pair lud, luu, ru, rd, ldd, ldu, lmd, lmu; + % urectld = upper rectangle left-down, lrectru = lower rectangle right-up + pair urectld, urectlu, urectru, urectrd, lrectld, lrectlu, lrectru, lrectrd; + lud = ne - (14, 5 ); + luu = lud + (0, 2 ); + ru = luu + (8, 0 ); + rd = ru - (0, 14); + ldd = rd - (8, 0 ); + ldu = ldd + (0, 2 ); + lmd = ldu + (0, 3 ); + lmu = lud - (0, 3 ); + + urectld = lmu - (3, 0); + urectlu = lud - (3, 0); + urectru = lud + (3, 0); + urectrd = lmu + (3, 0); + + lrectld = ldu - (3, 0); + lrectlu = lmd - (3, 0); + lrectru = lmd + (3, 0); + lrectrd = ldu + (3, 0); + + draw lud -- luu -- ru -- rd -- ldd -- ldu; + draw lmd -- lmu; + draw urectld -- urectlu -- urectru -- urectrd -- urectld; + draw lrectld -- lrectlu -- lrectru -- lrectrd -- lrectld; +enddef; + +vardef Component_border@#= + @#border +enddef; diff --git a/Master/texmf-dist/metapost/metauml/metauml_component_relations.mp b/Master/texmf-dist/metapost/metauml/metauml_component_relations.mp new file mode 100644 index 00000000000..3c8f68c225e --- /dev/null +++ b/Master/texmf-dist/metapost/metauml/metauml_component_relations.mp @@ -0,0 +1,69 @@ +% 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_component_relations_mp: + expandafter endinput +fi; +_metauml_component_relations_mp:=1; + +defaultRelationHeadWidth := 25; +defaultRelationHeadHeight := 10; +requiredInterfaceHeadWidth := 5; +requiredInterfaceHeadHeight := 15; + +vardef requiredInterfaceInfo@# = + LinkInfo@#; + + @#widthA = 0; + @#heightA = 0; + @#drawMethodA = "drawNothing"; + + @#widthB = requiredInterfaceHeadWidth; + @#heightB = requiredInterfaceHeadHeight; + @#drawMethodB = "drawSemiCircle"; + + @#drawMethod = "drawLine"; +enddef; + +vardef providedInterfaceInfo@# = + LinkInfo@#; + + @#widthB = defaultRelationHeadWidth; + @#heightB = defaultRelationHeadHeight; + @#drawMethodB = "drawCircle"; + + @#widthA = 0; + @#heightA = 0; + @#drawMethodA = "drawNothing"; + + @#drawMethod = "drawLine"; +enddef; + +requiredInterfaceInfo.requiredInterface; +providedInterfaceInfo.providedInterface; + +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_instance.mp b/Master/texmf-dist/metapost/metauml/metauml_instance.mp index 3732d600d4f..cbe3b64f611 100644 --- a/Master/texmf-dist/metapost/metauml/metauml_instance.mp +++ b/Master/texmf-dist/metapost/metauml/metauml_instance.mp @@ -20,12 +20,24 @@ if known _metauml_instance_mp: fi; _metauml_instance_mp:=1; -input metauml_defaults; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce metauml_defaults; +inputonce util_log; -input util_picture; -input util_picture_stack; -input util_shade; +inputonce util_picture; +inputonce util_picture_stack; +inputonce util_shade; vardef InstanceInfo@#= attributes(@#); diff --git a/Master/texmf-dist/metapost/metauml/metauml_note.mp b/Master/texmf-dist/metapost/metauml/metauml_note.mp index 92d0aac93b9..c0f1252cbf2 100644 --- a/Master/texmf-dist/metapost/metauml/metauml_note.mp +++ b/Master/texmf-dist/metapost/metauml/metauml_note.mp @@ -23,13 +23,25 @@ _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; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce metauml_defaults; +inputonce util_log; -input util_object; -input util_picture_stack; -input util_shade; -input util_margins; +inputonce util_object; +inputonce util_picture_stack; +inputonce util_shade; +inputonce util_margins; vardef NoteInfo@#= attributes(@#); @@ -81,14 +93,19 @@ vardef ENote@#(text _info)(text contents)= 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"); + %% The following code cannot work when pictures are given in the contents argument, such as in: + %% ENote.myNote(iNote)("This is a formula", TEX("$a=b$")); + %% + %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"); + + EPictureStack.@#stack(@#info.iStack)(contents)("vleftbase"); enddef; vardef Note_layout@#= diff --git a/Master/texmf-dist/metapost/metauml/metauml_package.mp b/Master/texmf-dist/metapost/metauml/metauml_package.mp index a2be4e920c0..8394efcaf2a 100644 --- a/Master/texmf-dist/metapost/metauml/metauml_package.mp +++ b/Master/texmf-dist/metapost/metauml/metauml_package.mp @@ -20,8 +20,20 @@ if known _metauml_package_mp: fi; _metauml_package_mp:=1; -input metauml_defaults; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce metauml_defaults; +inputonce util_log; vardef PackageInfo@#= attributes(@#); diff --git a/Master/texmf-dist/metapost/metauml/metauml_paths.mp b/Master/texmf-dist/metapost/metauml/metauml_paths.mp index cb307f8df00..d0fc27bb332 100644 --- a/Master/texmf-dist/metapost/metauml/metauml_paths.mp +++ b/Master/texmf-dist/metapost/metauml/metauml_paths.mp @@ -24,12 +24,113 @@ def pathDirect(expr pA,pB) = pA--pB enddef; -vardef pathManhattanX(expr pA,pB) = - pA--(xpart(pB), ypart(pA))--pB +vardef pathManhattanX(text twoParams) = + pair pointA__, pointB__; + string paramA_str__, paramB_str__; + boolean paramA_isObject__, paramB_isObject__; + + paramA_isObject__ := true; + paramB_isObject__ := true; + + boolean isFirstParam__; + isFirstParam__ := true; + + %string twoParams; + %twoParams := ""; + + %twoParams := str paramA & ", " & str paramB; + %%includeonce% show "the two params are: " & twoParams; + + forsuffixes param__ = twoParams: + + if isFirstParam__: + isFirstParam__ := false; + paramA_str__ := str param__; + %includeonce% show "paramA_str__ <-- " & paramA_str__; + + if not known (scantokens (paramA_str__ & ".className")): + %includeonce% show "paramA is not an object"; + paramA_isObject__ := false; + fi; + else: + paramB_str__ := str param__; + %includeonce% show "paramB_str__ <-- " & paramB_str__; + + if not known (scantokens (paramB_str__ & ".className")): + %includeonce% show "paramB is not an object"; + paramB_isObject__ := false; + fi; + fi; + endfor; + + %includeonce% show paramA_str__; + %includeonce% show paramA_isObject__; + + %includeonce% show paramB_str__; + %includeonce% show paramB_isObject__; + + string stringPath__; + stringPath__ := "(0,0)--(50,50)"; + + if (not paramA_isObject__) and (not paramB_isObject__): + %includeonce% show "Both are points!"; + + + stringPath__ := paramA_str__ & "--(xpart " & paramB_str__ & ", ypart " & paramA_str__ & ") -- " & paramB_str__; + %includeonce% show stringPath__; + else: + pair refPointA__, refPointB__; + if paramA_isObject__: + refPointA__ := scantokens (paramA_str__ & ".c"); + else: + refPointA__ := scantokens paramA_str__; + fi; + if paramB_isObject__: + refPointB__ := scantokens (paramB_str__ & ".c"); + else: + refPointB__ := scantokens paramB_str__; + fi; + + %includeonce% show "Reference point A: "; + %includeonce% show refPointA__; + %includeonce% show "Reference point B: "; + %includeonce% show refPointB__; + + numeric dx__, dy__; + dx__ := xpart refPointB__ - xpart refPointA__; + dy__ := ypart refPointB__ - ypart refPointA__; + + string addornmentA__; + addornmentA__ := ""; + string addornmentB__; + addornmentB__ := ""; + + if (paramA_isObject__): + if (dx__ > 0): + addornmentA__ := ".e"; + else: + addornmentA__ := ".w"; + fi; + fi; + + if (paramB_isObject__): + if (dy__ > 0): + addornmentB__ := ".s"; + else: + addornmentB__ := ".n"; + fi; + fi; + stringPath__ := "pathManhattanX(" & paramA_str__ & addornmentA__ & ", " & paramB_str__ & addornmentB__ & ")"; + + %includeonce% show stringPath; + %includeonce% show "-------------------> recursive call"; + fi; + + scantokens stringPath__ enddef; -vardef rpathManhattanX(expr pA,pB) = - pB--(xpart(pB), ypart(pA))--pA +vardef rpathManhattanX(text twoParams) = + reverse pathManhattanX(twoParams) enddef; vardef pathManhattanY(expr pA,pB) = diff --git a/Master/texmf-dist/metapost/metauml/metauml_state.mp b/Master/texmf-dist/metapost/metauml/metauml_state.mp index 7d4b348afad..fb9875e262a 100644 --- a/Master/texmf-dist/metapost/metauml/metauml_state.mp +++ b/Master/texmf-dist/metapost/metauml/metauml_state.mp @@ -20,8 +20,20 @@ if known _metauml_state_mp: fi; _metauml_state_mp:=1; -input metauml_defaults; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce metauml_defaults; +inputonce util_log; vardef StateInfo@#= attributes(@#); diff --git a/Master/texmf-dist/metapost/metauml/metauml_stereotype.mp b/Master/texmf-dist/metapost/metauml/metauml_stereotype.mp index afc4ef14a8a..64beff494d8 100644 --- a/Master/texmf-dist/metapost/metauml/metauml_stereotype.mp +++ b/Master/texmf-dist/metapost/metauml/metauml_stereotype.mp @@ -20,7 +20,19 @@ if known _metauml_stereotype_mp: fi; _metauml_stereotype_mp:=1; -input metauml_defaults; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce metauml_defaults; FontInfo.assocFont(metauml_defaultFont, .7); PictureInfo.iStereo(2, 2, 2, 2)(assocFont); diff --git a/Master/texmf-dist/metapost/metauml/metauml_templates.mp b/Master/texmf-dist/metapost/metauml/metauml_templates.mp index f4125097108..4ce5fc44e78 100644 --- a/Master/texmf-dist/metapost/metauml/metauml_templates.mp +++ b/Master/texmf-dist/metapost/metauml/metauml_templates.mp @@ -20,8 +20,20 @@ if known _metauml_templates_mp: fi; _metauml_templates_mp:=1; -input metauml_defaults; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce metauml_defaults; +inputonce util_log; vardef TemplateInfo@#= color @#background; diff --git a/Master/texmf-dist/metapost/metauml/metauml_usecase.mp b/Master/texmf-dist/metapost/metauml/metauml_usecase.mp index 1fc98b5879e..e9edf9471b2 100644 --- a/Master/texmf-dist/metapost/metauml/metauml_usecase.mp +++ b/Master/texmf-dist/metapost/metauml/metauml_usecase.mp @@ -20,8 +20,20 @@ if known _metauml_usecase_mp: fi; _metauml_usecase_mp:=1; -input metauml_defaults; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce metauml_defaults; +inputonce util_log; vardef ActorInfo@#= FontInfo.@#iFont(metauml_defaultFont, defaultscale); diff --git a/Master/texmf-dist/metapost/metauml/metauml_usecase_clipart.mp b/Master/texmf-dist/metapost/metauml/metauml_usecase_clipart.mp index 4e573fae3be..a4750b5f52f 100644 --- a/Master/texmf-dist/metapost/metauml/metauml_usecase_clipart.mp +++ b/Master/texmf-dist/metapost/metauml/metauml_usecase_clipart.mp @@ -25,7 +25,19 @@ if known _metauml_usecase_clipart_mp: fi; _metauml_usecase_clipart_mp:=1; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce util_log; vardef HumanInfo@#(expr _width, _height, _yHeadRatio, _yBodyRatio, _yHandsRatio, _xHandsRatio, _xLegsRatio)= attributes(@#); diff --git a/Master/texmf-dist/metapost/metauml/util_commons.mp b/Master/texmf-dist/metapost/metauml/util_commons.mp index b333ee57a5a..1229da6b025 100644 --- a/Master/texmf-dist/metapost/metauml/util_commons.mp +++ b/Master/texmf-dist/metapost/metauml/util_commons.mp @@ -20,7 +20,19 @@ if known _util_commons_mp: fi; _util_commons_mp:=1; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce util_log; vardef lmax(text items)= log "finding lmax of items " & str items; diff --git a/Master/texmf-dist/metapost/metauml/util_group.mp b/Master/texmf-dist/metapost/metauml/util_group.mp index 732deba4bdf..1a3380c9f5c 100644 --- a/Master/texmf-dist/metapost/metauml/util_group.mp +++ b/Master/texmf-dist/metapost/metauml/util_group.mp @@ -20,10 +20,22 @@ if known _util_group_mp: fi; _util_group_mp:=1; -input util_object; -input util_commons; -input util_margins; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce util_object; +inputonce util_commons; +inputonce util_margins; +inputonce util_log; vardef GroupInfo@#(expr pleft, pright, ptop, pbottom)= attributes(@#); diff --git a/Master/texmf-dist/metapost/metauml/util_infrastructure.mp b/Master/texmf-dist/metapost/metauml/util_infrastructure.mp index 26dc421cdb9..457f6bf89ca 100644 --- a/Master/texmf-dist/metapost/metauml/util_infrastructure.mp +++ b/Master/texmf-dist/metapost/metauml/util_infrastructure.mp @@ -20,7 +20,19 @@ if known _util_infrastructure_mp: fi; _util_infrastructure_mp:=1; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce util_log; vardef attributes(text objectName)= _n_ := str objectName diff --git a/Master/texmf-dist/metapost/metauml/util_log.mp b/Master/texmf-dist/metapost/metauml/util_log.mp index 20efc47fe08..d7adb3c8589 100644 --- a/Master/texmf-dist/metapost/metauml/util_log.mp +++ b/Master/texmf-dist/metapost/metauml/util_log.mp @@ -15,9 +15,9 @@ % 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; +%%% if known _util_log_mp: +%%% expandafter endinput +%%% fi; _util_log_mp:=1; util_loglevel_PARANOIA:=1; @@ -30,7 +30,7 @@ util_log_defaultlevel := util_loglevel_RELEASE; def elog(expr loglevel) text txt= if (loglevel <= util_log_thresholdlevel): - show txt + %includeonce% show txt else: % do nothing fi; @@ -38,7 +38,7 @@ enddef; def log text txt= if (util_log_defaultlevel <= util_log_thresholdlevel): - show txt + %includeonce% show txt else: % do nothing fi; diff --git a/Master/texmf-dist/metapost/metauml/util_margins.mp b/Master/texmf-dist/metapost/metauml/util_margins.mp index 7b6b0446cfb..508a0e6bb44 100644 --- a/Master/texmf-dist/metapost/metauml/util_margins.mp +++ b/Master/texmf-dist/metapost/metauml/util_margins.mp @@ -16,7 +16,7 @@ % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. if known _util_margins_mp: - expandafter endinput + expandafter endinput fi; _util_margins_mp:=1; diff --git a/Master/texmf-dist/metapost/metauml/util_object.mp b/Master/texmf-dist/metapost/metauml/util_object.mp index 7cd6c0404c6..52f932ddc34 100644 --- a/Master/texmf-dist/metapost/metauml/util_object.mp +++ b/Master/texmf-dist/metapost/metauml/util_object.mp @@ -20,8 +20,20 @@ if known _util_object_mp: fi; _util_object_mp:=1; -input util_infrastructure; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce util_infrastructure; +inputonce util_log; def ObjectEquations(suffix $)= attributes($); diff --git a/Master/texmf-dist/metapost/metauml/util_picture.mp b/Master/texmf-dist/metapost/metauml/util_picture.mp index fc9133392d9..b148f04857e 100644 --- a/Master/texmf-dist/metapost/metauml/util_picture.mp +++ b/Master/texmf-dist/metapost/metauml/util_picture.mp @@ -20,9 +20,21 @@ if known _util_picture_mp: fi; _util_picture_mp:=1; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce util_log; +inputonce util_margins; -input util_margins; if not known _n_cur_:input boxes;fi; vardef FontInfo@#(expr tname, tscale)= @@ -65,13 +77,38 @@ vardef PictureInfo@#(expr pleft, pright, ptop, pbottom)(text pfont)= var(color) borderColor; var(numeric) boxed; + %% Used to set the base of a text to the natural base of the letters. + %% If set to '1', 'y' and 'a' will have the same base line, the tail + %% of 'y' being rendered below that line + %% var(numeric) ignoreNegativeBase; + %% If these attributes are set to -1, the height and width of the + %% Picture object is deduced from the dimensions of the contained + %% object (picture or text). If one of these parameters is set to + %% a positive value, then the given value is used, regardless of the + %% size of the contents. + %% + var(numeric) fixedWidth, fixedHeight; + + %% Controls how the contents of the picture is to be alligned relatively + %% to the picture margins. Can be one of "left", "centered", defaults to + %% "left". The "centered" setting is useful for Picture-s whose fixedWidth + %% is set to a given value. + %% + var(string) halign, valign; + @#boxed := 0; @#borderColor := blue; @#ignoreNegativeBase := 0; + @#fixedWidth := -1; + @#fixedHeight := -1; + + @#halign := "left"; + @#valign := "bottom"; + Margins.@#(pleft, pright, ptop, pbottom); FontInfoCopy.@#iFont(pfont); @@ -83,6 +120,12 @@ vardef PictureInfoCopy@#(text src)= @#boxed := src.boxed; @#borderColor := src.borderColor; @#ignoreNegativeBase := src.ignoreNegativeBase; + + @#fixedWidth := src.fixedWidth; + @#fixedHeight := src.fixedHeight; + + @#halign := src.halign; + @#valign := src.valign; enddef; vardef PictureInfo_toString@#= @@ -139,7 +182,9 @@ enddef; %% Lays out the Picture. %% vardef Picture_layout@# = - if @#layedout = 0: + if @#layedout = 1: + log "Picture " & str @# & " already layed out."; + else: log "Laying out " & (str @#); @#layedout := 1; @@ -148,28 +193,50 @@ vardef Picture_layout@# = log "Content is known to be a picture"; @#pict = @#contentAsPicture; elseif known @#contentAsString: - log "Content is known to be a string"; - log @#contentAsString; + log "Content is known to be a string: " & @#contentAsString; @#pict = @#contentAsString infont @#info.iFont.name scaled @#info.iFont.scale; else: log "Show unknown parameter type in picture layout"; - 2 = 3; + 2 = 3; % force an error 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) ; + negativeBaseAdjustement__ := 0; + else: + negativeBaseAdjustement__ := @#negativeBase; + fi; + + if @#info.fixedWidth = -1: + @#width = pictWidth(@#pict) + @#info.left + @#info.right; else: - @#height = pictHeight(@#pict) + @#info.top + @#info.bottom + @#negativeBase; - @#contentShift = @#sw + (@#info.left, @#info.bottom); + @#width = @#info.fixedWidth; fi; - else: - log "Picture " & str @# & " already layed out."; + if @#info.fixedHeight = -1: + @#height = pictHeight(@#pict) + @#info.top + @#info.bottom + negativeBaseAdjustement__; + else: + @#height = @#info.fixedHeight; + fi; + + if @#info.halign = "left": + xdelta__ := @#info.left; + elseif @#info.halign = "center": + xdelta__ := (@#width-pictWidth(@#pict))/2; + else: + 2 = 3; % throw exception illegal value for @#info.hallign + fi; + + if @#info.valign = "bottom": + ydelta__ := @#info.bottom - @#negativeBase + negativeBaseAdjustement__; + elseif @#info.valign = "center": + ydelta__ := (@#height-pictHeight(@#pict))/2 - @#negativeBase + negativeBaseAdjustement__; + else: + 2 = 3; % throw exception illegal value for @#info.vallign + fi; + + @#contentShift = @#sw + (xdelta__, ydelta__); fi; enddef; diff --git a/Master/texmf-dist/metapost/metauml/util_picture_stack.mp b/Master/texmf-dist/metapost/metauml/util_picture_stack.mp index 11b6b7a16fa..e1a1a51bfba 100644 --- a/Master/texmf-dist/metapost/metauml/util_picture_stack.mp +++ b/Master/texmf-dist/metapost/metauml/util_picture_stack.mp @@ -20,11 +20,23 @@ if known _util_picture_stack_mp: fi; _util_picture_stack_mp:=1; -input util_picture; -input util_commons; -input util_group; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce util_picture; +inputonce util_commons; +inputonce util_group; -input util_log; +inputonce util_log; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % @@ -110,6 +122,8 @@ vardef PictureStack_layout@#= 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); + elseif @#joinMethod = "vrightbase": + setObjectJoin(pa.right=pb.right; pa.bottom = pb.bottom + @#info.spacing); fi; joinObjects(scantokens @#picturesAsString); diff --git a/Master/texmf-dist/metapost/metauml/util_positioning.mp b/Master/texmf-dist/metapost/metauml/util_positioning.mp index 442fc534d55..758ab63afda 100644 --- a/Master/texmf-dist/metapost/metauml/util_positioning.mp +++ b/Master/texmf-dist/metapost/metauml/util_positioning.mp @@ -20,7 +20,19 @@ if known _util_positioning_mp: fi; _util_positioning_mp:=1; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce util_log; %% Gives a point which is below the given @point with the given @value. %% @@ -47,7 +59,7 @@ def atleft(expr point, value) = enddef; %% Positions the given objects so that they: -%% * have their tops alligned +%% * have their tops aligned %% * the distance between the objects is @distance %% * the center of gravity of the objects (taken on the top line) is at @middlePoint %% @@ -58,13 +70,21 @@ enddef; %% __________|_____________._____________|____________ the same top %% [objectA] | [objectB] %% -vardef centered_allign_top(suffix objectA, objectB)(expr distance, middlePoint)= +vardef centered_align_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; +%% Deprecated, kept for backward compatibility (align is misspelled). +%% +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. @@ -72,7 +92,7 @@ enddef; %% "hanging" on a horizontal line, like freshly washed %% clothes on a string. -vardef allign(suffix theString, extremityNew, extremityOld) +vardef align(suffix theString, extremityNew, extremityOld) (text distanceBetweenObjects)(expr sign)(text objects)= string objectsAsString__; objectsAsString__ := enumToString(objects)(""); @@ -122,37 +142,37 @@ enddef; vardef leftToRight@#(text distanceBetweenObjects)(text objects)= if str @# = "": - log "String is empty, alligning to midy"; - allign(midy, left, right)(distanceBetweenObjects)("+")(objects); + log "String is empty, aligning to midy"; + align(midy, left, right)(distanceBetweenObjects)("+")(objects); else: - allign(@#, left, right)(distanceBetweenObjects)("+")(objects); + align(@#, 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); + log "String is empty, aligning to midy"; + align(midy, right, left)(distanceBetweenObjects)("-")(objects); else: - allign(@#, right, left)(distanceBetweenObjects)("-")(objects); + align(@#, 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); + log "String is empty, aligning to midx"; + align(midx, top, bottom)(distanceBetweenObjects)("-")(objects); else: - allign(@#, top, bottom)(distanceBetweenObjects)("-")(objects); + align(@#, 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); + log "String is empty, aligning to midx"; + align(midx, bottom, top)(distanceBetweenObjects)("+")(objects); else: - allign(@#, bottom, top)(distanceBetweenObjects)("+")(objects); + align(@#, bottom, top)(distanceBetweenObjects)("+")(objects); fi; enddef; diff --git a/Master/texmf-dist/metapost/metauml/util_shade.mp b/Master/texmf-dist/metapost/metauml/util_shade.mp index 2cc6f99af91..f8c7b1bdcdb 100644 --- a/Master/texmf-dist/metapost/metauml/util_shade.mp +++ b/Master/texmf-dist/metapost/metauml/util_shade.mp @@ -15,12 +15,24 @@ % 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: +if known _util_shade_mp: expandafter endinput fi; -_metauml_shade_mp:=1; +_util_shade_mp:=1; -input util_log; +% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. +% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, +% but this macro makes sure that MetaPost won't try to load the file and display a message for that. +def inputonce text libraryFile= + if not known scantokens ("_" & str libraryFile & "_mp"): + %includeonce% show "Loading " & str libraryFile; + scantokens ("input " & str libraryFile); + else: + %includeonce% show str libraryFile & " already loaded."; + fi; +enddef; + +inputonce util_log; vardef ShadeInfo@#= _n_ := str @#; |