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/metauml/metauml_activity.mp | |
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/metauml/metauml_activity.mp')
-rw-r--r-- | Master/texmf-dist/metapost/metauml/metauml_activity.mp | 231 |
1 files changed, 231 insertions, 0 deletions
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; |