if (possibleHeight != this.minimumOrigin.getY()) {
int delta = this.minimumOrigin.getY() - possibleHeight;
newOriginY = newOriginY - delta;
// as the height of the other split viewport has changed, we
// need to update the minimum height too
this.minimumOrigin = new PixelCoordinate(this.minimumOrigin.getX(),
this.minimumOrigin.getY() - delta);
}
} else {
int originY = this.savedOrigin.getY();
int visibleHeight = calculateVisibleHeight(originY);
int clientAreaHeight = getClientAreaHeight();
if (visibleHeight < clientAreaHeight) {
int possibleHeight = 0;
int rowCount = getMaxRowPosition() >= 0 ? getMaxRowPosition()
: this.scrollableLayer.getRowCount();
for (int row = rowPosition; row < rowCount; row++) {
possibleHeight += this.scrollableLayer
.getRowHeightByPosition(row);
}
if (possibleHeight >= clientAreaHeight) {
newOriginY = this.scrollableLayer
.getStartYOfRowPosition(rowPosition);
} else {
newOriginY = this.scrollableLayer.getHeight() - clientAreaHeight;
}
newOriginY = Math.max(0, newOriginY);
}
}
this.savedOrigin = new PixelCoordinate(this.savedOrigin.getX(), newOriginY);
}