Package chemaxon.marvin.space
Class MSpaceEasy
- java.lang.Object
-
- chemaxon.marvin.space.MSpaceEasy
-
- All Implemented Interfaces:
chemaxon.marvin.util.CallbackIface
@PublicAPI public class MSpaceEasy extends 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
-
-
Field Summary
Fields Modifier and Type Field Description protected JFrame
containerFrame
protected 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
Constructors Constructor Description MSpaceEasy(boolean install)
Creates the JPanel with the OpenGL2 canvas, but does not embed it in any swing container.MSpaceEasy(boolean install, boolean verbose, 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, URL codebase)
Creates the JPanel with the OpenGL2 canvas, but does not embed it in any swing container.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCanvas(Container container)
Adds the basic MarvinSpace viewer to the container.void
addMenuBar(RootPaneContainer frame)
Adds the basic MarvinSpace menubar to the container.MoleculeComponent
addMolecule(Molecule mol)
Adds aMolecule
object to the actual cell of the viewer.ArrayList<Object>
addMolecule(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.ArrayList
addMoleculeToEmptyCell(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 aMolecule
object to the actual cell of the viewer and resets the view only if required.void
addPDB(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(RootPaneContainer appletOrFrame)
Adds the basic MarvinSpace selection panel to the container.void
addSelectionPanelAndProgressBar(RootPaneContainer appletOrFrame)
Adds the basic MarvinSpace selection panel to the container.void
addToolBar(RootPaneContainer appletOrFrame)
Adds the basic MarvinSpace toolbar to the container.Object
callback(String method, Object arg)
Callback function to make avoiding direct calls easier.MolecularSurfaceComponent
computeSurface(MacroMoleculeComponent.MoleculeVisualizer mv)
Activates the container cell of theMoleculeVisualizer
, and computes its Connolly surface.MolecularSurfaceComponent
computeSurface(String type)
Computes the given type of surface in the active cell of the viewer.JPanel
createSelectionPanel(int maxSize)
Adds the basic MarvinSpace selection panel to the container.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 theGraphicScene
of MarvinSpace to be able to explicitly set more advanced features.static InputStream
getInputStream(String s)
Creates anInputStream
from the givenString
.static MolInputStream
getMolInputStream(String s)
Creates aMolInputStream
from the givenString
to be able to manually add molecules to the event handler.static String
getRCSBLink(String pdbId)
Returns the URL of the RCSB databasestatic String
getRCSBLink(String pdbId, boolean compressed)
Returns the URL of the RCSB databasestatic boolean
isURL(String path)
Tells whether the given path is an URL (Uniform Resource Locator) or not.void
mapPropertyFile(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.ArrayList<Object>
openMolecule(String s)
Closes all components from the viewer, and reads the molecule(s).void
processArguments(int maxMolCount, ArrayList infileName, ArrayList molecules, boolean readStdIn, boolean multicell, boolean singleCell, Properties sceneProperties, String displayQuality)
Processes the command line arguments of MarvinSpace listed below.void
readPDB(String s)
Reads a protein given as String.void
readPropertyFile(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(String propertyName, String propertyValue)
Sets a draw property of MarvinSpace that will affect the active cell only.void
setComponentProperty(Object component, String propertyName, String propertyValue)
Sets a draw property of MarvinSpace that will affect only the given component.static void
setIconImage(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(String propertyName, 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.
-
-
-
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 JSplitPane jSplitPane1
-
optionsDialog
protected chemaxon.marvin.space.gui.JMSpaceOptionsDialog optionsDialog
-
containerFrame
protected JFrame containerFrame
-
verbose
protected static boolean verbose
-
-
Constructor Detail
-
MSpaceEasy
public MSpaceEasy(boolean install) throws Exception
Creates the JPanel with the OpenGL2 canvas, but does not embed it in any swing container. SeeaddSelectionPanel(javax.swing.RootPaneContainer)
,addSelectionPanelAndProgressBar(javax.swing.RootPaneContainer)
,addCanvas(java.awt.Container)
.- Parameters:
install
- should Jogl libraries be loaded or they are already loaded- Throws:
Exception
- on installation failure
-
MSpaceEasy
public MSpaceEasy(int rowCount, int columnCount, boolean install) throws Exception
Creates the JPanel with the OpenGL2 canvas, but does not embed it in any swing container. SeeaddSelectionPanel(javax.swing.RootPaneContainer)
,addSelectionPanelAndProgressBar(javax.swing.RootPaneContainer)
,addCanvas(java.awt.Container)
.- Parameters:
rowCount
- number of cells of the viewer in vertical directioncolumnCount
- number of cells of the viewer in horizontal directioninstall
- should Jogl libraries be loaded or they are already loaded- Throws:
Exception
- on installation failure
-
MSpaceEasy
public MSpaceEasy(boolean install, boolean verbose, URL codebase) throws Exception
Creates the JPanel with the OpenGL2 canvas, but does not embed it in any swing container. SeeaddSelectionPanel(javax.swing.RootPaneContainer)
,addSelectionPanelAndProgressBar(javax.swing.RootPaneContainer)
,addCanvas(java.awt.Container)
.- Parameters:
install
- should Jogl libraries be loaded or they are already loadedverbose
- should technical details be writed to the console or notcodebase
- in case of applets codebase is required for installing- Throws:
Exception
- on installation failure
-
MSpaceEasy
public MSpaceEasy(int rowCount, int columnCount, boolean install, boolean verboseMsg, URL codebase) throws Exception
Creates the JPanel with the OpenGL2 canvas, but does not embed it in any swing container. SeeaddSelectionPanel(javax.swing.RootPaneContainer)
,addSelectionPanelAndProgressBar(javax.swing.RootPaneContainer)
,addCanvas(java.awt.Container)
.- Parameters:
rowCount
- number of cells of the viewer in vertical directioncolumnCount
- number of cells of the viewer in horizontal directioninstall
- should Jogl libraries be loaded or they are already loadedverboseMsg
- should technical details be written to the console or notcodebase
- in case of applets codebase is required for installing- Throws:
Exception
- on installation failure
-
-
Method Detail
-
isURL
public static boolean isURL(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(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 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 directioncolumnCount
- number of cells of the viewer in horizontal direction- Throws:
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 pixelsh
- height of the panel in pixels
-
addMenuBar
public void addMenuBar(RootPaneContainer frame)
Adds the basic MarvinSpace menubar to the container. Note that the menubar itself is not customizable yet.- Parameters:
frame
- the container swing component of the JPanel
-
addToolBar
public void addToolBar(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(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(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 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 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(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(String propertyName, 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 propertypropertyValue
- value of the property to be set given as aString
-
setCellProperty
public void setCellProperty(String propertyName, 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 propertypropertyValue
- value of the property to be set given as aString
-
setComponentProperty
public void setComponentProperty(Object component, String propertyName, 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 aUsableObject
propertyName
- identifier of a draw propertypropertyValue
- value of the property to be set given as aString
-
addPDB
public void addPDB(String pdbId) throws 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:
IOException
- if connecting RCSB failsException
-
readPDB
public void readPDB(String s) throws Exception
Reads a protein given as String.- Parameters:
s
- String content of a PDB file- Throws:
Exception
- when reading or adding component fails
-
getRCSBLink
public static String getRCSBLink(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 String getRCSBLink(String pdbId, boolean compressed)
Returns the URL of the RCSB database- Parameters:
pdbId
- the 4 letter id of a protein, e.g. 1AIDcompressed
- whether the protein is required in gzipped format- Returns:
- the full URL to the required protein
-
addMolecule
public ArrayList<Object> addMolecule(String s) throws 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:
Exception
- when reading file or adding component fails
-
addMoleculeToEmptyCell
public ArrayList addMoleculeToEmptyCell(String s) throws 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:
Exception
- when reading adding component fails
-
openMolecule
public ArrayList<Object> openMolecule(String s) throws 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:
Exception
- when reading or adding component fails
-
addMolecule
public MoleculeComponent addMolecule(Molecule mol) throws Exception
Adds aMolecule
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:
Exception
- if adding component fails
-
addMoleculeWithoutChange
public MoleculeComponent addMoleculeWithoutChange(Molecule mol, boolean reset) throws Exception
Adds aMolecule
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, seeresetAll()
.- Returns:
MoleculeComponent
that is the visualizer component of the molecule- Throws:
Exception
- if adding component fails
-
addMoleculeToEmptyCell
public MoleculeComponent addMoleculeToEmptyCell(Molecule mol) throws 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:
Exception
- if adding component fails
-
addMoleculeTo
public MoleculeComponent addMoleculeTo(Molecule mol, int cellIndex) throws 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:
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 theMoleculeVisualizer
, and computes its Connolly surface.- Parameters:
mv
- seeMacroMoleculeComponent.MoleculeVisualizer
- Returns:
MolecularSurfaceComponent
that is the visualizer component of molecular surface.
-
computeSurface
public MolecularSurfaceComponent computeSurface(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(String filename)
-
mapPropertyFile
public void mapPropertyFile(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 mappedmin
- values less than the minimum will be colored by the color of the minimum valuemax
- 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, ArrayList infileName, ArrayList molecules, boolean readStdIn, boolean multicell, boolean singleCell, Properties sceneProperties, String displayQuality) throws Exception
Processes the command line arguments of MarvinSpace listed below.- Parameters:
maxMolCount
- maximum number of molecules that can be displayed at a timeinfileName
- list of molecule files that should be readmolecules
- molecule objects to be readreadStdIn
- if input molecules should be read from the standard inputmulticell
- whether the read molecules should be put in different cells or asksingleCell
- whether the read molecules should be put in one cells or asksceneProperties
- a set of drawing propertiesdisplayQuality
- requires display quality, can be "High", "Medium" or "Low"- Throws:
Exception
- if processing an argument fails
-
getMolInputStream
public static MolInputStream getMolInputStream(String s) throws IOException
Creates aMolInputStream
from the givenString
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:
IOException
- if an I/O exception occurs- Since:
- Marvin 4.0.3
-
getInputStream
public static InputStream getInputStream(String s) throws IOException
Creates anInputStream
from the givenString
. TheInputStream
is either aMonitorableInputStream
orFileInputStream
orByteArrayInputStream
.- Parameters:
s
- url or absolute filename or String- Returns:
- InputStream
- Throws:
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 theGraphicScene
of MarvinSpace to be able to explicitly set more advanced features. It is necessary if features given byMSpaceEasy
is not enough for the required action.- Returns:
- the top level visualizer class
- Since:
- Marvin 4.1
-
callback
public Object callback(String method, Object arg)
Callback function to make avoiding direct calls easier.- Specified by:
callback
in interfacechemaxon.marvin.util.CallbackIface
- Parameters:
method
- name ofMSpaceEasy
methodarg
-Object[]
orObject
ornull
- Returns:
- the return object of the function or the Exception if there is any
-
-