Source Code Cross Referenced for JRVerticalFiller.java in  » Report » jasperreports-2.0.1 » net » sf » jasperreports » engine » fill » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » jasperreports 2.0.1 » net.sf.jasperreports.engine.fill 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * ============================================================================
0003:         * GNU Lesser General Public License
0004:         * ============================================================================
0005:         *
0006:         * JasperReports - Free Java report-generating library.
0007:         * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
0008:         *
0009:         * This library is free software; you can redistribute it and/or
0010:         * modify it under the terms of the GNU Lesser General Public
0011:         * License as published by the Free Software Foundation; either
0012:         * version 2.1 of the License, or (at your option) any later version.
0013:         *
0014:         * This library is distributed in the hope that it will be useful,
0015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0017:         * Lesser General Public License for more details.
0018:         *
0019:         * You should have received a copy of the GNU Lesser General Public
0020:         * License along with this library; if not, write to the Free Software
0021:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
0022:         *
0023:         * JasperSoft Corporation
0024:         * 303 Second Street, Suite 450 North
0025:         * San Francisco, CA 94107
0026:         * http://www.jaspersoft.com
0027:         */
0028:        package net.sf.jasperreports.engine.fill;
0029:
0030:        import java.util.Iterator;
0031:
0032:        import org.apache.commons.logging.Log;
0033:        import org.apache.commons.logging.LogFactory;
0034:
0035:        import net.sf.jasperreports.engine.JRException;
0036:        import net.sf.jasperreports.engine.JRExpression;
0037:        import net.sf.jasperreports.engine.JRGroup;
0038:        import net.sf.jasperreports.engine.JRPrintElement;
0039:        import net.sf.jasperreports.engine.JRReport;
0040:        import net.sf.jasperreports.engine.JRRuntimeException;
0041:        import net.sf.jasperreports.engine.JRVariable;
0042:        import net.sf.jasperreports.engine.JasperReport;
0043:
0044:        /**
0045:         * @author Teodor Danciu (teodord@users.sourceforge.net)
0046:         * @version $Id: JRVerticalFiller.java 1807 2007-08-06 12:39:58Z teodord $
0047:         */
0048:        public class JRVerticalFiller extends JRBaseFiller {
0049:
0050:            private static final Log log = LogFactory
0051:                    .getLog(JRVerticalFiller.class);
0052:
0053:            /**
0054:             *
0055:             */
0056:            protected JRVerticalFiller(JasperReport jasperReport)
0057:                    throws JRException {
0058:                this (jasperReport, null, null);
0059:            }
0060:
0061:            /**
0062:             *
0063:             */
0064:            protected JRVerticalFiller(JasperReport jasperReport,
0065:                    JRBaseFiller parentFiller) throws JRException {
0066:                super (jasperReport, null, parentFiller);
0067:
0068:                setPageHeight(pageHeight);
0069:            }
0070:
0071:            /**
0072:             *
0073:             */
0074:            protected JRVerticalFiller(JasperReport jasperReport,
0075:                    JREvaluator evaluator, JRBaseFiller parentFiller)
0076:                    throws JRException {
0077:                super (jasperReport, evaluator, parentFiller);
0078:
0079:                setPageHeight(pageHeight);
0080:            }
0081:
0082:            /**
0083:             *
0084:             */
0085:            protected void setPageHeight(int pageHeight) {
0086:                this .pageHeight = pageHeight;
0087:
0088:                columnFooterOffsetY = pageHeight - bottomMargin;
0089:                if (pageFooter != null)
0090:                    columnFooterOffsetY -= pageFooter.getHeight();
0091:                if (columnFooter != null)
0092:                    columnFooterOffsetY -= columnFooter.getHeight();
0093:
0094:                lastPageColumnFooterOffsetY = pageHeight - bottomMargin;
0095:                if (lastPageFooter != null)
0096:                    lastPageColumnFooterOffsetY -= lastPageFooter.getHeight();
0097:                if (columnFooter != null)
0098:                    lastPageColumnFooterOffsetY -= columnFooter.getHeight();
0099:            }
0100:
0101:            /**
0102:             *
0103:             */
0104:            protected synchronized void fillReport() throws JRException {
0105:                setLastPageFooter(false);
0106:
0107:                if (next()) {
0108:                    fillReportStart();
0109:
0110:                    while (next()) {
0111:                        fillReportContent();
0112:                    }
0113:
0114:                    fillReportEnd();
0115:                } else {
0116:                    if (log.isDebugEnabled()) {
0117:                        log.debug("Fill " + fillerId + ": no data");
0118:                    }
0119:
0120:                    switch (whenNoDataType) {
0121:                    case JRReport.WHEN_NO_DATA_TYPE_ALL_SECTIONS_NO_DETAIL: {
0122:                        if (log.isDebugEnabled()) {
0123:                            log.debug("Fill " + fillerId + ": all sections");
0124:                        }
0125:
0126:                        scriptlet.callBeforeReportInit();
0127:                        calculator
0128:                                .initializeVariables(JRVariable.RESET_TYPE_REPORT);
0129:                        scriptlet.callAfterReportInit();
0130:
0131:                        printPage = newPage();
0132:                        addPage(printPage);
0133:                        setFirstColumn();
0134:                        offsetY = topMargin;
0135:
0136:                        fillBackground();
0137:
0138:                        fillTitle();
0139:
0140:                        fillPageHeader(JRExpression.EVALUATION_DEFAULT);
0141:
0142:                        fillColumnHeader(JRExpression.EVALUATION_DEFAULT);
0143:
0144:                        fillGroupHeaders(true);
0145:
0146:                        fillGroupFooters(true);
0147:
0148:                        fillSummary();
0149:
0150:                        break;
0151:                    }
0152:                    case JRReport.WHEN_NO_DATA_TYPE_BLANK_PAGE: {
0153:                        if (log.isDebugEnabled()) {
0154:                            log.debug("Fill " + fillerId + ": blank page");
0155:                        }
0156:
0157:                        printPage = newPage();
0158:                        addPage(printPage);
0159:                        break;
0160:                    }
0161:                    case JRReport.WHEN_NO_DATA_TYPE_NO_DATA_SECTION: {
0162:                        if (log.isDebugEnabled()) {
0163:                            log.debug("Fill " + fillerId + ": all sections");
0164:                        }
0165:
0166:                        scriptlet.callBeforeReportInit();
0167:                        calculator
0168:                                .initializeVariables(JRVariable.RESET_TYPE_REPORT);
0169:                        scriptlet.callAfterReportInit();
0170:
0171:                        printPage = newPage();
0172:                        addPage(printPage);
0173:                        setFirstColumn();
0174:                        offsetY = topMargin;
0175:
0176:                        fillBackground();
0177:
0178:                        fillNoData();
0179:
0180:                        break;
0181:
0182:                    }
0183:                    case JRReport.WHEN_NO_DATA_TYPE_NO_PAGES:
0184:                    default: {
0185:                        if (log.isDebugEnabled()) {
0186:                            log.debug("Fill " + fillerId + ": no pages");
0187:                        }
0188:                    }
0189:                    }
0190:                }
0191:
0192:                if (isSubreport()) {
0193:                    //if (
0194:                    //	columnIndex == 0 ||
0195:                    //	(columnIndex > 0 && printPageStretchHeight < offsetY + bottomMargin)
0196:                    //	)
0197:                    //{
0198:                    printPageStretchHeight = offsetY + bottomMargin;
0199:                    //}
0200:
0201:                    if (fillContext.isUsingVirtualizer()) {
0202:                        removePageIdentityDataProvider();
0203:                    }
0204:                }
0205:
0206:                if (fillContext.isIgnorePagination()) {
0207:                    jasperPrint.setPageHeight(offsetY + bottomMargin);
0208:                }
0209:            }
0210:
0211:            /**
0212:             *
0213:             */
0214:            private void fillReportStart() throws JRException {
0215:                scriptlet.callBeforeReportInit();
0216:                calculator.initializeVariables(JRVariable.RESET_TYPE_REPORT);
0217:                scriptlet.callAfterReportInit();
0218:
0219:                printPage = newPage();
0220:                addPage(printPage);
0221:                setFirstColumn();
0222:                offsetY = topMargin;
0223:
0224:                fillBackground();
0225:
0226:                fillTitle();
0227:
0228:                fillPageHeader(JRExpression.EVALUATION_DEFAULT);
0229:
0230:                fillColumnHeader(JRExpression.EVALUATION_DEFAULT);
0231:
0232:                fillGroupHeaders(true);
0233:
0234:                fillDetail();
0235:            }
0236:
0237:            /**
0238:             *
0239:             */
0240:            private void fillReportContent() throws JRException {
0241:                calculator.estimateGroupRuptures();
0242:
0243:                fillGroupFooters(false);
0244:
0245:                resolveGroupBoundElements(JRExpression.EVALUATION_OLD, false);
0246:                scriptlet.callBeforeGroupInit();
0247:                calculator.initializeVariables(JRVariable.RESET_TYPE_GROUP);
0248:                scriptlet.callAfterGroupInit();
0249:
0250:                fillGroupHeaders(false);
0251:
0252:                fillDetail();
0253:            }
0254:
0255:            /**
0256:             *
0257:             */
0258:            private void fillReportEnd() throws JRException {
0259:                fillGroupFooters(true);
0260:
0261:                fillSummary();
0262:            }
0263:
0264:            /**
0265:             *
0266:             */
0267:            private void fillTitle() throws JRException {
0268:                if (log.isDebugEnabled() && !title.isEmpty()) {
0269:                    log.debug("Fill " + fillerId + ": title");
0270:                }
0271:
0272:                title
0273:                        .evaluatePrintWhenExpression(JRExpression.EVALUATION_DEFAULT);
0274:
0275:                if (title.isToPrint()) {
0276:                    while (title.getHeight() > pageHeight - bottomMargin
0277:                            - offsetY) {
0278:                        addPage(false);
0279:                    }
0280:
0281:                    title.evaluate(JRExpression.EVALUATION_DEFAULT);
0282:
0283:                    JRPrintBand printBand = title.fill(pageHeight
0284:                            - bottomMargin - offsetY - title.getHeight());
0285:
0286:                    if (title.willOverflow() && !title.isSplitAllowed()
0287:                            && isSubreport()) {
0288:                        resolveGroupBoundElements(
0289:                                JRExpression.EVALUATION_DEFAULT, false);
0290:                        resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT);
0291:                        resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT);
0292:                        scriptlet.callBeforePageInit();
0293:                        calculator
0294:                                .initializeVariables(JRVariable.RESET_TYPE_PAGE);
0295:                        scriptlet.callAfterPageInit();
0296:
0297:                        addPage(false);
0298:
0299:                        printBand = title.refill(pageHeight - bottomMargin
0300:                                - offsetY - title.getHeight());
0301:                    }
0302:
0303:                    fillBand(printBand);
0304:                    offsetY += printBand.getHeight();
0305:
0306:                    while (title.willOverflow()) {
0307:                        resolveGroupBoundElements(
0308:                                JRExpression.EVALUATION_DEFAULT, false);
0309:                        resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT);
0310:                        resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT);
0311:                        scriptlet.callBeforePageInit();
0312:                        calculator
0313:                                .initializeVariables(JRVariable.RESET_TYPE_PAGE);
0314:                        scriptlet.callAfterPageInit();
0315:
0316:                        addPage(false);
0317:
0318:                        printBand = title.fill(pageHeight - bottomMargin
0319:                                - offsetY - title.getHeight());
0320:
0321:                        fillBand(printBand);
0322:                        offsetY += printBand.getHeight();
0323:                    }
0324:
0325:                    resolveBandBoundElements(title,
0326:                            JRExpression.EVALUATION_DEFAULT);
0327:
0328:                    if (isTitleNewPage) {
0329:                        resolveGroupBoundElements(
0330:                                JRExpression.EVALUATION_DEFAULT, false);
0331:                        resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT);
0332:                        resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT);
0333:                        scriptlet.callBeforePageInit();
0334:                        calculator
0335:                                .initializeVariables(JRVariable.RESET_TYPE_PAGE);
0336:                        scriptlet.callAfterPageInit();
0337:
0338:                        addPage(false);
0339:                    }
0340:                }
0341:            }
0342:
0343:            /**
0344:             *
0345:             */
0346:            private void fillPageHeader(byte evaluation) throws JRException {
0347:                if (log.isDebugEnabled() && !pageHeader.isEmpty()) {
0348:                    log.debug("Fill " + fillerId + ": page header");
0349:                }
0350:
0351:                setNewPageColumnInBands();
0352:
0353:                pageHeader
0354:                        .evaluatePrintWhenExpression(JRExpression.EVALUATION_DEFAULT);
0355:
0356:                if (pageHeader.isToPrint()) {
0357:                    int reattempts = getMasterColumnCount();
0358:                    if (isCreatingNewPage) {
0359:                        --reattempts;
0360:                    }
0361:
0362:                    boolean filled = fillBandNoOverflow(pageHeader, evaluation);
0363:
0364:                    for (int i = 0; !filled && i < reattempts; ++i) {
0365:                        resolveGroupBoundElements(evaluation, false);
0366:                        resolveColumnBoundElements(evaluation);
0367:                        resolvePageBoundElements(evaluation);
0368:                        scriptlet.callBeforePageInit();
0369:                        calculator
0370:                                .initializeVariables(JRVariable.RESET_TYPE_PAGE);
0371:                        scriptlet.callAfterPageInit();
0372:
0373:                        addPage(false);
0374:
0375:                        filled = fillBandNoOverflow(pageHeader, evaluation);
0376:                    }
0377:
0378:                    if (!filled) {
0379:                        throw new JRRuntimeException(
0380:                                "Infinite loop creating new page due to page header overflow.");
0381:                    }
0382:                }
0383:
0384:                columnHeaderOffsetY = offsetY;
0385:
0386:                isNewPage = true;
0387:                isFirstPageBand = true;
0388:            }
0389:
0390:            private boolean fillBandNoOverflow(JRFillBand band, byte evaluation)
0391:                    throws JRException {
0392:                int availableStretch = columnFooterOffsetY - offsetY
0393:                        - band.getHeight();
0394:                boolean overflow = availableStretch < 0;
0395:
0396:                if (!overflow) {
0397:                    band.evaluate(evaluation);
0398:                    JRPrintBand printBand = band.fill(availableStretch);
0399:
0400:                    overflow = band.willOverflow();
0401:                    if (overflow) {
0402:                        band.rewind();
0403:                    } else {
0404:                        fillBand(printBand);
0405:                        offsetY += printBand.getHeight();
0406:
0407:                        resolveBandBoundElements(band, evaluation);
0408:                    }
0409:                }
0410:
0411:                return !overflow;
0412:            }
0413:
0414:            /**
0415:             *
0416:             */
0417:            private void fillColumnHeader(byte evaluation) throws JRException {
0418:                if (log.isDebugEnabled() && !columnHeader.isEmpty()) {
0419:                    log.debug("Fill " + fillerId + ": column header");
0420:                }
0421:
0422:                setNewPageColumnInBands();
0423:
0424:                columnHeader.evaluatePrintWhenExpression(evaluation);
0425:
0426:                if (columnHeader.isToPrint()) {
0427:                    int reattempts = getMasterColumnCount();
0428:                    if (isCreatingNewPage) {
0429:                        --reattempts;
0430:                    }
0431:
0432:                    boolean filled = fillBandNoOverflow(columnHeader,
0433:                            evaluation);
0434:
0435:                    for (int i = 0; !filled && i < reattempts; ++i) {
0436:                        while (columnIndex < columnCount - 1) {
0437:                            resolveGroupBoundElements(evaluation, false);
0438:                            resolveColumnBoundElements(evaluation);
0439:                            scriptlet.callBeforeColumnInit();
0440:                            calculator
0441:                                    .initializeVariables(JRVariable.RESET_TYPE_COLUMN);
0442:                            scriptlet.callAfterColumnInit();
0443:
0444:                            columnIndex += 1;
0445:                            offsetX = leftMargin + columnIndex
0446:                                    * (columnSpacing + columnWidth);
0447:                            offsetY = columnHeaderOffsetY;
0448:
0449:                            setColumnNumberVar();
0450:                        }
0451:
0452:                        fillPageFooter(evaluation);
0453:
0454:                        resolveGroupBoundElements(evaluation, false);
0455:                        resolveColumnBoundElements(evaluation);
0456:                        resolvePageBoundElements(evaluation);
0457:                        scriptlet.callBeforePageInit();
0458:                        calculator
0459:                                .initializeVariables(JRVariable.RESET_TYPE_PAGE);
0460:                        scriptlet.callAfterPageInit();
0461:
0462:                        addPage(false);
0463:
0464:                        fillPageHeader(evaluation);
0465:
0466:                        filled = fillBandNoOverflow(columnHeader, evaluation);
0467:                    }
0468:
0469:                    if (!filled) {
0470:                        throw new JRRuntimeException(
0471:                                "Infinite loop creating new page due to column header overflow.");
0472:                    }
0473:                }
0474:
0475:                isNewColumn = true;
0476:                isFirstColumnBand = true;
0477:            }
0478:
0479:            /**
0480:             *
0481:             */
0482:            private void fillGroupHeaders(boolean isFillAll) throws JRException {
0483:                if (groups != null && groups.length > 0) {
0484:                    for (int i = 0; i < groups.length; i++) {
0485:                        if (isFillAll) {
0486:                            fillGroupHeader(groups[i]);
0487:                        } else {
0488:                            if (groups[i].hasChanged()) {
0489:                                fillGroupHeader(groups[i]);
0490:                            }
0491:                        }
0492:                    }
0493:                }
0494:            }
0495:
0496:            /**
0497:             *
0498:             */
0499:            private void fillGroupHeader(JRFillGroup group) throws JRException {
0500:                JRFillBand groupHeader = (JRFillBand) group.getGroupHeader();
0501:
0502:                if (log.isDebugEnabled() && !groupHeader.isEmpty()) {
0503:                    log.debug("Fill " + fillerId + ": " + group.getName()
0504:                            + " header");
0505:                }
0506:
0507:                byte evalPrevPage = (group.isTopLevelChange() ? JRExpression.EVALUATION_OLD
0508:                        : JRExpression.EVALUATION_DEFAULT);
0509:
0510:                if ((group.isStartNewPage() || group.isResetPageNumber())
0511:                        && !isNewPage) {
0512:                    fillPageBreak(group.isResetPageNumber(), evalPrevPage,
0513:                            JRExpression.EVALUATION_DEFAULT, true);
0514:                } else if (group.isStartNewColumn() && !isNewColumn) {
0515:                    fillColumnBreak(evalPrevPage,
0516:                            JRExpression.EVALUATION_DEFAULT);
0517:                }
0518:
0519:                groupHeader
0520:                        .evaluatePrintWhenExpression(JRExpression.EVALUATION_DEFAULT);
0521:
0522:                if (groupHeader.isToPrint()) {
0523:                    while (groupHeader.getHeight() > columnFooterOffsetY
0524:                            - offsetY
0525:                            || group.getMinHeightToStartNewPage() > columnFooterOffsetY
0526:                                    - offsetY) {
0527:                        fillColumnBreak(evalPrevPage,
0528:                                JRExpression.EVALUATION_DEFAULT);
0529:                    }
0530:                }
0531:
0532:                setNewGroupInBands(group);
0533:
0534:                group.setFooterPrinted(false);
0535:
0536:                if (groupHeader.isToPrint()) {
0537:                    fillColumnBand(groupHeader, JRExpression.EVALUATION_DEFAULT);
0538:                }
0539:
0540:                group.setHeaderPrinted(true);
0541:
0542:                isNewGroup = true;
0543:                isFirstPageBand = false;
0544:                isFirstColumnBand = false;
0545:            }
0546:
0547:            /**
0548:             *
0549:             */
0550:            private void fillGroupHeadersReprint(byte evaluation)
0551:                    throws JRException {
0552:                if (groups != null && groups.length > 0) {
0553:                    for (int i = 0; i < groups.length; i++) {
0554:                        fillGroupHeaderReprint(groups[i], evaluation);
0555:                    }
0556:                }
0557:            }
0558:
0559:            /**
0560:             *
0561:             */
0562:            private void fillGroupHeaderReprint(JRFillGroup group,
0563:                    byte evaluation) throws JRException {
0564:                if (group.isReprintHeaderOnEachPage()
0565:                        && (!group.hasChanged() || (group.hasChanged() && group
0566:                                .isHeaderPrinted()))) {
0567:                    JRFillBand groupHeader = (JRFillBand) group
0568:                            .getGroupHeader();
0569:
0570:                    groupHeader.evaluatePrintWhenExpression(evaluation);
0571:
0572:                    if (groupHeader.isToPrint()) {
0573:                        while (groupHeader.getHeight() > columnFooterOffsetY
0574:                                - offsetY
0575:                                || group.getMinHeightToStartNewPage() > columnFooterOffsetY
0576:                                        - offsetY) {
0577:                            fillColumnBreak(evaluation, evaluation);
0578:                        }
0579:
0580:                        fillColumnBand(groupHeader, evaluation);
0581:                    }
0582:
0583:                    isFirstPageBand = false;
0584:                    isFirstColumnBand = false;
0585:                }
0586:            }
0587:
0588:            /**
0589:             *
0590:             */
0591:            private void fillDetail() throws JRException {
0592:                if (log.isDebugEnabled() && !detail.isEmpty()) {
0593:                    log.debug("Fill " + fillerId + ": detail");
0594:                }
0595:
0596:                if (!detail.isPrintWhenExpressionNull()) {
0597:                    calculator.estimateVariables();
0598:                    detail
0599:                            .evaluatePrintWhenExpression(JRExpression.EVALUATION_ESTIMATED);
0600:                }
0601:
0602:                if (detail.isToPrint()) {
0603:                    while (detail.getHeight() > columnFooterOffsetY - offsetY) {
0604:                        byte evalPrevPage = (isNewGroup ? JRExpression.EVALUATION_DEFAULT
0605:                                : JRExpression.EVALUATION_OLD);
0606:
0607:                        fillColumnBreak(evalPrevPage,
0608:                                JRExpression.EVALUATION_DEFAULT);
0609:                    }
0610:                }
0611:
0612:                scriptlet.callBeforeDetailEval();
0613:                calculator.calculateVariables();
0614:                scriptlet.callAfterDetailEval();
0615:
0616:                if (!detail.isPrintWhenExpressionNull()) {
0617:                    detail
0618:                            .evaluatePrintWhenExpression(JRExpression.EVALUATION_DEFAULT);
0619:                }
0620:
0621:                if (detail.isToPrint()) {
0622:                    fillColumnBand(detail, JRExpression.EVALUATION_DEFAULT);
0623:                }
0624:
0625:                isNewPage = false;
0626:                isNewColumn = false;
0627:                isNewGroup = false;
0628:                isFirstPageBand = false;
0629:                isFirstColumnBand = false;
0630:            }
0631:
0632:            /**
0633:             *
0634:             */
0635:            private void fillGroupFooters(boolean isFillAll) throws JRException {
0636:                if (groups != null && groups.length > 0) {
0637:                    byte evaluation = (isFillAll) ? JRExpression.EVALUATION_DEFAULT
0638:                            : JRExpression.EVALUATION_OLD;
0639:
0640:                    for (int i = groups.length - 1; i >= 0; i--) {
0641:                        if (isFillAll) {
0642:                            fillGroupFooter(groups[i], evaluation);
0643:                        } else {
0644:                            if (groups[i].hasChanged()) {
0645:                                fillGroupFooter(groups[i], evaluation);
0646:                            }
0647:                        }
0648:                    }
0649:                }
0650:            }
0651:
0652:            /**
0653:             *
0654:             */
0655:            private void fillGroupFooter(JRFillGroup group, byte evaluation)
0656:                    throws JRException {
0657:                JRFillBand groupFooter = (JRFillBand) group.getGroupFooter();
0658:
0659:                if (log.isDebugEnabled() && !groupFooter.isEmpty()) {
0660:                    log.debug("Fill " + fillerId + ": " + group.getName()
0661:                            + " footer");
0662:                }
0663:
0664:                groupFooter.evaluatePrintWhenExpression(evaluation);
0665:
0666:                if (groupFooter.isToPrint()) {
0667:                    if (groupFooter.getHeight() > columnFooterOffsetY - offsetY) {
0668:                        fillColumnBreak(evaluation, evaluation);
0669:                    }
0670:
0671:                    fillColumnBand(groupFooter, evaluation);
0672:                }
0673:
0674:                isNewPage = false;
0675:                isNewColumn = false;
0676:                isFirstPageBand = false;
0677:                isFirstColumnBand = false;
0678:
0679:                group.setHeaderPrinted(false);
0680:                group.setFooterPrinted(true);
0681:            }
0682:
0683:            /**
0684:             *
0685:             */
0686:            private void fillColumnFooter(byte evaluation) throws JRException {
0687:                if (log.isDebugEnabled() && !columnFooter.isEmpty()) {
0688:                    log.debug("Fill " + fillerId + ": column footer");
0689:                }
0690:
0691:                /*
0692:                if (!isSubreport)
0693:                {
0694:                	offsetY = columnFooterOffsetY;
0695:                }
0696:                 */
0697:
0698:                if (isSubreport() && columnIndex == 0) {
0699:                    columnFooterOffsetY = offsetY;
0700:                }
0701:
0702:                int oldOffsetY = offsetY;
0703:                if (!isFloatColumnFooter && !fillContext.isIgnorePagination()) {
0704:                    offsetY = columnFooterOffsetY;
0705:                }
0706:
0707:                columnFooter.evaluatePrintWhenExpression(evaluation);
0708:
0709:                if (columnFooter.isToPrint()) {
0710:                    fillFixedBand(columnFooter, evaluation);
0711:                }
0712:
0713:                if (isFloatColumnFooter && !fillContext.isIgnorePagination()) {
0714:                    offsetY += columnFooterOffsetY - oldOffsetY;
0715:                }
0716:            }
0717:
0718:            /**
0719:             *
0720:             */
0721:            private void fillPageFooter(byte evaluation) throws JRException {
0722:                JRFillBand crtPageFooter = getCurrentPageFooter();
0723:
0724:                if (log.isDebugEnabled() && !crtPageFooter.isEmpty()) {
0725:                    log
0726:                            .debug("Fill " + fillerId + ": "
0727:                                    + (isLastPageFooter ? "last " : "")
0728:                                    + "page footer");
0729:                }
0730:
0731:                offsetX = leftMargin;
0732:
0733:                if (!isSubreport() && !fillContext.isIgnorePagination()) {
0734:                    offsetY = pageHeight - crtPageFooter.getHeight()
0735:                            - bottomMargin;
0736:                }
0737:
0738:                crtPageFooter.evaluatePrintWhenExpression(evaluation);
0739:
0740:                if (crtPageFooter.isToPrint()) {
0741:                    fillFixedBand(crtPageFooter, evaluation);
0742:                }
0743:            }
0744:
0745:            /**
0746:             *
0747:             */
0748:            private void fillSummary() throws JRException {
0749:                if (log.isDebugEnabled() && !summary.isEmpty()) {
0750:                    log.debug("Fill " + fillerId + ": summary");
0751:                }
0752:
0753:                if (lastPageFooter == missingFillBand) {
0754:                    if (!isSummaryNewPage
0755:                            && columnIndex == 0
0756:                            && summary.getHeight() <= columnFooterOffsetY
0757:                                    - offsetY) {
0758:                        fillSummarySamePage();
0759:                    } else {
0760:                        fillSummaryNewPage();
0761:                    }
0762:                } else {
0763:                    if (!isSummaryNewPage
0764:                            && columnIndex == 0
0765:                            && summary.getHeight() <= lastPageColumnFooterOffsetY
0766:                                    - offsetY) {
0767:                        setLastPageFooter(true);
0768:
0769:                        fillSummarySamePage();
0770:                    } else if (!isSummaryNewPage
0771:                            && columnIndex == 0
0772:                            && summary.getHeight() <= columnFooterOffsetY
0773:                                    - offsetY) {
0774:                        fillSummarySamePageMixedFooters();
0775:                    } else if (columnIndex == 0
0776:                            && offsetY <= lastPageColumnFooterOffsetY) {
0777:                        setLastPageFooter(true);
0778:
0779:                        fillSummaryNewPage();
0780:                    } else {
0781:                        fillPageBreak(false, JRExpression.EVALUATION_DEFAULT,
0782:                                JRExpression.EVALUATION_DEFAULT, false);
0783:
0784:                        setLastPageFooter(true);
0785:
0786:                        if (isSummaryNewPage) {
0787:                            fillSummaryNewPage();
0788:                        } else {
0789:                            fillSummarySamePage();
0790:                        }
0791:                    }
0792:                }
0793:
0794:                resolveGroupBoundElements(JRExpression.EVALUATION_DEFAULT, true);
0795:                resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT);
0796:                resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT);
0797:                resolveReportBoundElements();
0798:            }
0799:
0800:            /**
0801:             *
0802:             */
0803:            private void fillSummarySamePage() throws JRException {
0804:                summary
0805:                        .evaluatePrintWhenExpression(JRExpression.EVALUATION_DEFAULT);
0806:
0807:                if (summary != missingFillBand && summary.isToPrint()) {
0808:                    summary.evaluate(JRExpression.EVALUATION_DEFAULT);
0809:
0810:                    JRPrintBand printBand = summary.fill(columnFooterOffsetY
0811:                            - offsetY - summary.getHeight());
0812:
0813:                    if (summary.willOverflow() && !summary.isSplitAllowed()) {
0814:                        fillColumnFooter(JRExpression.EVALUATION_DEFAULT);
0815:
0816:                        fillPageFooter(JRExpression.EVALUATION_DEFAULT);
0817:
0818:                        resolveGroupBoundElements(
0819:                                JRExpression.EVALUATION_DEFAULT, true);
0820:                        resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT);
0821:                        resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT);
0822:                        scriptlet.callBeforePageInit();
0823:                        calculator
0824:                                .initializeVariables(JRVariable.RESET_TYPE_PAGE);
0825:                        scriptlet.callAfterPageInit();
0826:
0827:                        addPage(false);
0828:
0829:                        printBand = summary.refill(pageHeight - bottomMargin
0830:                                - offsetY - summary.getHeight());
0831:
0832:                        fillBand(printBand);
0833:                        offsetY += printBand.getHeight();
0834:                    } else {
0835:                        fillBand(printBand);
0836:                        offsetY += printBand.getHeight();
0837:
0838:                        fillColumnFooter(JRExpression.EVALUATION_DEFAULT);
0839:
0840:                        fillPageFooter(JRExpression.EVALUATION_DEFAULT);
0841:                    }
0842:
0843:                    while (summary.willOverflow()) {
0844:                        resolveGroupBoundElements(
0845:                                JRExpression.EVALUATION_DEFAULT, true);
0846:                        resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT);
0847:                        resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT);
0848:                        scriptlet.callBeforePageInit();
0849:                        calculator
0850:                                .initializeVariables(JRVariable.RESET_TYPE_PAGE);
0851:                        scriptlet.callAfterPageInit();
0852:
0853:                        addPage(false);
0854:
0855:                        printBand = summary.fill(pageHeight - bottomMargin
0856:                                - offsetY - summary.getHeight());
0857:
0858:                        fillBand(printBand);
0859:                        offsetY += printBand.getHeight();
0860:                    }
0861:
0862:                    resolveBandBoundElements(summary,
0863:                            JRExpression.EVALUATION_DEFAULT);
0864:                } else {
0865:                    fillColumnFooter(JRExpression.EVALUATION_DEFAULT);
0866:
0867:                    fillPageFooter(JRExpression.EVALUATION_DEFAULT);
0868:                }
0869:            }
0870:
0871:            /**
0872:             *
0873:             */
0874:            private void fillSummarySamePageMixedFooters() throws JRException {
0875:                summary
0876:                        .evaluatePrintWhenExpression(JRExpression.EVALUATION_DEFAULT);
0877:
0878:                if (summary != missingFillBand && summary.isToPrint()) {
0879:                    summary.evaluate(JRExpression.EVALUATION_DEFAULT);
0880:
0881:                    JRPrintBand printBand = summary.fill(columnFooterOffsetY
0882:                            - offsetY - summary.getHeight());
0883:
0884:                    if (summary.willOverflow() && !summary.isSplitAllowed()) {
0885:                        if (offsetY <= lastPageColumnFooterOffsetY) {
0886:                            setLastPageFooter(true);
0887:
0888:                            fillColumnFooter(JRExpression.EVALUATION_DEFAULT);
0889:
0890:                            fillPageFooter(JRExpression.EVALUATION_DEFAULT);
0891:
0892:                            resolveGroupBoundElements(
0893:                                    JRExpression.EVALUATION_DEFAULT, true);
0894:                            resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT);
0895:                            resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT);
0896:                            scriptlet.callBeforePageInit();
0897:                            calculator
0898:                                    .initializeVariables(JRVariable.RESET_TYPE_PAGE);
0899:                            scriptlet.callAfterPageInit();
0900:
0901:                            addPage(false);
0902:
0903:                            printBand = summary.refill(pageHeight
0904:                                    - bottomMargin - offsetY
0905:                                    - summary.getHeight());
0906:
0907:                            fillBand(printBand);
0908:                            offsetY += printBand.getHeight();
0909:                        } else {
0910:                            fillPageBreak(false,
0911:                                    JRExpression.EVALUATION_DEFAULT,
0912:                                    JRExpression.EVALUATION_DEFAULT, false);
0913:
0914:                            setLastPageFooter(true);
0915:
0916:                            printBand = summary
0917:                                    .refill(lastPageColumnFooterOffsetY
0918:                                            - offsetY - summary.getHeight());
0919:                            //printBand = summary.refill(pageHeight - bottomMargin - offsetY - summary.getHeight());
0920:
0921:                            fillBand(printBand);
0922:                            offsetY += printBand.getHeight();
0923:
0924:                            fillColumnFooter(JRExpression.EVALUATION_DEFAULT);
0925:
0926:                            fillPageFooter(JRExpression.EVALUATION_DEFAULT);
0927:                        }
0928:                    } else {
0929:                        fillBand(printBand);
0930:                        offsetY += printBand.getHeight();
0931:
0932:                        fillPageBreak(false, JRExpression.EVALUATION_DEFAULT,
0933:                                JRExpression.EVALUATION_DEFAULT, false);
0934:
0935:                        setLastPageFooter(true);
0936:
0937:                        if (summary.willOverflow()) {
0938:                            printBand = summary
0939:                                    .fill(lastPageColumnFooterOffsetY - offsetY
0940:                                            - summary.getHeight());
0941:
0942:                            fillBand(printBand);
0943:                            offsetY += printBand.getHeight();
0944:                        }
0945:
0946:                        fillColumnFooter(JRExpression.EVALUATION_DEFAULT);
0947:
0948:                        fillPageFooter(JRExpression.EVALUATION_DEFAULT);
0949:                    }
0950:
0951:                    while (summary.willOverflow()) {
0952:                        resolveGroupBoundElements(
0953:                                JRExpression.EVALUATION_DEFAULT, true);
0954:                        resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT);
0955:                        resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT);
0956:                        scriptlet.callBeforePageInit();
0957:                        calculator
0958:                                .initializeVariables(JRVariable.RESET_TYPE_PAGE);
0959:                        scriptlet.callAfterPageInit();
0960:
0961:                        addPage(false);
0962:
0963:                        printBand = summary.fill(pageHeight - bottomMargin
0964:                                - offsetY - summary.getHeight());
0965:
0966:                        fillBand(printBand);
0967:                        offsetY += printBand.getHeight();
0968:                    }
0969:
0970:                    resolveBandBoundElements(summary,
0971:                            JRExpression.EVALUATION_DEFAULT);
0972:                } else {
0973:                    if (offsetY > lastPageColumnFooterOffsetY) {
0974:                        fillPageBreak(false, JRExpression.EVALUATION_DEFAULT,
0975:                                JRExpression.EVALUATION_DEFAULT, false);
0976:                    }
0977:
0978:                    setLastPageFooter(true);
0979:
0980:                    fillColumnFooter(JRExpression.EVALUATION_DEFAULT);
0981:
0982:                    fillPageFooter(JRExpression.EVALUATION_DEFAULT);
0983:                }
0984:            }
0985:
0986:            /**
0987:             *
0988:             */
0989:            private void fillSummaryNewPage() throws JRException {
0990:                fillColumnFooter(JRExpression.EVALUATION_DEFAULT);
0991:
0992:                fillPageFooter(JRExpression.EVALUATION_DEFAULT);
0993:
0994:                summary
0995:                        .evaluatePrintWhenExpression(JRExpression.EVALUATION_DEFAULT);
0996:
0997:                if (summary != missingFillBand && summary.isToPrint()) {
0998:                    resolveGroupBoundElements(JRExpression.EVALUATION_DEFAULT,
0999:                            true);
1000:                    resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT);
1001:                    resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT);
1002:                    scriptlet.callBeforePageInit();
1003:                    calculator.initializeVariables(JRVariable.RESET_TYPE_PAGE);
1004:                    scriptlet.callAfterPageInit();
1005:
1006:                    addPage(false);
1007:
1008:                    columnIndex = -1;// FIXME why?
1009:
1010:                    summary.evaluate(JRExpression.EVALUATION_DEFAULT);
1011:
1012:                    JRPrintBand printBand = summary.fill(pageHeight
1013:                            - bottomMargin - offsetY - summary.getHeight());
1014:
1015:                    if (summary.willOverflow() && !summary.isSplitAllowed()
1016:                            && isSubreport()) {
1017:                        resolveGroupBoundElements(
1018:                                JRExpression.EVALUATION_DEFAULT, true);
1019:                        resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT);
1020:                        resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT);
1021:                        scriptlet.callBeforePageInit();
1022:                        calculator
1023:                                .initializeVariables(JRVariable.RESET_TYPE_PAGE);
1024:                        scriptlet.callAfterPageInit();
1025:
1026:                        addPage(false);
1027:
1028:                        printBand = summary.refill(pageHeight - bottomMargin
1029:                                - offsetY - summary.getHeight());
1030:                    }
1031:
1032:                    fillBand(printBand);
1033:                    offsetY += printBand.getHeight();
1034:
1035:                    while (summary.willOverflow()) {
1036:                        resolveGroupBoundElements(
1037:                                JRExpression.EVALUATION_DEFAULT, true);
1038:                        resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT);
1039:                        resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT);
1040:                        scriptlet.callBeforePageInit();
1041:                        calculator
1042:                                .initializeVariables(JRVariable.RESET_TYPE_PAGE);
1043:                        scriptlet.callAfterPageInit();
1044:
1045:                        addPage(false);
1046:
1047:                        printBand = summary.fill(pageHeight - bottomMargin
1048:                                - offsetY - summary.getHeight());
1049:
1050:                        fillBand(printBand);
1051:                        offsetY += printBand.getHeight();
1052:                    }
1053:
1054:                    resolveBandBoundElements(summary,
1055:                            JRExpression.EVALUATION_DEFAULT);
1056:                }
1057:            }
1058:
1059:            /**
1060:             *
1061:             */
1062:            private void fillBackground() throws JRException {
1063:                if (log.isDebugEnabled() && !background.isEmpty()) {
1064:                    log.debug("Fill " + fillerId + ": background");
1065:                }
1066:
1067:                //offsetX = leftMargin;
1068:
1069:                //if (!isSubreport)
1070:                //{
1071:                //	offsetY = pageHeight - pageFooter.getHeight() - bottomMargin;
1072:                //}
1073:
1074:                if (background.getHeight() <= pageHeight - bottomMargin
1075:                        - offsetY) {
1076:                    background
1077:                            .evaluatePrintWhenExpression(JRExpression.EVALUATION_DEFAULT);
1078:
1079:                    if (background.isToPrint()) {
1080:                        background.evaluate(JRExpression.EVALUATION_DEFAULT);
1081:
1082:                        JRPrintBand printBand = background.fill(pageHeight
1083:                                - bottomMargin - offsetY
1084:                                - background.getHeight());
1085:
1086:                        fillBand(printBand);
1087:                        //offsetY += printBand.getHeight();
1088:                    }
1089:                }
1090:            }
1091:
1092:            /**
1093:             *
1094:             */
1095:            private void addPage(boolean isResetPageNumber) throws JRException {
1096:                if (isSubreport()) {
1097:                    if (!parentFiller.isBandOverFlowAllowed()) {
1098:                        throw new JRRuntimeException(
1099:                                "Subreport overflowed on a band that does not support overflow.");
1100:                    }
1101:
1102:                    //if (
1103:                    //	columnIndex == 0 ||
1104:                    //	(columnIndex > 0 && printPageStretchHeight < offsetY + bottomMargin)
1105:                    //	)
1106:                    //{
1107:                    printPageStretchHeight = offsetY + bottomMargin;
1108:                    //}
1109:
1110:                    if (fillContext.isUsingVirtualizer()) {
1111:                        removePageIdentityDataProvider();
1112:                    }
1113:
1114:                    suspendSubreportRunner();
1115:                }
1116:
1117:                printPage = newPage();
1118:
1119:                if (isSubreport() && fillContext.isUsingVirtualizer()) {
1120:                    addPageIdentityDataProvider();
1121:                }
1122:
1123:                if (isResetPageNumber) {
1124:                    calculator.getPageNumber().setValue(new Integer(1));
1125:                } else {
1126:                    calculator.getPageNumber().setValue(
1127:                            new Integer(((Number) calculator.getPageNumber()
1128:                                    .getValue()).intValue() + 1));
1129:                }
1130:
1131:                calculator.getPageNumber().setOldValue(
1132:                        calculator.getPageNumber().getValue());
1133:
1134:                addPage(printPage);
1135:
1136:                setFirstColumn();
1137:                offsetY = topMargin;
1138:
1139:                fillBackground();
1140:            }
1141:
1142:            private void setFirstColumn() {
1143:                columnIndex = 0;
1144:                offsetX = leftMargin;
1145:                setColumnNumberVar();
1146:            }
1147:
1148:            private void setColumnNumberVar() {
1149:                JRFillVariable columnNumber = calculator.getColumnNumber();
1150:                columnNumber.setValue(new Integer(columnIndex + 1));
1151:                columnNumber.setOldValue(columnNumber.getValue());
1152:            }
1153:
1154:            /**
1155:             *
1156:             */
1157:            private void fillPageBreak(boolean isResetPageNumber,
1158:                    byte evalPrevPage, byte evalNextPage,
1159:                    boolean isReprintGroupHeaders) throws JRException {
1160:                if (isCreatingNewPage) {
1161:                    throw new JRException("Infinite loop creating new page.");
1162:                }
1163:
1164:                isCreatingNewPage = true;
1165:
1166:                fillColumnFooter(evalPrevPage);
1167:
1168:                fillPageFooter(evalPrevPage);
1169:
1170:                resolveGroupBoundElements(evalPrevPage, false);
1171:                resolveColumnBoundElements(evalPrevPage);
1172:                resolvePageBoundElements(evalPrevPage);
1173:                scriptlet.callBeforePageInit();
1174:                calculator.initializeVariables(JRVariable.RESET_TYPE_PAGE);
1175:                scriptlet.callAfterPageInit();
1176:
1177:                addPage(isResetPageNumber);
1178:
1179:                fillPageHeader(evalNextPage);
1180:
1181:                fillColumnHeader(evalNextPage);
1182:
1183:                if (isReprintGroupHeaders) {
1184:                    fillGroupHeadersReprint(evalNextPage);
1185:                }
1186:
1187:                isCreatingNewPage = false;
1188:            }
1189:
1190:            /**
1191:             *
1192:             */
1193:            private void fillColumnBreak(byte evalPrevPage, byte evalNextPage)
1194:                    throws JRException {
1195:                if (columnIndex == columnCount - 1) {
1196:                    fillPageBreak(false, evalPrevPage, evalNextPage, true);
1197:                } else {
1198:                    fillColumnFooter(evalPrevPage);
1199:
1200:                    resolveGroupBoundElements(evalPrevPage, false);
1201:                    resolveColumnBoundElements(evalPrevPage);
1202:                    scriptlet.callBeforeColumnInit();
1203:                    calculator
1204:                            .initializeVariables(JRVariable.RESET_TYPE_COLUMN);
1205:                    scriptlet.callAfterColumnInit();
1206:
1207:                    columnIndex += 1;
1208:                    offsetX = leftMargin + columnIndex
1209:                            * (columnSpacing + columnWidth);
1210:                    offsetY = columnHeaderOffsetY;
1211:
1212:                    setColumnNumberVar();
1213:
1214:                    fillColumnHeader(evalNextPage);
1215:                }
1216:            }
1217:
1218:            /**
1219:             *
1220:             */
1221:            protected void fillPageBand(JRFillBand band, byte evaluation)
1222:                    throws JRException {
1223:                band.evaluate(evaluation);
1224:
1225:                JRPrintBand printBand = band.fill(columnFooterOffsetY - offsetY
1226:                        - band.getHeight());
1227:
1228:                if (band.willOverflow() && !band.isSplitAllowed()) {
1229:                    fillPageBreak(false, evaluation, evaluation, true);
1230:
1231:                    printBand = band.refill(columnFooterOffsetY - offsetY
1232:                            - band.getHeight());
1233:                }
1234:
1235:                fillBand(printBand);
1236:                offsetY += printBand.getHeight();
1237:
1238:                while (band.willOverflow()) {
1239:                    fillPageBreak(false, evaluation, evaluation, true);
1240:
1241:                    printBand = band.fill(columnFooterOffsetY - offsetY
1242:                            - band.getHeight());
1243:
1244:                    fillBand(printBand);
1245:                    offsetY += printBand.getHeight();
1246:                }
1247:
1248:                resolveBandBoundElements(band, evaluation);
1249:            }
1250:
1251:            /**
1252:             *
1253:             */
1254:            protected void fillColumnBand(JRFillBand band, byte evaluation)
1255:                    throws JRException {
1256:                band.evaluate(evaluation);
1257:
1258:                JRPrintBand printBand = band.fill(columnFooterOffsetY - offsetY
1259:                        - band.getHeight());
1260:
1261:                if (band.willOverflow() && !band.isSplitAllowed()) {
1262:                    fillColumnBreak(evaluation, evaluation);
1263:
1264:                    printBand = band.refill(columnFooterOffsetY - offsetY
1265:                            - band.getHeight());
1266:                }
1267:
1268:                fillBand(printBand);
1269:                offsetY += printBand.getHeight();
1270:
1271:                while (band.willOverflow()) {
1272:                    fillColumnBreak(evaluation, evaluation);
1273:
1274:                    printBand = band.fill(columnFooterOffsetY - offsetY
1275:                            - band.getHeight());
1276:
1277:                    fillBand(printBand);
1278:                    offsetY += printBand.getHeight();
1279:                }
1280:
1281:                resolveBandBoundElements(band, evaluation);
1282:            }
1283:
1284:            /**
1285:             *
1286:             */
1287:            protected void fillFixedBand(JRFillBand band, byte evaluation)
1288:                    throws JRException {
1289:                band.evaluate(evaluation);
1290:
1291:                JRPrintBand printBand = band.fill();
1292:
1293:                fillBand(printBand);
1294:                offsetY += printBand.getHeight();
1295:
1296:                resolveBandBoundElements(band, evaluation);
1297:            }
1298:
1299:            /**
1300:             *
1301:             */
1302:            protected void fillBand(JRPrintBand band) {
1303:                java.util.List elements = band.getElements();
1304:
1305:                if (elements != null && elements.size() > 0) {
1306:                    JRPrintElement element = null;
1307:                    for (Iterator it = elements.iterator(); it.hasNext();) {
1308:                        element = (JRPrintElement) it.next();
1309:                        element.setX(element.getX() + offsetX);
1310:                        element.setY(element.getY() + offsetY);
1311:                        printPage.addElement(element);
1312:                    }
1313:                }
1314:            }
1315:
1316:            /**
1317:             *
1318:             */
1319:            private void setNewPageColumnInBands() {
1320:                title.setNewPageColumn(true);
1321:                pageHeader.setNewPageColumn(true);
1322:                columnHeader.setNewPageColumn(true);
1323:                detail.setNewPageColumn(true);
1324:                columnFooter.setNewPageColumn(true);
1325:                pageFooter.setNewPageColumn(true);
1326:                lastPageFooter.setNewPageColumn(true);
1327:                summary.setNewPageColumn(true);
1328:                noData.setNewPageColumn(true);
1329:
1330:                if (groups != null && groups.length > 0) {
1331:                    for (int i = 0; i < groups.length; i++) {
1332:                        ((JRFillBand) groups[i].getGroupHeader())
1333:                                .setNewPageColumn(true);
1334:                        ((JRFillBand) groups[i].getGroupFooter())
1335:                                .setNewPageColumn(true);
1336:                    }
1337:                }
1338:            }
1339:
1340:            /**
1341:             *
1342:             */
1343:            private void setNewGroupInBands(JRGroup group) {
1344:                title.setNewGroup(group, true);
1345:                pageHeader.setNewGroup(group, true);
1346:                columnHeader.setNewGroup(group, true);
1347:                detail.setNewGroup(group, true);
1348:                columnFooter.setNewGroup(group, true);
1349:                pageFooter.setNewGroup(group, true);
1350:                lastPageFooter.setNewGroup(group, true);
1351:                summary.setNewGroup(group, true);
1352:                noData.setNewGroup(group, true);
1353:
1354:                if (groups != null && groups.length > 0) {
1355:                    for (int i = 0; i < groups.length; i++) {
1356:                        ((JRFillBand) groups[i].getGroupHeader()).setNewGroup(
1357:                                group, true);
1358:                        ((JRFillBand) groups[i].getGroupFooter()).setNewGroup(
1359:                                group, true);
1360:                    }
1361:                }
1362:            }
1363:
1364:            /**
1365:             *
1366:             */
1367:            private JRFillBand getCurrentPageFooter() {
1368:                return isLastPageFooter ? lastPageFooter : pageFooter;
1369:            }
1370:
1371:            /**
1372:             *
1373:             */
1374:            private void setLastPageFooter(boolean isLastPageFooter) {
1375:                this .isLastPageFooter = isLastPageFooter;
1376:
1377:                if (isLastPageFooter) {
1378:                    columnFooterOffsetY = lastPageColumnFooterOffsetY;
1379:                }
1380:            }
1381:
1382:            /**
1383:             *
1384:             */
1385:            private void fillNoData() throws JRException {
1386:                if (log.isDebugEnabled() && !noData.isEmpty()) {
1387:                    log.debug("Fill " + fillerId + ": noData");
1388:                }
1389:
1390:                noData
1391:                        .evaluatePrintWhenExpression(JRExpression.EVALUATION_DEFAULT);
1392:
1393:                if (noData.isToPrint()) {
1394:                    while (noData.getHeight() > pageHeight - bottomMargin
1395:                            - offsetY) {
1396:                        addPage(false);
1397:                    }
1398:
1399:                    noData.evaluate(JRExpression.EVALUATION_DEFAULT);
1400:
1401:                    JRPrintBand printBand = noData.fill(pageHeight
1402:                            - bottomMargin - offsetY - noData.getHeight());
1403:
1404:                    if (noData.willOverflow() && !noData.isSplitAllowed()
1405:                            && isSubreport()) {
1406:                        resolveGroupBoundElements(
1407:                                JRExpression.EVALUATION_DEFAULT, false);
1408:                        resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT);
1409:                        resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT);
1410:                        scriptlet.callBeforePageInit();
1411:                        calculator
1412:                                .initializeVariables(JRVariable.RESET_TYPE_PAGE);
1413:                        scriptlet.callAfterPageInit();
1414:
1415:                        addPage(false);
1416:
1417:                        printBand = noData.refill(pageHeight - bottomMargin
1418:                                - offsetY - noData.getHeight());
1419:                    }
1420:
1421:                    fillBand(printBand);
1422:                    offsetY += printBand.getHeight();
1423:
1424:                    while (noData.willOverflow()) {
1425:                        resolveGroupBoundElements(
1426:                                JRExpression.EVALUATION_DEFAULT, false);
1427:                        resolveColumnBoundElements(JRExpression.EVALUATION_DEFAULT);
1428:                        resolvePageBoundElements(JRExpression.EVALUATION_DEFAULT);
1429:                        scriptlet.callBeforePageInit();
1430:                        calculator
1431:                                .initializeVariables(JRVariable.RESET_TYPE_PAGE);
1432:                        scriptlet.callAfterPageInit();
1433:
1434:                        addPage(false);
1435:
1436:                        printBand = noData.fill(pageHeight - bottomMargin
1437:                                - offsetY - noData.getHeight());
1438:
1439:                        fillBand(printBand);
1440:                        offsetY += printBand.getHeight();
1441:                    }
1442:
1443:                    resolveBandBoundElements(noData,
1444:                            JRExpression.EVALUATION_DEFAULT);
1445:                }
1446:            }
1447:
1448:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.