org.proteinshader.gui.viewing
Class Rotation

java.lang.Object
  extended by org.proteinshader.gui.viewing.Rotation

public class Rotation
extends Object

Keeps track of rotation transformations of the current model.


Field Summary
static double HALF_PI
          One-half Pi is defined as 1.57079632679489, and is equal to 90 degrees.
static double PI
          Pi is defined as 3.14159265358979, and is equal to 180 degrees.
static double RADIANS_PER_DEGREE
          Pi divided by 180 degrees.
static double TWO_PI
          2*Pi is defined as 6.28318530717958, and is equal to 360 degrees.
static Vec3d X_AXIS
          Vector representing an x-axis.
static Vec3d Y_AXIS
          Vector representing an y-axis.
static Vec3d Z_AXIS
          Vector representing an z-axis.
 
Constructor Summary
Rotation(Mediator mediator, FpsLabel fpsLabel)
          Constructs a Renderer.
 
Method Summary
 void calculateTimeAndRotation()
          Calculates an x-axis and y-axis rotation based on the current system time and the previous time this method was called.
 double getScale()
          Returns the scale factor for the image.
 void loadFpsFontFile(GL gl)
          Tells the FpsLabel object to read in the font file that it needs for displaying a frames per second label on the canvas.
 void rotateAboutXY(double deltaX, double deltaY)
          Rotates the model about the x-axis and y-axis.
 void rotateAboutZ(double deltaZ)
          Rotates the model about the z-axis.
 void rotateScaleAndCenterModel(GL gl)
          This helper method for display() rotates, scales, and centers the model.
 void setCenter(double x, double y, double z)
          Sets the xyz-coordinates for the center of gravity of the current model.
 void setImageOrientation(OrientationEnum orientation)
          Resets the orientation of the image by resetting the angle of rotation about the x-axis and the angle of rotation about the y-axis.
 void setScale(double scale)
          Sets the scale factor for the image.
 void startAnimation(double xAxisSpeed, double yAxisSpeed, GLCanvas canvas)
          Uses an Animator object to rotate the protein image about its x-axis and/or y-axis.
 void stopAnimation()
          Stops the rotation animation that is started with startAnimation().
 void writeFps(GL gl, GLAutoDrawable canvas)
          Updates the frames per second display on the canvas.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HALF_PI

public static final double HALF_PI
One-half Pi is defined as 1.57079632679489, and is equal to 90 degrees.

See Also:
Constant Field Values

PI

public static final double PI
Pi is defined as 3.14159265358979, and is equal to 180 degrees.

See Also:
Constant Field Values

TWO_PI

public static final double TWO_PI
2*Pi is defined as 6.28318530717958, and is equal to 360 degrees.

See Also:
Constant Field Values

RADIANS_PER_DEGREE

public static final double RADIANS_PER_DEGREE
Pi divided by 180 degrees.

See Also:
Constant Field Values

X_AXIS

public static final Vec3d X_AXIS
Vector representing an x-axis.


Y_AXIS

public static final Vec3d Y_AXIS
Vector representing an y-axis.


Z_AXIS

public static final Vec3d Z_AXIS
Vector representing an z-axis.

Constructor Detail

Rotation

public Rotation(Mediator mediator,
                FpsLabel fpsLabel)
Constructs a Renderer.

Parameters:
mediator - the Mediator that holds the currently selected model.
fpsLabel - the FpsLabel object for writing fps on canvas.
Method Detail

setCenter

public void setCenter(double x,
                      double y,
                      double z)
Sets the xyz-coordinates for the center of gravity of the current model.

Parameters:
x - the x-coordinate.
y - the y-coordinate.
z - the z-coordinate.

setImageOrientation

public void setImageOrientation(OrientationEnum orientation)
Resets the orientation of the image by resetting the angle of rotation about the x-axis and the angle of rotation about the y-axis.

Setting the orientation to ORIGINAL is the same as setting it to FRONT, except that ORIGINAL will also reset the scale of the image. This class does not have access to the camera, so if the camera orientation needs to be reset, it should be reset before calling this method.

Parameters:
orientation - the desired view of the structure (original, front, back, left, right, top, bottom).

rotateScaleAndCenterModel

public void rotateScaleAndCenterModel(GL gl)
This helper method for display() rotates, scales, and centers the model.

The ModelView matrix should be made active with a call to glMatrixMode() before this method is called.

Parameters:
gl - the current GL object.

rotateAboutXY

public void rotateAboutXY(double deltaX,
                          double deltaY)
Rotates the model about the x-axis and y-axis.

Parameters:
deltaX - the change in angle of rotation about the x-axis.
deltaY - the change in angle of rotation about the y-axis.

rotateAboutZ

public void rotateAboutZ(double deltaZ)
Rotates the model about the z-axis.

Parameters:
deltaZ - the change in angle of rotation about the z-axis.

startAnimation

public void startAnimation(double xAxisSpeed,
                           double yAxisSpeed,
                           GLCanvas canvas)
Uses an Animator object to rotate the protein image about its x-axis and/or y-axis.

Parameters:
xAxisSpeed - the x-axis speed in degrees per second.
yAxisSpeed - the y-axis speed in degrees per second.
canvas - the GLCanvas to create an Animator for.

stopAnimation

public void stopAnimation()
Stops the rotation animation that is started with startAnimation().


calculateTimeAndRotation

public void calculateTimeAndRotation()
Calculates an x-axis and y-axis rotation based on the current system time and the previous time this method was called. This method should only be called after checking that the rotation animation flag, m_animate, is true.

x-axis angle = x-axis angle + (frame time * x-axis speed)
y-axis angle = y-axis angle + (frame time * y-axis speed)

where frame time is in seconds and speed is in degrees per second.


loadFpsFontFile

public void loadFpsFontFile(GL gl)
                     throws glFont2.FontReaderException
Tells the FpsLabel object to read in the font file that it needs for displaying a frames per second label on the canvas. If the font file cannot be loaded, the FpsLabel attribute will be set to null.

Parameters:
gl - the current GL object.
Throws:
glFont2.FontReaderException

writeFps

public void writeFps(GL gl,
                     GLAutoDrawable canvas)
Updates the frames per second display on the canvas.

Parameters:
gl - the current GL object.
canvas - the canvas to draw on.

getScale

public double getScale()
Returns the scale factor for the image.

Returns:
The scale factor as a double.

setScale

public void setScale(double scale)
Sets the scale factor for the image.

Parameters:
scale - the scale factor as a double.


Copyright © 2007-2008