How to draw image like this:

enter image description here

I use MetaUML package for drawing Uml.

Can it be used to draw this image? I want to keep my image styles uniform and don't want to use other drawing package just for one image.

I can draw it like this:

enter image description here

but how can I get rid of the Component icon? And how to make boxes same dimension?

This is the code I use

input metauml;

    A.info.iAttributeStack.top := 0;
    A.info.iAttributeStack.bottom := 0;
    A.info.iMethodStack.top := 0;
    A.info.iMethodStack.bottom := 0;

    B.info.iAttributeStack.top := 0;
    B.info.iAttributeStack.bottom := 0;
    B.info.iMethodStack.top := 0;
    B.info.iMethodStack.bottom := 0;

    C.info.iAttributeStack.top := 0;
    C.info.iAttributeStack.bottom := 0;
    C.info.iMethodStack.top := 0;
    C.info.iMethodStack.bottom := 0;

    Component.BigC("Spoon")(A, B, C);

    leftToRight(10)(A, B, C);



edit I can get rid of component symbol by using Package instead of Component, but result looks a lot different than original image


MetaUML does not provide any easy way to control the width of your classes, but you can get them looking close to what you want with the built in "ClassName" function. And you can get rid of the stereotype in the Component by redefining the macro that draws it to do nothing. Like this:


input metauml;
vardef drawComponentVisualStereotype(text ne)= relax enddef;

     Component.BigC("Spoon")(A, B, C);
     leftToRight(10)(A, B, C);

which produces this: enter image description here

If you only want to suppress the visual stereotype in this one figure, then move the re-definition inside the beginfig / endfig scope.

If you were not already committed to MetaUML, you could consider using good old boxes.mp that comes with Metapost as standard. Here's an example of what you could do with it (designed to continue the above file).

input boxes;
verbatimtex \font\sf=phvr8r\sf etex

    boxit.bA(btex \strut Entity etex);
    boxit.bB(btex \strut Render etex);
    boxit.bC(btex \strut Collectable etex);
    boxit.bS(btex \vrule width 0pt depth 40pt Spoon etex);

    % make the class boxes the same size
    forsuffixes $=bA,bB,bC:$.ne-$.sw = (60,30); endfor

    bA.c = bB.c + 80 left;
    bC.c = bB.c + 80 right;
    bS.c = bB.n; 
    bS.sw = bA.sw - (10,10);

    forsuffixes $=bA,bB,bC: fill bpath.$ withcolor .88white; endfor

which gives you this: enter image description here

Note that boxit tries hard to center the text contents horizontally and vertically, so one way to offset the text is to use an invisible rule sticking down as I have done here in the "Spoon" box.

  • Thank you! It looked it is wouldn't be answered. Once again, thank you! – relaxxx Nov 9 '13 at 9:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.