Step-by-step code examples¶
Create a JFrame containing a MarvinSpace canvas¶
Let's create a simple MarvinSpace application.
First, we have to install the Jogl native libraries. MSpaceInstaller will do this for us.
The second step is creating a JFrame.
Third, we have to put the MarvinSpace canvas on it. MSpaceEasy makes it simple, we can also add several GUI components such as Popup Menu and MenuBar.
Finally the frame is ready:
Load a molecule¶
To go one step further, we will need some molecules to display. The following code lines can be placed for example before the frame.pack()call.
In case of having a SMILES String:
By default MarvinSpace checks whether the molecule is defined in plane or not, and calls Clean, Hydrogenize and Aromatize functions of the Molecule .
Loading from a file or URL:
Let's suppose we have a properly initilaized Vector containing Molecule objects. We can place them in different cells each:
Loading a molecule without calling Clean, Hydrogenize and Aromatize:
In the previous examples we added the molecules to the scene, but we can also load a molecule by closing all molecules before:
Loading molecule to a specific cell (indexing starts from 0, from top to bottom and left to right):
.