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.JRBox; 34 import net.sf.jasperreports.engine.JRConstants; 35 import net.sf.jasperreports.engine.JRDefaultStyleProvider; 36 import net.sf.jasperreports.engine.JRGraphicElement; 37 import net.sf.jasperreports.engine.JRStyle; 38 import net.sf.jasperreports.engine.util.JRStyleResolver; 39 40 41 47 public class JRBaseBox implements JRBox, Serializable 48 { 49 50 51 54 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 55 56 59 protected Byte border = null; 60 protected Byte topBorder = null; 61 protected Byte leftBorder = null; 62 protected Byte bottomBorder = null; 63 protected Byte rightBorder = null; 64 protected Color borderColor = null; 65 protected Color topBorderColor = null; 66 protected Color leftBorderColor = null; 67 protected Color bottomBorderColor = null; 68 protected Color rightBorderColor = null; 69 protected Integer padding = null; 70 protected Integer topPadding = null; 71 protected Integer leftPadding = null; 72 protected Integer bottomPadding = null; 73 protected Integer rightPadding = null; 74 75 76 79 public JRBaseBox() 80 { 81 super(); 82 } 83 84 85 public JRBaseBox(byte pen, Color color) 86 { 87 setBorder(pen); 88 setBorderColor(color); 89 } 90 91 96 public JRBaseBox(JRBox box) 97 { 98 border = box.getOwnBorder(); 99 borderColor = box.getOwnBorderColor(); 100 padding = box.getOwnPadding(); 101 102 topBorder = box.getOwnTopBorder(); 103 topBorderColor = box.getOwnTopBorderColor(); 104 topPadding = box.getOwnTopPadding(); 105 106 leftBorder = box.getOwnLeftBorder(); 107 leftBorderColor = box.getOwnLeftBorderColor(); 108 leftPadding = box.getOwnLeftPadding(); 109 110 bottomBorder = box.getOwnBottomBorder(); 111 bottomBorderColor = box.getOwnBottomBorderColor(); 112 bottomPadding = box.getOwnBottomPadding(); 113 114 rightBorder = box.getOwnRightBorder(); 115 rightBorderColor = box.getOwnRightBorderColor(); 116 rightPadding = box.getOwnRightPadding(); 117 } 118 119 120 130 public JRBaseBox(JRBox box, boolean left, boolean right, boolean top, boolean bottom, JRBox complementaryBox) 131 { 132 if (left && box.getLeftBorder() != JRGraphicElement.PEN_NONE) 133 { 134 leftBorder = new Byte (box.getLeftBorder()); 135 leftBorderColor = box.getLeftBorderColor(); 136 leftPadding = new Integer (box.getLeftPadding()); 137 } 138 else if (complementaryBox != null) 139 { 140 leftBorder = new Byte (complementaryBox.getLeftBorder()); 141 leftBorderColor = complementaryBox.getLeftBorderColor(); 142 leftPadding = new Integer (complementaryBox.getLeftPadding()); 143 } 144 145 if (right && box.getRightBorder() != JRGraphicElement.PEN_NONE) 146 { 147 rightBorder = new Byte (box.getRightBorder()); 148 rightBorderColor = box.getRightBorderColor(); 149 rightPadding = new Integer (box.getRightPadding()); 150 } 151 else if (complementaryBox != null) 152 { 153 rightBorder = new Byte (complementaryBox.getRightBorder()); 154 rightBorderColor = complementaryBox.getRightBorderColor(); 155 rightPadding = new Integer (complementaryBox.getRightPadding()); 156 } 157 158 if (top && box.getTopBorder() != JRGraphicElement.PEN_NONE) 159 { 160 topBorder = new Byte (box.getTopBorder()); 161 topBorderColor = box.getTopBorderColor(); 162 topPadding = new Integer (box.getTopPadding()); 163 } 164 else if (complementaryBox != null) 165 { 166 topBorder = new Byte (complementaryBox.getTopBorder()); 167 topBorderColor = complementaryBox.getTopBorderColor(); 168 topPadding = new Integer (complementaryBox.getTopPadding()); 169 } 170 171 if (bottom && box.getBottomBorder() != JRGraphicElement.PEN_NONE) 172 { 173 bottomBorder = new Byte (box.getBottomBorder()); 174 bottomBorderColor = box.getBottomBorderColor(); 175 bottomPadding = new Integer (box.getBottomPadding()); 176 } 177 else if (complementaryBox != null) 178 { 179 bottomBorder = new Byte (complementaryBox.getBottomBorder()); 180 bottomBorderColor = complementaryBox.getBottomBorderColor(); 181 bottomPadding = new Integer (complementaryBox.getBottomPadding()); 182 } 183 } 184 185 186 public JRBaseBox(JRBox box, boolean resetLeft, boolean resetRight, boolean resetTop, boolean resetBottom) 187 { 188 border = box.getOwnBorder(); 189 borderColor = box.getOwnBorderColor(); 190 padding = box.getOwnPadding(); 191 192 if (resetLeft) 193 { 194 leftBorder = new Byte (JRGraphicElement.PEN_NONE); 195 leftBorderColor = null; 196 leftPadding = new Integer (0); 197 } 198 else 199 { 200 leftBorder = box.getOwnLeftBorder(); 201 leftBorderColor = box.getOwnLeftBorderColor(); 202 leftPadding = box.getOwnLeftPadding(); 203 } 204 205 if (resetTop) 206 { 207 topBorder = new Byte (JRGraphicElement.PEN_NONE); 208 topBorderColor = null; 209 topPadding = new Integer (0); 210 } 211 else 212 { 213 topBorder = box.getOwnTopBorder(); 214 topBorderColor = box.getOwnTopBorderColor(); 215 topPadding = box.getOwnTopPadding(); 216 } 217 218 if (resetRight) 219 { 220 rightBorder = new Byte (JRGraphicElement.PEN_NONE); 221 rightBorderColor = null; 222 rightPadding = new Integer (0); 223 } 224 else 225 { 226 rightBorder = box.getOwnRightBorder(); 227 rightBorderColor = box.getOwnRightBorderColor(); 228 rightPadding = box.getOwnRightPadding(); 229 } 230 231 if (resetBottom) 232 { 233 bottomBorder = new Byte (JRGraphicElement.PEN_NONE); 234 bottomBorderColor = null; 235 bottomPadding = new Integer (0); 236 } 237 else 238 { 239 bottomBorder = box.getOwnBottomBorder(); 240 bottomBorderColor = box.getOwnBottomBorderColor(); 241 bottomPadding = box.getOwnBottomPadding(); 242 } 243 } 244 245 248 public JRDefaultStyleProvider getDefaultStyleProvider() 249 { 250 return null; 251 } 252 253 256 public JRStyle getStyle() 257 { 258 return null; 259 } 260 261 264 public byte getBorder() 265 { 266 return JRStyleResolver.getBorder(this); 267 } 268 269 272 public Byte getOwnBorder() 273 { 274 return border; 275 } 276 277 280 public void setBorder(byte border) 281 { 282 this.border = new Byte (border); 283 } 284 285 288 public void setBorder(Byte border) 289 { 290 this.border = border; 291 } 292 293 296 public Color getBorderColor() 297 { 298 return JRStyleResolver.getBorderColor(this, Color.black); 299 } 300 301 public Color getOwnBorderColor() 302 { 303 return borderColor; 304 } 305 306 309 public void setBorderColor(Color borderColor) 310 { 311 this.borderColor = borderColor; 312 } 313 314 317 public int getPadding() 318 { 319 return JRStyleResolver.getPadding(this); 320 } 321 322 public Integer getOwnPadding() 323 { 324 return padding; 325 } 326 327 330 public void setPadding(int padding) 331 { 332 this.padding = new Integer (padding); 333 } 334 335 338 public void setPadding(Integer padding) 339 { 340 this.padding = padding; 341 } 342 343 346 public byte getTopBorder() 347 { 348 return JRStyleResolver.getTopBorder(this); 349 } 350 351 354 public Byte getOwnTopBorder() 355 { 356 return topBorder; 357 } 358 359 362 public void setTopBorder(byte topBorder) 363 { 364 this.topBorder = new Byte (topBorder); 365 } 366 367 370 public void setTopBorder(Byte topBorder) 371 { 372 this.topBorder = topBorder; 373 } 374 375 378 public Color getTopBorderColor() 379 { 380 return JRStyleResolver.getTopBorderColor(this, Color.black); 381 } 382 383 386 public Color getOwnTopBorderColor() 387 { 388 return topBorderColor; 389 } 390 391 394 public void setTopBorderColor(Color topBorderColor) 395 { 396 this.topBorderColor = topBorderColor; 397 } 398 399 402 public int getTopPadding() 403 { 404 return JRStyleResolver.getTopPadding(this); 405 } 406 407 410 public Integer getOwnTopPadding() 411 { 412 return topPadding; 413 } 414 415 418 public void setTopPadding(int topPadding) 419 { 420 this.topPadding = new Integer (topPadding); 421 } 422 423 426 public void setTopPadding(Integer topPadding) 427 { 428 this.topPadding = topPadding; 429 } 430 431 434 public byte getLeftBorder() 435 { 436 return JRStyleResolver.getLeftBorder(this); 437 } 438 439 442 public Byte getOwnLeftBorder() 443 { 444 return leftBorder; 445 } 446 447 450 public void setLeftBorder(byte leftBorder) 451 { 452 this.leftBorder = new Byte (leftBorder); 453 } 454 455 458 public void setLeftBorder(Byte leftBorder) 459 { 460 this.leftBorder = leftBorder; 461 } 462 463 466 public Color getLeftBorderColor() 467 { 468 return JRStyleResolver.getLeftBorderColor(this, Color.black); 469 } 470 471 474 public Color getOwnLeftBorderColor() 475 { 476 return leftBorderColor; 477 } 478 479 482 public void setLeftBorderColor(Color leftBorderColor) 483 { 484 this.leftBorderColor = leftBorderColor; 485 } 486 487 490 public int getLeftPadding() 491 { 492 return JRStyleResolver.getLeftPadding(this); 493 } 494 495 498 public Integer getOwnLeftPadding() 499 { 500 return leftPadding; 501 } 502 503 506 public void setLeftPadding(int leftPadding) 507 { 508 this.leftPadding = new Integer (leftPadding); 509 } 510 511 514 public void setLeftPadding(Integer leftPadding) 515 { 516 this.leftPadding = leftPadding; 517 } 518 519 522 public byte getBottomBorder() 523 { 524 return JRStyleResolver.getBottomBorder(this); 525 } 526 527 530 public Byte getOwnBottomBorder() 531 { 532 return bottomBorder; 533 } 534 535 538 public void setBottomBorder(byte bottomBorder) 539 { 540 this.bottomBorder = new Byte (bottomBorder); 541 } 542 543 546 public void setBottomBorder(Byte bottomBorder) 547 { 548 this.bottomBorder = bottomBorder; 549 } 550 551 554 public Color getBottomBorderColor() 555 { 556 return JRStyleResolver.getBottomBorderColor(this, Color.black); 557 } 558 559 562 public Color getOwnBottomBorderColor() 563 { 564 return bottomBorderColor; 565 } 566 567 570 public void setBottomBorderColor(Color bottomBorderColor) 571 { 572 this.bottomBorderColor = bottomBorderColor; 573 } 574 575 578 public int getBottomPadding() 579 { 580 return JRStyleResolver.getBottomPadding(this); 581 } 582 583 586 public Integer getOwnBottomPadding() 587 { 588 return bottomPadding; 589 } 590 591 594 public void setBottomPadding(int bottomPadding) 595 { 596 this.bottomPadding = new Integer (bottomPadding); 597 } 598 599 602 public void setBottomPadding(Integer bottomPadding) 603 { 604 this.bottomPadding = bottomPadding; 605 } 606 607 610 public byte getRightBorder() 611 { 612 return JRStyleResolver.getRightBorder(this); 613 } 614 615 618 public Byte getOwnRightBorder() 619 { 620 return rightBorder; 621 } 622 623 626 public void setRightBorder(byte rightBorder) 627 { 628 this.rightBorder = new Byte (rightBorder); 629 } 630 631 634 public void setRightBorder(Byte rightBorder) 635 { 636 this.rightBorder = rightBorder; 637 } 638 639 642 public Color getRightBorderColor() 643 { 644 return JRStyleResolver.getRightBorderColor(this, Color.black); 645 } 646 647 650 public Color getOwnRightBorderColor() 651 { 652 return rightBorderColor; 653 } 654 655 658 public void setRightBorderColor(Color rightBorderColor) 659 { 660 this.rightBorderColor = rightBorderColor; 661 } 662 663 666 public int getRightPadding() 667 { 668 return JRStyleResolver.getRightPadding(this); 669 } 670 671 674 public Integer getOwnRightPadding() 675 { 676 return rightPadding; 677 } 678 679 682 public void setRightPadding(int rightPadding) 683 { 684 this.rightPadding = new Integer (rightPadding); 685 } 686 687 690 public void setRightPadding(Integer rightPadding) 691 { 692 this.rightPadding = rightPadding; 693 } 694 695 696 } 697 | Popular Tags |