JMV 0.74 Programmer's Documentation

Class MolecGraphics

java.lang.Object
  |
  +--MolecGraphics

public class MolecGraphics
extends java.lang.Object

Responsible for drawing and updating the molecule graphics.


Field Summary
static int BACK
          Enumeration indicating back light
 javax.media.j3d.DirectionalLight backLight
          DirectionalLight for back light
static int BGR
          Enumeration for color gradient blue-green-red
static int BONDS
          Enumeration indicating Bonds drawing representation
static int BW
          Enumeration for color gradient black-white
static int BWR
          Enumeration for color gradient blue-white-red
static int CARTOON
          Enumeration indicating Cartoon drawing representation
 ColorCategory cc
          ColorCategory for determining and changing colors
static int CHAIN
          Enumeration indicating coloring by atom chain
static int CPK
          Enumeration indicating CPK drawing representation
 javax.media.j3d.ExponentialFog exponentialFog
          Fog for depth cueing
static int FRONT
          Enumeration indicating front light
 javax.media.j3d.DirectionalLight frontLight
          DirectionalLight for front light
static int INDEX
          Enumeration indicating coloring by atom index
static int LINES
          Enumeration indicating Lines drawing representation
static int LOWER
          Enumeration indicating lower light
 javax.media.j3d.DirectionalLight lowerLight
          DirectionalLight for lower light
static int MIX
          Enumeration indicating mixed drawing representations
static int NAME
          Enumeration indicating coloring by atom name
static int RESNAME
          Enumeration indicating coloring by atom residue
static int RGB
          Enumeration for color gradient red-green-blue
static int RWB
          Enumeration for color gradient red-white-blue
static int SEGNAME
          Enumeration indicating coloring by atom segment
static int STEREO_OFF
          Enumeration indicating Stereo mode off
static int STEREO_ON
          Enumeration indicating Stereo mode on
static int STRUCTURE
          Enumeration indicating coloring by structure
static int TRACE
          Enumeration indicating Trace drawing representation
static int TUBE
          Enumeration indicating Tube drawing representation
static int UPPER
          Enumeration indicating upper light
 javax.media.j3d.DirectionalLight upperLight
          DirectionalLight for upper light
static int VDW
          Enumeration indicating VDW drawing representation
static int WB
          Enumeration for color gradient white-black
 
Constructor Summary
MolecGraphics()
          Constructor
 
Method Summary
 void addUtilities(javax.media.j3d.BranchGroup objRoot)
          Adds lights, rotations to the main branch group
 void changeColors(Molecule molec, int rep, int newScheme)
          Changes the color of an already drawn molecule
 void changeDepth(int on)
          Toggles depth cueing
 void changeGradient(int grad)
          Sets gradient based on the selected option
 void changeLights(int light)
          Turns a light in the scene on or off
 void changeStereoMode(int mode)
          Sets the stereo mode
static javax.media.j3d.Appearance createAPR(float r, float g, float b)
          Creates an Appearance with the given color uses default shininess, etc
 javax.media.j3d.BranchGroup createSceneGraph(Molecule molecule, int rep, int colorScheme, java.util.Vector v)
          Creates the entire sceneGraph used when changing molecules
 javax.media.j3d.BranchGroup drawAllCylinders(Molecule molecule, int colorScheme, float scale)
          Draws the bonds of a molecule as cylinders
 javax.media.j3d.BranchGroup drawAtoms(Molecule molec, java.util.Vector v)
          Draws atoms on a per atom basis
 javax.media.j3d.BranchGroup drawBondAtom(Molecule molec, int colorScheme, float scale, int index)
           
 javax.media.j3d.BranchGroup drawBonds(Molecule molecule, int colorScheme)
          Draws line representation
 javax.media.j3d.BranchGroup drawCPKAtom(Molecule molec, int colorScheme, float sphereScale, float cylScale, int index)
           
 javax.media.j3d.TransformGroup drawCylinder(float[] coords, int startPt, int endPt, javax.media.j3d.Appearance currentAppearance, float scale, boolean full)
          Creates a single cylinder
 javax.media.j3d.BranchGroup drawLineAtom(Molecule molecule, int colorScheme, int index)
          Draws one atom in line representation
 javax.media.j3d.BranchGroup drawMolecule(Molecule molecule, int rep, int colorScheme)
          Returns a branchGroup from the given molecule, with the given representation used when changing the representation.
 javax.media.j3d.BranchGroup drawOneSphere(Molecule molecule, int colorScheme, float scale, int index)
          Draws one atom as a sphere for a given molecule
 javax.media.j3d.BranchGroup drawSpheres(Molecule molecule, int colorScheme, float scale)
          Draws atoms as spheres for a given molecule
 javax.media.j3d.BranchGroup drawTrace(Molecule molec, int colorScheme)
          Draws a molecule in Trace representation
 javax.media.j3d.BranchGroup drawTraceAtom(Molecule molec, int colorScheme, int index)
          Draws a specified atom in Trace representation
 javax.media.j3d.BranchGroup drawTube(Molecule molec, int colorScheme, float scale)
          Draws the molecule in Tube representation
 javax.media.j3d.BranchGroup drawTubeAtom(Molecule molec, int colorScheme, float scale, int index)
          Draw a single atom in Tube rep
 float[] getColorArray(Molecule molec, int scheme)
          Gets the array of colors for a LineArray
 void init(java.awt.Panel p)
          Initializes the scene and add it to the panel for display
