JMV 0.80 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 mixed drawing representations
 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 LICORICE
          Enumeration indicating Cartoon drawing representation
static int LINES
          Enumeration indicating Lines drawing representation
static int LOWER
          Enumeration indicating lower light
 javax.media.j3d.DirectionalLight lowerLight
          DirectionalLight for lower light
 javax.media.j3d.BranchGroup m_bgCalculating
           
 javax.media.j3d.BranchGroup m_bgLoading
           
 util.SoftHashMap m_map
          SoftHashMap for storing BranchGroups
 java.lang.String m_strFilename
          filename of the current molecule
static int MIX
          Enumeration indicating Licorice drawing representation
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 VRML
          Enumeration indicating a VRML scene
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 changeColorsInBranchGroup(javax.media.j3d.BranchGroup bg, Molecule molec, int rep, int newScheme)
          Changes the color for a BranchGroup containing a molecule (or part of a 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
 IndexedBranchGroup 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
 IndexedBranchGroup drawBondAtom(Molecule molec, int colorScheme, float scale, int index)
          Draws an atom in Bond representation
 javax.media.j3d.BranchGroup drawBonds(Molecule molecule, int colorScheme)
          Draws line representation
 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.Shape3D drawLineAtoms(Molecule molecule, PubSynchBean.DrawAtoms da)
          Draws some atoms of a molecule in Lines 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.TransformGroup drawOneSphere(Molecule molecule, int colorScheme, float scale, int index)
          Draws one atom as a sphere for a given molecule
 javax.media.j3d.TransformGroup drawOneSphere(Molecule molecule, int colorScheme, float scale, int index, boolean radScale)
          Draws one atom as a sphere for a given molecule
 IndexedBranchGroup drawSpheres(Molecule molecule, int colorScheme, float scale)
          Draws atoms as spheres for a given molecule
 IndexedBranchGroup drawSpheres(Molecule molecule, int colorScheme, float scale, boolean radScale)
          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
 float[] getColorArray(Molecule molec, int scheme, java.util.Vector v)
          Creates the array of colors for a LineArray
 void init(java.awt.Panel p)
          Initializes the scene and add it to the panel for display
 void loadVRMLFile(java.lang.String file)
           
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)
          Redraws molecule.
 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

See Also:
Constant Field Values

STEREO_ON

public static final int STEREO_ON
Enumeration indicating Stereo mode on

See Also:
Constant Field Values

LINES

public static final int LINES
Enumeration indicating Lines drawing representation

See Also:
Constant Field Values

VDW

public static final int VDW
Enumeration indicating VDW drawing representation

See Also:
Constant Field Values

BONDS

public static final int BONDS
Enumeration indicating Bonds drawing representation

See Also:
Constant Field Values

CPK

public static final int CPK
Enumeration indicating CPK drawing representation

See Also:
Constant Field Values

TRACE

public static final int TRACE
Enumeration indicating Trace drawing representation

See Also:
Constant Field Values

TUBE

public static final int TUBE
Enumeration indicating Tube drawing representation

See Also:
Constant Field Values

LICORICE

public static final int LICORICE
Enumeration indicating Cartoon drawing representation

See Also:
Constant Field Values

CARTOON

public static final int CARTOON
Enumeration indicating mixed drawing representations

See Also:
Constant Field Values

MIX

public static final int MIX
Enumeration indicating Licorice drawing representation

See Also:
Constant Field Values

VRML

public static final int VRML
Enumeration indicating a VRML scene

See Also:
Constant Field Values

NAME

public static final int NAME
Enumeration indicating coloring by atom name

See Also:
Constant Field Values

INDEX

public static final int INDEX
Enumeration indicating coloring by atom index

See Also:
Constant Field Values

RESNAME

public static final int RESNAME
Enumeration indicating coloring by atom residue

See Also:
Constant Field Values

CHAIN

public static final int CHAIN
Enumeration indicating coloring by atom chain

See Also:
Constant Field Values

SEGNAME

public static final int SEGNAME
Enumeration indicating coloring by atom segment

See Also:
Constant Field Values

STRUCTURE

public static final int STRUCTURE
Enumeration indicating coloring by structure

See Also:
Constant Field Values

FRONT

public static final int FRONT
Enumeration indicating front light

