public int getScroll(RectBox visibleRect, int orientation, int direction) { int cellSize = this.getCellSize(); double scrollPos = 0.0D; if (orientation == 0) { if (direction < 0) { scrollPos = visibleRect.getMinX(); } else if (direction > 0) { scrollPos = visibleRect.getMaxX(); } } else if (direction < 0) { scrollPos = visibleRect.getMinY(); } else if (direction > 0) { scrollPos = visibleRect.getMaxY(); } int increment = Math.abs((int) Math.IEEEremainder(scrollPos, cellSize)); if (increment == 0) { increment = cellSize; } return increment; }