protected void generateTitleBand ( ) { log . debug ( "Generating title band..." ) ; JRDesignBand band = ( JRDesignBand ) getDesign ( ) . getPageHeader ( ) ; int yOffset = 0 ; //If title is not present then subtitle will be ignored if ( getReport ( ) . getTitle ( ) == null ) return ; if ( band != null && ! getDesign ( ) . isTitleNewPage ( ) ) { //Title and subtitle comes afer the page header yOffset = band . getHeight ( ) ; } else { band = ( JRDesignBand ) getDesign ( ) . getTitle ( ) ; if ( band == null ) { band = new JRDesignBand ( ) ; getDesign ( ) . setTitle ( band ) ; } } JRDesignExpression printWhenExpression = new JRDesignExpression ( ) ; printWhenExpression . setValueClass ( Boolean . class ) ; printWhenExpression . setText ( EXPRESSION_TRUE_WHEN_FIRST_PAGE ) ; JRDesignTextField title = new JRDesignTextField ( ) ; JRDesignExpression exp = new JRDesignExpression ( ) ; if ( getReport ( ) . isTitleIsJrExpression ( ) ) { exp . setText ( getReport ( ) . getTitle ( ) ) ; } else { exp . setText ( "\"" + Utils . escapeTextForExpression ( getReport ( ) . getTitle ( ) ) + "\"" ) ; } exp . setValueClass ( String . class ) ; title . setExpression ( exp ) ; title . setWidth ( getReport ( ) . getOptions ( ) . getPrintableWidth ( ) ) ; title . setHeight ( getReport ( ) . getOptions ( ) . getTitleHeight ( ) ) ; title . setY ( yOffset ) ; title . setPrintWhenExpression ( printWhenExpression ) ; title . setRemoveLineWhenBlank ( true ) ; applyStyleToElement ( getReport ( ) . getTitleStyle ( ) , title ) ; title . setStretchType ( StretchTypeEnum . NO_STRETCH ) ; band . addElement ( title ) ; JRDesignTextField subtitle = new JRDesignTextField ( ) ; if ( getReport ( ) . getSubtitle ( ) != null ) { JRDesignExpression exp2 = new JRDesignExpression ( ) ; exp2 . setText ( "\"" + getReport ( ) . getSubtitle ( ) + "\"" ) ; exp2 . setValueClass ( String . class ) ; subtitle . setExpression ( exp2 ) ; subtitle . setWidth ( getReport ( ) . getOptions ( ) . getPrintableWidth ( ) ) ; subtitle . setHeight ( getReport ( ) . getOptions ( ) . getSubtitleHeight ( ) ) ; subtitle . setY ( title . getY ( ) + title . getHeight ( ) ) ; subtitle . setPrintWhenExpression ( printWhenExpression ) ; subtitle . setRemoveLineWhenBlank ( true ) ; applyStyleToElement ( getReport ( ) . getSubtitleStyle ( ) , subtitle ) ; title . setStretchType ( StretchTypeEnum . NO_STRETCH ) ; band . addElement ( subtitle ) ; } }
Adds title and subtitle to the TitleBand when it applies . If title is not present then subtitle will be ignored