Interface CanvasCellHandler


  • public interface CanvasCellHandler
    Canvas table cell handler - Java API. Supports custom drawing functionality - for example can draw molecule mass spectrum, custom charts, etc. Must be implemented as a Netbeans ServiceProvider to be found.

    Example implementation:

     @ServiceProvider(service = CanvasCellHandler.class)
     public class ExampleCell implements CanvasCellHandler {
         @Override
         public void onPaintComponent(Graphics g, DefaultTableCellRenderer cell, Object value) {
             g.setColor(Color.blue);
             g.fillRect(0, 0, cell.getWidth() / 2, cell.getHeight() / 2);
         }
     }
     
    Since:
    20.18.0
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default java.awt.Color getBackground​(java.lang.Object value)
      Background color based on a cell value.
      default java.lang.String getDefaultConfig()
      When this cell renderer is chosen, default configuration is setup if not null.
      default java.lang.String getToolTipText​(java.lang.Object value)
      Tooltip based on a cell value.
      default java.lang.Object getValue​(java.lang.Object value)
      Temporary method used for printing table cell values.
      void onPaintComponent​(java.awt.Graphics g, javax.swing.table.DefaultTableCellRenderer cell, java.lang.Object value)
      Called during paintComponent() of a table cell.
      default void setConfig​(java.util.Map<java.lang.String,​java.lang.Object> config)
      Passes renderer configuration which was set in Column renderer customizer.
      default void setField​(com.im.df.api.ddl.DFField field)
      Passes field bound to a table column.
      default void setResultSet​(com.im.df.api.dml.DFResultSet resultSet)
      Passes current result set.
      default boolean supportsMimeType​(java.lang.String type)
      Chooses this cell renderer if bound field has matching Mime type.
      default boolean supportsType​(java.lang.Class fieldClass)
      Chooses this cell renderer if bound field has matching data type field class.
    • Method Detail

      • supportsType

        default boolean supportsType​(java.lang.Class fieldClass)
        Chooses this cell renderer if bound field has matching data type field class.
        Parameters:
        fieldClass - Field class - for example CustomData.class
        Returns:
        true if this cell renderer supports given field class, otherwise false
      • supportsMimeType

        default boolean supportsMimeType​(java.lang.String type)
        Chooses this cell renderer if bound field has matching Mime type.
        Parameters:
        type - Mime type - for example text/mass-spectrum
        Returns:
        true if this cell renderer supports given Mime type, otherwise false
      • getDefaultConfig

        default java.lang.String getDefaultConfig()
        When this cell renderer is chosen, default configuration is setup if not null.
        Returns:
        default configuration as JSON string or null
      • setConfig

        default void setConfig​(java.util.Map<java.lang.String,​java.lang.Object> config)
        Passes renderer configuration which was set in Column renderer customizer.
        Parameters:
        config - key-value configuration
      • setField

        default void setField​(com.im.df.api.ddl.DFField field)
        Passes field bound to a table column.
        Parameters:
        field - bound field
      • setResultSet

        default void setResultSet​(com.im.df.api.dml.DFResultSet resultSet)
        Passes current result set. Contains vertex state with information about ids, selected ids, sort, etc. Allows to get child ids and data.
        Parameters:
        resultSet - current result set
      • getValue

        default java.lang.Object getValue​(java.lang.Object value)
        Temporary method used for printing table cell values. Useful when data is stored in child entities. Will be removed in the future as soon as new type of DFField, which gets child entity data, is implemented. Calculated fields are not sufficient for all kind of cases and do not support Java handlers.
        Parameters:
        value - rendered or printed value
        Returns:
        new value containing additional information - e.g. child entity data
      • getToolTipText

        default java.lang.String getToolTipText​(java.lang.Object value)
        Tooltip based on a cell value.
        Parameters:
        value - cell value
        Returns:
        tooltip text or null
      • getBackground

        default java.awt.Color getBackground​(java.lang.Object value)
        Background color based on a cell value.
        Parameters:
        value - cell value
        Returns:
        background color or null
      • onPaintComponent

        void onPaintComponent​(java.awt.Graphics g,
                              javax.swing.table.DefaultTableCellRenderer cell,
                              java.lang.Object value)
        Called during paintComponent() of a table cell. Allows to implement custom drawing functionality.
        Parameters:
        g - Java Graphics
        cell - this cell component based on a JLabel
        value - cell value