org.proteinshader.graphics
Class Ribbon

java.lang.Object
  extended by org.proteinshader.graphics.Shape
      extended by org.proteinshader.graphics.ExtrudedShape
          extended by org.proteinshader.graphics.Ribbon

public class Ribbon
extends ExtrudedShape

Draws a segment of a three-dimensional ribbon by using a rectangular-shaped waist polygon.

The broad surface of the ribbon will have texture coordinates and will be whatever material color is set before drawing. However, the narrower sides will be set to a default color for now.


Field Summary
static double ALPHA_HEIGHT
          The default ribbon height (y-axis dimension) for an alpha-helix region is 3.0 angstroms.
static float ALPHA_S_COORD_END
          The texture s-coordinate for alpha-helices ends at 1.0.
static float ALPHA_S_COORD_START
          The texture s-coordinate for alpha-helices starts at 0.0.
static int ALPHA_STACKS
          The default number of stacks for an alpha-helix segment is 10.
static float ALPHA_THIN_SIDE_S_MAX
          The texture s-coordinate for the thin side of alpha-helices ends at 0.125.
static float ALPHA_THIN_SIDE_S_MIN
          The texture s-coordinate for the thin side of alpha-helices starts at 0.0.
static double ALPHA_WIDTH
          The default ribbon width (x-axis dimension) for an alpha-helix region is 0.2 angstroms.
static double BETA_HEIGHT
          The default is 4.0 angstroms.
static float BETA_S_COORD_END
          The texture s-coordinate for beta-strands ends at 1.0.
static float BETA_S_COORD_START
          The texture s-coordinate for beta-strands starts at 0.0.
static int BETA_STACKS
          The default number of stacks for a beta-strand segment is 10.
static float BETA_THIN_SIDE_S_MAX
          The texture s-coordinate for the thin side of beta-strands ends at 0.125.
static float BETA_THIN_SIDE_S_MIN
          The texture s-coordinate for the thin side of beta-strands starts at 0.0.
static double BETA_WIDTH
          The default ribbon width (x-axis dimension) for a BetaStrand region is 0.2 angstroms.
static double LOOP_HEIGHT
          The default ribbon height (y-axis dimension) for a Loop region is 1.0 angstroms.
static float LOOP_S_COORD_END
          The texture s-coordinate for loops ends at 0.75 rather than at 1.0.
static float LOOP_S_COORD_START
          The texture s-coordinate for loops starts at 0.25 rather than at 0.0.
static int LOOP_STACKS
          The default number of stacks for a loop segment is 10.
static float LOOP_THIN_SIDE_S_MAX
          The texture s-coordinate for the thin side of loops ends at 0.125.
static float LOOP_THIN_SIDE_S_MIN
          The texture s-coordinate for the thin side of loops starts at 0.0.
static double LOOP_WIDTH
          The default ribbon width (x-axis dimension) for a Loop region is 0.25 angstroms.
static float[] THIN_SIDES_COLOR
          The default color for the narrow sides of the three-dimensional ribbon is gray.
 
Fields inherited from class org.proteinshader.graphics.ExtrudedShape
END_CAP_COLOR, START_CAP_COLOR
 
Fields inherited from class org.proteinshader.graphics.Shape
HALF_PI, PI, SPECULAR_COLOR, TWO_PI
 
Constructor Summary
Ribbon()
          Constructs a Ribbon using the default values for a LOOP.
Ribbon(double width, double height, double sCoordStart, double sCoordEnd, boolean counterclockwise, double thinMinS, double thinMaxS)
          Constructs a Ribbon.
Ribbon(RegionEnum regionType)
          Constructs a Ribbon using default values based on the Region type (Helix, BetaStrand, or Loop).
 
