|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.proteinshader.graphics.adapter.StructureToGraphics
public class StructureToGraphics
Knows how to get numbers (such as zyz-coordinates and colors) from a
Drawable object (Atom, Bond, or Segment) and plug them into the right
graphics class for rendering a Shape (Sphere, Cylinder, or Segment).
When the program first starts up, OpenGL display lists for spheres and cylinders
will be cached, so actually rendering of spheres and cylinders will be sped up
by calling on OpenGL display lists rather than rendering on-the-fly. Ribbon
and tube segments will be cached as OpenGL display lists whenever ribbons or
tubes is selected from the Cartoon submenu of the Style menu above the canvas,
so normally all rendering of ribbon and tube segments will be sped up by calling
on cached geometry.
On a fairly new (less than a year old) Macintosh 2.16 GHz Intel Core 2 Duo
with an ATI Radeon X1600 graphics card, using OpenGL display lists results in
about 10 times faster rendering for tubes, 9 times faster rendering for ribbons,
and 7 times faster rendering for spheres. However, the exact difference in
frames per second during an animation will probably vary depending on the
machine and graphics card.
To allows testing of the effects of caching geometry in the form of OpenGL
display lists, the StructureToGraphics class has a boolean instance variable
named renderOnTheFly that can be used to shut off the use of OpenGL display
lists for rendering spheres, ribbon segments, and tube segments, so that
calls to Java drawing routines will be made every time a frame is rendered.
The renderOnTheFly variable is normally set to false, but can be set to true
by giving the command line argument "-DrenderOnTheFly=true" when staring the
program. If Ant (a Java build tool) is installed, the program can be started
by typing "ant run.slow" on the command line instead of "ant run".
Field Summary | |
---|---|
static boolean |
AUTO_TILING
Automatic tiling (level of detail) for spheres and cylinders is set to true by default. |
Constructor Summary | |
---|---|
StructureToGraphics()
Constructs a StructureToGraphics object. |
Method Summary | |
---|---|
void |
blendObjectEdges(boolean b)
Turns on or off the ability of the halftoning shaders to soften aliasing (jagged edges) by rendering translucent black silhouettes of tube and ribbon segments (and using jitter) before calling on the halftoning shaders. |
void |
cacheDefaultGeometricObjects(GL gl)
Uses the default values for tiling (slices and stacks) to cache geometric objects (spheres and cylinders) in the form of OpenGL display lists. |
void |
cacheGeometricObject(GL gl,
GeometricListInfo info)
Caches a new OpenGL display list for a geometric object. |
void |
cacheSegmentGeometry(GL gl,
Model model,
StyleEnum style)
Calls on the SegmentReferences object to cache OpenGL display lists for the Segments of the current Model. |
void |
cacheTextLabels(GL gl,
List<String> textLabels)
Informs the TextLabelManager that OpenGL display lists for text label sub need to be cached. |
void |
compileShaders(GL gl)
Compiles the OpenGL Shading Language vertex and fragment shaders that will be needed for lighting calculations and texture mapping. |
void |
draw(GL gl,
Atom atom)
Draws an Atom as a sphere. |
void |
draw(GL gl,
Bond bond)
Draws the Bond as a single cylinder for a Balls-and-Sticks style display, but two cylinders for a Sticks style display. |
void |
draw(GL gl,
Drawable d)
Determines if a Drawable object is an Atom, Bond, or Segment, and then calls on the appropriate draw() method. |
void |
draw(GL gl,
Segment segment)
Draws a Segment of a Region (GeneralLoop, Helix, or BetaStrand). |
Vector<Texture> |
getBendTextures()
Returns the bend Texture objects that were created with the loadTextures() method and are intended for use with halftoning. |
CylinderListInfo |
getCylinderInfo(StyleEnum style)
Returns the CylinderListInfo object that holds the information on an OpenGL display list for a cylinder that is currently used for drawing Bonds. |
Vector<Texture> |
getHalftoningTextures()
Returns the Texture objects that were created with the loadTextures() method and are intended for use with halftoning. |
Vector<Texture> |
getPatternsTextures()
Returns the Texture objects that were created with the loadTextures() method and are intended for use as patterns to apply to tubes and ribbons drawn in color (rather than halftoning). |
SphereListInfo |
getSphereInfo(StyleEnum style)
Returns the SphereListInfo object that holds the information on an OpenGL display list for a sphere that is currently used for drawing Atoms. |
StyleEnum |
getStyle()
Returns the current style (TUBES, RIBBONS, RIBBONS_AND_TUBES, FRENET_FRAMES, SPACE_FILLING, BALLS_AND_STICKS, or STICKS). |
void |
loadTextures(GL gl)
Loads the default texture objects needed for text labels and real-time halftoning. |
void |
printAutoTilingNumbers(boolean b)
If automatic tiling is in use, setting this method to true will cause the tiling numbers to be printed to standard out for testing and debugging purposes. |
void |
readGlyphSet()
Obtains a set of glyphs by using the default '.conf' configuration file in the fonts directory. |
void |
setAutoTiling(boolean autoTiling)
If automatic tiling is set to true, then the level of detail (tiling number) for a sphere or cylinder will be calculated based on the camera distance for each Atom or Bond, respectively. |
void |
setExtraLines(boolean extraLines)
If tubes or ribbons are being rendered, lines will be drawn at the beginning and end of each segment if extra lines is set to true. |
void |
setFPSTextureAndShader(GL gl,
int texName)
Sets the texture object and shaders to be used when drawing an fps (frames per second) label on the canvas. |
void |
setStyle(StyleEnum style)
Sets the style (TUBES, RIBBONS, RIBBONS_AND_TUBES, FRENET_FRAMES, SPACE_FILLING, BALLS_AND_STICKS, or STICKS). |
void |
toggleBlendObjectEdges()
Toggles the boolean value that is set with the blendObjectsEdges() method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean AUTO_TILING
Constructor Detail |
---|
public StructureToGraphics()
Method Detail |
---|
public void blendObjectEdges(boolean b)
b
- boolean value to determine if object edges should be smoothed.public void toggleBlendObjectEdges()
public void setAutoTiling(boolean autoTiling)
autoTiling
- boolean value for automatic tiling.public void setExtraLines(boolean extraLines)
extraLines
- boolean value for extra lines.public void printAutoTilingNumbers(boolean b)
b
- boolean value for printing tiling numbers.public void cacheDefaultGeometricObjects(GL gl)
gl
- the current GL object.public void cacheGeometricObject(GL gl, GeometricListInfo info)
gl
- the current GL object.info
- describes the requested OpenGL display list.public void cacheSegmentGeometry(GL gl, Model model, StyleEnum style)
gl
- the current GL object.model
- the current Model.style
- the cartoon-style (Tubes, Ribbons, or Frames).public void readGlyphSet() throws GlyphException
GlyphException
- if a problem occurs while trying to read
the set of glyphs from a file.public void cacheTextLabels(GL gl, List<String> textLabels)
textLabels
- the text label to create a subimage for.public void draw(GL gl, Drawable d)
gl
- the current GL object.d
- the Drawable object to draw.public void draw(GL gl, Atom atom)
gl
- the current GL object.atom
- the Atom to draw.public void draw(GL gl, Bond bond)
gl
- the current GL object.bond
- the Bond to draw.public void draw(GL gl, Segment segment)
gl
- the current GL object.segment
- the Segment to draw.public void compileShaders(GL gl) throws ShaderException
gl
- the current GL object.
ShaderException
- if an error occurs while trying to
compile and link any of the shader pairs.public void loadTextures(GL gl) throws TextureException
gl
- the current GL object.
TextureException
- if an error occurs while trying to read
a texture file.public Vector<Texture> getPatternsTextures()
public Vector<Texture> getHalftoningTextures()
public Vector<Texture> getBendTextures()
public StyleEnum getStyle()
public void setStyle(StyleEnum style)
style
- the style as an enum.public SphereListInfo getSphereInfo(StyleEnum style)
public CylinderListInfo getCylinderInfo(StyleEnum style)
public void setFPSTextureAndShader(GL gl, int texName)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |