KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > engine > fill > JRFillBreak


1 /*
2  * ============================================================================
3  * GNU Lesser General Public License
4  * ============================================================================
5  *
6  * JasperReports - Free Java report-generating library.
7  * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * JasperSoft Corporation
24  * 303 Second Street, Suite 450 North
25  * San Francisco, CA 94107
26  * http://www.jaspersoft.com
27  */

28 package net.sf.jasperreports.engine.fill;
29
30 import java.io.IOException JavaDoc;
31
32 import net.sf.jasperreports.engine.JRAbstractObjectFactory;
33 import net.sf.jasperreports.engine.JRBreak;
34 import net.sf.jasperreports.engine.JRChild;
35 import net.sf.jasperreports.engine.JRException;
36 import net.sf.jasperreports.engine.JRExpressionCollector;
37 import net.sf.jasperreports.engine.JRPrintElement;
38 import net.sf.jasperreports.engine.xml.JRXmlWriter;
39
40
41 /**
42  * @author Teodor Danciu (teodord@users.sourceforge.net)
43  * @version $Id: JRFillLine.java 1357 2006-08-10 12:36:24 +0300 (Thu, 10 Aug 2006) lucianc $
44  */

45 public class JRFillBreak extends JRFillElement implements JRBreak
46 {
47
48
49     /**
50      *
51      */

52     protected JRFillBreak(
53         JRBaseFiller filler,
54         JRBreak breakElement,
55         JRFillObjectFactory factory
56         )
57     {
58         super(filler, breakElement, factory);
59     }
60
61
62     protected JRFillBreak(JRFillBreak breakElement, JRFillCloneFactory factory)
63     {
64         super(breakElement, factory);
65     }
66
67
68     /**
69      *
70      */

71     public int getWidth()
72     {
73         return filler.columnWidth;
74     }
75
76     /**
77      *
78      */

79     public byte getType()
80     {
81         return ((JRBreak)parent).getType();
82     }
83         
84     /**
85      *
86      */

87     public void setType(byte type)
88     {
89     }
90
91
92     /**
93      *
94      */

95     protected void evaluate(
96         byte evaluation
97         ) throws JRException
98     {
99         this.reset();
100         
101         this.evaluatePrintWhenExpression(evaluation);
102         
103         setValueRepeating(true);
104     }
105
106
107     /**
108      *
109      */

110     protected JRPrintElement fill()
111     {
112         return null;
113 // JRPrintLine printLine = null;
114
//
115
// printLine = new JRBasePrintLine(filler.getJasperPrint().getDefaultStyleProvider());
116
// printLine.setX(0);
117
// printLine.setY(this.getRelativeY());
118
// printLine.setWidth(getWidth());
119
// printLine.setHeight(1);
120
// printLine.setPen(JRGraphicElement.PEN_DOTTED);
121
// printLine.setForecolor(getForecolor());
122
//
123
// return printLine;
124
}
125
126
127     /**
128      *
129      */

130     public JRChild getCopy(JRAbstractObjectFactory factory)
131     {
132         return factory.getBreak(this);
133     }
134
135     /**
136      *
137      */

138     public void collectExpressions(JRExpressionCollector collector)
139     {
140         collector.collect(this);
141     }
142
143     /**
144      *
145      */

146     public void writeXml(JRXmlWriter xmlWriter) throws IOException JavaDoc
147     {
148         xmlWriter.writeBreak(this);
149     }
150
151     /**
152      *
153      */

154     protected void resolveElement (JRPrintElement element, byte evaluation)
155     {
156         // nothing
157
}
158
159
160     public JRCloneable createClone(JRFillCloneFactory factory)
161     {
162         return new JRFillBreak(this, factory);
163     }
164
165
166     /**
167      *
168      */

169     public void rewind()
170     {
171     }
172
173
174     /**
175      *
176      */

177     protected boolean prepare(
178         int availableStretchHeight,
179         boolean isOverflow
180         ) throws JRException
181     {
182         super.prepare(availableStretchHeight, isOverflow);
183         
184         if (!this.isToPrint())
185         {
186             return false;
187         }
188         
189         boolean isToPrint = true;
190
191         if (isOverflow && this.isAlreadyPrinted())// && !this.isPrintWhenDetailOverflows())
192
{
193             isToPrint = false;
194         }
195
196         //boolean willOverflow = false;
197

198         if (
199             isToPrint &&
200             availableStretchHeight < this.getRelativeY() - this.getY() - this.getBandBottomY()
201             )
202         {
203             isToPrint = false;
204             //willOverflow = true;
205
}
206         
207         if (isToPrint)
208         {
209             if (getType() == JRBreak.TYPE_COLUMN)
210             {
211                 if (!filler.isNewColumn || band.firstYElement != null)
212                 {
213                     setStretchHeight(getHeight() + availableStretchHeight - getRelativeY() + getY() + getBandBottomY());
214                 }
215             }
216             else
217             {
218                 if (!filler.isNewPage || band.firstYElement != null)
219                 {
220                     setStretchHeight(getHeight() + availableStretchHeight - getRelativeY() + getY() + getBandBottomY());
221                     filler.columnIndex = filler.columnCount - 1;
222                 }
223             }
224         }
225             
226         this.setToPrint(isToPrint);
227         this.setReprinted(false);
228
229         return false;
230     }
231     
232     
233 }
234
Popular Tags