chemaxon.marvin.space
Class MSpaceEasy

java.lang.Object
  extended by chemaxon.marvin.space.MSpaceEasy
All Implemented Interfaces:
chemaxon.marvin.util.CallbackIface

public class MSpaceEasy
extends java.lang.Object
implements chemaxon.marvin.util.CallbackIface

Easy-to-use functions of MarvinSpace, customizable gui for applets and applications. Reaching basic functions, loading molecules from files, setting the draw properties of MarvinSpace.

Since:
Marvin 4.0.2
Version:
Marvin 5.0.2
Author:
Judit Vasko-Szedlar

Field Summary
protected  javax.swing.JFrame containerFrame
           
protected  javax.swing.JSplitPane jSplitPane1
           
protected  chemaxon.marvin.space.gui.JMSpaceMenuBar menubar
           
protected  chemaxon.marvin.space.gui.JMSpaceOptionsDialog optionsDialog
           
protected  chemaxon.marvin.space.gui.JMSpacePopupMenu popup
           
protected  chemaxon.marvin.space.gui.JMSpaceProgressBar progressBar
           
protected  chemaxon.marvin.space.gui.JMSpaceTree selectionBar
           
protected  chemaxon.marvin.space.gui.JMSpaceToolBar toolbar
           
protected static boolean verbose
           
 
Constructor Summary
MSpaceEasy(boolean install)
          Creates the JPanel with the OpenGL2 canvas, but does not embed it in any swing container.
MSpaceEasy(boolean install, boolean verbose, java.net.URL codebase)
          Creates the JPanel with the OpenGL2 canvas, but does not embed it in any swing container.
MSpaceEasy(int rowCount, int columnCount, boolean install)
          Creates the JPanel with the OpenGL2 canvas, but does not embed it in any swing container.
MSpaceEasy(int rowCount, int columnCount, boolean install, boolean verboseMsg, java.net.URL codebase)
          Creates the JPanel with the OpenGL2 canvas, but does not embed it in any swing container.
 
