1 28 package net.sf.jasperreports.engine.fill; 29 30 import java.io.IOException ; 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 45 public class JRFillBreak extends JRFillElement implements JRBreak 46 { 47 48 49 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 71 public int getWidth() 72 { 73 return filler.columnWidth; 74 } 75 76 79 public byte getType() 80 { 81 return ((JRBreak)parent).getType(); 82 } 83 84 87 public void setType(byte type) 88 { 89 } 90 91 92 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 110 protected JRPrintElement fill() 111 { 112 return null; 113 } 125 126 127 130 public JRChild getCopy(JRAbstractObjectFactory factory) 131 { 132 return factory.getBreak(this); 133 } 134 135 138 public void collectExpressions(JRExpressionCollector collector) 139 { 140 collector.collect(this); 141 } 142 143 146 public void writeXml(JRXmlWriter xmlWriter) throws IOException 147 { 148 xmlWriter.writeBreak(this); 149 } 150 151 154 protected void resolveElement (JRPrintElement element, byte evaluation) 155 { 156 } 158 159 160 public JRCloneable createClone(JRFillCloneFactory factory) 161 { 162 return new JRFillBreak(this, factory); 163 } 164 165 166 169 public void rewind() 170 { 171 } 172 173 174 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()) { 193 isToPrint = false; 194 } 195 196 198 if ( 199 isToPrint && 200 availableStretchHeight < this.getRelativeY() - this.getY() - this.getBandBottomY() 201 ) 202 { 203 isToPrint = false; 204 } 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 |