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.io.IOException;
031:
032: import net.sf.jasperreports.engine.JRAbstractObjectFactory;
033: import net.sf.jasperreports.engine.JRBreak;
034: import net.sf.jasperreports.engine.JRChild;
035: import net.sf.jasperreports.engine.JRException;
036: import net.sf.jasperreports.engine.JRExpressionCollector;
037: import net.sf.jasperreports.engine.JRPrintElement;
038: import net.sf.jasperreports.engine.xml.JRXmlWriter;
039:
040: /**
041: * @author Teodor Danciu (teodord@users.sourceforge.net)
042: * @version $Id: JRFillBreak.java 1774 2007-06-28 13:40:16Z lucianc $
043: */
044: public class JRFillBreak extends JRFillElement implements JRBreak {
045:
046: /**
047: *
048: */
049: protected JRFillBreak(JRBaseFiller filler, JRBreak breakElement,
050: JRFillObjectFactory factory) {
051: super (filler, breakElement, factory);
052: }
053:
054: protected JRFillBreak(JRFillBreak breakElement,
055: JRFillCloneFactory factory) {
056: super (breakElement, factory);
057: }
058:
059: /**
060: *
061: */
062: public int getWidth() {
063: return filler.columnWidth;
064: }
065:
066: /**
067: *
068: */
069: public byte getType() {
070: return ((JRBreak) parent).getType();
071: }
072:
073: /**
074: *
075: */
076: public void setType(byte type) {
077: }
078:
079: /**
080: *
081: */
082: protected void evaluate(byte evaluation) throws JRException {
083: this .reset();
084:
085: this .evaluatePrintWhenExpression(evaluation);
086:
087: setValueRepeating(true);
088: }
089:
090: /**
091: *
092: */
093: protected JRPrintElement fill() {
094: return null;
095: // JRPrintLine printLine = null;
096: //
097: // printLine = new JRBasePrintLine(filler.getJasperPrint().getDefaultStyleProvider());
098: // printLine.setX(0);
099: // printLine.setY(this.getRelativeY());
100: // printLine.setWidth(getWidth());
101: // printLine.setHeight(1);
102: // printLine.setPen(JRGraphicElement.PEN_DOTTED);
103: // printLine.setForecolor(getForecolor());
104: //
105: // return printLine;
106: }
107:
108: /**
109: *
110: */
111: public JRChild getCopy(JRAbstractObjectFactory factory) {
112: return factory.getBreak(this );
113: }
114:
115: /**
116: *
117: */
118: public void collectExpressions(JRExpressionCollector collector) {
119: collector.collect(this );
120: }
121:
122: /**
123: *
124: */
125: public void writeXml(JRXmlWriter xmlWriter) throws IOException {
126: xmlWriter.writeBreak(this );
127: }
128:
129: /**
130: *
131: */
132: protected void resolveElement(JRPrintElement element,
133: byte evaluation) {
134: // nothing
135: }
136:
137: public JRCloneable createClone(JRFillCloneFactory factory) {
138: return new JRFillBreak(this , factory);
139: }
140:
141: /**
142: *
143: */
144: public void rewind() {
145: }
146:
147: /**
148: *
149: */
150: protected boolean prepare(int availableStretchHeight,
151: boolean isOverflow) throws JRException {
152: super .prepare(availableStretchHeight, isOverflow);
153:
154: if (!this .isToPrint()) {
155: return false;
156: }
157:
158: boolean isToPrint = true;
159:
160: if (isOverflow && this .isAlreadyPrinted())// && !this.isPrintWhenDetailOverflows())
161: {
162: isToPrint = false;
163: }
164:
165: //boolean willOverflow = false;
166:
167: if (isToPrint
168: && availableStretchHeight < this .getRelativeY()
169: - this .getY() - this .getBandBottomY()) {
170: isToPrint = false;
171: //willOverflow = true;
172: }
173:
174: if (isToPrint) {
175: if (getType() == JRBreak.TYPE_COLUMN) {
176: if (!filler.isFirstColumnBand
177: || band.firstYElement != null) {
178: setStretchHeight(getHeight()
179: + availableStretchHeight - getRelativeY()
180: + getY() + getBandBottomY());
181: }
182: } else {
183: if (!filler.isFirstPageBand
184: || band.firstYElement != null) {
185: setStretchHeight(getHeight()
186: + availableStretchHeight - getRelativeY()
187: + getY() + getBandBottomY());
188: filler.columnIndex = filler.columnCount - 1;
189: }
190: }
191: }
192:
193: this .setToPrint(isToPrint);
194: this .setReprinted(false);
195:
196: return false;
197: }
198:
199: }
|