Class JMView

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended byjava.applet.Applet
                  extended byjavax.swing.JApplet
                      extended byJMView
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.lang.Runnable, java.io.Serializable

public class JMView
extends javax.swing.JApplet
implements java.lang.Runnable

Swing version of the MarvinView Applet.

Since:
2.0
Version:
3.3, 12/23/2003
Author:
Peter Csizmadia
See Also:
ViewPanel, Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JApplet
javax.swing.JApplet.AccessibleJApplet
 
Nested classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Nested classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
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
JMView()
           
 
Method Summary
 void animate(java.lang.String arg)
          Starts or stops animation.
 void destroy()
          Dispose all the frames.
 java.lang.String getAppletInfo()
          Returns a string containing the version and the author.
 int getAtomCount(int i)
          Get number of atoms in the specified molecule cell.
 double getBestTabScale()
          Gets the smallest best scale value in the molecule table.
 double getBestTabScale(int i)
          Gets the best scale value for a molecule cell.
 boolean getC(int i)
          Gets the state of a checkbox.
 int getCellCount()
          Gets the number of cells in the table.
 java.lang.String getL(int i)
          Gets a label.
 java.lang.String getM(int n, java.lang.String fmt)
          Gets the nth molecule in a text format.
 int getSelectedIndex()
          Gets the index of the molecule that is selected by the user.
 java.lang.String getT(int i)
          Gets the value of a text field.
 double getTabScale(int i)
          Gets the magnification for a molecule cell.
 void init()
          Initializes the applet.
 boolean isAtomSetVisible(int id)
          Is the specified atom set visible?
 boolean isSelected(int i, int atom)
          Is the specified atom selected?
 boolean isSetVisible(int id)
          Deprecated. as of Marvin 3.3, replaced by isAtomSetVisible
 void run()
          Runs the thread that handles JavaScript calls.
 boolean selectAllAtoms(int i, boolean v)
          Select or unselect all atoms in the specified molecule.
 boolean selectAtom(int i, int atom, boolean v)
          Select or unselect an atom in the specified molecule.
 void setActionB(int i, java.lang.String s)
          Sets the action string (URL or JavaScript expression) of a button.
 void setActionC(int i, boolean c, java.lang.String s)
          Sets one of the two action strings (JavaScript expressions) of a checkbox.
 void setAtomSetColor(int i, int rgb)
          Sets the color of an atom set.
 boolean setAtomSetSeq(int i, int atom, int id)
          Sets the set sequence number of the atom.
 void setAtomSetVisible(int id, boolean v)
          Set the visibility of the specified atom set.
 void setBondSetColor(int i, int rgb)
          Sets the color of a bond set.
 boolean setBondSetSeq(int i, int j1, int j2, int id)
          Sets the set sequence number of a bond.
 boolean setBondSetSeqAll(int i, int id)
          Sets the set sequence number for each bond.
 void setC(int i, boolean s)
          Sets the state of a checkbox.
 void setL(int i, java.lang.String s)
          Sets a label.
 void setM(int n, java.lang.String s)
          Starts loading a molecule into the nth cell.
 void setM(int n, java.lang.String s, java.lang.String opts)
          Starts loading a molecule into the nth cell.
 void setSelectedIndex(int i)
          Selects a molecule.
 void setSetColor(int i, int rgb)
          Deprecated. as of Marvin 3.3, replaced by setAtomSetColor
 boolean setSetSeq(int i, int atom, int id)
          Deprecated. as of Marvin 3.3, replaced by setAtomSetSeq
 void setSetVisible(int id, boolean v)
          Deprecated. as of Marvin 3.3, replaced by setAtomSetVisible
 void setT(int i, java.lang.String s)
          Gets the value of a text field.
 void start()
          Starts the applet.
 void stop()
          Stops the applet.
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.applet.Applet
getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, 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, getBackground, 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, 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, isOpaque, 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, setName, 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
 

Constructor Detail

JMView

public JMView()
Method Detail

init

public void init()
Initializes the applet.


start

public void start()
Starts the applet.


run

public void run()
Runs the thread that handles JavaScript calls.

Specified by:
run in interface java.lang.Runnable

stop

public void stop()
Stops the applet.


destroy

public void destroy()
Dispose all the frames.


getAppletInfo

