org.proteinshader.graphics.displaylists
Class SphereReferences

java.lang.Object
  extended by org.proteinshader.graphics.displaylists.SphereReferences

public class SphereReferences
extends Object

Stores information on multiple OpenGL display lists that can be used for rendering spheres with different degrees of detail.


Field Summary
static double COEFFICIENT
          The empirically-determined coefficient for the power equation is 226.1.
static double DEFAULT_RADIUS
          The spheres cached by this class will use a default radius of 1.0.
static int DEFAULT_TILING
          The default tiling is 12, and is used to set the initial number of slices and stacks for a generic sphere for SPACE_FILLING style displays and a generic sphere for BALLS_AND_STICKS style displays.
static double EXPONENT
          The empirically-determined exponent for the power equation is -0.7367.
static int MAX_TILING
          The maximum tiling number (slices and stacks) for spheres cached by this class is 57, while the minimum will be the MIN_TILING declared in class Sphere, which is 3.
 
Constructor Summary
SphereReferences()
          Constructs a SphereReferences object.
 
Method Summary
 void cacheDefaultSpheres(GL gl, Sphere sphere)
          Caches a collection of spheres using OpenGL display lists.
 void cacheSphereDisplayList(GL gl, Sphere sphere, SphereListInfo info)
          Caches a new OpenGL display list for a SPACE_FILLING sphere or a BALLS_AND_STICKS sphere with the requested tiling (number of slices and stacks).
 int getBallsAndSticksRef()
          Returns the name (an integer) of an OpenGL display list for a sphere intended to be used for a Balls-and-Sticks style display.
 int getBallsAndSticksRef(double cameraDistance)
          Returns the name (an integer) of an OpenGL display list for a sphere intended to be used for a Balls-and-Sticks style display.
 SphereListInfo getBallsAndSticksSphereInfo()
          Returns the SphereListInfo object that holds the information on an OpenGL display list for a sphere to be used in a BALLS_AND_STICKS style display.
 int getSpaceFillingRef()
          Returns the name (an integer) of an OpenGL display list for a sphere intended to be used for Space-Filling style displays.
 int getSpaceFillingRef(double cameraDistance)
          Returns the name (an integer) of an OpenGL display list for a sphere intended to be used for a Space-Filling style display.
 int getSpaceFillingSlices()
          Returns the number of slices that should be used for a sphere if automatic calculation of tiling number is turned off.
 SphereListInfo getSpaceFillingSphereInfo()
          Returns the SphereListInfo object that holds the information on an OpenGL display list for a sphere to be used for SPACE_FILLING style.
 int getSpaceFillingStacks()
          Returns the number of stacks that should be used for a sphere if automatic calculation of tiling number is turned off.
 int getSpaceFillingTilingNumber(double cameraDistance)
          Returns the recommended level of detail (tiling number = slices = stacks) for rendering a sphere at a given camera distance in angstroms.
 void printAutoTilingNumbers(boolean b)
          If automatic tiling is in use, giving this method an argument of true will cause the tiling numbers to be printed to standard out for testing and debugging purposes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_RADIUS

public static final double DEFAULT_RADIUS
The spheres cached by this class will use a default radius of 1.0.

See Also:
Constant Field Values

MAX_TILING

public static final int MAX_TILING
The maximum tiling number (slices and stacks) for spheres cached by this class is 57, while the minimum will be the MIN_TILING declared in class Sphere, which is 3.

See Also:
Constant Field Values

DEFAULT_TILING

public static final int DEFAULT_TILING
The default tiling is 12, and is used to set the initial number of slices and stacks for a generic sphere for SPACE_FILLING style displays and a generic sphere for BALLS_AND_STICKS style displays.

See Also:
Constant Field Values

COEFFICIENT

public static final double COEFFICIENT
The empirically-determined coefficient for the power equation is 226.1.

See Also:
Constant Field Values

EXPONENT

public static final double EXPONENT
The empirically-determined exponent for the power equation is -0.7367.

See Also:
Constant Field Values
Constructor Detail

SphereReferences

public SphereReferences()
Constructs a SphereReferences object.

Method Detail

printAutoTilingNumbers

public void printAutoTilingNumbers(boolean b)
If automatic tiling is in use, giving this method an argument of true will cause the tiling numbers to be printed to standard out for testing and debugging purposes.

Parameters:
b - boolean value for printing tiling numbers.

cacheDefaultSpheres

public void cacheDefaultSpheres(GL gl,
                                Sphere sphere)
