chemaxon.marvin.view.swing
Class TableSupport

java.lang.Object
  extended by chemaxon.marvin.view.swing.TableSupport

public class TableSupport
extends java.lang.Object

Viewer table support class.

Since:
Marvin 5.0
Version:
5.3, 09/15/2009
Author:
Peter Csizmadia, Nora Mate

Field Summary
 TaskScheduler scheduler
          Record access task scheduler.
 
Method Summary
 void enqueueUpdate()
          Enqueues an update task.
 java.awt.Dimension getDefaultSize()
          Gets the default size of an MViewPane containing the generated table.
 MDocStorage getDocStorage()
          Gets the sparse dynamic document storage.
 TableOptions getTableOptions()
          Gets the table options component.
 void makeTableMenu(java.awt.Container menu)
          Creates Table menu items.
 void setCellSize(java.awt.Dimension size)
          Sets the molecule cell size for GridBagView.
 boolean setDocument(int k, MDocument doc)
          Sets the k-th record directly.
 void setSDFColoring(java.lang.String tag, java.util.Properties props)
          Sets SDF coloring.
 void start(MDocSource dsrc, java.lang.String inputName)
          Starts loading molecules.
 void startNow(MDocSource dsrc, java.lang.String inputName)
          Starts loading molecules immediately.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scheduler

public final TaskScheduler scheduler
Record access task scheduler. To prevent multithreading problems when the user scrolls the molecule table, record access operations should be performed only in tasks running on the scheduler's thread. Example:
final MDocStorage ds = tableSupport.getDocStorage();
final int start = 0;
final int end = ds.getSize();
Runnable task = new Runnable() {
    public void run() {
        try {
            for(int i = start; i < end; ++i) {
                MDocument d = ds.getMainDoc(i);
                ...
            }
        } catch(MDocStorage.RecordUnavailableException ex) {
            ...
        } catch(IOException ex) {
            ...
        }
    }
};
tableSupport.scheduler.invokeLater(task, start);
try {
    tableSupport.scheduler.waitForAll();
} catch(InterruptedException ex) {
    ex.printStackTrace();
}

Method Detail

getTableOptions

public TableOptions getTableOptions()
Gets the table options component.

Returns:
the table options

setCellSize

public void setCellSize(java.awt.Dimension size)
Sets the molecule cell size for GridBagView.

Parameters:
size - the molecule cell size

setSDFColoring

public void setSDFColoring(java.lang.String tag,
                           java.util.Properties props)
Sets SDF coloring.

Parameters:
tag - ?
props - ?

start

public void start(MDocSource dsrc,
                  java.lang.String inputName)
Starts loading molecules. Note that molecule loading is performed asynchronously, on a different thread.

Parameters:
dsrc - the document source
inputName - input file name or other identifier

startNow

public void startNow(MDocSource dsrc,
                     java.lang.String inputName)
              throws java.lang.InterruptedException,
                     java.lang.reflect.InvocationTargetException
Starts loading molecules immediately. This method must not be called from the AWT event dispatch thread.

Parameters:
dsrc - the document source
inputName - input file name or other identifier
Throws:
java.lang.InterruptedException - if another thread has interrupted the task thread
java.lang.reflect.InvocationTargetException - if an throwable is thrown when running runnable

enqueueUpdate

public void enqueueUpdate()
Enqueues an update task.


setDocument

public boolean setDocument(int k,
                           MDocument doc)
Sets the k-th record directly.

Note that this method should normally not be used if the input is an MDocSource; use start(MDocSource, String) instead.

Parameters:
k - record index
doc - the document
Returns:
true if setting was successful, false if no ViewHandler found

getDocStorage

public MDocStorage getDocStorage()
Gets the sparse dynamic document storage.

Note that MDocStorage should only be used via record access tasks,

Returns:
the storage object
See Also:
scheduler

getDefaultSize

public java.awt.Dimension getDefaultSize()
Gets the default size of an MViewPane containing the generated table.

Returns:
the size

makeTableMenu

public void makeTableMenu(java.awt.Container menu)
Creates Table menu items.

Parameters:
menu - the Table menu