static javax.media.j3d.BranchGroup messageScreen(java.lang.String strMessage)
          Creates a quick message screen to display (such as while a molecule is being loaded and created)
 int redraw(Molecule molec, int rep, int colorScheme, boolean redrawScene, java.util.Vector v)
          Redraws molecule.
static javax.media.j3d.BranchGroup titleScreen()
          Displays the JMV title screen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cc

public ColorCategory cc
ColorCategory for determining and changing colors

frontLight

public javax.media.j3d.DirectionalLight frontLight
DirectionalLight for front light

backLight

public javax.media.j3d.DirectionalLight backLight
DirectionalLight for back light

upperLight

public javax.media.j3d.DirectionalLight upperLight
DirectionalLight for upper light

lowerLight

public javax.media.j3d.DirectionalLight lowerLight
DirectionalLight for lower light

exponentialFog

public javax.media.j3d.ExponentialFog exponentialFog
Fog for depth cueing

STEREO_OFF

public static final int STEREO_OFF
Enumeration indicating Stereo mode off

STEREO_ON

public static final int STEREO_ON
Enumeration indicating Stereo mode on

LINES

public static final int LINES
Enumeration indicating Lines drawing representation

VDW

public static final int VDW
Enumeration indicating VDW drawing representation

BONDS

public static final int BONDS
Enumeration indicating Bonds drawing representation

CPK

public static final int CPK
Enumeration indicating CPK drawing representation

TRACE

public static final int TRACE
Enumeration indicating Trace drawing representation

TUBE

public static final int TUBE
Enumeration indicating Tube drawing representation

CARTOON

public static final int CARTOON
Enumeration indicating Cartoon drawing representation

MIX

public static final int MIX
Enumeration indicating mixed drawing representations

NAME

public static final int NAME
Enumeration indicating coloring by atom name

INDEX

public static final int INDEX
Enumeration indicating coloring by atom index

RESNAME

public static final int RESNAME
Enumeration indicating coloring by atom residue

CHAIN

public static final int CHAIN
Enumeration indicating coloring by atom chain

SEGNAME

public static final int SEGNAME
Enumeration indicating coloring by atom segment

STRUCTURE

public static final int STRUCTURE
Enumeration indicating coloring by structure

FRONT

public static final int FRONT
Enumeration indicating front light

BACK

public static final int BACK
Enumeration indicating back light

UPPER

public static final int UPPER
Enumeration indicating upper light

LOWER

public static final int LOWER
Enumeration indicating lower light

RGB

public static final int RGB
Enumeration for color gradient red-green-blue

BGR

public static final int BGR
Enumeration for color gradient blue-green-red

RWB

public static final int RWB
Enumeration for color gradient red-white-blue

BWR

public static final int BWR
Enumeration for color gradient blue-white-red

BW

public static final int BW
Enumeration for color gradient black-white

WB

public static final int WB
Enumeration for color gradient white-black
Constructor Detail

MolecGraphics

public MolecGraphics()
Constructor
Method Detail

createAPR

public static javax.media.j3d.Appearance createAPR(float r,
                                                   float g,
                                                   float b)
