columnIndex < columnCount; columnIndex++) {
TableView.Column column = columns.get(columnIndex);
int columnWidth = columnWidths.get(columnIndex);
String columnName = column.getName();
SortDirection sortDirection = tableView.getSort().get(columnName);
if (sortDirection != null) {
graphics.fillRect(columnX, 0, columnWidth, height);
}
columnX += columnWidth + 1;
}
}
// Paint the table contents
for (int rowIndex = rowStart; rowIndex <= rowEnd; rowIndex++) {
Object rowData = tableData.get(rowIndex);
boolean rowHighlighted = (rowIndex == highlightedIndex
&& tableView.getSelectMode() != TableView.SelectMode.NONE);
boolean rowSelected = tableView.isRowSelected(rowIndex);
boolean rowDisabled = tableView.isRowDisabled(rowIndex);
int rowY = getRowY(rowIndex);
int rowHeight = getRowHeight(rowIndex);
// Paint selection state
Color rowBackgroundColor = null;
if (rowSelected) {
rowBackgroundColor = (tableView.isFocused())
? this.selectionBackgroundColor : inactiveSelectionBackgroundColor;
} else {
if (rowHighlighted && showHighlight && !rowDisabled) {
rowBackgroundColor = highlightBackgroundColor;
}
}
if (rowBackgroundColor != null) {
graphics.setPaint(rowBackgroundColor);
graphics.fillRect(0, rowY, width, rowHeight);
}
// Paint the cells
columnX = 0;
for (int columnIndex = 0, columnCount = columns.getLength();
columnIndex < columnCount; columnIndex++) {
TableView.Column column = columns.get(columnIndex);
TableView.CellRenderer cellRenderer = column.getCellRenderer();
int columnWidth = columnWidths.get(columnIndex);
Graphics2D rendererGraphics = (Graphics2D)graphics.create(columnX, rowY,
columnWidth, rowHeight);
cellRenderer.render(rowData, rowIndex, columnIndex, tableView, column.getName(),
rowSelected, rowHighlighted, rowDisabled);
cellRenderer.setSize(columnWidth, rowHeight);
cellRenderer.paint(rendererGraphics);
rendererGraphics.dispose();
columnX += columnWidth + 1;
}
}
// Paint the vertical grid lines
graphics.setPaint(verticalGridColor);
if (showVerticalGridLines) {
columnX = 0;
for (int columnIndex = 0, columnCount = columns.getLength();
columnIndex < columnCount; columnIndex++) {
columnX += columnWidths.get(columnIndex);
if (columnIndex < columnCount - 1
|| includeTrailingVerticalGridLine) {
GraphicsUtilities.drawLine(graphics, columnX, 0, height, Orientation.VERTICAL);
}
columnX++;
}
}
// Paint the horizontal grid lines
graphics.setPaint(horizontalGridColor);
if (showHorizontalGridLines) {
int rowCount = tableData.getLength();
for (int rowIndex = rowStart; rowIndex <= rowEnd; rowIndex++) {
int gridY = getRowY(rowIndex + 1) - 1;
if (rowIndex < rowCount - 1
|| includeTrailingHorizontalGridLine) {
GraphicsUtilities.drawLine(graphics, 0, gridY, width, Orientation.HORIZONTAL);
}
}
if (columnSelectionHorizontalGridColor != null) {
graphics.setColor(columnSelectionHorizontalGridColor);
columnX = 0;
for (int columnIndex = 0, columnCount = columns.getLength();
columnIndex < columnCount; columnIndex++) {
TableView.Column column = columns.get(columnIndex);
int columnWidth = columnWidths.get(columnIndex);
String columnName = column.getName();
SortDirection sortDirection = tableView.getSort().get(columnName);
if (sortDirection != null) {
for (int rowIndex = rowStart; rowIndex <= rowEnd; rowIndex++) {
int gridY = getRowY(rowIndex + 1) - 1;
if (rowIndex < rowCount - 1