if (possibleWidth != this.minimumOrigin.getX()) {
int delta = this.minimumOrigin.getX() - possibleWidth;
newOriginX = newOriginX - delta;
// as the width of the other split viewport has changed, we need
// to update the minimum width too
this.minimumOrigin = new PixelCoordinate(this.minimumOrigin.getX()
- delta, this.minimumOrigin.getY());
}
} else {
int originX = this.savedOrigin.getX();
int visibleWidth = calculateVisibleWidth(originX);
int clientAreaWidth = getClientAreaWidth();
if (visibleWidth < clientAreaWidth) {
int possibleWidth = 0;
int columnCount = getMaxColumnPosition() >= 0 ? getMaxColumnPosition()
: this.scrollableLayer.getColumnCount();
for (int col = columnPosition; col < columnCount; col++) {
possibleWidth += this.scrollableLayer
.getColumnWidthByPosition(col);
}
if (possibleWidth >= clientAreaWidth) {
newOriginX = this.scrollableLayer
.getStartXOfColumnPosition(columnPosition);
} else {
newOriginX = this.scrollableLayer.getWidth() - clientAreaWidth;
}
newOriginX = Math.max(0, newOriginX);
}
}
this.savedOrigin = new PixelCoordinate(newOriginX, this.savedOrigin.getY());
}