showMol
Class ShowMol

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by showMol.ShowMol
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class ShowMol
extends java.applet.Applet

ShowMol is a molecular viewer for the following file types:

Applet Parameters

NAME Variable Type Default Description
BackgroundColor String 000000 Sets the background color for the display. By default the background is black. Color is specified by six digit hexadecimal RGB value.
Center Boolean true If true, the molecule is positioned at the center of the display. Applies only to the file specified by the File parameter.
Display Integer 1 Display format. See documentation for codes.
File String   Name of file to be loaded.
Format String PDB Format of the molecular structure file.
    PDB Brookhave Protein Database (recognizes only ATOM, HETATM, and CONECT keywords)
    XYZ List of atoms with x,y,z positions
    COM Gaussian job file
    CUBE Gaussian cube file <\UL>
IsReady String   JavaScript variable that will be set to true when applet has initialized. Must use MAYSCRIPT in APPLET tag to use this feature.
Path String   Path from the current directory to the orbital VRML files
ViewDistance float 20.0 Distance of view from origin. Set to keep entire molecule in view.

Version:
1.1
Author:
David N. Blauch
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int BALL
           
static int BALLANDSTICK
           
static int CENTERED
           
static int COM
           
static int CREATEBONDS
           
static int CUBE
           
static int PDB
           
static int SPACEFILLING
           
static int WIREFRAME
           
static int XYZ
           
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ShowMol()
           
 
Method Summary
 void addLine(double x1, double y1, double z1, double x2, double y2, double z2)
          Creates a line between two points with the pre-defined emissive color.
 void addMolecule(java.lang.String filename)
          Adds a molecule to the display.
 void addMolecule(java.lang.String filename, int dFormat)
          Adds a molecule to the display.
 void addMolecule(java.lang.String filename, int dFormat, int fFormat)
          Adds a molecule to the display.
 void addMoleculeRotation(int n, double x, double y, double z, double a)
          Rotates the selected molecule.
 void addSpecial(int s)
          Adds a Molecule based upon one of the special, pre-defined settings.
 void addSphere(float r, float x, float y, float z)
          Adds a sphere to the display.
 void centerMolecule(int idx)
          Centers the specified molecule.
 void centerMoleculeOnAtom(int idx, int a)
          Translates the indicated molecule so that the specified atom is at the origin.
 void centerSpheres()
          Translates all spheres so that the center of the set lies at the origin.
 void clearMouse()
          Clears the mouse transformations.
 void clearRotation(int idx)
          Clears the rotation component of the transform for this specified molecule.
 void destroy()
           
 java.lang.String getAppletInfo()
           
 java.lang.String getParameter(java.lang.String key, java.lang.String def)
           
 java.lang.String[][] getParameterInfo()
           
 void init()
           
 void setDiffuseColor(float r, float g, float b)
          Sets the diffuse color for new spheres and lines.
 void setDisplayFormat(int d)
          Sets the display format for molecules that will be loaded.
 void setDisplayFormat(int n, int d)
          Sets the display format for the indicated molecule, which must have previously been loaded.
 void setDisplayFormats(int d)
          Sets the display format for all molecules currently loaded.
 void setEmissiveColor(float r, float g, float b)
          Sets the emissive color for new spheres and lines.
 void setFileFormat(int format)
          Sets the default format for molecular structure files.
 void setMoleculeRotation(int n, double x, double y, double z, double a)
          Rotates the selected molecule.
 void setMoleculeRotationOnAtom(int n, int idx, double x, double y, double z, double a)
          Rotates the selected molecule.
 void setMoleculesVisible(boolean s)
          Sets all or none of the molecules to be visible
 void setMoleculeTranslation(int n, double x, double y, double z)
          Sets the location of the selected molecule.
 void setMoleculeVisible(int n, boolean s)
          Determines whether the specified molecule is displayed.
 void setPath(java.lang.String filePath)
          Sets the default path for files.
 void setRotation(double x, double y, double z, double a)
          Rotates the scene.
 void setTranslation(double x, double y, double z)
          Shifts the position of the scene.
 void setViewDistance(float r)
          Sets the viewing distance.
 void start()
           
 void stop()
           
 
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PDB

public static int PDB

XYZ

public static int XYZ

COM

public static int COM

CUBE

public static int CUBE

BALLANDSTICK

public static int BALLANDSTICK

BALL

public static int BALL

SPACEFILLING

public static int SPACEFILLING

WIREFRAME

public static int WIREFRAME

CENTERED

public static int CENTERED

CREATEBONDS

public static int CREATEBONDS
Constructor Detail

ShowMol

public ShowMol()
Method Detail

getAppletInfo

public java.lang.String getAppletInfo()
Overrides:
getAppletInfo in class java.applet.Applet

getParameterInfo

public java.lang.String[][] getParameterInfo()
Overrides:
getParameterInfo in class java.applet.Applet

getParameter

public java.lang.String getParameter(java.lang.String key,
                                     java.lang.String def)

init

public void init()
Overrides:
init in class java.applet.Applet

start

public void start()
Overrides:
start in class java.applet.Applet

stop

public void stop()
Overrides:
stop in class java.applet.Applet

destroy

public void destroy()
Overrides:
destroy in class java.applet.Applet

addMolecule

public void addMolecule(java.lang.String filename)
Adds a molecule to the display. The file must be of the default file format (PDB) or the format specified by the setFileFormat method. The default or user-defined display format is shown.

Parameters:
filename - name of file to be loaded

addMolecule