See Also:
Constant Field Values

BACK

public static final int BACK
Enumeration indicating back light

See Also:
Constant Field Values

UPPER

public static final int UPPER
Enumeration indicating upper light

See Also:
Constant Field Values

LOWER

public static final int LOWER
Enumeration indicating lower light

See Also:
Constant Field Values

RGB

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

See Also:
Constant Field Values

BGR

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

See Also:
Constant Field Values

RWB

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

See Also:
Constant Field Values

BWR

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

See Also:
Constant Field Values

BW

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

See Also:
Constant Field Values

WB

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

See Also:
Constant Field Values

m_strFilename

public java.lang.String m_strFilename
filename of the current molecule


m_map

public util.SoftHashMap m_map
SoftHashMap for storing BranchGroups


m_bgLoading

public javax.media.j3d.BranchGroup m_bgLoading

m_bgCalculating

public javax.media.j3d.BranchGroup m_bgCalculating
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

drawLineAtoms

public javax.media.j3d.Shape3D drawLineAtoms(Molecule molecule,
                                             PubSynchBean.DrawAtoms da)
Draws some atoms of a molecule in Lines representation

Parameters:
molecule - the molecule to draw
da - the DrawAtoms containing the color scheme and Vector of which atoms to draw
Returns:
a Shape3D containing the atoms listed in 'da' drawn in Lines representation
See Also:
PubSynchBean.DrawAtoms

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)
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)

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)
v - Vector of PubSynchBean.DrawAtoms's. Only used if rep==MIX. (otherwise null)

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

changeColorsInBranchGroup

public void changeColorsInBranchGroup(javax.media.j3d.BranchGroup bg,
                                      Molecule molec,
                                      int rep,
                                      int newScheme)
Changes the color for a BranchGroup containing a molecule (or part of a molecule)

Parameters:
bg - the BranchGroup to change the color of
molec - the molecule to be colored
rep - the current representation of the molecule
newScheme - the new color scheme to use in coloring the molecule

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,
                             java.util.Vector v)
Creates the array of colors for a LineArray

Parameters:
molec - the Molecule to get the colors for
scheme - the color scheme to get colors for
v - Vector of Integers of which atoms to get colors for
Returns:
a float array of rgb colors to color the LineArray

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 IndexedBranchGroup 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 IndexedBranchGroup 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

drawSpheres

public IndexedBranchGroup drawSpheres(Molecule molecule,
                                      int colorScheme,
                                      float scale,
                                      boolean radScale)
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
radScale - true if scale based on the atom type, false if not
Returns:
a BranchGroup containing all the translated Spheres representing the atoms of this molecule

drawOneSphere

public javax.media.j3d.TransformGroup drawOneSphere(Molecule molecule,
                                                    int colorScheme,
                                                    float scale,
                                                    int index)
Draws one atom as a sphere for a given molecule

Parameters:
molecule - the Molecule the atom is in
colorScheme - the color scheme used to color the sphere
scale - the factor to scale the sphere. The original sizes are determined by atom name
index - the atom index of the atom to draw
Returns:
a BranchGroup containing a translated Sphere representing an atom of this molecule

drawOneSphere

public javax.media.j3d.TransformGroup drawOneSphere(Molecule molecule,
                                                    int colorScheme,
                                                    float scale,
                                                    int index,
                                                    boolean radScale)
Draws one atom as a sphere for a given molecule

Parameters:
molecule - the Molecule the atom is in
colorScheme - the color scheme used to color the sphere
scale - the factor to scale the sphere. The original sizes are determined by atom name
index - the atom index of the atom to draw
radScale - true if you scale based on the atom type, false if not
Returns:
a BranchGroup containing a translated Sphere representing an atom 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 IndexedBranchGroup drawBondAtom(Molecule molec,
                                       int colorScheme,
                                       float scale,
                                       int index)
Draws an atom in Bond representation

Parameters:
molec - the molecule the atom is in
colorScheme - the color scheme to use
scale - the scale of the cylinder radius
index - the atom index of the atom to draw
Returns:
an IndexedBranchGroup containing the atom in Bond representation

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)

Returns:
a BranchGroup displaying a message screen

loadVRMLFile

public void loadVRMLFile(java.lang.String file)

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