Source Code Cross Referenced for JRFillBand.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) 


001:        /*
002:         * ============================================================================
003:         * GNU Lesser General Public License
004:         * ============================================================================
005:         *
006:         * JasperReports - Free Java report-generating library.
007:         * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
008:         * 
009:         * This library is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU Lesser General Public
011:         * License as published by the Free Software Foundation; either
012:         * version 2.1 of the License, or (at your option) any later version.
013:         * 
014:         * This library is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:         * Lesser General Public License for more details.
018:         * 
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
022:         * 
023:         * JasperSoft Corporation
024:         * 303 Second Street, Suite 450 North
025:         * San Francisco, CA 94107
026:         * http://www.jaspersoft.com
027:         */
028:        package net.sf.jasperreports.engine.fill;
029:
030:        import java.util.HashMap;
031:        import java.util.HashSet;
032:        import java.util.Iterator;
033:        import java.util.Map;
034:        import java.util.Set;
035:
036:        import org.apache.commons.logging.Log;
037:        import org.apache.commons.logging.LogFactory;
038:
039:        import net.sf.jasperreports.engine.JRBand;
040:        import net.sf.jasperreports.engine.JRException;
041:        import net.sf.jasperreports.engine.JRExpression;
042:        import net.sf.jasperreports.engine.JRGroup;
043:
044:        /**
045:         * @author Teodor Danciu (teodord@users.sourceforge.net)
046:         * @version $Id: JRFillBand.java 1621 2007-03-06 13:55:00Z lucianc $
047:         */
048:        public class JRFillBand extends JRFillElementContainer implements 
049:                JRBand {
050:
051:            private static final Log log = LogFactory.getLog(JRFillBand.class);
052:
053:            /**
054:             *
055:             */
056:            private JRBand parent = null;
057:
058:            private boolean isPrintWhenTrue = true;
059:
060:            /**
061:             *
062:             */
063:            private boolean isNewPageColumn = false;
064:            private boolean isFirstWholeOnPageColumn = false;
065:            private Map isNewGroupMap = new HashMap();
066:
067:            private Set nowEvaluationTimes;
068:
069:            // used by subreports to save values of variables used as return receptacles
070:            // so that the values can be restored when the bands gets rewound
071:            private Map savedVariableValues = new HashMap();
072:
073:            /**
074:             *
075:             */
076:            protected JRFillBand(JRBaseFiller filler, JRBand band,
077:                    JRFillObjectFactory factory) {
078:                super (filler, band, factory);
079:
080:                parent = band;
081:
082:                if (deepElements.length > 0) {
083:                    for (int i = 0; i < deepElements.length; i++) {
084:                        deepElements[i].setBand(this );
085:                    }
086:                }
087:
088:                initElements();
089:
090:                initConditionalStyles();
091:
092:                nowEvaluationTimes = new HashSet();
093:            }
094:
095:            /**
096:             *
097:             */
098:            protected void setNewPageColumn(boolean isNew) {
099:                this .isNewPageColumn = isNew;
100:            }
101:
102:            /**
103:             *
104:             */
105:            protected boolean isNewPageColumn() {
106:                return isNewPageColumn;
107:            }
108:
109:            /**
110:             * Decides whether this band is the for whole band on the page/column.
111:             *
112:             * @return whether this band is the for whole band on the page/column
113:             */
114:            protected boolean isFirstWholeOnPageColumn() {
115:                return isFirstWholeOnPageColumn;
116:            }
117:
118:            /**
119:             *
120:             */
121:            protected void setNewGroup(JRGroup group, boolean isNew) {
122:                isNewGroupMap.put(group, isNew ? Boolean.TRUE : Boolean.FALSE);
123:            }
124:
125:            /**
126:             *
127:             */
128:            protected boolean isNewGroup(JRGroup group) {
129:                Boolean value = (Boolean) isNewGroupMap.get(group);
130:
131:                if (value == null) {
132:                    value = Boolean.FALSE;
133:                }
134:
135:                return value.booleanValue();
136:            }
137:
138:            /**
139:             *
140:             */
141:            public int getHeight() {
142:                return (parent != null ? parent.getHeight() : 0);
143:            }
144:
145:            /**
146:             *
147:             */
148:            public boolean isSplitAllowed() {
149:                return parent.isSplitAllowed();
150:            }
151:
152:            /**
153:             *
154:             */
155:            public void setSplitAllowed(boolean isSplitAllowed) {
156:            }
157:
158:            /**
159:             *
160:             */
161:            public JRExpression getPrintWhenExpression() {
162:                return (parent != null ? parent.getPrintWhenExpression() : null);
163:            }
164:
165:            /**
166:             *
167:             */
168:            protected boolean isPrintWhenExpressionNull() {
169:                return (getPrintWhenExpression() == null);
170:            }
171:
172:            /**
173:             *
174:             */
175:            protected boolean isPrintWhenTrue() {
176:                return isPrintWhenTrue;
177:            }
178:
179:            /**
180:             *
181:             */
182:            protected void setPrintWhenTrue(boolean isPrintWhenTrue) {
183:                this .isPrintWhenTrue = isPrintWhenTrue;
184:            }
185:
186:            /**
187:             *
188:             */
189:            protected boolean isToPrint() {
190:                return (isPrintWhenExpressionNull() || (!isPrintWhenExpressionNull() && isPrintWhenTrue()));
191:            }
192:
193:            /**
194:             *
195:             */
196:            protected void evaluatePrintWhenExpression(byte evaluation)
197:                    throws JRException {
198:                boolean isPrintTrue = false;
199:
200:                JRExpression expression = getPrintWhenExpression();
201:                if (expression != null) {
202:                    Boolean printWhenExpressionValue = (Boolean) filler
203:                            .evaluateExpression(expression, evaluation);
204:                    if (printWhenExpressionValue == null) {
205:                        isPrintTrue = false;
206:                    } else {
207:                        isPrintTrue = printWhenExpressionValue.booleanValue();
208:                    }
209:                }
210:
211:                setPrintWhenTrue(isPrintTrue);
212:            }
213:
214:            /**
215:             *
216:             */
217:            protected JRPrintBand refill(int availableStretchHeight)
218:                    throws JRException {
219:                rewind();
220:                restoreSavedVariables();
221:
222:                return fill(availableStretchHeight);
223:            }
224:
225:            /**
226:             *
227:             */
228:            protected JRPrintBand fill() throws JRException {
229:                return fill(0, false);
230:            }
231:
232:            /**
233:             *
234:             */
235:            protected JRPrintBand fill(int availableStretchHeight)
236:                    throws JRException {
237:                return fill(availableStretchHeight, true);
238:            }
239:
240:            /**
241:             *
242:             */
243:            protected JRPrintBand fill(int availableStretchHeight,
244:                    boolean isOverflowAllowed) throws JRException {
245:                filler.fillContext.ensureMasterPageAvailable();
246:
247:                if (Thread.currentThread().isInterrupted()
248:                        || filler.isInterrupted()) {
249:                    if (log.isDebugEnabled()) {
250:                        log.debug("Fill " + filler.fillerId + ": interrupted");
251:                    }
252:
253:                    // child fillers will stop if this parent filler was marked as interrupted
254:                    filler.setInterrupted(true);
255:
256:                    throw new JRFillInterruptedException();
257:                }
258:
259:                filler.setBandOverFlowAllowed(isOverflowAllowed);
260:
261:                initFill();
262:
263:                if (isNewPageColumn && !isOverflow) {
264:                    isFirstWholeOnPageColumn = true;
265:                }
266:
267:                resetElements();
268:
269:                prepareElements(availableStretchHeight, isOverflowAllowed);
270:
271:                stretchElements();
272:
273:                moveBandBottomElements();
274:
275:                removeBlankElements();
276:
277:                isFirstWholeOnPageColumn = isNewPageColumn && isOverflow;
278:                isNewPageColumn = false;
279:                isNewGroupMap = new HashMap();
280:
281:                JRPrintBand printBand = new JRPrintBand();
282:                fillElements(printBand);
283:
284:                return printBand;
285:            }
286:
287:            protected int getContainerHeight() {
288:                return getHeight();
289:            }
290:
291:            protected boolean isVariableUsedInSubreportReturns(
292:                    String variableName) {
293:                boolean used = false;
294:                if (deepElements != null) {
295:                    for (int i = 0; i < deepElements.length; i++) {
296:                        JRFillElement element = deepElements[i];
297:                        if (element instanceof  JRFillSubreport) {
298:                            JRFillSubreport subreport = (JRFillSubreport) element;
299:                            if (subreport.usesForReturnValue(variableName)) {
300:                                used = true;
301:                                break;
302:                            }
303:                        }
304:                    }
305:                }
306:
307:                return used;
308:            }
309:
310:            protected void addNowEvaluationTime(JREvaluationTime evaluationTime) {
311:                nowEvaluationTimes.add(evaluationTime);
312:            }
313:
314:            protected void addNowEvaluationTimes(
315:                    JREvaluationTime[] evaluationTimes) {
316:                for (int i = 0; i < evaluationTimes.length; i++) {
317:                    nowEvaluationTimes.add(evaluationTimes[i]);
318:                }
319:            }
320:
321:            protected boolean isNowEvaluationTime(
322:                    JREvaluationTime evaluationTime) {
323:                return nowEvaluationTimes.contains(evaluationTime);
324:            }
325:
326:            protected int getId() {
327:                return System.identityHashCode(this );
328:            }
329:
330:            protected void evaluate(byte evaluation) throws JRException {
331:                resetSavedVariables();
332:                evaluateConditionalStyles(evaluation);
333:                super .evaluate(evaluation);
334:            }
335:
336:            protected void resetSavedVariables() {
337:                savedVariableValues.clear();
338:            }
339:
340:            protected void saveVariable(String variableName) {
341:                if (!savedVariableValues.containsKey(variableName)) {
342:                    Object value = filler.getVariableValue(variableName);
343:                    savedVariableValues.put(variableName, value);
344:                }
345:            }
346:
347:            protected void restoreSavedVariables() {
348:                for (Iterator it = savedVariableValues.entrySet().iterator(); it
349:                        .hasNext();) {
350:                    Map.Entry entry = (Map.Entry) it.next();
351:                    String variableName = (String) entry.getKey();
352:                    Object value = entry.getValue();
353:                    JRFillVariable variable = filler.getVariable(variableName);
354:                    variable.setOldValue(value);
355:                    variable.setValue(value);
356:                    variable.setIncrementedValue(value);
357:                }
358:            }
359:
360:            protected boolean isEmpty() {
361:                return this  == filler.missingFillBand
362:                        || (getHeight() == 0
363:                                && (getElements() == null || getElements().length == 0) && getPrintWhenExpression() == null);
364:            }
365:
366:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.