org.proteinshader.graphics.typography
Class TextLabelFactory

java.lang.Object
  extended by org.proteinshader.graphics.typography.TextLabelFactory

public class TextLabelFactory
extends Object

Uses a GlyphSet to create short text labels to place on segments of a tube or ribbon. The labels will be amino acid abbreviations and sequence numbers (e.g. 'A 123' for alanine as the 123 amino acid in a chain).


Constructor Summary
TextLabelFactory()
          Constructs a TextLabelFactory.
 
Method Summary
 TextLabel createLabel(String text, int width, int height)
          Uses Glyph objects to create a TextLabel with a Buffer containing an image based on the text String given as an argument.
 void readGlyphSet()
          Obtains a set of glyphs by using the default '.conf' configuration file in the fonts directory.
 void readGlyphSet(String config)
          Reads the config file given as an argument and use the info to create a GlyphSet.
 void setDebug(boolean debug)
          Setting debug to true will turn on debugging (which prints data to standard out) for the GlyphSetFactory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextLabelFactory

public TextLabelFactory()
Constructs a TextLabelFactory.

Method Detail

setDebug

public void setDebug(boolean debug)
Setting debug to true will turn on debugging (which prints data to standard out) for the GlyphSetFactory.

Parameters:
debug - boolean value to turn debugging on or off.

createLabel

public TextLabel createLabel(String text,
                             int width,
                             int height)
Uses Glyph objects to create a TextLabel with a Buffer containing an image based on the text String given as an argument.

Parameters:
text - the string of characters to create an image for.
width - the width of the label in pixels.
height - the height of the label in pixels.
Returns:
A TextLabel object with a Buffer holding the image.

readGlyphSet

public void readGlyphSet()
                  throws GlyphException
Obtains a set of glyphs by using the default '.conf' configuration file in the fonts directory.

Throws:
GlyphException - if a problem occurs while trying to read the set of glyphs from a file.

readGlyphSet

public void readGlyphSet(String config)
                  throws GlyphException
Reads the config file given as an argument and use the info to create a GlyphSet.

The config file needs to specify the full package qualified name of a concrete GlyphSetFactory and whatever other information the GlyphSetFactory will need to find a source and read in the Glyphs. For the first written GlyphSetFactory, the keys are filename, fontname, typeface, fontSize, and bytesPerPixel. However, the exact set of keys for future GlyphSetFactories could vary, which is why a Properties object (a type of hash) is used to store the key-value pairs.

Parameters:
config - the name of the configuration file to read.
Throws:
GlyphException - if a problem occurs while trying to read the set of glyphs from a file.


Copyright © 2007-2008