MarvinView Table View¶
This example demonstrates the creation of scrollable molecule tables.
A mechanism by which molecules are loaded dynamically and cached automatically is also shown. This makes it possible that input files are supported with arbitrary size.
Specifying the Input¶
To allow dynamic loading and caching the input of the viewer must be an implementation of MDocSource. You can either use an existing implementation like MolImporter or ArrayMDocSource, or you can create a custom implementation.
In the current example, the input is a molecule file hence it is convenient to use MolImporter:
Creating the GUI¶
The creation of the GUI must be performed in the event dispatch thread.
It consists of the following steps:
-
The creation of an
MViewPaneobject: -
Adding the
viewPaneand menubar to a JFrame: -
The creation of a
TableSupportobject is performed with the firstMViewPane.getTableSupport()call: -
Adding Table menu items using
TableSupport.makeTableMenu:
-
Optional table settings using the
TableOptionsclass: -
Making the window visible.
-
Starting molecule table visualization using
TableSupport.start(docSource, inputName), wheredocSourceis the input document source (see the previous section) andinputNameis a string describing the input, for example, name of the input file — its function is to make error messages more specific.
Changing the Background of Molecule ID Fields¶
The Example menu contains a Highlight menu which demonstrates the highlighting of a record by changing the background color of its ID field.
The color of the ID field is changed using view pane.setRecordIDBackground and setRecordIDForeground:
Source code: ViewTable.java