*/
public void setColSpan(int row, int cell, int newSpan) {
// update cell count
int oldSpan;
{
Dimension span = m_cellToSpan.get(new Point(cell, row));
oldSpan = span.width;
// we can change span: 1 -> some value; or some value -> 1
Assert.isTrue(oldSpan == 1 || newSpan == 1);
// set new span for cell
span.width = newSpan;
}
// update count of cells (they will be filled by fillAllCells() method)
updateCellCount(row, oldSpan - newSpan);
// update span table
{
int delta = oldSpan - newSpan;
if (oldSpan == 1) {
// remove cells that will be filled
for (int i = cell + 1; i < cell + newSpan; i++) {
m_cellToSpan.remove(new Point(i, row));
}
// update cells after current on same row
for (Point key : m_cellToSpan.keySet()) {
if (key.y == row && key.x > cell) {
key.x += delta;
}
}
} else {
// update cells after current on same row
for (Point key : m_cellToSpan.keySet()) {
if (key.y == row && key.x > cell) {
key.x += delta;
}
}
// add cells that are not filled anymore
for (int i = cell + 1; i < cell + oldSpan; i++) {
m_cellToSpan.put(new Point(i, row), new Dimension(1, 1));
}
}
// rehash
rehashMap(m_cellToSpan);
}