Module com.googlecode.lanterna
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 java.lang.Object implements TableCellRenderer<V>
Default implementation ofTableCellRenderer
-
-
Constructor Summary
Constructors Constructor Description DefaultTableCellRenderer()
-
Method Summary
All Methods Instance Methods Concrete Methods 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 thetextGUIGraphics
.protected java.lang.String[]
getContent(V cell)
Turns a cell into a multiline string, as an array.TerminalSize
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 beprotected 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.
-
-
-
Method Detail
-
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 interfaceTableCellRenderer<V>
- Parameters:
table
- Table containing the cellcell
- Data stored in the cellcolumnIndex
- Column index of the cellrowIndex
- 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 thetextGUIGraphics
. The top-left position of the graphics object is the top-left position of this cell.- Specified by:
drawCell
in interfaceTableCellRenderer<V>
- Parameters:
table
- Table containing the cellcell
- Data stored in the cellcolumnIndex
- Column index of the cellrowIndex
- Row index of the celltextGUIGraphics
- 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 customizeDefaultTableCellRenderer
. UnlessdrawCell(Table, Object, int, int, TextGUIGraphics)
it overridden, it will be called when the cell is rendered.- Parameters:
table
- Table the cell belongs tocell
- Cell being renderedcolumnIndex
- Column index of the cell being renderedrowIndex
- Row index of the cell being renderedisSelected
- Set totrue
if the cell is currently selected by the usertextGUIGraphics
-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 customizeDefaultTableCellRenderer
. UnlessdrawCell(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 tocell
- Cell being renderedcolumnIndex
- Column index of the cell being renderedrowIndex
- Row index of the cell being renderedisSelected
- Set totrue
if the cell is currently selected by the usertextGUIGraphics
-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 customizeDefaultTableCellRenderer
. UnlessdrawCell(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 tocell
- Cell being renderedcolumnIndex
- Column index of the cell being renderedrowIndex
- Row index of the cell being renderedisSelected
- Set totrue
if the cell is currently selected by the usertextGUIGraphics
-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 customizeDefaultTableCellRenderer
. UnlessdrawCell(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 tocell
- Cell being renderedcolumnIndex
- Column index of the cell being renderedrowIndex
- Row index of the cell being renderedisSelected
- Set totrue
if the cell is currently selected by the usertextGUIGraphics
-TextGUIGraphics
object for the cell, already having been prepared with styling
-
getContent
protected java.lang.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.
-
-