chemaxon.marvin.plugin
Class CalculatorPluginDisplay

java.lang.Object
  extended by chemaxon.marvin.plugin.CalculatorPluginDisplay

public class CalculatorPluginDisplay
extends java.lang.Object

Common base class for calculator plugin displays. Also provides default implementation for molecule display, therefore plugins with molecule / atom data only may use the base class itself.

Since:
Marvin 4.0
Version:
Marvin 5.4, 09/29/2010
Author:
Nora Mate

Field Summary
protected static int CELLSIZE
          The default viewer cell size.
protected  boolean displayInMarvinSpace
          Display in MarvinSpace is enabled or not.
protected static int HTML
          Property display type: display in html text.
protected  int icell
          The viewer cell index (0 for sketcher).
protected static int LABEL
          Property display type: display in label.
protected static int MAX_LINE_LENGTH
          Maximum desired line length used to form multi-line text.
protected static int NONE
          Property display type: no property display.
protected  java.awt.Component parent
          The parent component.
protected  DPoint3[] reactionArrow
          The reaction arrow endpoints, null if not a reaction.
protected  java.util.ArrayList resultMolList
          The result molecules to be displayed.
protected  java.util.ArrayList resultValues
          The result values to be displayed in MarvinSpace.
protected static int TEXT
          Property display type: display in text.
protected  java.lang.String title
          The result frame title.
protected static java.lang.String WORD_SEPARATORS
          Word separators used to form multi-line text if the text is too long.
 
Constructor Summary
CalculatorPluginDisplay()
           
 
Method Summary
protected  java.lang.String appendpHText(java.lang.String text)
          Appends the pH text.
 void clear()
          Clears the display.
protected  chemaxon.marvin.util.CallbackIface createMolsFrame()
           
protected  ParameterPanelHandler createParameterPanel()
          Creates the parameter panel.
protected  chemaxon.marvin.plugin.gui.ResultView createResultView(java.lang.String title, chemaxon.marvin.common.swing.MolPanel mpan)
           
protected  java.awt.Component createSpacePanel(Molecule[] mols)
          Creates space panel with given molecules, creates colored surface to each molecule.
protected  chemaxon.marvin.view.swing.ViewPanel createViewPanel(Molecule[] mols)
          Creates view panel with given molecules, places molecule properties in formatted texts.
protected  chemaxon.marvin.view.swing.ViewPanel createViewPanel(Molecule[] mols, int rows, int cols, int size, int propertyDisplayType)
          Creates view panel with given molecules, places molecule properties in formatted texts.
 java.awt.Component getErrorComponent()
          Returns a component with the appropriate error message.
protected  java.lang.Object getHResult(int i)
          Returns the sum result of the H neighbours of the given atom.
 java.lang.String[] getLabels(double[] values)
          Returns formatted array.
 ParameterPanelHandler getParameterPanel()
          Returns the parameter panel.
protected  CalculatorPlugin getPlugin()
          Returns the plugin.
 chemaxon.common.util.MProgressMonitor getProgressMonitor(java.awt.Component parent)
          Creates a progress observer object to be used in CalculatorPlugin.setProgressMonitor(chemaxon.common.util.MProgressMonitor).
protected  java.lang.String getPropertyText(Molecule mol)
          Returns molecule properties is text form.
 java.lang.String getRemark()
          Returns the calculation remark.
 java.awt.Component getResultComponent()
          Returns the result component for display.
protected  java.lang.String getTableText(java.lang.String header, java.lang.String[] labels, double[][] values)
          Returns table in string form.
 java.lang.String getTitle()
          Returns the frame title.
protected  boolean isMSpaceDisplayLabelOnlyOnHeavyAtoms()
          Returns if mspace should display label only on heavy atoms.
 boolean isMultipleDisplay()
          Returns true if results for more molecules can be displayed in a single component, false if each molecule should be displayed in a separate component.
 void pop()
          Clears the last stored item from the display.
 void setCellIndex(int icell)
          Sets the viewer cell index.
 void setParameters(java.util.Properties params)
          Sets parameters.
 void setParent(java.awt.Component parent)
          Sets the parent component.
 void setPlugin(CalculatorPlugin plugin)
          Sets the plugin.
 void setReactionArrow(DPoint3[] reactionArrow)
          Sets the reaction arrow.
 void setTitle(java.lang.String title)
          Sets the frame title.
 void store()
          Stores a new result item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CELLSIZE