Method Summary
 void addCanvas(java.awt.Container container)
          Adds the basic MarvinSpace viewer to the container.
 void addMenuBar(javax.swing.RootPaneContainer appletOrFrame)
          Adds the basic MarvinSpace menubar to the container.
 MoleculeComponent addMolecule(Molecule mol)
          Adds a Molecule object to the actual cell of the viewer.
 java.util.ArrayList<java.lang.Object> addMolecule(java.lang.String s)
          Reads the molecule file, and adds molecule component(s) to the actual cell of the viewer.
 MoleculeComponent addMoleculeTo(Molecule mol, int cellIndex)
          Makes the given cell to be the active cell, and adds the molecule to it.
 MoleculeComponent addMoleculeToEmptyCell(Molecule mol)
          Adds the molecule to the next empty cell, or creates a new empty cell if all existing cell contains at least 1 component.
 java.util.ArrayList addMoleculeToEmptyCell(java.lang.String s)
          Reads the molecule, and adds molecule(s) to the next empty cell of the viewer, creating new cell if necessary.
 MoleculeComponent addMoleculeWithoutChange(Molecule mol, boolean reset)
          Adds a Molecule object to the actual cell of the viewer and resets the view only if required.
 void addPDB(java.lang.String pdbId)
          Loads a pdb file from the RCSB Protein Data Bank (http://www.rcsb.org/)
 void addPopupMenu()
          Adds the basic MarvinSpace popup menu to the JPanel.
 void addSelectionPanel(javax.swing.RootPaneContainer appletOrFrame)
          Adds the basic MarvinSpace selection panel to the container.
 void addSelectionPanelAndProgressBar(javax.swing.RootPaneContainer appletOrFrame)
          Adds the basic MarvinSpace selection panel to the container.
 void addToolBar(javax.swing.RootPaneContainer appletOrFrame)
          Adds the basic MarvinSpace toolbar to the container.
 java.lang.Object callback(java.lang.String method, java.lang.Object arg)
          Callback function to make avoiding direct calls easier.
 MolecularSurfaceComponent computeSurface(MacroMoleculeComponent.MoleculeVisualizer mv)
          Activates the container cell of the MoleculeVisualizer, and computes its Connolly surface.
 MolecularSurfaceComponent computeSurface(java.lang.String type)
          Computes the given type of surface in the active cell of the viewer.
 javax.swing.JPanel createSelectionPanel(int maxSize)
          Adds the basic MarvinSpace selection panel to the container.
 javax.swing.JPanel createSelectionPanelAndProgressBar()
          Adds the basic MarvinSpace selection panel to the container.
 chemaxon.marvin.space.MSpaceEventHandler getEventHandler()
          Returns the actual event handler of MarvinSpace.
 GraphicScene getGraphicScene()
          Returns the GraphicScene of MarvinSpace to be able to explicitly set more advanced features.
static java.io.InputStream getInputStream(java.lang.String s)
          Creates an InputStream from the given String.
static MolInputStream getMolInputStream(java.lang.String s)
          Creates a MolInputStream from the given String to be able to manually add molecules to the event handler.
static java.lang.String getRCSBLink(java.lang.String pdbId)
          Returns the URL of the RCSB database
static java.lang.String getRCSBLink(java.lang.String pdbId, boolean compressed)
          Returns the URL of the RCSB database
static boolean isURL(java.lang.String path)
          Tells whether the given path is an URL (Uniform Resource Locator) or not.
 void mapPropertyFile(java.lang.String filename, float min, float max)
          Maps the given property file (Gaussian or Charmm) to a previously read or computed molecular surface and sets minimum and maximum values as visualization setting of the surface coloring.
 java.util.ArrayList<java.lang.Object> openMolecule(java.lang.String s)
          Closes all components from the viewer, and reads the molecule(s).
 void processArguments(int maxMolCount, java.util.ArrayList infileName, java.util.ArrayList molecules, boolean readStdIn, boolean multicell, boolean singleCell, java.util.Properties sceneProperties, java.lang.String displayQuality)
          Processes the command line arguments of MarvinSpace listed below.
 void readPDB(java.lang.String s)
          Reads a protein given as String.
 void readPropertyFile(java.lang.String filename)
           
 void refresh()
          Makes all unprocessed event to be processed and makes the graphic canvas redraw.
 void removeAllComponents()
          Removes all components from the scene.
 void removeComponent(GraphicComponent gc)
          Activates the container cell of the component, removes it from the scene, and also from the selection panel if that exists.
 void resetAll()
          Resets view settings of all cells including rotation, zoom and shifting.
 void setCellProperty(java.lang.String propertyName, java.lang.String propertyValue)
          Sets a draw property of MarvinSpace that will affect the active cell only.
 void setComponentProperty(java.lang.Object component, java.lang.String propertyName, java.lang.String propertyValue)
          Sets a draw property of MarvinSpace that will affect only the given component.
static void setIconImage(javax.swing.JFrame frame)
          Sets the MarvinSpace icon to the frame.
 void setLayout(int rowCount, int columnCount)
          Sets the number of rows and columns of cells the viewport is sepearted to.
 void setProperty(java.lang.String propertyName, java.lang.String propertyValue)
          Sets a draw property of MarvinSpace.
 void setSize(int w, int h)
          Sets the physical size of the graphic canvas.
 void setVerbose(boolean flag)
          Sets whether writing technical details to console is enabled or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

menubar

protected chemaxon.marvin.space.gui.JMSpaceMenuBar menubar

toolbar

protected chemaxon.marvin.space.gui.JMSpaceToolBar toolbar

popup

protected chemaxon.marvin.space.gui.JMSpacePopupMenu popup

selectionBar

protected chemaxon.marvin.space.gui.JMSpaceTree selectionBar

progressBar

protected chemaxon.marvin.space.gui.JMSpaceProgressBar progressBar

jSplitPane1

protected javax.swing.JSplitPane jSplitPane1

optionsDialog

protected chemaxon.marvin.space.gui.JMSpaceOptionsDialog optionsDialog

containerFrame

protected javax.swing.JFrame containerFrame

verbose

protected static boolean verbose
Constructor Detail

MSpaceEasy

public MSpaceEasy(boolean install)
           throws java.lang.Exception
Creates the JPanel with the OpenGL2 canvas, but does not embed it in any swing container. See addSelectionPanel(javax.swing.RootPaneContainer), addSelectionPanelAndProgressBar(javax.swing.RootPaneContainer), addCanvas(java.awt.Container).

Parameters:
install - should Jogl libraries be loaded or they are already loaded
Throws:
java.lang.Exception - on installation failure

MSpaceEasy

public MSpaceEasy(int rowCount,
                  int columnCount,
                  boolean install)
           throws java.lang.Exception
Creates the JPanel with the OpenGL2 canvas, but does not embed it in any swing container. See addSelectionPanel(javax.swing.RootPaneContainer), addSelectionPanelAndProgressBar(javax.swing.RootPaneContainer), addCanvas(java.awt.Container).

Parameters:
rowCount - number of cells of the viewer in vertical direction
columnCount - number of cells of the viewer in horizontal direction
install - should Jogl libraries be loaded or they are already loaded
Throws:
java.lang.Exception - on installation failure

MSpaceEasy

public MSpaceEasy(boolean install,
                  boolean verbose,
                  java.net.URL codebase)
           throws java.lang.Exception
Creates the JPanel with the OpenGL2 canvas, but does not embed it in any swing container. See addSelectionPanel(javax.swing.RootPaneContainer), addSelectionPanelAndProgressBar(javax.swing.RootPaneContainer), addCanvas(java.awt.Container).

Parameters:
install - should Jogl libraries be loaded or they are already loaded
verbose - should technical details be writed to the console or not
codebase - in case of applets codebase is required for installing
Throws:
java.lang.Exception - on installation failure

MSpaceEasy

public MSpaceEasy(int rowCount,
                  int columnCount,
                  boolean install,
                  boolean verboseMsg,
                  java.net.URL codebase)
           throws java.lang.Exception
Creates the JPanel with the OpenGL2 canvas, but does not embed it in any swing container. See addSelectionPanel(javax.swing.RootPaneContainer), addSelectionPanelAndProgressBar(javax.swing.RootPaneContainer), addCanvas(java.awt.Container).

Parameters:
rowCount - number of cells of the viewer in vertical direction
columnCount - number of cells of the viewer in horizontal direction
install - should Jogl libraries be loaded or they are already loaded
verboseMsg - should technical details be written to the console or not
codebase - in case of applets codebase is required for installing
Throws:
java.lang.Exception - on installation failure
Method Detail

isURL

public static boolean isURL(java.lang.String path)
Tells whether the given path is an URL (Uniform Resource Locator) or not.

Parameters:
path - String to be recognized as an URL expression
Returns:
true if the given string starts with a specific expression

setIconImage

public static void setIconImage(javax.swing.JFrame frame)
Sets the MarvinSpace icon to the frame.

Parameters:
frame - a JFrame to set mspace icon to

setLayout

public void setLayout(int rowCount,
                      int columnCount)
               throws java.lang.Exception
Sets the number of rows and columns of cells the viewport is sepearted to.

Parameters:
rowCount - number of cells of the viewer in vertical direction
columnCount - number of cells of the viewer in horizontal direction
Throws:
java.lang.Exception - if the graphic canvas couldn't be initialized

setVerbose

public void setVerbose(boolean flag)
Sets whether writing technical details to console is enabled or not.

Parameters:
flag - verbosing is enabled or not

setSize

public void setSize(int w,
                    int h)
Sets the physical size of the graphic canvas.

Parameters:
w - width of the panel in pixels
h - height of the panel in pixels

addMenuBar

public void addMenuBar(javax.swing.RootPaneContainer appletOrFrame)
Adds the basic MarvinSpace menubar to the container. Note that the menubar itself is not customizable yet.

Parameters:
appletOrFrame - the container swing component of the JPanel

addToolBar

public void addToolBar(javax.swing.RootPaneContainer appletOrFrame)
Adds the basic MarvinSpace toolbar to the container. Note that the toolbar itself is not customizable yet.

Parameters:
appletOrFrame - the container swing component of the JPanel

addPopupMenu

public void addPopupMenu()
Adds the basic MarvinSpace popup menu to the JPanel. Note that the popup menu itself is not customizable yet.


addSelectionPanel

public void addSelectionPanel(javax.swing.RootPaneContainer appletOrFrame)
Adds the basic MarvinSpace selection panel to the container. The viewer itself is a JPanel with the OpenGL2 canvas. The viewer and the selection panel will be embedded in a JSplitPane. // * Note that for technical reasons the selection panel is essential to add now.

Parameters:
appletOrFrame - the container swing component of the JPanel

addSelectionPanelAndProgressBar

public void addSelectionPanelAndProgressBar(javax.swing.RootPaneContainer appletOrFrame)
Adds the basic MarvinSpace selection panel to the container. The viewer itself is a JPanel with the OpenGL2 canvas. The viewer and the selection panel will be embedded in a JSplitPane. // * Note that for technical reasons the selection panel is essential to add now.

Parameters:
appletOrFrame - the container swing component of the JPanel

createSelectionPanel

public javax.swing.JPanel createSelectionPanel(int maxSize)
Adds the basic MarvinSpace selection panel to the container. The viewer itself is a JPanel with the OpenGL2 canvas. The viewer and the selection panel will be added directly on graphicScene.

Returns:
JPanel containing the canvas and the selection panel

createSelectionPanelAndProgressBar

public javax.swing.JPanel createSelectionPanelAndProgressBar()
Adds the basic MarvinSpace selection panel to the container. The viewer itself is a JPanel with the OpenGL2 canvas. The viewer and the selection panel will be embedded in a JSplitPane.

Returns:
JPanel containing the canvas and the selection panel in a JSplitPane

addCanvas

public void addCanvas(java.awt.Container container)
Adds the basic MarvinSpace viewer to the container. The viewer itself is a JPanel with the OpenGL2 canvas.

Parameters:
container - the container swing component of the JPanel

setProperty

public void setProperty(java.lang.String propertyName,
                        java.lang.String propertyValue)
Sets a draw property of MarvinSpace. To see available properties, value ranges and default values, please visit this page.

Parameters:
propertyName - identifier of a draw property
propertyValue - value of the property to be set given as a String

setCellProperty

public void setCellProperty(java.lang.String propertyName,
                            java.lang.String propertyValue)
Sets a draw property of MarvinSpace that will affect the active cell only. To see available properties, value ranges and default values, please visit this page.

Parameters:
propertyName - identifier of a draw property
propertyValue - value of the property to be set given as a String

setComponentProperty

public void setComponentProperty(java.lang.Object component,
                                 java.lang.String propertyName,
                                 java.lang.String propertyValue)
Sets a draw property of MarvinSpace that will affect only the given component. To see available properties, value ranges and default values, please visit this page.

Parameters:
component - this must be a UsableObject
propertyName - identifier of a draw property
propertyValue - value of the property to be set given as a String

addPDB

public void addPDB(java.lang.String pdbId)
            throws java.lang.Exception
Loads a pdb file from the RCSB Protein Data Bank (http://www.rcsb.org/)

Parameters:
pdbId - PDB ID used by the RSCB PDB
Throws:
java.io.IOException - if connecting RCSB fails
java.lang.Exception

readPDB

public void readPDB(java.lang.String s)
             throws java.lang.Exception
Reads a protein given as String.

Parameters:
s - String content of a PDB file
Throws:
java.lang.Exception - when reading or adding component fails

getRCSBLink

public static java.lang.String getRCSBLink(java.lang.String pdbId)
Returns the URL of the RCSB database

Parameters:
pdbId - the 4 letter id of a protein, e.g. 1AID
Returns:
the full URL to the required protein

getRCSBLink

public static java.lang.String getRCSBLink(java.lang.String pdbId,
                                           boolean compressed)
Returns the URL of the RCSB database

Parameters:
pdbId - the 4 letter id of a protein, e.g. 1AID
compressed - whether the protein is required in gzipped format
Returns:
the full URL to the required protein

addMolecule

public java.util.ArrayList<java.lang.Object> addMolecule(java.lang.String s)
                                                  throws java.lang.Exception
Reads the molecule file, and adds molecule component(s) to the actual cell of the viewer.

Parameters:
s - url or filename or molecule as String
Returns:
list of read molecules
Throws:
java.lang.Exception - when reading file or adding component fails

addMoleculeToEmptyCell

public java.util.ArrayList addMoleculeToEmptyCell(java.lang.String s)
                                           throws java.lang.Exception
Reads the molecule, and adds molecule(s) to the next empty cell of the viewer, creating new cell if necessary.

Parameters:
s - url or filename or molecule as String
Returns:
list of read molecules
Throws:
java.lang.Exception - when reading adding component fails

openMolecule

public java.util.ArrayList<java.lang.Object> openMolecule(java.lang.String s)
                                                   throws java.lang.Exception
Closes all components from the viewer, and reads the molecule(s).

Parameters:
s - url or filename or molecule as String
Returns:
list of read molecules
Throws:
java.lang.Exception - when reading or adding component fails

addMolecule

public MoleculeComponent addMolecule(Molecule mol)
                              throws java.lang.Exception
Adds a Molecule object to the actual cell of the viewer.

Parameters:
mol - Molecule object that will be cleaned and hydrogenized if necessary.
Returns:
MoleculeComponent that is the visualizer component of the molecule.
Throws:
java.lang.Exception - if adding component fails

addMoleculeWithoutChange

public MoleculeComponent addMoleculeWithoutChange(Molecule mol,
                                                  boolean reset)
                                           throws java.lang.Exception
Adds a Molecule object to the actual cell of the viewer and resets the view only if required.

Parameters:
mol - Molecule object that won't be cleaned, hydrogenized or aromatized.
reset - whether resetting the view is required, see resetAll().
Returns:
MoleculeComponent that is the visualizer component of the molecule
Throws:
java.lang.Exception - if adding component fails

addMoleculeToEmptyCell

public MoleculeComponent addMoleculeToEmptyCell(Molecule mol)
                                         throws java.lang.Exception
Adds the molecule to the next empty cell, or creates a new empty cell if all existing cell contains at least 1 component.

Parameters:
mol - Molecule object that will be cleaned and hydrogenized if it is necessary.
Returns:
MoleculeComponent that is the visualizer component of the molecule
Throws:
java.lang.Exception - if adding component fails

addMoleculeTo

public MoleculeComponent addMoleculeTo(Molecule mol,
                                       int cellIndex)
                                throws java.lang.Exception
Makes the given cell to be the active cell, and adds the molecule to it.

Parameters:
mol - Molecule object that will be cleaned and hydrogenized if it is necessary.
cellIndex - internal index of the cell
Returns:
MoleculeComponent that is the visualizer component of the molecule
Throws:
java.lang.Exception - if adding component fails

removeComponent

public void removeComponent(GraphicComponent gc)
Activates the container cell of the component, removes it from the scene, and also from the selection panel if that exists.

Parameters:
gc - component to remove

removeAllComponents

public void removeAllComponents()
Removes all components from the scene.


computeSurface

public MolecularSurfaceComponent computeSurface(MacroMoleculeComponent.MoleculeVisualizer mv)
Activates the container cell of the MoleculeVisualizer, and computes its Connolly surface.

Parameters:
mv - see MacroMoleculeComponent.MoleculeVisualizer
Returns:
MolecularSurfaceComponent that is the visualizer component of molecular surface.

computeSurface

public MolecularSurfaceComponent computeSurface(java.lang.String type)
Computes the given type of surface in the active cell of the viewer. Note that spaces and other delimiters are allowed in the parameter.

Parameters:
type - "van der Waals", "Solvent-accessible", "Connolly", "Blobby"
Returns:
the computed surface

readPropertyFile

public void readPropertyFile(java.lang.String filename)

mapPropertyFile

public void mapPropertyFile(java.lang.String filename,
                            float min,
                            float max)
Maps the given property file (Gaussian or Charmm) to a previously read or computed molecular surface and sets minimum and maximum values as visualization setting of the surface coloring. This function is equivalent of the following:
      eventHandler.readPropertyFile( filename );
      graphicScene.processEvent("Palette.Minimum", ""+min);
      graphicScene.processEvent("Palette.Maximum", ""+max);
      eventHandler.refresh();
 

Parameters:
filename - url of the property file to be mapped
min - values less than the minimum will be colored by the color of the minimum value
max - values greater than the maximum will be colored by the color of the maximum value

refresh

public void refresh()
Makes all unprocessed event to be processed and makes the graphic canvas redraw.

Since:
Marvin 4.1

resetAll

public void resetAll()
Resets view settings of all cells including rotation, zoom and shifting. Takes effect at the next redraw because of threading issues.

Since:
Marvin 4.1

processArguments

public void processArguments(int maxMolCount,
                             java.util.ArrayList infileName,
                             java.util.ArrayList molecules,
                             boolean readStdIn,
                             boolean multicell,
                             boolean singleCell,
                             java.util.Properties sceneProperties,
                             java.lang.String displayQuality)
                      throws java.lang.Exception
Processes the command line arguments of MarvinSpace listed below.

Parameters:
maxMolCount - maximum number of molecules that can be displayed at a time
infileName - list of molecule files that should be read
molecules - molecule objects to be read
readStdIn - if input molecules should be read from the standard input
multicell - whether the read molecules should be put in different cells or ask
singleCell - whether the read molecules should be put in one cells or ask
sceneProperties - a set of drawing properties
displayQuality - requires display quality, can be "High", "Medium" or "Low"
Throws:
java.lang.Exception - if processing an argument fails

getMolInputStream

public static MolInputStream getMolInputStream(java.lang.String s)
                                        throws java.io.IOException
Creates a MolInputStream from the given String to be able to manually add molecules to the event handler.

Parameters:
s - url or absolute filename or a molecule as String
Returns:
MolInputStream to read the molecules from
Throws:
java.io.IOException - if an I/O exception occurs
Since:
Marvin 4.0.3

getInputStream

public static java.io.InputStream getInputStream(java.lang.String s)
                                          throws java.io.IOException
Creates an InputStream from the given String. The InputStream is either a MonitorableInputStream or FileInputStream or ByteArrayInputStream.

Parameters:
s - url or absolute filename or String
Returns:
InputStream
Throws:
java.io.IOException - if an I/O exception occurs

getEventHandler

public chemaxon.marvin.space.MSpaceEventHandler getEventHandler()
Returns the actual event handler of MarvinSpace.

Returns:
handler of advanced events
Since:
Marvin 4.1

getGraphicScene

public GraphicScene getGraphicScene()
Returns the GraphicScene of MarvinSpace to be able to explicitly set more advanced features. It is necessary if features given by MSpaceEasy is not enough for the required action.

Returns:
the top level visualizer class
Since:
Marvin 4.1

callback

public java.lang.Object callback(java.lang.String method,
                                 java.lang.Object arg)
Callback function to make avoiding direct calls easier.

Specified by:
callback in interface chemaxon.marvin.util.CallbackIface
Parameters:
method - name of MSpaceEasy method
arg - Object[] or Object or null
Returns:
the return object of the function or the Exception if there is any