ArrayFieldModel model = (ArrayFieldModel)getModel();
Stroke defaultStroke = ((Graphics2D)g).getStroke();
for (int row = rowCount; row <= currentHeightOfAllRows/rowHeight; row++) {
int xPos = 0; // PM this needs to be zero because the line does not repaint correctly
for (int col = 0; col < colModel.getColumnCount(); col++) {
ArrayColumn column = (ArrayColumn)this.getColumnModel().getColumn(col);
Color backgroundColour = this.getBackground();
// Rectangle place holders
g.setColor(backgroundColour);
g.fillRect(xPos, row*rowHeight, column.getWidth(), rowHeight);
// Details in rectangle place holders
if (this.paintEmptyRowRectangles && rowHeight > inset*2 && column.getWidth() > inset*2) {
// If we can append a row, we are on the last row, and this column is editable
if (this.isAllowsAppendAndEditable() && row == rowCount && model.isColumnEditable(col)) {
TableCellRenderer renderer = ((ArrayFieldCellRenderer)column.getCellRenderer()).getRenderer();
// The renderer supports painting in an empty row. CraigM:20/01/2009.
if (renderer instanceof ArrayFieldEmptyCellRenderer) {
// Paint an editable row (not faded)
// TF:27/11/2009:Changed this to pass in the width, which allows us to draw the proper image when the column is resized.
BufferedImage img = ((ArrayFieldEmptyCellRenderer)renderer).getImage(column.getWidth());
g.drawImage(img, xPos + ((column.getWidth() - img.getWidth()) / 2), (row*rowHeight) + ((rowHeight - img.getHeight()) / 2), null);
}
// Draw a filled white rectangle
else {
Color emptyCellColor = backgroundColour.equals(Color.gray) ? Color.lightGray : Color.gray;
g.setColor(emptyCellColor);
g.drawRect(xPos+inset, (row*rowHeight)+inset, column.getWidth()-(inset*2), rowHeight-(inset*2));
}
}
else {
TableCellRenderer renderer = ((ArrayFieldCellRenderer)column.getCellRenderer()).getRenderer();
// The renderer supports painting in an empty row. CraigM:20/01/2009.
if (renderer instanceof ArrayFieldEmptyCellRenderer) {
// These are non editable rows, so fade them out a little
((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
BufferedImage img = ((ArrayFieldEmptyCellRenderer)renderer).getImage(column.getWidth());
g.drawImage(img, xPos + ((column.getWidth() - img.getWidth()) / 2), (row*rowHeight) + ((rowHeight - img.getHeight()) / 2), null);
((Graphics2D)g).setComposite(AlphaComposite.Src);
}
else {
Color emptyCellColor = backgroundColour.equals(Color.lightGray) ? Color.gray : Color.lightGray;
g.setColor(emptyCellColor);
((Graphics2D)g).setStroke(dashed);
g.drawRect(xPos+inset, (row*rowHeight)+inset, column.getWidth()-(inset*2), rowHeight-(inset*2));
}
}
}
// --- End ---
xPos += column.getWidth();
}
}
((Graphics2D)g).setStroke(defaultStroke);
}
}