The Label Factory

The LabelFactory lets you position labels on your webpage with minimal effort. To add the label "Hello" at position (400,400), simply add the line

    lf.makeLabel ("Hello", 400, 400, "cc");
to your script; see below for a complete example. The LabelFactory uses the Vector Markup Language (VML), which is currently only supported by Microsoft Internet Explorer 5 and higher.

The 4th argument lets you align the label relative to the position. The argument is a 2-character string and must have the following values:

ltlclb ctcccb rtrcrb
left
top
left
center
left
bottom
center
top
center
center
center
bottom
right
top
right
center
right
bottom

The diagram to the left shows all 9 different alignments in action. The diagram is an image. You can also view a live-diagram in Explorer.

The following examples shows the minimal code you need to use the LabelFactory. It centers the label "Hello" in a red oval. Note that (1000,1000) is the local coordinate size, and (400,400) is the center of the oval. The actual size of the oval is 200×100 pixels. The LabelFactory needs to know the corresponding scale factors (5,10).

<v:group coordsize='1000,1000' style='width:200;height:100'>
<v:oval fillcolor="red" 
           style="position:absolute;left:0;top:0;width:800;height:800"/>
<script language="JavaScript">
    var lf = new LabelFactory(1000/200, 1000/100);
    lf.makeLabel ("Hello", 400, 400, "cc");
</script>
</v:group>

View this example in Explorer.
Last modified by Wolfgang Kühn on Wed Mar 08 18:15:21 2000.