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