protected static final int CELLSIZE
The default viewer cell size.

See Also:
Constant Field Values

NONE

protected static final int NONE
Property display type: no property display.

See Also:
Constant Field Values

LABEL

protected static final int LABEL
Property display type: display in label.

See Also:
Constant Field Values

TEXT

protected static final int TEXT
Property display type: display in text.

See Also:
Constant Field Values

HTML

protected static final int HTML
Property display type: display in html text.

See Also:
Constant Field Values

WORD_SEPARATORS

protected static final java.lang.String WORD_SEPARATORS
Word separators used to form multi-line text if the text is too long.

See Also:
Constant Field Values

MAX_LINE_LENGTH

protected static final int MAX_LINE_LENGTH
Maximum desired line length used to form multi-line text.

See Also:
Constant Field Values

parent

protected java.awt.Component parent
The parent component.


title

protected java.lang.String title
The result frame title.


icell

protected int icell
The viewer cell index (0 for sketcher).


displayInMarvinSpace

protected boolean displayInMarvinSpace
Display in MarvinSpace is enabled or not.


resultMolList

protected java.util.ArrayList resultMolList
The result molecules to be displayed.


resultValues

protected java.util.ArrayList resultValues
The result values to be displayed in MarvinSpace.


reactionArrow

protected DPoint3[] reactionArrow
The reaction arrow endpoints, null if not a reaction.

Constructor Detail

CalculatorPluginDisplay

public CalculatorPluginDisplay()
Method Detail

setPlugin

public void setPlugin(CalculatorPlugin plugin)
Sets the plugin.

Parameters:
plugin - is the plugin

getPlugin

protected final CalculatorPlugin getPlugin()
Returns the plugin.

Returns:
the plugin

setParent

public final void setParent(java.awt.Component parent)
Sets the parent component.

Parameters:
parent - is the parent component

setCellIndex

public final void setCellIndex(int icell)
Sets the viewer cell index.

Parameters:
icell - is the viewer cell index

setParameters

public void setParameters(java.util.Properties params)
Sets parameters. The default implementation checks whether displaying in MarvinSpace is required and possible, descendant classes may fetch display parameters.

Parameters:
params - is the parameter table

setTitle

public void setTitle(java.lang.String title)
Sets the frame title.

Parameters:
title - is the frame title

getTitle

public java.lang.String getTitle()
Returns the frame title.

Returns:
the frame title

setReactionArrow

public void setReactionArrow(DPoint3[] reactionArrow)
Sets the reaction arrow. If set then molecules stored by store() will be taken as reaction components. The next clear() resets this reaction mode.

Parameters:
reactionArrow - is the reaction arrow endpoint array

getProgressMonitor

public chemaxon.common.util.MProgressMonitor getProgressMonitor(java.awt.Component parent)
Creates a progress observer object to be used in CalculatorPlugin.setProgressMonitor(chemaxon.common.util.MProgressMonitor). Short calculations do not need this object. The default implementation returns null, subclasses may return MProgressMonitor or any other progress monitor implemeting MProgressMonitor.

Parameters:
parent - is the parent component (centralize relative to)
Returns:
a progress observer object

getParameterPanel

public final ParameterPanelHandler getParameterPanel()
                                              throws PluginException
Returns the parameter panel.

Returns:
the parameter panel
Throws:
PluginException - on error

createParameterPanel

protected ParameterPanelHandler createParameterPanel()
                                              throws PluginException
Creates the parameter panel. The default implementation creates a ParameterPanel object from the <plugin class name>Parameters.xml configuration XML read from CalculatorPlugin.PLUGIN_DIR with user parameter settings read from $HOME/chemaxon/<plugin class name>Parameters.properties (Windows), or $HOME/.chemaxon/<plugin class name>Parameters.properties (UNIX / Linux). Returns null (no paramter panel for this plugin) if the configuration XML is not found.

Returns:
the parameter panel
Throws:
PluginException - on error