public java.lang.String getAppletInfo()
Returns a string containing the version and the author.

Returns:
the information

animate

public void animate(java.lang.String arg)
Starts or stops animation. Animation can be an XYZ movie for multframe XYZ files, or simple 3D rotation in other cases. The argument of this method is in the same format as the "animate" applet parameter. Use "all" to start, "off" to stop animating all molecules. To animate only some of the molecules in in a table, use a comma separated list of indices (0...n-1). To stop animating them, use a comma separated list of negative integers (minus cell index minus one = -1...-n). Examples:
 MView.animate("all"); // starts animating all molecules
 MView.animate("off"); // stops animating all molecules
 MView.animate("3");        // starts animation in cell 3
 MView.animate("0,1,2");    // starts animation in cells 0, 1 and 2
 MView.animate("-1,-2,-3"); // stops animation in cells 0, 1 and 2
 

Parameters:
arg - "off", "all" or a comma separated list of integers
Since:
3.0, 12/26/2002

getM

public java.lang.String getM(int n,
                             java.lang.String fmt)
Gets the nth molecule in a text format. For a simple viewer with only one molecule, n must be zero. Nonzero n should only be used if the viewer is a molecule table. The format descriptor string can also contain export options. Format and options are separated by a colon, multiple options can be separated by commas. See the text formats and their options on the File Formats in Marvin page. Examples:
 s1 = mview.getM(0, "mol");
 s2 = mview.getM(0, "smiles:a-H"); // aromatize and remove Hydrogens
 

Parameters:
n - molecule cell number
fmt - the format descriptor string
Returns:
string containing the molecule in a molecule file format

setM

public void setM(int n,
                 java.lang.String s)
Starts loading a molecule into the nth cell.

Parameters:
n - molecule cell number (0 for simple viewer)
s - molecule file contents, URL, or (Unix) filename

setM

public void setM(int n,
                 java.lang.String s,
                 java.lang.String opts)
Starts loading a molecule into the nth cell. The file format and/or import options can be specified if the second argument is in one of the following forms: "options", "format:", or "format:options".

Parameters:
n - molecule cell number (0 for simple viewer)
s - molecule file contents, URL, or (Unix) filename
opts - options or null
Since:
3.3

getL

public java.lang.String getL(int i)
Gets a label.

Parameters:
i - the label index
Returns:
the label

setL

public void setL(int i,
                 java.lang.String s)
Sets a label.

Parameters:
i - the label index
s - the label

getC

public boolean getC(int i)
Gets the state of a checkbox.

Parameters:
i - the checkbox index
Returns:
true if checked, false if unchecked

setC

public void setC(int i,
                 boolean s)
Sets the state of a checkbox.

Parameters:
i - the checkbox index
s - true to check, false to uncheck

setActionB

public void setActionB(int i,
                       java.lang.String s)
Sets the action string (URL or JavaScript expression) of a button.

Parameters:
i - the button number
s - action string

setActionC

public void setActionC(int i,
                       boolean c,
                       java.lang.String s)
Sets one of the two action strings (JavaScript expressions) of a checkbox.

Parameters:
i - the button number
c - checked (true) or unchecked (false) state
s - action string

getT

public java.lang.String getT(int i)
Gets the value of a text field.

Parameters:
i - the text field index
Returns:
the text

setT

public void setT(int i,
                 java.lang.String s)
Gets the value of a text field.

Parameters:
i - the text field index
s - the text

getCellCount

public int getCellCount()
Gets the number of cells in the table.

Returns:
the number of cells, or 1 if the viewer is not a table
Since:
2.1.1

getSelectedIndex

public int getSelectedIndex()
Gets the index of the molecule that is selected by the user.

Returns:
the cell index or -1 if no molecule is selected
Since:
2.1

setSelectedIndex

public void setSelectedIndex(int i)
Selects a molecule.

Parameters:
i - the cell index or -1 to unselect
Since:
2.2

getAtomCount

public int getAtomCount(int i)
Get number of atoms in the specified molecule cell.

Parameters:
i - molecule cell index
Returns:
the number of atoms, or 0 if there is no such cell
Since:
2.6

selectAllAtoms

public boolean selectAllAtoms(int i,
                              boolean v)
Select or unselect all atoms in the specified molecule.