Method Summary
 void applyThinSidesColor(GL gl, float alpha, float specularExp)
          Calls the setMaterial() method of superclass Shape with the THIN_SIDES_COLOR along with the alpha value and specular exponent given as aguments.
 void createDisplayLists(GL gl, LocalFrame[] frames, SegmentListInfo info)
          Creates an OpenGL display list for the thin sides of the ribbon, and also calls on the createDisplayLists() method of superclass ExtrudedShape to save the OpenGL display lists for the main (broad surface) part of the ribbon and for the start and end caps.
 int createThinSidesDisplayList(GL gl, LocalFrame[] frames)
          Caches an OpenGL display list for the thin sides of a segment of a ribbon.
 void draw(GL gl, LocalFrame[] frames)
          Uses an array of LocalFrame objects to draw the broad surfaces of of a ribbon.
 void drawEndCap(GL gl, LocalFrame frame)
          Creates a cap for the end of a segment by drawing the waist polygon.
 void drawStartCap(GL gl, LocalFrame frame)
          Creates a cap for the beginning of a segment by drawing the waist polygon.
 void drawThinSideSurfaces(GL gl, LocalFrame[] frames)
          Draws the thin side surfaces for a segment of a ribbon.
 void setDimensions(double width, double height)
          Sets the width (x-axis dimension) and the height (y-axis dimension) of the rectangular waist polygon.
 void setSCoordParameters(double sCoordStart, double sCoordEnd, boolean counterclockwise)
          Sets the lowest and highest s-coordinate for texture, and also sets the direction in which the s-texture coordinate increases.
 void setThinSideMinAndMaxS(double thinMinS, double thinMaxS)
          Sets the minimum and maximum values for the texture s-coordinate for the thin sides of the ribbon.
 
Methods inherited from class org.proteinshader.graphics.ExtrudedShape
applyEndCapColor, applyStartCapColor, createDisplayList, createEndCapDisplayList, createStartCapDisplayList
 
Methods inherited from class org.proteinshader.graphics.Shape
deleteDisplayList, executeDisplayList, executeDisplayList, setMaterial
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THIN_SIDES_COLOR

public static final float[] THIN_SIDES_COLOR
The default color for the narrow sides of the three-dimensional ribbon is gray.


LOOP_WIDTH

public static final double LOOP_WIDTH
The default ribbon width (x-axis dimension) for a Loop region is 0.25 angstroms.

See Also:
Constant Field Values

LOOP_HEIGHT

public static final double LOOP_HEIGHT
The default ribbon height (y-axis dimension) for a Loop region is 1.0 angstroms.

See Also:
Constant Field Values

LOOP_STACKS

public static final int LOOP_STACKS
The default number of stacks for a loop segment is 10.

See Also:
Constant Field Values

LOOP_S_COORD_START

public static final float LOOP_S_COORD_START
The texture s-coordinate for loops starts at 0.25 rather than at 0.0.

See Also:
Constant Field Values

LOOP_S_COORD_END

public static final float LOOP_S_COORD_END
The texture s-coordinate for loops ends at 0.75 rather than at 1.0.

See Also:
Constant Field Values

LOOP_THIN_SIDE_S_MIN

public static final float LOOP_THIN_SIDE_S_MIN
The texture s-coordinate for the thin side of loops starts at 0.0.

See Also:
Constant Field Values

LOOP_THIN_SIDE_S_MAX

public static final float LOOP_THIN_SIDE_S_MAX
The texture s-coordinate for the thin side of loops ends at 0.125.

See Also:
Constant Field Values

ALPHA_WIDTH

public static final double ALPHA_WIDTH
The default ribbon width (x-axis dimension) for an alpha-helix region is 0.2 angstroms.

See Also:
Constant Field Values

ALPHA_HEIGHT

public static final double ALPHA_HEIGHT
The default ribbon height (y-axis dimension) for an alpha-helix region is 3.0 angstroms.

See Also:
Constant Field Values

ALPHA_STACKS

public static final int ALPHA_STACKS
The default number of stacks for an alpha-helix segment is 10.

See Also:
Constant Field Values

ALPHA_S_COORD_START

public static final float ALPHA_S_COORD_START
The texture s-coordinate for alpha-helices starts at 0.0.

See Also:
Constant Field Values

ALPHA_S_COORD_END