Creates an Appearance with the given color uses default shininess, etc
Parameters:
r - red component
g - green component
b - blue component
Returns:
an Appearance with the rgb color and default shininess

changeGradient

public void changeGradient(int grad)
Sets gradient based on the selected option
Parameters:
grad - the gradient enumeration to use

drawBonds

public javax.media.j3d.BranchGroup drawBonds(Molecule molecule,
                                             int colorScheme)
Draws line representation
Parameters:
molecule - the molecule to draw
colorScheme - the color scheme to use
Returns:
a BranchGroup that represents molecule drawn in line representation

drawLineAtom

public javax.media.j3d.BranchGroup drawLineAtom(Molecule molecule,
                                                int colorScheme,
                                                int index)
Draws one atom in line representation
Parameters:
molecule - the Molecule the atom is in
colorScheme - the color scheme in which to color the atom
index - the index of the atom to draw
Returns:
a BranchGroup containing the atom drawn in lines representation

drawMolecule

public javax.media.j3d.BranchGroup drawMolecule(Molecule molecule,
                                                int rep,
                                                int colorScheme)
Returns a branchGroup from the given molecule, with the given representation used when changing the representation.
Parameters:
molecule - the molecule to draw
rep - the representation (Lines, VDW, etc)
colorScheme - the color scheme to use
Returns:
a BranchGroup that contains the Java3D objects for displaying this molecule

createSceneGraph

public javax.media.j3d.BranchGroup createSceneGraph(Molecule molecule,
                                                    int rep,
                                                    int colorScheme,
                                                    java.util.Vector v)
Creates the entire sceneGraph used when changing molecules
Parameters:
molecule - the new Molecule object to draw
rep - the representation (lines, vdw, etc).
colorScheme - the colorization to use when coloring atoms
v - Vector of PubSynchBean.DrawAtoms's. Only used if rep == MIX.
Returns:
the BranchGroup for the new Molecule

addUtilities

public void addUtilities(javax.media.j3d.BranchGroup objRoot)
Adds lights, rotations to the main branch group
Parameters:
objRoot - the main branchGroup

init

public void init(java.awt.Panel p)
Initializes the scene and add it to the panel for display
Parameters:
p - Panel to add scene to

redraw

public int redraw(Molecule molec,
                  int rep,
                  int colorScheme,
                  boolean redrawScene,
                  java.util.Vector v)
Redraws molecule. Used when molecule changes.
Parameters:
molec - the new molecule to draw
rep - the representation
colorScheme - the color scheme to use
redrawScene - redraws the entire scene if true (entirely new molecule), else just redraws the molecule (new representation of already drawn molecule)

changeStereoMode

public void changeStereoMode(int mode)
Sets the stereo mode
Parameters:
mode - STEREO_ON to turn it on or STEREO_OFF to turn it off

changeColors

public void changeColors(Molecule molec,
                         int rep,
                         int newScheme)
Changes the color of an already drawn molecule
Parameters:
molec - the molecule to be colored
rep - the current representation of the molecule
newScheme - the new color scheme to use in coloring the molecule

getColorArray

public float[] getColorArray(Molecule molec,
                             int scheme)
Gets the array of colors for a LineArray
Parameters:
molec - the Molecule to get the colors for
scheme - the color scheme to get colors for
Returns:
a float array of rgb colors to color the LineArray

drawCylinder

public javax.media.j3d.TransformGroup drawCylinder(float[] coords,
                                                   int startPt,
                                                   int endPt,
                                                   javax.media.j3d.Appearance currentAppearance,
                                                   float scale,
                                                   boolean full)
Creates a single cylinder
Parameters:
coords - the coordinates for the molecule
startPt - the index of the first atom
endPt - the index of the second atom
currentAppearance - the Appearance used to color the cylinder
scale - factor to scale the cylinder radius. The original radius is determined in MolecGraphicsProperties.
full - if true, draws a full cylinder from startPt to endPt if false, draws a cylinder starting at startPt, and ending 1/2 way between startPt and endPt.
Returns:
a TransformGroup whose child is the Cylinder

drawAllCylinders

public javax.media.j3d.BranchGroup drawAllCylinders(Molecule molecule,
                                                    int colorScheme,
                                                    float scale)
