001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either 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, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * ApplyCachedValuesStep.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.layout.process;
030:
031: import org.jfree.report.layout.model.BlockRenderBox;
032: import org.jfree.report.layout.model.CanvasRenderBox;
033: import org.jfree.report.layout.model.InlineRenderBox;
034: import org.jfree.report.layout.model.ParagraphRenderBox;
035: import org.jfree.report.layout.model.RenderBox;
036: import org.jfree.report.layout.model.RenderNode;
037: import org.jfree.util.Log;
038:
039: /**
040: * Creation-Date: 19.04.2007, 20:47:38
041: *
042: * @author Thomas Morgner
043: */
044: public final class ApplyCachedValuesStep extends
045: IterateStructuralProcessStep {
046: private RenderBox uncleanBox;
047:
048: public ApplyCachedValuesStep() {
049: }
050:
051: public void compute(final RenderBox box) {
052: try {
053: startProcessing(box);
054: } finally {
055: uncleanBox = null;
056: }
057: }
058:
059: protected void processParagraphChilds(final ParagraphRenderBox box) {
060: processBoxChilds(box);
061: }
062:
063: public boolean startCanvasBox(final CanvasRenderBox box) {
064: if (uncleanBox == null) {
065: final int state = box.getCacheState();
066: if (state == RenderNode.CACHE_CLEAN) {
067: return false;
068: }
069: if (state == RenderNode.CACHE_DEEP_DIRTY) {
070: uncleanBox = box;
071: }
072: }
073:
074: box.apply();
075: box.setStaticBoxPropertiesAge(box.getChangeTracker());
076: return true;
077: }
078:
079: protected void processOtherNode(final RenderNode node) {
080: node.apply();
081: }
082:
083: protected boolean startBlockBox(final BlockRenderBox box) {
084: if (uncleanBox == null) {
085: final int state = box.getCacheState();
086: if (state == RenderNode.CACHE_CLEAN) {
087: if (box.getStaticBoxPropertiesAge() == box
088: .getChangeTracker()) {
089: return false;
090: } else {
091: Log
092: .debug("State clean but changetracker not clean: "
093: + box);
094: }
095: }
096: if (state == RenderNode.CACHE_DEEP_DIRTY) {
097: uncleanBox = box;
098: }
099: }
100:
101: box.apply();
102: box.setStaticBoxPropertiesAge(box.getChangeTracker());
103: return true;
104: }
105:
106: protected boolean startInlineBox(final InlineRenderBox box) {
107: if (uncleanBox == null) {
108: final int state = box.getCacheState();
109: if (state == RenderNode.CACHE_CLEAN) {
110: return false;
111: }
112: if (state == RenderNode.CACHE_DEEP_DIRTY) {
113: uncleanBox = box;
114: }
115: }
116:
117: box.apply();
118: box.setStaticBoxPropertiesAge(box.getChangeTracker());
119: return true;
120: }
121:
122: protected boolean startOtherBox(final RenderBox box) {
123: if (uncleanBox == null) {
124: final int state = box.getCacheState();
125: if (state == RenderNode.CACHE_CLEAN) {
126: return false;
127: }
128: if (state == RenderNode.CACHE_DEEP_DIRTY) {
129: uncleanBox = box;
130: }
131: }
132:
133: box.apply();
134: box.setStaticBoxPropertiesAge(box.getChangeTracker());
135: return true;
136: }
137:
138: public void finishCanvasBox(final CanvasRenderBox box) {
139: if (box == uncleanBox) {
140: uncleanBox = null;
141: }
142: }
143:
144: protected void finishBlockBox(final BlockRenderBox box) {
145: if (box == uncleanBox) {
146: uncleanBox = null;
147: }
148: }
149:
150: protected void finishInlineBox(final InlineRenderBox box) {
151: if (box == uncleanBox) {
152: uncleanBox = null;
153: }
154: }
155:
156: protected void finishOtherBox(final RenderBox box) {
157: if (box == uncleanBox) {
158: uncleanBox = null;
159: }
160: }
161: }
|