1 28 package net.sf.jasperreports.engine.base; 29 30 import java.awt.Color ; 31 import java.io.Serializable ; 32 33 import net.sf.jasperreports.engine.JRConstants; 34 import net.sf.jasperreports.engine.JRDefaultStyleProvider; 35 import net.sf.jasperreports.engine.JRElement; 36 import net.sf.jasperreports.engine.JRElementGroup; 37 import net.sf.jasperreports.engine.JRExpression; 38 import net.sf.jasperreports.engine.JRGroup; 39 import net.sf.jasperreports.engine.JRStyle; 40 import net.sf.jasperreports.engine.util.JRStyleResolver; 41 42 43 50 public abstract class JRBaseElement implements JRElement, Serializable 51 { 52 53 54 57 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 58 59 62 protected String key = null; 63 protected byte positionType; 64 protected byte stretchType; 65 protected boolean isPrintRepeatedValues = true; 66 protected Byte mode; 67 protected int x = 0; 68 protected int y = 0; 69 protected int width = 0; 70 protected int height = 0; 71 protected boolean isRemoveLineWhenBlank = false; 72 protected boolean isPrintInFirstWholeBand = false; 73 protected boolean isPrintWhenDetailOverflows = false; 74 protected Color forecolor = null; 75 protected Color backcolor = null; 76 77 80 protected JRExpression printWhenExpression = null; 81 protected JRGroup printWhenGroupChanges = null; 82 protected JRElementGroup elementGroup = null; 83 84 protected JRDefaultStyleProvider defaultStyleProvider; 85 protected JRStyle parentStyle; 86 87 88 91 protected JRBaseElement(JRDefaultStyleProvider defaultStyleProvider) 92 { 93 this.defaultStyleProvider = defaultStyleProvider; 94 } 95 96 97 104 protected JRBaseElement(JRElement element, JRBaseObjectFactory factory) 105 { 106 factory.put(element, this); 107 108 defaultStyleProvider = factory.getDefaultStyleProvider(); 109 110 parentStyle = factory.getStyle(element.getStyle()); 111 112 key = element.getKey(); 113 positionType = element.getPositionType(); 114 stretchType = element.getStretchType(); 115 isPrintRepeatedValues = element.isPrintRepeatedValues(); 116 mode = element.getOwnMode(); 117 x = element.getX(); 118 y = element.getY(); 119 width = element.getWidth(); 120 height = element.getHeight(); 121 isRemoveLineWhenBlank = element.isRemoveLineWhenBlank(); 122 isPrintInFirstWholeBand = element.isPrintInFirstWholeBand(); 123 isPrintWhenDetailOverflows = element.isPrintWhenDetailOverflows(); 124 forecolor = element.getOwnForecolor(); 125 backcolor = element.getOwnBackcolor(); 126 127 printWhenExpression = factory.getExpression(element.getPrintWhenExpression()); 128 printWhenGroupChanges = factory.getGroup(element.getPrintWhenGroupChanges()); 129 elementGroup = factory.getElementGroup(element.getElementGroup()); 130 } 131 132 133 136 public JRDefaultStyleProvider getDefaultStyleProvider() 137 { 138 return defaultStyleProvider; 139 } 140 141 144 protected JRStyle getBaseStyle() 145 { 146 if (parentStyle != null) 147 return parentStyle; 148 if (defaultStyleProvider != null) 149 return defaultStyleProvider.getDefaultStyle(); 150 return null; 151 } 152 153 156 public String getKey() 157 { 158 return this.key; 159 } 160 161 164 public byte getPositionType() 165 { 166 return positionType; 167 } 168 169 172 public void setPositionType(byte positionType) 173 { 174 this.positionType = positionType; 175 } 176 177 180 public byte getStretchType() 181 { 182 return stretchType; 183 } 184 185 188 public void setStretchType(byte stretchType) 189 { 190 this.stretchType = stretchType; 191 } 192 193 196 public boolean isPrintRepeatedValues() 197 { 198 return this.isPrintRepeatedValues; 199 } 200 201 204 public void setPrintRepeatedValues(boolean isPrintRepeatedValues) 205 { 206 this.isPrintRepeatedValues = isPrintRepeatedValues; 207 } 208 209 212 public byte getMode() 213 { 214 return JRStyleResolver.getMode(this, MODE_OPAQUE); 215 } 216 217 220 public Byte getOwnMode() 221 { 222 return mode; 223 } 224 225 228 public void setMode(byte mode) 229 { 230 this.mode = new Byte (mode); 231 } 232 233 236 public void setMode(Byte mode) 237 { 238 this.mode = mode; 239 } 240 241 244 public int getX() 245 { 246 return this.x; 247 } 248 249 252 public void setX(int x) 253 { 254 this.x = x; 255 } 256 257 260 public int getY() 261 { 262 return this.y; 263 } 264 265 268 public int getWidth() 269 { 270 return this.width; 271 } 272 273 276 public void setWidth(int width) 277 { 278 this.width = width; 279 } 280 281 284 public int getHeight() 285 { 286 return this.height; 287 } 288 289 292 public boolean isRemoveLineWhenBlank() 293 { 294 return this.isRemoveLineWhenBlank; 295 } 296 297 300 public void setRemoveLineWhenBlank(boolean isRemoveLine) 301 { 302 this.isRemoveLineWhenBlank = isRemoveLine; 303 } 304 305 308 public boolean isPrintInFirstWholeBand() 309 { 310 return this.isPrintInFirstWholeBand; 311 } 312 313 316 public void setPrintInFirstWholeBand(boolean isPrint) 317 { 318 this.isPrintInFirstWholeBand = isPrint; 319 } 320 321 324 public boolean isPrintWhenDetailOverflows() 325 { 326 return this.isPrintWhenDetailOverflows; 327 } 328 329 332 public void setPrintWhenDetailOverflows(boolean isPrint) 333 { 334 this.isPrintWhenDetailOverflows = isPrint; 335 } 336 337 340 public Color getForecolor() 341 { 342 return JRStyleResolver.getForecolor(this); 343 } 344 345 348 public Color getOwnForecolor() 349 { 350 return forecolor; 351 } 352 353 356 public void setForecolor(Color forecolor) 357 { 358 this.forecolor = forecolor; 359 } 360 361 364 public Color getBackcolor() 365 { 366 return JRStyleResolver.getBackcolor(this); 367 } 368 369 372 public Color getOwnBackcolor() 373 { 374 return backcolor; 375 } 376 377 380 public void setBackcolor(Color backcolor) 381 { 382 this.backcolor = backcolor; 383 } 384 385 388 public JRExpression getPrintWhenExpression() 389 { 390 return this.printWhenExpression; 391 } 392 393 396 public JRGroup getPrintWhenGroupChanges() 397 { 398 return this.printWhenGroupChanges; 399 } 400 401 404 public JRElementGroup getElementGroup() 405 { 406 return this.elementGroup; 407 } 408 409 public JRStyle getStyle() 410 { 411 return parentStyle; 412 } 413 } 414 | Popular Tags |