isMultipleDisplay

public boolean isMultipleDisplay()
Returns true if results for more molecules can be displayed in a single component, false if each molecule should be displayed in a separate component. The default implementation returns true.

Returns:
true if results for more molecules can be displayed in a single component

pop

public void pop()
Clears the last stored item from the display. The default implemetation clears the top element in resultMolList and resets reactionArrow.


clear

public void clear()
Clears the display. The default implemetation clears resultMolList and resets reactionArrow.


store

public void store()
           throws PluginException
Stores a new result item. The default implementation adds the current result molecule returned by CalculatorPlugin.getResultMolecule() to resultMolList.

Throws:
PluginException

getHResult

protected java.lang.Object getHResult(int i)
                               throws PluginException
Returns the sum result of the H neighbours of the given atom.

Parameters:
i - index of the atom
Returns:
result the result item for the specified index
Throws:
PluginException
Since:
Marvin 4.1

getResultComponent

public java.awt.Component getResultComponent()
                                      throws PluginException
Returns the result component for display. The default implementation places the molecules stored in resultMolList in a viewer and displays molecular results (stored in molecule properties) in text fields.

Returns:
the result component
Throws:
PluginException - on error
Since:
Marvin 4.0

createResultView

protected chemaxon.marvin.plugin.gui.ResultView createResultView(java.lang.String title,
                                                                 chemaxon.marvin.common.swing.MolPanel mpan)
                                                          throws PluginException
Throws:
PluginException

createMolsFrame

protected chemaxon.marvin.util.CallbackIface createMolsFrame()
                                                      throws PluginException
Throws:
PluginException

getErrorComponent

public java.awt.Component getErrorComponent()
                                     throws PluginException
Returns a component with the appropriate error message. Relevant if CalculatorPlugin.run(), or equivalently CalculatorPlugin.isOK() returns false.

Returns:
the error component
Throws:
PluginException

getRemark

public java.lang.String getRemark()
                           throws PluginException
Returns the calculation remark.

Returns:
the calculation remark
Throws:
PluginException

createViewPanel

protected chemaxon.marvin.view.swing.ViewPanel createViewPanel(Molecule[] mols)
                                                        throws PluginException
Creates view panel with given molecules, places molecule properties in formatted texts. Fuses molecules if no properties to be displayed.

Parameters:
mols - is the molecule array
Returns:
the view panel
Throws:
PluginException

createViewPanel

protected chemaxon.marvin.view.swing.ViewPanel createViewPanel(Molecule[] mols,
                                                               int rows,
                                                               int cols,
                                                               int size,
                                                               int propertyDisplayType)
Creates view panel with given molecules, places molecule properties in formatted texts.

Parameters:
mols - is the molecule array
rows - the number of visible rows
cols - the number of columns
propertyDisplayType - is TEXT, LABEL, HTML or NONE
Returns:
the view panel

getPropertyText

protected java.lang.String getPropertyText(Molecule mol)
Returns molecule properties is text form.

Parameters:
mol - is the molecule
Returns:
molecule properties in text form

appendpHText

protected java.lang.String appendpHText(java.lang.String text)
Appends the pH text.

Parameters:
text - is the text
Returns:
the text + the pH text

isMSpaceDisplayLabelOnlyOnHeavyAtoms

protected boolean isMSpaceDisplayLabelOnlyOnHeavyAtoms()
Returns if mspace should display label only on heavy atoms.

Since:
Marvin 5.4

getLabels

public final java.lang.String[] getLabels(double[] values)
Returns formatted array.

Parameters:
values - is the numerical array
Returns:
the formatted array

getTableText

protected final java.lang.String getTableText(java.lang.String header,
                                              java.lang.String[] labels,
                                              double[][] values)
Returns table in string form.

Parameters:
header - is the header (the first char is the separator)
labels - is the first column
values - is the value column array

createSpacePanel

protected java.awt.Component createSpacePanel(Molecule[] mols)
                                       throws PluginException
Creates space panel with given molecules, creates colored surface to each molecule.

Parameters:
mols - is the molecule array
Returns:
the space panel
Throws:
PluginException
Since:
Marvin 4.1