Caches a collection of spheres using OpenGL display lists.

All spheres are colorless and have a radius of DEFAULT_RADIUS. An array of sphere display lists will be created with tiling numbers that begin at Sphere.MIN_TILING and increment by 1 until MAX_TILING is reached. A single space-filling sphere with DEFAULT_TILING and a single balls-and-sticks sphere with DEFAULT_TILING are also cached.

Parameters:
gl - the current GL object.
sphere - the Sphere object used for drawing.

cacheSphereDisplayList

public void cacheSphereDisplayList(GL gl,
                                   Sphere sphere,
                                   SphereListInfo info)
Caches a new OpenGL display list for a SPACE_FILLING sphere or a BALLS_AND_STICKS sphere with the requested tiling (number of slices and stacks).

These are the standard spheres that will be used by the getSpaceFillingRef() and getBallsAndSticksRef() if no camera distance is given as an argument.

If the SphereListInfo object given as an argument already holds the name of a valid OpenGL display list, the old display list will be deleted from graphics card memory before the new OpenGL display list is created.

Parameters:
gl - the current GL object.
sphere - the sphere object used for drawing.
info - describes the requested OpengGL display list.

getSpaceFillingSphereInfo

public SphereListInfo getSpaceFillingSphereInfo()
Returns the SphereListInfo object that holds the information on an OpenGL display list for a sphere to be used for SPACE_FILLING style.

The reason for making this SphereListInfo object accessible is so that it can be modified and plugged back in to the cacheSphereDisplayList() method in order to change the tiling number (the number of slices and stacks that the sphere is composed of).

Returns:
The display list info object for a sphere.

getSpaceFillingSlices

public int getSpaceFillingSlices()
Returns the number of slices that should be used for a sphere if automatic calculation of tiling number is turned off.

Returns:
The number of slices for a space filling sphere.

getSpaceFillingStacks

public int getSpaceFillingStacks()
Returns the number of stacks that should be used for a sphere if automatic calculation of tiling number is turned off.

Returns:
The number of stacks for a space filling sphere.

getSpaceFillingTilingNumber

public int getSpaceFillingTilingNumber(double cameraDistance)
Returns the recommended level of detail (tiling number = slices = stacks) for rendering a sphere at a given camera distance in angstroms.

Parameters:
cameraDistance - the distance between the center of the sphere and the camera.
Returns:
The tiling number.

getBallsAndSticksSphereInfo

public SphereListInfo getBallsAndSticksSphereInfo()
Returns the SphereListInfo object that holds the information on an OpenGL display list for a sphere to be used in a BALLS_AND_STICKS style display.

The reason for making this SphereListInfo object accessible is so that it can be modified and plugged back in to the cacheSphereDisplayList() method in order to change the tiling number (the number of slices and stacks that the sphere is composed of).

Returns:
The display list info object for a sphere.

getSpaceFillingRef

public int getSpaceFillingRef()
Returns the name (an integer) of an OpenGL display list for a sphere intended to be used for Space-Filling style displays. The sphere will have DEFAULT_TILING number of slices and stacks, unless the cacheSphereDisplayList() method has been used to change the tiling number. If this method is called before a display list has been cached, zero will be returned.

Returns:
An integer reference to an OpenGL display list for a sphere.

getSpaceFillingRef

public int getSpaceFillingRef(double cameraDistance)
Returns the name (an integer) of an OpenGL display list for a sphere intended to be used for a Space-Filling style display. The tiling number (number of slices and stacks) of the sphere will depend on the camera distance.

Parameters:
cameraDistance - the distance between the center of the sphere and the camera.
Returns:
An integer reference to an OpenGL display list for a sphere.

getBallsAndSticksRef

public int getBallsAndSticksRef()
Returns the name (an integer) of an OpenGL display list for a sphere intended to be used for a Balls-and-Sticks style display. The sphere will have DEFAULT_TILING number of slices and stacks, unless the cacheSphereDisplayList() method has been used to change the tiling number. If this method is called before a display list has been cached, zero will be returned.

Returns:
An integer reference to an OpenGL display list for a sphere.

getBallsAndSticksRef

public int getBallsAndSticksRef(double cameraDistance)
Returns the name (an integer) of an OpenGL display list for a sphere intended to be used for a Balls-and-Sticks style display. The tiling number (number of slices and stacks) of the sphere will depend on the camera distance.

Parameters:
cameraDistance - the distance between the center of the sphere and the camera.
Returns:
An integer reference to an OpenGL display list for a sphere.


Copyright © 2007-2008