The intermediary document : Boxes structure (second example)

In this chapter, we will use the same example used as first example, but we will add more boxes and introduce springs.

1. Our second example

Save the following code under editor/XML/Examples/example2.grp :

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE grp SYSTEM "../grp.dtd">
        <tbox fontSize="30" fontStyle="italic">Hello</tbox>

        <spring minSize="10"/>

        <tbox fontSize="30" fontStyle="italic">world</tbox>

        <spring minSize="10"/>

        <tbox fontSize="30" fontStyle="italic">!</tbox>

We will use the same definitions document than previously. In a console, change to directory editor/XML/Examples (if not already done), and then type :

    java -cp ../../lib/taxi.jar -grp_in example2.grp -defs examples.def -svg_dtd ../svg.dtd

You should see the following output :

    Parsing file examples.def
    Parsing file example2.grp
    Creating SVG document
    Generating SVG file example2.svg

The document example2.svg in the directory editor/XML/Examples has been generated. It looks like that with the Adobe plugin :

2. Our second example explained

Instead of using only one tbox to hold the text Hello world !, we used 3 tbox separated by 2 springs.

2.1. The springs

A spring is an element that is able to stretch on a single axis. It must be placed in a non-final box (as hbox).

In our example, we used 2 springs to separate 3 boxes. We specified a minimum size of 10 via the attribute minSize. Before explaining in detail the element spring, let's have a thrid example to use more functionalities of springs.