Draws the bonds of a molecule as cylinders
Parameters:
molecule - the molecule to draw bonds for
colorScheme - the color scheme used to color the cylinders
scale - factor to scale the cylinder radius. The original radius is determined in MolecGraphicsProperties.
Returns:
a BranchGroup containing all the rotated Cylinders to that represent the bonds of the molecule

drawSpheres

public javax.media.j3d.BranchGroup drawSpheres(Molecule molecule,
                                               int colorScheme,
                                               float scale)
Draws atoms as spheres for a given molecule
Parameters:
molecule - the Molecule to draw
colorScheme - the color scheme used to color the spheres
scale - the factor to scale the spheres. The original sizes are determined by atom name
Returns:
a BranchGroup containing all the translated Spheres representing the atoms of this molecule

drawOneSphere

public javax.media.j3d.BranchGroup drawOneSphere(Molecule molecule,
                                                 int colorScheme,
                                                 float scale,
                                                 int index)
Draws one atom as a sphere for a given molecule
Parameters:
molecule - the Molecule to draw
colorScheme - the color scheme used to color the spheres
scale - the factor to scale the spheres. The original sizes are determined by atom name
index - the atom index of the atom to draw
Returns:
a BranchGroup containing all the translated Spheres representing the atoms of this molecule

drawTrace

public javax.media.j3d.BranchGroup drawTrace(Molecule molec,
                                             int colorScheme)
Draws a molecule in Trace representation
Parameters:
molec - the molecule to draw
colorScheme - the color scheme to use
Returns:
a BranchGroup containing the Molecule drawn in Trace representation

drawTraceAtom

public javax.media.j3d.BranchGroup drawTraceAtom(Molecule molec,
                                                 int colorScheme,
                                                 int index)
Draws a specified atom in Trace representation
Parameters:
molec - the molecule the atom is in
colorScheme - the color scheme used to color the atom
index - the atom index of the atom
Returns:
a BranchGroup containing the atom drawn in Trace representation

drawBondAtom

public javax.media.j3d.BranchGroup drawBondAtom(Molecule molec,
                                                int colorScheme,
                                                float scale,
                                                int index)

drawCPKAtom

public javax.media.j3d.BranchGroup drawCPKAtom(Molecule molec,
                                               int colorScheme,
                                               float sphereScale,
                                               float cylScale,
                                               int index)

drawTube

public javax.media.j3d.BranchGroup drawTube(Molecule molec,
                                            int colorScheme,
                                            float scale)
Draws the molecule in Tube representation
Parameters:
molec - the molecule to draw
colorScheme - the color scheme to use
scale - the scale for the cylinder radius
Returns:
a BranchGroup containing the molecule drawn in Tube representation

drawTubeAtom

public javax.media.j3d.BranchGroup drawTubeAtom(Molecule molec,
                                                int colorScheme,
                                                float scale,
                                                int index)
Draw a single atom in Tube rep
Parameters:
molec - the molecule
colorScheme - the color scheme used to color the atom
scale - the scale for cylinder radius
index - the index of the atom to draw
Returns:
a BranchGroup containing the atom drawn in Tube representation

drawAtoms

public javax.media.j3d.BranchGroup drawAtoms(Molecule molec,
                                             java.util.Vector v)
Draws atoms on a per atom basis
Parameters:
molec - the molecule to draw
v - the Vector of PubSynch.DrawAtoms's to draw
Returns:
a BranchGroup containing the Molecule drawn as the DrawAtoms's in Vector v specify.
See Also:
PubSynchBean.DrawAtoms

changeLights

public void changeLights(int light)
Turns a light in the scene on or off
Parameters:
light - the index of the light to toggle

changeDepth

public void changeDepth(int on)
Toggles depth cueing
Parameters:
on - 1 if it is to be turned on, else 0

titleScreen

public static javax.media.j3d.BranchGroup titleScreen()
Displays the JMV title screen
Returns:
a BranchGroup displaying the JMV title screen and credits

messageScreen

public static javax.media.j3d.BranchGroup messageScreen(java.lang.String strMessage)
Creates a quick message screen to display (such as while a molecule is being loaded and created)
Parameters:
message - the message to display
Returns:
a BranchGroup displaying a message screen

Copyright (C) 2000-2002 The Board of Trustees of the University of Illinois