org.proteinshader.graphics.typography
Class TextLabelManager

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

public class TextLabelManager
extends Object

Knows how to create and cache OpenGL display lists holding the glTexSubImage() with a bitmap for a text label that can be pasted onto curved surfaces.


Field Summary
static int BYTES_PER_PIXEL
          The blank texture map has 2 bytes per pixel.
static String MAP
          The 'textlabel.frag' fragment shader uniform variable for a 2D texture map is named 'textLabelMap'.
static int TABLA_RASA_HEIGHT
          The blank texture map is 128 pixels high.
static int TABLA_RASA_WIDTH
          The blank texture map is 128 pixels wide.
static int X_OFFSET
          The x-offset for pasting a subimage is 47 pixels.
static int Y_OFFSET
          The y-offset is 0 pasting a submimage is 0 pixels.
 
Constructor Summary
TextLabelManager()
          Constructs a TextLabelManager.
 
Method Summary
 void cacheDisplayLists(GL gl, List<String> textLabels)
          Caches an OpenGL display list holding glTexSubImage2D( bitmap ) for each textLabel in the list given as an argument.
 void deleteDisplayLists(GL gl)
          Frees graphics card memory for any OpenGL display lists currently being used to store text labels.
 void deleteTablaRasa(GL gl)
          Frees graphics card memory for the tabla rasa.
 void enableTexture(GL gl, String segmentID, int shaders, RegionEnum regionType)
          Enables OpenGL texture mapping and binds a texture with text cooresponding to the segmentID given as an argument.
 void loadTablaRasa(GL gl)
          Loads a blank texture map, the reusable tabla rasa.
 void readGlyphSet()
          Obtains a set of glyphs by using the default '.conf' configuration file in the fonts directory.
 void setDebug(boolean debug)
          Setting debug to true will turn on debugging (which prints data to standard out).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAP

public static final String MAP
The 'textlabel.frag' fragment shader uniform variable for a 2D texture map is named 'textLabelMap'.

See Also:
Constant Field Values

X_OFFSET

public static final int X_OFFSET
The x-offset for pasting a subimage is 47 pixels.

See Also:
Constant Field Values

Y_OFFSET

public static final int Y_OFFSET
The y-offset is 0 pasting a submimage is 0 pixels.

See Also:
Constant Field Values

TABLA_RASA_WIDTH

public static final int TABLA_RASA_WIDTH
The blank texture map is 128 pixels wide.

See Also:
Constant Field Values

TABLA_RASA_HEIGHT

public static final int TABLA_RASA_HEIGHT
The blank texture map is 128 pixels high.

See Also:
Constant Field Values

BYTES_PER_PIXEL

public static final int BYTES_PER_PIXEL
The blank texture map has 2 bytes per pixel.

See Also:
Constant Field Values
Constructor Detail

TextLabelManager

public TextLabelManager()
Constructs a TextLabelManager.

Method Detail

cacheDisplayLists

public void cacheDisplayLists(GL gl,
                              List<String> textLabels)
Caches an OpenGL display list holding glTexSubImage2D( bitmap ) for each textLabel in the list given as an argument.

The name (an integer) of each OpenGL display list is stored in a hash and can be obtained by giving a text label as an argument to the getTextLabelRef() method. A text label is a segmentID (which is the same as the residueID of the AminoAcid that the Segment cooresponds to).

Parameters:
gl - the current GL object.
textLabels - a list of AminoAcid residueIDs.

deleteDisplayLists

public void deleteDisplayLists(GL gl)
Frees graphics card memory for any OpenGL display lists currently being used to store text labels.

Parameters:
gl - the current GL object.

enableTexture

public void enableTexture(GL gl,
                          String segmentID,
                          int shaders,
                          RegionEnum regionType)
Enables OpenGL texture mapping and binds a texture with text cooresponding to the segmentID given as an argument.

A blank texture map (the tabla rasa) will be loaded and then a subimage (based on the segmentID) will be copied into the texture map by using the glTexSubImage2D() function.

If the region type argument is HELIX, then the texture wrapping mode will be set to GL_CLAMP so that the text label will only appear on one side of a tube representation (the side facing the outside of the Helix). For LOOP and BETA_STRAND, the texture wrapping mode will be set to GL_REPEAT so that the text label will be pasted on both side of a tube segment.

Parameters:
gl - the current GL object.
segmentID - the segmentID will be used to select a subimage.
shaders - the name (an integer) of the shader pair that is used for texture mapped text.
regionType - the region type can be Loop, Helix, or BetaStrand.

loadTablaRasa

public void loadTablaRasa(GL gl)
Loads a blank texture map, the reusable tabla rasa.

If there is already a table rasa, its memory will be freed before creating a new one.

Parameters:
gl - the current GL object.

deleteTablaRasa

public void deleteTablaRasa(GL gl)
Frees graphics card memory for the tabla rasa.

Parameters:
gl - the current GL object.

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.

setDebug

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

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


Copyright © 2007-2008