private int getViewportOffset(int row) {

		// Do some object checking up front and exit if these aren't set.
		if (!isStateValid()) {
			return 0;
		}

		// First figure out which rows in the table our viewport is bounding.
		int viewportRowStart = viewport.getViewPosition().y / table.getRowHeight();
		int viewportRowEnd = viewportRowStart + viewport.getHeight() / table.getRowHeight();

		// Now calculate if the given row is in, above, or below the viewport.
		if (row < viewportRowStart) {
			return row - viewportRowStart;
		}
		else if (row > viewportRowEnd) {
			return row - viewportRowEnd;
		}

		return 0;
	}
Returns how many rows the given row is above or below the current viewport. 

@param row

@return negative value if above the top of the viewport, positive value if below the bottom
        of the viewport, 0 if the line is already in the viewport.
Ghidra/Framework/Project/src/main/java/ghidra/framework/main/logviewer/ui/ViewportUtility.java