public void scrollLinesToVisible ( int startLine , int endLine , Collection < Integer > otherLines ) { int startY , endY ; try { startY = lineToY ( startLine ) ; } catch ( BadLocationException ble ) { if ( MainFrame . GUI2_DEBUG ) { ble . printStackTrace ( ) ; } return ; // give up } try { endY = lineToY ( endLine ) ; } catch ( BadLocationException ble ) { endY = startY ; // better than nothing } int max = parentHeight ( ) - 0 ; if ( endY - startY > max ) { endY = startY + max ; } else if ( otherLines != null && otherLines . size ( ) > 0 ) { int origin = startY + endY / 2 ; PriorityQueue < Integer > pq = new PriorityQueue <> ( otherLines . size ( ) , new DistanceComparator ( origin ) ) ; for ( int line : otherLines ) { int otherY ; try { otherY = lineToY ( line ) ; } catch ( BadLocationException ble ) { continue ; // give up on this one } pq . add ( otherY ) ; } while ( ! pq . isEmpty ( ) ) { int y = pq . remove ( ) ; int lo = Math . min ( startY , y ) ; int hi = Math . max ( endY , y ) ; if ( hi - lo > max ) { break ; } else { startY = lo ; endY = hi ; } } } if ( endY - startY > max ) { endY = startY + max ; } scrollYToVisibleImpl ( ( startY + endY ) / 2 , max / 2 ) ; }
scroll the specified primary lines into view along with as many of the other lines as is convenient