[tex-eplain] Drawing leaders using \gridcommdiag macro

Guy Worthington guyw@multiline.com.au
23 Sep 2001 19:59:42 +0800


I'm having trouble following the \gridcommdiag{} macro.  I've 
posted a sample figure below, in which every single parameter
I can get my hands on, I've adjusted.  I'm sure this type of 
visual design offends TeX (it certainly doesn't lead to any 
repeatability in my diagrams).  Has anyone developed a more
parametric method of drawing leaders in diagrams?

%--------------------------------------------------
\input eplain

\hsize=30pc  \vsize=50pc
\newdimen\fullsize \fullsize=\hsize
\newdimen\halfsize \halfsize=\hsize
\divide\halfsize by2 \advance\halfsize by-6pt

\newbox\leftcolumn
\newbox\rightcolumn

\font\eightrm=cmr8
\def\morphism#1{{\eightrm #1}}

%begin figure:general method structure with try-catch

\hsize=\halfsize
\parindent=0pt
 
\setbox\leftcolumn=\vtop to0pt{\verbatim
double dosomething (int aParam) 
        throws ExceptionType1, 
               ExceptionType2 {

    // Code that does not
    // throw exceptions

    // Set of try, catch,
    // finally blocks

    // Code that does not
    // throw exceptions

    // Set of try, catch,
    // finally blocks

    // Code that does not
    // throw exceptions

    // Set of try, catch,
    // finally blocks

    // Code that does not
    // throw exceptions

    //...
}|endverbatim}
\setbox\rightcolumn=\vbox{\verbatim
try {

    // Code may throw exceptions
} catch (Exception1 e) {

    // Code to process Exception1
} catch (Exception2 e) {

    // Code to process Exception2
} finally {

    // Code executed after try
}|endverbatim}
\setbox\rightcolumn=\boxit{\box\rightcolumn}
\setbox\rightcolumn=\vtop to0pt{\vskip12pt\box\rightcolumn}

\hsize=\fullsize\vskip-6\baselineskip
\hgrid=64pt \vgrid=60pt \sarrowlength=40pt
$$
  \gridcommdiag{
    \box\leftcolumn &&& \kern-12pt\box\rightcolumn \cr
    & \arrow(2,3)\rt{\kern-12pt\lower18pt\hbox{\rlap{\morphism{Typical}}{\lower12pt\hbox{\morphism{Structure}}}}} \cr
    & \arrow(2,-3) \cr\cr\cr
  }
$$

\bye
%--------------------------------------------------