Class DefaultTableCellRenderer<V>

java.lang.Object
com.googlecode.lanterna.gui2.table.DefaultTableCellRenderer<V>
Type Parameters:
V - Type of data stored in each table cell
All Implemented Interfaces:
TableCellRenderer<V>

public class DefaultTableCellRenderer<V> extends Object implements TableCellRenderer<V>
Default implementation of TableCellRenderer
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    afterRender(Table<V> table, V cell, int columnIndex, int rowIndex, boolean isSelected, TextGUIGraphics textGUIGraphics)
    Called by the cell renderer after the cell content has been drawn into the assigned area.
    protected void
    applyStyle(Table<V> table, V cell, int columnIndex, int rowIndex, boolean isSelected, TextGUIGraphics textGUIGraphics)
    Called by the cell renderer to setup all the styling (colors and SGRs) before rendering the cell.
    protected void
    beforeRender(Table<V> table, V cell, int columnIndex, int rowIndex, boolean isSelected, TextGUIGraphics textGUIGraphics)
    Called by the cell renderer to prepare the cell area before rendering the cell.
    void
    drawCell(Table<V> table, V cell, int columnIndex, int rowIndex, TextGUIGraphics textGUIGraphics)
    Called by the table when it's time to draw a cell, you can see how much size is available by checking the size of the textGUIGraphics.
    protected String[]
    getContent(V cell)
    Turns a cell into a multiline string, as an array.
    getPreferredSize(Table<V> table, V cell, int columnIndex, int rowIndex)
    Called by the table when it wants to know how big a particular table cell should be
    protected void
    render(Table<V> table, V cell, int columnIndex, int rowIndex, boolean isSelected, TextGUIGraphics textGUIGraphics)
    Called by the cell renderer to draw the content of the cell into the assigned area.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DefaultTableCellRenderer

      public DefaultTableCellRenderer()
  • Method Details

    • getPreferredSize

      public TerminalSize getPreferredSize(Table<V> table, V cell, int columnIndex, int rowIndex)
      Description copied from interface: TableCellRenderer
      Called by the table when it wants to know how big a particular table cell should be
      Specified by:
      getPreferredSize in interface TableCellRenderer<V>
      Parameters:
      table - Table containing the cell
      cell - Data stored in the cell
      columnIndex - Column index of the cell
      rowIndex - Row index of the cell
      Returns:
      Size this renderer would like the cell to have
    • drawCell

      public void drawCell(Table<V> table, V cell, int columnIndex, int rowIndex, TextGUIGraphics textGUIGraphics)
      Description copied from interface: TableCellRenderer
      Called by the table when it's time to draw a cell, you can see how much size is available by checking the size of the textGUIGraphics. The top-left position of the graphics object is the top-left position of this cell.
      Specified by:
      drawCell in interface TableCellRenderer<V>
      Parameters:
      table - Table containing the cell
      cell - Data stored in the cell
      columnIndex - Column index of the cell
      rowIndex - Row index of the cell
      textGUIGraphics - Graphics object to draw with
    • applyStyle

      protected void applyStyle(Table<V> table, V cell, int columnIndex, int rowIndex, boolean isSelected, TextGUIGraphics textGUIGraphics)
      Called by the cell renderer to setup all the styling (colors and SGRs) before rendering the cell. This method exists as protected in order to make it easier to extend and customize DefaultTableCellRenderer. Unless drawCell(Table, Object, int, int, TextGUIGraphics) it overridden, it will be called when the cell is rendered.
      Parameters:
      table - Table the cell belongs to
      cell - Cell being rendered
      columnIndex - Column index of the cell being rendered
      rowIndex - Row index of the cell being rendered
      isSelected - Set to true if the cell is currently selected by the user
      textGUIGraphics - TextGUIGraphics object to set the style on, this will be used in the rendering later
    • beforeRender

      protected void beforeRender(Table<V> table, V cell, int columnIndex, int rowIndex, boolean isSelected, TextGUIGraphics textGUIGraphics)
      Called by the cell renderer to prepare the cell area before rendering the cell. In the default implementation it will clear the area with whitespaces. This method exists as protected in order to make it easier to extend and customize DefaultTableCellRenderer. Unless drawCell(Table, Object, int, int, TextGUIGraphics) it overridden, it will be called when the cell is rendered, after setting up the styling but before the cell content text is drawn.
      Parameters:
      table - Table the cell belongs to
      cell - Cell being rendered
      columnIndex - Column index of the cell being rendered
      rowIndex - Row index of the cell being rendered
      isSelected - Set to true if the cell is currently selected by the user
      textGUIGraphics - TextGUIGraphics object for the cell, already having been prepared with styling
    • render

      protected void render(Table<V> table, V cell, int columnIndex, int rowIndex, boolean isSelected, TextGUIGraphics textGUIGraphics)
      Called by the cell renderer to draw the content of the cell into the assigned area. In the default implementation it will transform the content to multilines are draw them one by one. This method exists as protected in order to make it easier to extend and customize DefaultTableCellRenderer. Unless drawCell(Table, Object, int, int, TextGUIGraphics) it overridden, it will be called when the cell is rendered, after setting up the styling and preparing the cell.
      Parameters:
      table - Table the cell belongs to
      cell - Cell being rendered
      columnIndex - Column index of the cell being rendered
      rowIndex - Row index of the cell being rendered
      isSelected - Set to true if the cell is currently selected by the user
      textGUIGraphics - TextGUIGraphics object for the cell, already having been prepared with styling
    • afterRender

      protected void afterRender(Table<V> table, V cell, int columnIndex, int rowIndex, boolean isSelected, TextGUIGraphics textGUIGraphics)
      Called by the cell renderer after the cell content has been drawn into the assigned area. In the default implementation it will do nothing. This method exists as protected in order to make it easier to extend and customize DefaultTableCellRenderer. Unless drawCell(Table, Object, int, int, TextGUIGraphics) it overridden, it will be called after the cell has been rendered but before the table moves on to the next cell.
      Parameters:
      table - Table the cell belongs to
      cell - Cell being rendered
      columnIndex - Column index of the cell being rendered
      rowIndex - Row index of the cell being rendered
      isSelected - Set to true if the cell is currently selected by the user
      textGUIGraphics - TextGUIGraphics object for the cell, already having been prepared with styling
    • getContent

      protected String[] getContent(V cell)
      Turns a cell into a multiline string, as an array.
      Parameters:
      cell - Cell to turn into string content
      Returns:
      The cell content turned into a multiline string, where each element in the array is one row.