Package chemaxon.marvin.beans
Class MViewEditor
- java.lang.Object
-
- javax.swing.AbstractCellEditor
-
- chemaxon.marvin.beans.MViewEditor
-
- All Implemented Interfaces:
Serializable
,CellEditor
,TableCellEditor
@PublicAPI public class MViewEditor extends AbstractCellEditor implements TableCellEditor
MViewEditor is an implementation of AbstractCellEditor and TableCellEditor that can be used to assign a cell editor to Molecule objects in JTables.Using MViewPane as a cell editor provides two major advantages.
- It offers many functionalities that modify the visualization but not the structure itself, for example rotation, zoom, display and color schemas, or the dimension in which the structure is shown.
- It can also be used as an indirect cell editor. Double clicking on the MViewPane cell editor brings up MarvinSketch, in which the structure can be modified. After MarvinSketch is closed, the molecule is updated.
- Since:
- Marvin 5.1.2
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class javax.swing.AbstractCellEditor
changeEvent, listenerList
-
-
Constructor Summary
Constructors Constructor Description MViewEditor()
Creates the cell editor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
getCellEditorValue()
Returns the edited molecule that is aMolecule
instance.int
getEditable()
Returns the mode that determines if the structure is editable.MViewPane
getEditorComponent()
Returns the editor component.Component
getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
Sets up the editor component.protected void
setBackgroundColor(JTable table, MViewPane mviewPane, boolean isSelected, int row, int column)
Sets the background color for the current cell based on selection.protected void
setBorder(JTable table, MViewPane mviewPane, boolean isSelected, int row, int column)
Sets the border for the current cell based on selection.void
setEditable(int e)
Sets the mode that determines if the structure is editable.-
Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditing
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.swing.CellEditor
addCellEditorListener, cancelCellEditing, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditing
-
-
-
-
Method Detail
-
getEditorComponent
public MViewPane getEditorComponent()
Returns the editor component.- Returns:
- the
MViewPane
editor component
-
getEditable
public int getEditable()
Returns the mode that determines if the structure is editable.- Returns:
MViewPane.VIEW_ONLY
if molecules can be viewed only,MViewPane.EDITABLE
if they are editable with MarvinView,MViewPane.SKETCHABLE
if they are editable with MarvinSketch.
-
setEditable
public void setEditable(int e)
Sets the mode that determines if the structure is editable. If the structure is allowed to be edited, the Edit > Structure menu or the double mouse click performs the editing.MViewPane.VIEW_ONLY
: editing is disabled,MViewPane.EDITABLE
: editing is enabled and launches MarvinView in a new window,MViewPane.SKETCHABLE
: editing is enabled and launches MarvinSketch in a new window.- Parameters:
e
- identifier of the mode
-
getCellEditorValue
public Object getCellEditorValue()
Returns the edited molecule that is aMolecule
instance.- Specified by:
getCellEditorValue
in interfaceCellEditor
-
getTableCellEditorComponent
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
Sets up the editor component.- Specified by:
getTableCellEditorComponent
in interfaceTableCellEditor
- Parameters:
table
- theJTable
that is asking the editor to edit; can benull
value
- the value of the cell to be edited; it is considered to be aMolecule
instance;null
is a valid valueisSelected
- true if the cell is to be rendered with highlightingrow
- the row of the cell being editedcolumn
- the column of the cell being edited- Returns:
- the component for editing
-
setBackgroundColor
protected void setBackgroundColor(JTable table, MViewPane mviewPane, boolean isSelected, int row, int column)
Sets the background color for the current cell based on selection. The default implementation sets the table selection color on the editor component. The method is called bygetTableCellEditorComponent(javax.swing.JTable, Object, boolean, int, int)
, overwrite to change the default behavior.- Parameters:
table
- theJTable
that is asking the editor to edit; can benull
mviewPane
- the editor componentisSelected
- true if the cell is to be rendered with the selection highlighted; otherwise falserow
- the row of the cell being editedcolumn
- the column of the cell being edited
-
setBorder
protected void setBorder(JTable table, MViewPane mviewPane, boolean isSelected, int row, int column)
Sets the border for the current cell based on selection. The default implementation sets the table selection color on the editor component. The method is called bygetTableCellEditorComponent(javax.swing.JTable, Object, boolean, int, int)
, overwrite to change the default behavior.- Parameters:
table
- theJTable
that is asking the editor to edit; can benull
mviewPane
- the editor componentisSelected
- true if the cell is to be rendered with the selection highlighted; otherwise falserow
- the row of the cell being editedcolumn
- the column of the cell being edited
-
-