Semantic Zooming

To take the glyph example a little bit further, you can easily include functionality to display amounts of information depending on the size that the glyph is rendered.

Here is the source for an example that will display a text String to fit inside the bounding area of its glyph.

The code for the applet shown which uses ScaleText is identical to the previous example except that it creates glyphs of type ScaleText rather than RoundRect.


        

Exercises

  1. Write a new text glyph that will crop a text string to fit within the glyph and keep the font size fixed.
  2. In this example new fonts are created when the text is scaled, though often they are created for sizes that may have been created previously. Change the ScaleText glyph to allow it to cache commonly used font sizes.

Next: Responding to Events