Class 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 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
      • optionsDialog

        protected chemaxon.marvin.space.gui.JMSpaceOptionsDialog optionsDialog
      • containerFrame

        protected JFrame containerFrame
      • verbose

        protected static boolean verbose
    • 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 direction
        columnCount - 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 pixels
        h - 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 property
        propertyValue - value of the property to be set given as a String
      • 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 property
        propertyValue - value of the property to be set given as a String
      • 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 a UsableObject
        propertyName - identifier of a draw property
        propertyValue - value of the property to be set given as a String
      • 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 fails
        Exception
      • 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. 1AID
        compressed - 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 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:
        Exception - if adding component fails
      • addMoleculeWithoutChange

        public MoleculeComponent addMoleculeWithoutChange​(Molecule mol,
                                                          boolean reset)
                                                   throws 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:
        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​(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 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,
                                     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 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:
        Exception - if processing an argument fails
      • getMolInputStream

        public static MolInputStream getMolInputStream​(String s)
                                                throws 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:
        IOException - if an I/O exception occurs
        Since:
        Marvin 4.0.3
      • getInputStream

        public static InputStream getInputStream​(String s)
                                          throws 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:
        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 Object callback​(String method,
                               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