Module com.googlecode.lanterna
Class DefaultTableRenderer<V>
java.lang.Object
com.googlecode.lanterna.gui2.table.DefaultTableRenderer<V>
- Type Parameters:
V- Type of data stored in each table cell
- All Implemented Interfaces:
ComponentRenderer<Table<V>>,InteractableRenderer<Table<V>>,TableRenderer<V>
Default implementation of
TableRenderer- Author:
- Martin
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddrawComponent(TextGUIGraphics graphics, Table<V> table) Using the supplied graphics object, draws the component passed in.booleangetCursorLocation(Table<V> component) getPreferredSize(Table<V> table) Given the supplied component, how large does this renderer want the component to be?intReturns the index of the first visible column with the renderers current stateintReturns the index of the first visible row with the renderers current stateintReturns the number of rows that could be drawn on the last draw operation.booleanvoidsetAllowPartialColumn(boolean allowPartialColumn) voidsetCellHorizontalBorderStyle(TableCellBorderStyle cellHorizontalBorderStyle) Sets the style to be used when horizontally separating table cells from each other.voidsetCellVerticalBorderStyle(TableCellBorderStyle cellVerticalBorderStyle) Sets the style to be used when vertically separating table cells from each other.voidsetExpandableColumns(Collection<Integer> expandableColumns) Sets the list of columns (by index, where 0 is the first column) that can be expanded, should the drawable area be larger than the table is requesting.voidsetHeaderHorizontalBorderStyle(TableCellBorderStyle headerHorizontalBorderStyle) Sets the style to be used when separating the table header labels from each other.voidsetHeaderVerticalBorderStyle(TableCellBorderStyle headerVerticalBorderStyle) Sets the style to be used when separating the table header row from the actual "data" cells below.voidsetScrollBarsHidden(boolean scrollBarsHidden) voidsetViewLeftColumn(int viewLeftColumn) Modifies which column is the first visible, this may be overwritten depending on the circumstances when drawing the table.voidsetViewTopRow(int viewTopRow) Modifies which row is the first visible, this may be overwritten depending on the circumstances when drawing the table.
-
Constructor Details
-
DefaultTableRenderer
public DefaultTableRenderer()Default constructor
-
-
Method Details
-
setHeaderVerticalBorderStyle
Sets the style to be used when separating the table header row from the actual "data" cells below. This will cause a new line to be added under the header labels, unless set toTableCellBorderStyle.None.- Parameters:
headerVerticalBorderStyle- Style to use to separate Table header from body
-
setHeaderHorizontalBorderStyle
Sets the style to be used when separating the table header labels from each other. This will cause a new column to be added in between each label, unless set toTableCellBorderStyle.None.- Parameters:
headerHorizontalBorderStyle- Style to use when separating header columns horizontally
-
setCellVerticalBorderStyle
Sets the style to be used when vertically separating table cells from each other. This will cause a new line to be added between every row, unless set toTableCellBorderStyle.None.- Parameters:
cellVerticalBorderStyle- Style to use to separate table cells vertically
-
setCellHorizontalBorderStyle
Sets the style to be used when horizontally separating table cells from each other. This will cause a new column to be added between every row, unless set toTableCellBorderStyle.None.- Parameters:
cellHorizontalBorderStyle- Style to use to separate table cells horizontally
-
setExpandableColumns
Sets the list of columns (by index, where 0 is the first column) that can be expanded, should the drawable area be larger than the table is requesting.- Parameters:
expandableColumns- Collection of indexes for expandable columns
-
isScrollBarsHidden
public boolean isScrollBarsHidden()- Specified by:
isScrollBarsHiddenin interfaceTableRenderer<V>
-
setScrollBarsHidden
public void setScrollBarsHidden(boolean scrollBarsHidden) - Specified by:
setScrollBarsHiddenin interfaceTableRenderer<V>
-
getVisibleRowsOnLastDraw
public int getVisibleRowsOnLastDraw()Returns the number of rows that could be drawn on the last draw operation. If the table doesn't have any visible row count set throughTable.setVisibleRows(int), this is the only way to find out exactly how large the table ended up. But even if you did set the number of visible rows explicitly, due to terminal size constraints the actually drawn size might have been different.- Specified by:
getVisibleRowsOnLastDrawin interfaceTableRenderer<V>- Returns:
- Number of rows that could be drawn on the last UI update call, will also return 0 if the table has not yet been drawn out
-
getViewTopRow
public int getViewTopRow()Description copied from interface:TableRendererReturns the index of the first visible row with the renderers current state- Specified by:
getViewTopRowin interfaceTableRenderer<V>- Returns:
- Index of the first visible row of the table
-
setViewTopRow
public void setViewTopRow(int viewTopRow) Description copied from interface:TableRendererModifies which row is the first visible, this may be overwritten depending on the circumstances when drawing the table.- Specified by:
setViewTopRowin interfaceTableRenderer<V>- Parameters:
viewTopRow- First row to be displayed when drawing the table
-
getViewLeftColumn
public int getViewLeftColumn()Description copied from interface:TableRendererReturns the index of the first visible column with the renderers current state- Specified by:
getViewLeftColumnin interfaceTableRenderer<V>- Returns:
- Index of the first visible column of the table
-
setViewLeftColumn
public void setViewLeftColumn(int viewLeftColumn) Description copied from interface:TableRendererModifies which column is the first visible, this may be overwritten depending on the circumstances when drawing the table.- Specified by:
setViewLeftColumnin interfaceTableRenderer<V>- Parameters:
viewLeftColumn- First column to be displayed when drawing the table
-
setAllowPartialColumn
public void setAllowPartialColumn(boolean allowPartialColumn) - Specified by:
setAllowPartialColumnin interfaceTableRenderer<V>- Parameters:
allowPartialColumn- when not all columns fit on the screen, whether to render part of a column, or skip rendering that column entirely
-
getAllowPartialColumn
public boolean getAllowPartialColumn()- Specified by:
getAllowPartialColumnin interfaceTableRenderer<V>- See Also:
-
getPreferredSize
Description copied from interface:ComponentRendererGiven the supplied component, how large does this renderer want the component to be? Notice that this is the responsibility of the renderer and not the component itself, since the component has no idea what its visual representation looks like.- Specified by:
getPreferredSizein interfaceComponentRenderer<V>- Specified by:
getPreferredSizein interfaceTableRenderer<V>- Parameters:
table- Component to calculate the preferred size of- Returns:
- The size this renderer would like the component to take up
-
getCursorLocation
- Specified by:
getCursorLocationin interfaceInteractableRenderer<V>
-
drawComponent
Description copied from interface:ComponentRendererUsing the supplied graphics object, draws the component passed in.- Specified by:
drawComponentin interfaceComponentRenderer<V>- Specified by:
drawComponentin interfaceTableRenderer<V>- Parameters:
graphics- Graphics object to use for drawingtable- Component to draw
-