Class MViewRenderer

All Implemented Interfaces:
ComponentListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, TableCellRenderer

@PublicAPI public class MViewRenderer extends MViewPane implements TableCellRenderer
MViewRenderer is a TableCellRenderer component that can be used to render Molecule objects in JTables.

Example of usage: http://www.chemaxon.com/marvin/examples/beans/view-jtable/index.html

Since:
Marvin 5.1.2
See Also:
  • Constructor Details

    • MViewRenderer

      public MViewRenderer()
      Creates the cell renderer. It can be assigned to JTables for example with table.setDefaultRenderer(Molecule.class, new MViewRenderer());
  • Method Details

    • getTableCellRendererComponent

      public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
      The implementation of this method sets up the rendering component to display the passed-in molecule, and then returns the component.
      Specified by:
      getTableCellRendererComponent in interface TableCellRenderer
      Parameters:
      table - the JTable that is asking the renderer to draw; can be null
      value - the value of the cell to be rendered; it is considered to be a Molecule instance
      isSelected - true if the cell is to be rendered with the selection highlighted; otherwise false
      hasFocus - if true, a special border is put on the cell, if the cell can be edited, it is rendered in the color used to indicate editing
      row - the row index of the cell being drawn. When drawing the header, the value of row is -1
      column - the column index of the cell being drawn
      Returns:
      MViewPane component that is configured to draw the molecule.
    • setBackgroundColor

      protected void setBackgroundColor(JTable table, boolean isSelected, boolean hasFocus, int row, int column)
      Sets the background color for the current cell based on selection. The default implementation sets the same color for the renderer as the colors of the table itself. The method is called by getTableCellRendererComponent(javax.swing.JTable, Object, boolean, boolean, int, int) , overwrite to change the default behavior.
      Parameters:
      table - the JTable that is asking the renderer to draw; can be null
      isSelected - true if the cell is to be rendered with the selection highlighted; otherwise false
      hasFocus - indicates if the cell is focused
      row - the row index of the cell being drawn. When drawing the header, the value of row is -1
      column - the column index of the cell being drawn
    • setBorder

      protected void setBorder(JTable table, boolean isSelected, boolean hasFocus, int row, int column)
      Sets the border for the current cell based on selection. The default implementation sets the default border of the table on the renderer. The method is called by getTableCellRendererComponent(javax.swing.JTable, Object, boolean, boolean, int, int) , overwrite to change the default behavior.
      Parameters:
      table - the JTable that is asking the renderer to draw; can be null
      isSelected - true if the cell is to be rendered with the selection highlighted; otherwise false
      hasFocus - if true, a special border is put on the cell, if the cell can be edited, it is rendered in the color used to indicate editing
      row - the row index of the cell being drawn. When drawing the header, the value of row is -1
      column - the column index of the cell being drawn