|
|
@ -101,44 +101,35 @@ public class DarkListUI extends DarkListUIBridge { |
|
|
|
|
|
|
|
|
|
|
|
int startColumn, endColumn; |
|
|
|
int startColumn, endColumn; |
|
|
|
if (c.getComponentOrientation().isLeftToRight()) { |
|
|
|
if (c.getComponentOrientation().isLeftToRight()) { |
|
|
|
startColumn = convertLocationToColumn(paintBounds.x, |
|
|
|
startColumn = convertLocationToColumn(paintBounds.x, paintBounds.y); |
|
|
|
paintBounds.y); |
|
|
|
endColumn = convertLocationToColumn(paintBounds.x + paintBounds.width, paintBounds.y); |
|
|
|
endColumn = convertLocationToColumn(paintBounds.x + |
|
|
|
|
|
|
|
paintBounds.width, |
|
|
|
|
|
|
|
paintBounds.y); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
startColumn = convertLocationToColumn(paintBounds.x + |
|
|
|
startColumn = convertLocationToColumn(paintBounds.x + paintBounds.width, paintBounds.y); |
|
|
|
paintBounds.width, |
|
|
|
endColumn = convertLocationToColumn(paintBounds.x, paintBounds.y); |
|
|
|
paintBounds.y); |
|
|
|
|
|
|
|
endColumn = convertLocationToColumn(paintBounds.x, |
|
|
|
|
|
|
|
paintBounds.y); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
int maxY = paintBounds.y + paintBounds.height; |
|
|
|
int maxY = paintBounds.y + paintBounds.height; |
|
|
|
|
|
|
|
int maxX = paintBounds.x + paintBounds.width; |
|
|
|
int leadIndex = adjustIndex(list.getLeadSelectionIndex(), list); |
|
|
|
int leadIndex = adjustIndex(list.getLeadSelectionIndex(), list); |
|
|
|
int rowIncrement = (layoutOrientation == JList.HORIZONTAL_WRAP) ? |
|
|
|
int rowIncrement = (layoutOrientation == JList.HORIZONTAL_WRAP) ? columnCount : 1; |
|
|
|
columnCount : 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int colCounter = startColumn; colCounter <= endColumn; |
|
|
|
Rectangle rowBounds; |
|
|
|
colCounter++) { |
|
|
|
for (int colCounter = startColumn; colCounter <= endColumn; colCounter++) { |
|
|
|
// And then how many rows in this columnn
|
|
|
|
|
|
|
|
int row = convertLocationToRowInColumn(paintBounds.y, colCounter); |
|
|
|
int row = convertLocationToRowInColumn(paintBounds.y, colCounter); |
|
|
|
int rowCount = Math.max(rowsPerColumn, getRowCount(colCounter)); |
|
|
|
int rowCount = Math.max(rowsPerColumn, getRowCount(colCounter)); |
|
|
|
int index = getModelIndex(colCounter, row); |
|
|
|
int index = getModelIndex(colCounter, row); |
|
|
|
Rectangle rowBounds = getCellBounds(list, index, index); |
|
|
|
rowBounds = getCellBounds(list, index); |
|
|
|
|
|
|
|
|
|
|
|
if (rowBounds == null) { |
|
|
|
if (rowBounds == null) { |
|
|
|
// Not valid, bail!
|
|
|
|
// Not valid, bail!
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int bgWidth = colCounter == endColumn ? maxX - rowBounds.x : 0; |
|
|
|
while (row < rowCount && rowBounds.y < maxY) { |
|
|
|
while (row < rowCount && rowBounds.y < maxY) { |
|
|
|
rowBounds.height = getHeight(colCounter, row); |
|
|
|
rowBounds.height = getHeight(colCounter, row); |
|
|
|
g.setClip(rowBounds.x, rowBounds.y, rowBounds.width, |
|
|
|
g.setClip(rowBounds.x, rowBounds.y, bgWidth > 0 ? bgWidth : rowBounds.width, rowBounds.height); |
|
|
|
rowBounds.height); |
|
|
|
g.clipRect(paintBounds.x, paintBounds.y, paintBounds.width, paintBounds.height); |
|
|
|
g.clipRect(paintBounds.x, paintBounds.y, paintBounds.width, |
|
|
|
paintCell(g, index, rowBounds, renderer, dataModel, selModel, leadIndex, row, bgWidth); |
|
|
|
paintBounds.height); |
|
|
|
|
|
|
|
paintCell(g, index, rowBounds, renderer, dataModel, selModel, |
|
|
|
|
|
|
|
leadIndex, row); |
|
|
|
|
|
|
|
rowBounds.y += rowBounds.height; |
|
|
|
rowBounds.y += rowBounds.height; |
|
|
|
index += rowIncrement; |
|
|
|
index += rowIncrement; |
|
|
|
row++; |
|
|
|
row++; |
|
|
@ -151,7 +142,8 @@ public class DarkListUI extends DarkListUIBridge { |
|
|
|
protected void paintCell(final Graphics g, final int index, final Rectangle rowBounds, |
|
|
|
protected void paintCell(final Graphics g, final int index, final Rectangle rowBounds, |
|
|
|
final ListCellRenderer<Object> cellRenderer, |
|
|
|
final ListCellRenderer<Object> cellRenderer, |
|
|
|
final ListModel<Object> dataModel, |
|
|
|
final ListModel<Object> dataModel, |
|
|
|
final ListSelectionModel selModel, final int leadIndex, final int row) { |
|
|
|
final ListSelectionModel selModel, final int leadIndex, final int row, |
|
|
|
|
|
|
|
final int bgWidth) { |
|
|
|
boolean empty = index >= list.getModel().getSize(); |
|
|
|
boolean empty = index >= list.getModel().getSize(); |
|
|
|
Object value = empty ? null : dataModel.getElementAt(index); |
|
|
|
Object value = empty ? null : dataModel.getElementAt(index); |
|
|
|
boolean cellHasFocus = list.hasFocus() && (index == leadIndex); |
|
|
|
boolean cellHasFocus = list.hasFocus() && (index == leadIndex); |
|
|
@ -162,19 +154,19 @@ public class DarkListUI extends DarkListUIBridge { |
|
|
|
int cw = rowBounds.width; |
|
|
|
int cw = rowBounds.width; |
|
|
|
int ch = rowBounds.height; |
|
|
|
int ch = rowBounds.height; |
|
|
|
|
|
|
|
|
|
|
|
if (empty) { |
|
|
|
if (empty || bgWidth > 0) { |
|
|
|
boolean alternativeRow = Boolean.TRUE.equals(list.getClientProperty(KEY_ALTERNATE_ROW_COLOR)); |
|
|
|
boolean alternativeRow = Boolean.TRUE.equals(list.getClientProperty(KEY_ALTERNATE_ROW_COLOR)); |
|
|
|
Color alternativeRowColor = UIManager.getColor("List.alternateRowBackground"); |
|
|
|
Color alternativeRowColor = UIManager.getColor("List.alternateRowBackground"); |
|
|
|
Color normalColor = list.getBackground(); |
|
|
|
Color normalColor = list.getBackground(); |
|
|
|
Color background = alternativeRow && row % 2 == 1 ? alternativeRowColor : normalColor; |
|
|
|
Color background = alternativeRow && row % 2 == 1 ? alternativeRowColor : normalColor; |
|
|
|
Color c = g.getColor(); |
|
|
|
Color c = g.getColor(); |
|
|
|
g.setColor(background); |
|
|
|
g.setColor(background); |
|
|
|
g.fillRect(cx, cy, cw, ch); |
|
|
|
g.fillRect(cx, cy, bgWidth > 0 ? bgWidth : cw, ch); |
|
|
|
g.setColor(c); |
|
|
|
g.setColor(c); |
|
|
|
} else { |
|
|
|
} |
|
|
|
|
|
|
|
if (!empty) { |
|
|
|
Component rendererComponent = |
|
|
|
Component rendererComponent = |
|
|
|
cellRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
|
|
|
cellRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
|
|
|
|
|
|
|
|
|
|
|
if (Boolean.TRUE.equals(list.getClientProperty(KEY_SHRINK_WRAP))) { |
|
|
|
if (Boolean.TRUE.equals(list.getClientProperty(KEY_SHRINK_WRAP))) { |
|
|
|
// Shrink renderer to preferred size. This is mostly used on Windows
|
|
|
|
// Shrink renderer to preferred size. This is mostly used on Windows
|
|
|
|
// where selection is only shown around the file name, instead of
|
|
|
|
// where selection is only shown around the file name, instead of
|
|
|
@ -185,7 +177,6 @@ public class DarkListUI extends DarkListUIBridge { |
|
|
|
} |
|
|
|
} |
|
|
|
cw = w; |
|
|
|
cw = w; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
rendererPane.paintComponent(g, rendererComponent, list, cx, cy, cw, ch, true); |
|
|
|
rendererPane.paintComponent(g, rendererComponent, list, cx, cy, cw, ch, true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|