org.proteinshader.graphics.typography
Class GLF2GlyphSetFactory

java.lang.Object
  extended by org.proteinshader.graphics.typography.GLF2GlyphSetFactory
All Implemented Interfaces:
GlyphSetFactory

public class GLF2GlyphSetFactory
extends Object
implements GlyphSetFactory

Reads a set of glyphs from a ".glf" file that was created with the glFont program (Version 2.0) written by Brad Fish (brad.fish@gmail.com).

The glFont program can be downloaded from http://students.cs.byu.edu/~bfish/glfont.php (cited January 2007).

glFont is a Win32 program that creates a texture file containing a user-specified range of characters in a Windows TrueType bitmap font selected from a menu. Brad Fish also wrote a C++ class, glFont.cpp (Copyright (c) 1998-2002 Brad Fish), that can be used to read in a '.glf' file to create an OpenGL texture object and then map characters from the texture onto OpenGL quads.

Because the ProteinShader program needs to map text onto curved surfaces, a somewhat different approach needs to be taken. After reading in a '.glf' file, the bitmap for each individual character will be stored in a Glyph object as a 2D array of bytes. These Glyph objects will be used by a TextLabelFactory to create TextLabel objects that hold a 2D array of bytes with the characters for an AminoAcid label (e.g., 'A 121' for alanine 121). To render the label onto the surface of a segment of a tube or ribbon, a byte array will be plugged in to the OpenGL glTexSubImage2D() function in order to replace the center region of an existing OpenGL texture object. This modified texture object can then be used to map the text label onto any curved surface that has texture coordinates.


Field Summary
static int BYTES_PER_PIXEL
          The '.glf' image uses 2 bytes per pixel.
static int DATA_TYPE
          The '.glf' data type is GL.GL_UNSIGNED_BYTE.
static int FORMAT
          The '.glf' format is GL.GL_LUMINANCE_ALPHA.
 
Constructor Summary
GLF2GlyphSetFactory()
          Constructs a GLF2GlyphSetFactory.
 
Method Summary
 GlyphSet readGlyphSet(Properties p)
          Reads information from a '.glf' file and constructs a GlyphSet object.
 void setDebug(boolean debug)
          Setting debug to true will activate several print statements that are useful for troubleshooting.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BYTES_PER_PIXEL

public static final int BYTES_PER_PIXEL
The '.glf' image uses 2 bytes per pixel.

See Also:
Constant Field Values

FORMAT

public static final int FORMAT
The '.glf' format is GL.GL_LUMINANCE_ALPHA.

See Also:
Constant Field Values

DATA_TYPE

public static final int DATA_TYPE
The '.glf' data type is GL.GL_UNSIGNED_BYTE.

See Also:
Constant Field Values
Constructor Detail

GLF2GlyphSetFactory

public GLF2GlyphSetFactory()
Constructs a GLF2GlyphSetFactory.

Method Detail

setDebug

public void setDebug(boolean debug)
Setting debug to true will activate several print statements that are useful for troubleshooting.

Specified by:
setDebug in interface GlyphSetFactory
Parameters:
debug - boolean value to turn debugging on or off.

readGlyphSet

public GlyphSet readGlyphSet(Properties p)
                      throws GlyphException
Reads information from a '.glf' file and constructs a GlyphSet object.

The Properties object given as an argument must hold values for the keys filename, fontname, typeface, fontSize, and bytesPerPixel. Here is an example:

filename=Verdana18Bold.glf
fontname=Verdana
typeface=Bold
fontSize=18
bytesPerPixel=2

Specified by:
readGlyphSet in interface GlyphSetFactory
Parameters:
p - a Properties object is a type of hash.
Returns:
A GlyphSet that holds Glyph objects.
Throws:
GlyphException


Copyright © 2007-2008