public void addMolecule(java.lang.String filename,
                        int dFormat)
Adds a molecule to the display. The file format must be the default (PDB) or user-specified (setFileFormat) format. The available display formats are The display format may be combined (via a logical OR) with the following options

Parameters:
filename - name of file to be loaded
dFormat - index for display format

addMolecule

public void addMolecule(java.lang.String filename,
                        int dFormat,
                        int fFormat)
Adds a molecule to the display. The file format is specified by The available display formats are The display format may be combined (via a logical OR) with the following options

Parameters:
filename - name of file to be loaded
dFormat - index for the display format
fFormat - index for file format

addSpecial

public void addSpecial(int s)
Adds a Molecule based upon one of the special, pre-defined settings. 1 graphite 2 cristobalite

Parameters:
s - index of special molecule

addMoleculeRotation

public void addMoleculeRotation(int n,
                                double x,
                                double y,
                                double z,
                                double a)
Rotates the selected molecule. Rotation is applied to existing transform.

Parameters:
n - index of molecule to be rotated
x - x component of axis of rotation
y - y component of axis of rotation
z - z component of axis of rotation
a - angle of rotation

addSphere

public void addSphere(float r,
                      float x,
                      float y,
                      float z)
Adds a sphere to the display. The diffuse and emissive colors must be previously defined.

Parameters:
r - radius of sphere
x - x coordinate for center of sphere
y - y coordinate for center of sphere
z - z coordinate for center of sphere

addLine

public void addLine(double x1,
                    double y1,
                    double z1,
                    double x2,
                    double y2,
                    double z2)
Creates a line between two points with the pre-defined emissive color.

Parameters:
x1 -
y1 -
z1 -
x2 -
y2 -
z2 -

centerMolecule

public void centerMolecule(int idx)
Centers the specified molecule.

Parameters:
idx - index of molecule to be centered

centerMoleculeOnAtom

public void centerMoleculeOnAtom(int idx,
                                 int a)
Translates the indicated molecule so that the specified atom is at the origin.

Parameters:
idx - index of molecule to be centered
a - index of atom to place at the origin

centerSpheres

public void centerSpheres()
Translates all spheres so that the center of the set lies at the origin.


clearMouse

public void clearMouse()
Clears the mouse transformations.


clearRotation

public void clearRotation(int idx)
Clears the rotation component of the transform for this specified molecule.

Parameters:
idx - index of molecule to be centered

setDiffuseColor

public void setDiffuseColor(float r,
                            float g,
                            float b)
Sets the diffuse color for new spheres and lines. Does not affect existing shapes.

Parameters:
r - red component
g - green component
b - blue component

setEmissiveColor

public void setEmissiveColor(float r,
                             float g,
                             float b)
Sets the emissive color for new spheres and lines. Does not affect existing shapes.

Parameters:
r - red component
g - green component
b - blue component

setDisplayFormat

public void setDisplayFormat(int d)
Sets the display format for molecules that will be loaded. The display index is specified with. The display format may be combined (via a logical OR) with the following options, which do not apply to molecules already loaded.

Parameters:
d - index for display

setDisplayFormat

public void setDisplayFormat(int n,
                             int d)
Sets the display format for the indicated molecule, which must have previously been loaded. The display index is specified with

setDisplayFormats

public void setDisplayFormats(int d)
Sets the display format for all molecules currently loaded. The display index is specified with

setFileFormat

public void setFileFormat(int format)
Sets the default format for molecular structure files.

Parameters:
format - format index

setMoleculeRotation

public void setMoleculeRotation(int n,
                                double x,
                                double y,
                                double z,
                                double a)
Rotates the selected molecule. Molecule is rotated about its center.

Parameters:
n - index of molecule to be rotated
x - x component of axis of rotation
y - y component of axis of rotation
z - z component of axis of rotation
a - angle of rotation

setMoleculeRotationOnAtom

public void setMoleculeRotationOnAtom(int n,
                                      int idx,
                                      double x,
                                      double y,
                                      double z,
                                      double a)
Rotates the selected molecule. Molecule is rotated about the indicated atom.

Parameters:
n - index of molecule to be rotated
idx - index of atom about which rotation occurs
x - x component of axis of rotation
y - y component of axis of rotation
z - z component of axis of rotation
a - angle of rotation

setMoleculeTranslation

public void setMoleculeTranslation(int n,
                                   double x,
                                   double y,
                                   double z)
Sets the location of the selected molecule. Overrides previous transformations.

Parameters:
n - index of molecule to be moved
x - x component of translation
y - y component of translation
z - z component of translation

setMoleculeVisible

public void setMoleculeVisible(int n,
                               boolean s)
Determines whether the specified molecule is displayed.

Parameters:
n - index of molecule
s - visibility state

setMoleculesVisible

public void setMoleculesVisible(boolean s)
Sets all or none of the molecules to be visible

Parameters:
s - visibility state

setPath

public void setPath(java.lang.String filePath)
Sets the default path for files.

Parameters:
filePath - path to files

setRotation

public void setRotation(double x,
                        double y,
                        double z,
                        double a)
Rotates the scene.

Parameters:
x - x component of axis of rotation
y - y component of axis of rotation
z - z component of axis of rotation
a - angle of rotation

setTranslation

public void setTranslation(double x,
                           double y,
                           double z)
Shifts the position of the scene.

Parameters:
x - x component of translation
y - y component of translation
z - z component of translation

setViewDistance

public void setViewDistance(float r)
Sets the viewing distance.

Parameters:
r - new viewing distance (along z axis)