int viewLine = Math.max(startLine - (numRowsVisible / 2), 0);
int viewLine = Math.max(startLine - (numRowsVisible > 0 ? numRowsVisible / 2 : 0), 0);
            public void run() {                // Highlight the lines from the source annotation.                // Note that the source lines start at 1, while the line numbers                // in the text area start at 0.                try {                    int startLine = srcLine.getStartLine() - 1;                    int endLine = srcLine.getEndLine();		    // Compute number of rows visible.		    // What a colossal pain in the ass this is.		    // You'd think there would be a convenient method to		    // return this information, but no.		    JViewport viewport = sourceTextAreaScrollPane.getViewport();		    Rectangle viewportRect = viewport.getViewRect();		    int height = sourceTextArea.getHeight();		    int topRow = sourceTextArea.getLineOfOffset(sourceTextArea.viewToModel(viewportRect.getLocation()));		    int bottomRow = sourceTextArea.getLineOfOffset(			sourceTextArea.viewToModel(new Point(viewportRect.x, (viewportRect.y + viewportRect.height) - 1)));		    int numRowsVisible = bottomRow - topRow;                                        // Scroll the window so the beginning of the		    // annotation text will be (approximately) centered.                    int viewLine = Math.max(startLine - (numRowsVisible / 2), 0);                    int viewBegin = sourceTextArea.getLineStartOffset(viewLine);                    Rectangle viewRect = sourceTextArea.modelToView(viewBegin);                    viewport.setViewPosition(new Point(viewRect.x, viewRect.y));                                        // Select (and highlight) the annotation.                    int selBegin = sourceTextArea.getLineStartOffset(startLine);                    int selEnd = sourceTextArea.getLineStartOffset(endLine);                    sourceTextArea.select(selBegin, selEnd);                    sourceTextArea.getCaret().setSelectionVisible(true);                } catch (javax.swing.text.BadLocationException e) {                    logger.logMessage(ConsoleLogger.ERROR, e.toString());                }            }