Class 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.

    1. 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.
    2. 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.
    Example of usage: http://www.chemaxon.com/marvin/examples/beans/view-jtable/index.html
    Since:
    Marvin 5.1.2
    See Also:
    Serialized Form
    • Constructor Detail

      • MViewEditor

        public MViewEditor()
        Creates the cell editor. It can be assigned to JTables for example with table.setDefaultEditor(Molecule.class, new MViewEditor());
    • Method Detail

      • getEditorComponent

        public MViewPane getEditorComponent()
        Returns the editor component.
        Returns:
        the MViewPane editor component
      • 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
      • getTableCellEditorComponent

        public Component getTableCellEditorComponent​(JTable table,
                                                     Object value,
                                                     boolean isSelected,
                                                     int row,
                                                     int column)
        Sets up the editor component.
        Specified by:
        getTableCellEditorComponent in interface TableCellEditor
        Parameters:
        table - the JTable that is asking the editor to edit; can be null
        value - the value of the cell to be edited; it is considered to be a Molecule instance; null is a valid value
        isSelected - true if the cell is to be rendered with highlighting
        row - the row of the cell being edited
        column - 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 by getTableCellEditorComponent(javax.swing.JTable, Object, boolean, int, int), overwrite to change the default behavior.
        Parameters:
        table - the JTable that is asking the editor to edit; can be null
        mviewPane - the editor component
        isSelected - true if the cell is to be rendered with the selection highlighted; otherwise false
        row - the row of the cell being edited
        column - 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 by getTableCellEditorComponent(javax.swing.JTable, Object, boolean, int, int), overwrite to change the default behavior.
        Parameters:
        table - the JTable that is asking the editor to edit; can be null
        mviewPane - the editor component
        isSelected - true if the cell is to be rendered with the selection highlighted; otherwise false
        row - the row of the cell being edited
        column - the column of the cell being edited