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