Parameters:
i - molecule cell index
v - select (true) or unselect (false)
Returns:
true if the operation was succesful, false if there is no such molecule
Since:
2.6

selectAtom

public boolean selectAtom(int i,
                          int atom,
                          boolean v)
Select or unselect an atom in the specified molecule.

Parameters:
i - molecule cell index
atom - atom index
v - select (true) or unselect (false)
Returns:
true if the operation was succesful, false if there is no such molecule or atom
Since:
2.6

isSelected

public boolean isSelected(int i,
                          int atom)
Is the specified atom selected?

Parameters:
i - molecule cell index
atom - atom index
Returns:
true if selected, false if not
Since:
2.6

isAtomSetVisible

public boolean isAtomSetVisible(int id)
Is the specified atom set visible?

Parameters:
id - atom set identifier (0, ..., 63)
Returns:
true if the set is visible, false if not
Since:
3.3

setAtomSetVisible

public void setAtomSetVisible(int id,
                              boolean v)
Set the visibility of the specified atom set.

Parameters:
id - atom set identifier (0, ..., 63)
v - visibility
Since:
3.3

setAtomSetColor

public void setAtomSetColor(int i,
                            int rgb)
Sets the color of an atom set.

Parameters:
i - atom set identifier (0, ..., 63)
rgb - 24-bit RGB color value
Since:
3.3

setAtomSetSeq

public boolean setAtomSetSeq(int i,
                             int atom,
                             int id)
Sets the set sequence number of the atom.

Parameters:
i - molecule cell index
atom - atom index
id - a number between 0 and 63. 0 is the default set. It contains all atoms that are not in another set.
Returns:
true if the operation was succesful, false if there is no such molecule or atom
Since:
3.3

setBondSetColor

public void setBondSetColor(int i,
                            int rgb)
Sets the color of a bond set.

Parameters:
i - bond set identifier (1, ..., 31)
rgb - 24-bit RGB color value
Since:
3.3

setBondSetSeq

public boolean setBondSetSeq(int i,
                             int j1,
                             int j2,
                             int id)
Sets the set sequence number of a bond.

Parameters:
i - molecule cell index
j1 - first atom index
j2 - second atom index
id - a number between 0 and 31
Returns:
true if the operation was succesful, false if there is no such molecule or bond
Since:
3.3

setBondSetSeqAll

public boolean setBondSetSeqAll(int i,
                                int id)
Sets the set sequence number for each bond.

Parameters:
i - molecule cell index
id - a number between 0 and 31
Returns:
true if the operation was succesful, false if there is no such molecule or bond
Since:
3.3

isSetVisible

public boolean isSetVisible(int id)
Deprecated. as of Marvin 3.3, replaced by isAtomSetVisible

Parameters:
id - atom set identifier (0, ..., 63)
Returns:
true if the set is visible, false if not

setSetVisible

public void setSetVisible(int id,
                          boolean v)
Deprecated. as of Marvin 3.3, replaced by setAtomSetVisible

Parameters:
id - atom set identifier (0, ..., 63)
v - visibility

setSetColor

public void setSetColor(int i,
                        int rgb)
Deprecated. as of Marvin 3.3, replaced by setAtomSetColor

Parameters:
i - atom set identifier (0, ..., 63)
rgb - 24-bit RGB color value

setSetSeq

public boolean setSetSeq(int i,
                         int atom,
                         int id)
Deprecated. as of Marvin 3.3, replaced by setAtomSetSeq

Parameters:
i - molecule cell index
atom - atom index
id - a number between 0 and 63
Returns:
true if the operation was succesful, false if there is no such molecule or atom
Since:
2.9.3

getTabScale

public double getTabScale(int i)
Gets the magnification for a molecule cell. The scale that would be used in non-window mode is returned even if the cell is its window.

Parameters:
i - molecule cell index
Returns:
the magnification, or -1 if it still cannot be determined
Since:
2.9.2

getBestTabScale

public double getBestTabScale(int i)
Gets the best scale value for a molecule cell.

Parameters:
i - the cell index
Returns:
the best scaling factor
Since:
2.9.2

getBestTabScale

public double getBestTabScale()
Gets the smallest best scale value in the molecule table.

Returns:
the best scaling factor
Since:
2.9.2