org.proteinshader.graphics.displaylists
Class CylinderReferences

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

public class CylinderReferences
extends Object

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


Field Summary
static double COEFFICIENT
          The empirically-determined coefficient for the power equation is 29.059.
static int DEFAULT_CAP_TILING
          The default tiling (number of slices and stacks) for a capping sphere is 5.
static double DEFAULT_HEIGHT
          The default cylinder height is 1.0.
static double DEFAULT_RADIUS
          Cylinders intended for a Sticks type of display will use a default cylinder radius is 0.15.
static int DEFAULT_SLICES
          The default number of slices for a cylinder is 10.
static int DEFAULT_STACKS
          The default number of stacks for a cylinder is 1.
static double EXPONENT
          The empirically-determined exponent for the power equation is -0.5267.
static int MAX_SLICES
          The maximum number of slices for cylinders cached by this class is 14, while the minimum will be the MIN_SLICES declared in class Cylinder, which is 3.
 
Constructor Summary
CylinderReferences()
          Constructs a CylinderReferences object.
 
Method Summary
 void cacheCylinderDisplayList(GL gl, Cylinder cylinder, CylinderListInfo info)
          Caches a new OpenGL display list for a BALLS_AND_STICKS cylinder or a STICKS cylinder with the requested number of slices and stacks.
 void cacheDefaultCylinders(GL gl, Cylinder cylinder)
          Caches a collection of cylinders using OpenGL display lists.
 CylinderListInfo getBallsAndSticksCylinderInfo()
          Returns the CylinderListInfo object that holds the information on an OpenGL display list for a cylinder to be used for a BALLS_AND_STICKS style display.
 int getBallsAndSticksRef()
          Returns the name (an integer) of an OpenGL display list for a cylinder intended to be used for Balls-and-Sticks style displays.
 int getBallsAndSticksRef(double cameraDistance)
          Returns the name (an integer) of an OpenGL display list for a cylinder intended to be used for Balls-and-Sticks displays.
 CylinderListInfo getSticksCylinderInfo()
          Returns the CylinderListInfo object that holds the information on an OpenGL display list for a cylinder to be used for a STICKS style display.
 int getSticksRef()
          Returns the name (an integer) of an OpenGL display list for a cylinder intended to be used for Sticks style displays.
 int getSticksRef(double cameraDistance)
          Returns the name (an integer) of an OpenGL display list for a cylinder intended to be used for Sticks style displays.
 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

MAX_SLICES

public static final int MAX_SLICES
The maximum number of slices for cylinders cached by this class is 14, while the minimum will be the MIN_SLICES declared in class Cylinder, which is 3.

See Also:
Constant Field Values

DEFAULT_HEIGHT

public static final double DEFAULT_HEIGHT
The default cylinder height is 1.0.

See Also:
Constant Field Values

DEFAULT_RADIUS

public static final double DEFAULT_RADIUS
Cylinders intended for a Sticks type of display will use a default cylinder radius is 0.15. Cylinders intended for a Balls-and-Sticks type display will use one-half of the default radius.

See Also:
Constant Field Values

DEFAULT_SLICES

public static final int DEFAULT_SLICES
The default number of slices for a cylinder is 10.

See Also:
Constant Field Values

DEFAULT_STACKS

public static final int DEFAULT_STACKS
The default number of stacks for a cylinder is 1.

See Also:
Constant Field Values

DEFAULT_CAP_TILING

public static final int DEFAULT_CAP_TILING
The default tiling (number of slices and stacks) for a capping sphere is 5.

See Also:
Constant Field Values

COEFFICIENT

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

See Also:
Constant Field Values

EXPONENT

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

See Also:
Constant Field Values
Constructor Detail

CylinderReferences

public CylinderReferences()
Constructs a CylinderReferences 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.

cacheDefaultCylinders

public void cacheDefaultCylinders(GL gl,
                                  Cylinder cylinder)
Caches a collection of cylinders using OpenGL display lists.

All cylinders are colorless and have a height of DEFAULT_HEIGHT. An array of cylinder display lists will be created with slices that begin at Cylinder.MIN_SLICES and increment by 1 until MAX_SLICES is reached. A single Balls-and-Sticks cylinder with DEFAULT_SLICES and DEFAULT_STACKS and a single Sticks cylinder with DEFAULT_SLICES and DEFAULT_STACKS are also cached. Any capping spheres are set to DEFAULT_CAP_TILING.

Parameters:
gl - the current GL object.
cylinder - the Cylinder object used for drawing.

cacheCylinderDisplayList

public void cacheCylinderDisplayList(GL gl,
                                     Cylinder cylinder,
                                     CylinderListInfo info)
Caches a new OpenGL display list for a BALLS_AND_STICKS cylinder or a STICKS cylinder with the requested number of slices and stacks.

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

If the CylinderListInfo 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.
cylinder - the Cylinder object used for drawing.
info - describes the requested OpenGL display list.

getBallsAndSticksCylinderInfo

public CylinderListInfo getBallsAndSticksCylinderInfo()
Returns the CylinderListInfo object that holds the information on an OpenGL display list for a cylinder to be used for a BALLS_AND_STICKS style display.

The reason for making this CylinderListInfo object accessible is so that it can be modified and plugged back into the cacheCylinderDisplayList() method in order to change the number of slices that the cylinder is made of.

Returns:
The display list info object for a cylinder.

getSticksCylinderInfo

public CylinderListInfo getSticksCylinderInfo()
Returns the CylinderListInfo object that holds the information on an OpenGL display list for a cylinder to be used for a STICKS style display.

The reason for making this CylinderListInfo object accessible is so that it can be modified and plugged back into the cacheCylinderDisplayList() method in order to change the number of slices that the cylinder is made of.

Returns:
The display list info object for a cylinder.

getBallsAndSticksRef

public int getBallsAndSticksRef()
Returns the name (an integer) of an OpenGL display list for a cylinder intended to be used for Balls-and-Sticks style displays. The cylinder will have DEFAULT_SLICES number of slices, unless the cacheCylinderDisplayList() method has been used to change the number of slices. 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 cylinder.

getBallsAndSticksRef

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

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

getSticksRef

public int getSticksRef()
Returns the name (an integer) of an OpenGL display list for a cylinder intended to be used for Sticks style displays. The cylinder will have DEFAULT_SLICES number of slices, unless the cacheCylinderDisplayList() method has been used to change the number of slices. 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 cylinder.

getSticksRef

public int getSticksRef(double cameraDistance)
Returns the name (an integer) of an OpenGL display list for a cylinder intended to be used for Sticks style displays. The number of slices for the cylinder will depend on the camera distance.

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


Copyright © 2007-2008