public static final float ALPHA_S_COORD_END
The texture s-coordinate for alpha-helices ends at 1.0.

See Also:
Constant Field Values

ALPHA_THIN_SIDE_S_MIN

public static final float ALPHA_THIN_SIDE_S_MIN
The texture s-coordinate for the thin side of alpha-helices starts at 0.0.

See Also:
Constant Field Values

ALPHA_THIN_SIDE_S_MAX

public static final float ALPHA_THIN_SIDE_S_MAX
The texture s-coordinate for the thin side of alpha-helices ends at 0.125.

See Also:
Constant Field Values

BETA_WIDTH

public static final double BETA_WIDTH
The default ribbon width (x-axis dimension) for a BetaStrand region is 0.2 angstroms.

See Also:
Constant Field Values

BETA_HEIGHT

public static final double BETA_HEIGHT
The default is 4.0 angstroms.

See Also:
Constant Field Values

BETA_STACKS

public static final int BETA_STACKS
The default number of stacks for a beta-strand segment is 10.

See Also:
Constant Field Values

BETA_S_COORD_START

public static final float BETA_S_COORD_START
The texture s-coordinate for beta-strands starts at 0.0.

See Also:
Constant Field Values

BETA_S_COORD_END

public static final float BETA_S_COORD_END
The texture s-coordinate for beta-strands ends at 1.0.

See Also:
Constant Field Values

BETA_THIN_SIDE_S_MIN

public static final float BETA_THIN_SIDE_S_MIN
The texture s-coordinate for the thin side of beta-strands starts at 0.0.

See Also:
Constant Field Values

BETA_THIN_SIDE_S_MAX

public static final float BETA_THIN_SIDE_S_MAX
The texture s-coordinate for the thin side of beta-strands ends at 0.125.

See Also:
Constant Field Values
Constructor Detail

Ribbon

public Ribbon()
Constructs a Ribbon using the default values for a LOOP.


Ribbon

public Ribbon(RegionEnum regionType)
Constructs a Ribbon using default values based on the Region type (Helix, BetaStrand, or Loop).

The waist polygon is a simple rectangle. The width is the x-axis dimension and the height is the y-axis dimension. See the setSCoordParameters() method comments for an explanation of how the s-texture coordinate is assigned to vertices of the rectangular waist polygon.

Parameters:
regionType - the type can be HELIX, BETA_STRAND, or LOOP.

Ribbon

public Ribbon(double width,
              double height,
              double sCoordStart,
              double sCoordEnd,
              boolean counterclockwise,
              double thinMinS,
              double thinMaxS)
Constructs a Ribbon.

The waist polygon is a simple rectangle. The width is the x-axis dimension and the height is the y-axis dimension. See the setDirectionOfTexCoordS() method comments for an explanation of how the s-texture coordinate is assigned to vertices of the rectangular waist polygon.

Parameters:
width - the x-axis dimension.
height - the y-axis dimension.
sCoordStart - lowest s-coordinate for texture mapping.
sCoordEnd - hightest s-coordinate for texture mapping.
counterclockwise - determines the direction in which the s-texture coordinate increases as it goes around the rectangle in the xy-plane.
thinMinS - minimum texture s-coordinate for thin side.
thinMaxS - maximum texture s-coordinate for thin side.
Method Detail

applyThinSidesColor

public void applyThinSidesColor(GL gl,
                                float alpha,
                                float specularExp)
Calls the setMaterial() method of superclass Shape with the THIN_SIDES_COLOR along with the alpha value and specular exponent given as aguments.

Parameters:
gl - the current GL object.
alpha - component of RGBA color
specularExp - the specular exponent for Phong lighting calculations.

createDisplayLists

public void createDisplayLists(GL gl,
                               LocalFrame[] frames,
                               SegmentListInfo info)
Creates an OpenGL display list for the thin sides of the ribbon, and also calls on the createDisplayLists() method of superclass ExtrudedShape to save the OpenGL display lists for the main (broad surface) part of the ribbon and for the start and end caps.

