public int calcComponentPageHeight ( ) { remainingComponentHeight = remainingComponentHeight + this . checkComponentHeight ( ) ; if ( remainingComponentHeight <= remainingPageHeight ) return remainingComponentHeight ; if ( currentComponent == null ) return 0 ; // Never if ( ! ( currentComponent instanceof Container ) ) return 0 ; // Never if ( currentComponent instanceof JTable ) { int rowHeight = ( ( JTable ) currentComponent ) . getRowHeight ( ) ; int currentComponentPageBreak = componentStartYLocation + remainingPageHeight ; int currentComponentPageRow = ( int ) ( currentComponentPageBreak / rowHeight ) ; return remainingPageHeight - ( currentComponentPageBreak - currentComponentPageRow * rowHeight ) ; } int lastComponentPageHeight = 0 ; int y = 0 ; int maxLowerBreak = ( int ) ( pageHeight * MAX_LOWER_BREAK ) ; Component component = null ; for ( y = remainingPageHeight ; y > remainingPageHeight - maxLowerBreak ; y -- ) { int x = 0 ; for ( x = 0 ; x < currentComponent . getWidth ( ) ; x ++ ) { component = ( ( Container ) currentComponent ) . getComponentAt ( x , componentStartYLocation + y ) ; if ( component != null ) if ( component != currentComponent ) if ( component . getY ( ) + component . getHeight ( ) - 1 != y ) // Don't count last line break ; // This line contains a component, don't break here (continue looking) } if ( x == currentComponent . getWidth ( ) ) break ; // White space thru this whole line, use this as a break if ( component != null ) lastComponentPageHeight = Math . max ( lastComponentPageHeight , component . getY ( ) - 1 ) ; } if ( y == remainingPageHeight - maxLowerBreak ) { // Did not find a break, try another way if ( ( lastComponentPageHeight == 0 ) || ( lastComponentPageHeight < pageHeight - maxLowerBreak ) ) y = pageHeight ; // No break found, break at the end of the page (in the middle of a component) else y = lastComponentPageHeight ; // No break found, use the start of the lowest component } return y ; }
Calculate the remaining height of this component on this page . This is used to calculate a smart page break that does not split a control between pages .