}
Rectangle clipRc = fixRectangle(oldRc, borderInsets);
//calc rectangle
SheetModel model = table.getModel();
CellPosition origin0 = getTopLeft(clipRc);
CellPosition originN = getBottomRight(clipRc);
if(origin0 == null || originN == null) {
//no cells
return;
}
int yBase = borderInsets.top;
for (int iRow = 0; iRow < origin0.row; iRow++) {
yBase += model.getRow(iRow).getHeight();
}
int xBase = borderInsets.left;
for (int iCol = 0; iCol < origin0.col; iCol++) {
xBase += model.getColumn(iCol).getWidth();
}
Spanned spanned[] = new Spanned[originN.col - origin0.col + 1];
for (int iRow = origin0.row; iRow <= originN.row; iRow++) {
int xLocalBase = xBase;
for (int iCol = origin0.col; iCol <= originN.col; ) { /// increment at end
//check if spanned
int index = iCol - origin0.col;
if(spanned[index] != null) {
spanned[index].rows--;
iCol += spanned[index].cols;
xLocalBase += spanned[index].width;
if(spanned[index].rows == 0) {
spanned[index] = null;
}
continue;
}
//define dimensions
CellPosition origin = model.getOrigin(new CellPosition(iRow, iCol));
Dimension size = model.getSize(origin);
Rectangle rc = new Rectangle();
//y offset for spanned cells may be > 0
rc.y = yBase;
for(int i=0; i < iRow-origin.row; i++) {