Overrides:
createDisplayLists in class ExtrudedShape
Parameters:
gl - the current GL object.
frames - array of LocalFrames for positioning a waist polygon.
info - the info object to store the name (an integer) of each OpenGL display list that is created.

createThinSidesDisplayList

public int createThinSidesDisplayList(GL gl,
                                      LocalFrame[] frames)
Caches an OpenGL display list for the thin sides of a segment of a ribbon.

The side surfaces are drawn separately so that they can be drawn using a different color that the main broad surfaces of the ribbon.

There must be at least two LocalFrames in order to draw a Segment. If there are less than two frames in the array, this method will return 0.

Parameters:
gl - the current GL object.
frames - array of LocalFrames for positioning a waist polygon.
Returns:
The name (an integer) of the OpenGL display list.

draw

public void draw(GL gl,
                 LocalFrame[] frames)
Uses an array of LocalFrame objects to draw the broad surfaces of of a ribbon.

Texture coordinates are associated with each vertex.

Specified by:
draw in class ExtrudedShape
Parameters:
gl - the current GL object.
frames - array of LocalFrames for positioning a waist polygon.

drawStartCap

public void drawStartCap(GL gl,
                         LocalFrame frame)
Creates a cap for the beginning of a segment by drawing the waist polygon. The surface normal will be the negative z-axis (the tangent) of the local coordinate frame.

Specified by:
drawStartCap in class ExtrudedShape
Parameters:
gl - the current GL object.
frame - the frame for positioning the waist polygon.

drawEndCap

public void drawEndCap(GL gl,
                       LocalFrame frame)
Creates a cap for the end of a segment by drawing the waist polygon. The surface normal will be the negative z-axis (the tangent) of the local coordinate frame.

Specified by:
drawEndCap in class ExtrudedShape
Parameters:
gl - the current GL object.
frame - the frame for positioning the waist polygon.

drawThinSideSurfaces

public void drawThinSideSurfaces(GL gl,
                                 LocalFrame[] frames)
Draws the thin side surfaces for a segment of a ribbon.

The side surfaces are drawn separately so that they can be drawn using a different color that the main broad surfaces of the ribbon. The thin side surfaces of the ribbon do not have texture coordinates (although they would be easy to add if that was desired).

Parameters:
gl - the current GL object.
frames - array of LocalFrames for positioning a waist polygon.

setDimensions

public void setDimensions(double width,
                          double height)
Sets the width (x-axis dimension) and the height (y-axis dimension) of the rectangular waist polygon.

Parameters:
width - the width.
height - the height.

setSCoordParameters

public void setSCoordParameters(double sCoordStart,
                                double sCoordEnd,
                                boolean counterclockwise)
Sets the lowest and highest s-coordinate for texture, and also sets the direction in which the s-texture coordinate increases.

If counterclockwise is true, then the s-texture coordinates are assigned as follows:

Broad face of ribbon facing +x direction:
s = sCoordStart for vertex[0] at (x, -y, 0)
s = sCoordEnd for vertex[1] at (x, y, 0)



Broad face of ribbon facing -x direction:
s = sCoordStart for vertex[2] at (-x, y, 0)
s = sCoordEnd for vertex[3] at (-x, -y, 0)



If counterclockwise is set to false, than s = sCoordStart and s = sCoordEnd are switched to that s will increase in the clockwise direction.

The thin sides of the ribbon are a solid color without texture, so the texture coordinates do not matter for vertex[1] to vertex[2] or vertex[3] to vertex[0].

Parameters:
sCoordStart - lowest s-coordinate for texture mapping.
sCoordEnd - hightest s-coordinate for texture mapping.
counterclockwise - determines the direction in which the s-texture coordinate increases as it goes around the rectangle in the xy-plane.

setThinSideMinAndMaxS

public void setThinSideMinAndMaxS(double thinMinS,
                                  double thinMaxS)
Sets the minimum and maximum values for the texture s-coordinate for the thin sides of the ribbon.

Parameters:
thinMinS - the starting s-coordinate.
thinMaxS - the ending s-coordinate.


Copyright © 2007-2008