1 28 package net.sf.jasperreports.engine.fill; 29 30 import java.awt.Color ; 31 import java.io.IOException ; 32 import java.io.ObjectInputStream ; 33 34 import net.sf.jasperreports.engine.JRAlignment; 35 import net.sf.jasperreports.engine.JRBox; 36 import net.sf.jasperreports.engine.JRChart; 37 import net.sf.jasperreports.engine.JRConstants; 38 import net.sf.jasperreports.engine.JRDefaultStyleProvider; 39 import net.sf.jasperreports.engine.JRElement; 40 import net.sf.jasperreports.engine.JRGraphicElement; 41 import net.sf.jasperreports.engine.JRHyperlink; 42 import net.sf.jasperreports.engine.JRHyperlinkHelper; 43 import net.sf.jasperreports.engine.JRImage; 44 import net.sf.jasperreports.engine.util.JRStyleResolver; 45 46 47 51 public class JRTemplateImage extends JRTemplateGraphicElement implements JRAlignment, JRBox 52 { 53 54 55 58 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 59 60 63 private Byte scaleImage = null; 64 private Byte horizontalAlignment = null; 65 private Byte verticalAlignment = null; 66 protected boolean isLazy = false; 67 private byte onErrorType = JRImage.ON_ERROR_TYPE_ERROR; 68 private byte hyperlinkType = JRHyperlink.HYPERLINK_TYPE_NULL; 69 private String linkType; 70 private byte hyperlinkTarget = JRHyperlink.HYPERLINK_TARGET_SELF; 71 73 76 protected Byte border; 77 protected Byte topBorder = null; 78 protected Byte leftBorder = null; 79 protected Byte bottomBorder = null; 80 protected Byte rightBorder = null; 81 protected Color borderColor = null; 82 protected Color topBorderColor = null; 83 protected Color leftBorderColor = null; 84 protected Color bottomBorderColor = null; 85 protected Color rightBorderColor = null; 86 protected Integer padding; 87 protected Integer topPadding = null; 88 protected Integer leftPadding = null; 89 protected Integer bottomPadding = null; 90 protected Integer rightPadding = null; 91 92 93 96 protected JRTemplateImage(JRDefaultStyleProvider defaultStyleProvider, JRImage image) 97 { 98 super(defaultStyleProvider); 99 100 setImage(image); 101 } 102 103 104 107 protected JRTemplateImage(JRDefaultStyleProvider defaultStyleProvider, JRChart chart) 108 { 109 super(defaultStyleProvider); 110 111 setChart(chart); 112 } 113 114 117 protected void setBox(JRBox box) 118 { 119 border = box.getOwnBorder(); 120 topBorder = box.getOwnTopBorder(); 121 leftBorder = box.getOwnLeftBorder(); 122 bottomBorder = box.getOwnBottomBorder(); 123 rightBorder = box.getOwnRightBorder(); 124 borderColor = box.getOwnBorderColor(); 125 topBorderColor = box.getOwnTopBorderColor(); 126 leftBorderColor = box.getOwnLeftBorderColor(); 127 bottomBorderColor = box.getOwnBottomBorderColor(); 128 rightBorderColor = box.getOwnRightBorderColor(); 129 padding = box.getOwnPadding(); 130 topPadding = box.getOwnTopPadding(); 131 leftPadding = box.getOwnLeftPadding(); 132 bottomPadding = box.getOwnBottomPadding(); 133 rightPadding = box.getOwnRightPadding(); 134 } 135 136 139 protected void setImage(JRImage image) 140 { 141 super.setGraphicElement(image); 142 143 setBox(image); 144 145 setScaleImage(image.getScaleImage()); 146 setHorizontalAlignment(image.getHorizontalAlignment()); 147 setVerticalAlignment(image.getVerticalAlignment()); 148 setLazy(image.isLazy()); 149 setOnErrorType(image.getOnErrorType()); 150 setLinkType(image.getLinkType()); 151 setHyperlinkTarget(image.getHyperlinkTarget()); 152 } 153 154 157 protected void setChart(JRChart chart) 158 { 159 super.setElement(chart); 160 161 setPen(JRGraphicElement.PEN_NONE); 162 setFill(JRGraphicElement.FILL_SOLID); 163 164 setBox(chart); 165 166 setLinkType(chart.getLinkType()); 167 setHyperlinkTarget(chart.getHyperlinkTarget()); 168 } 169 170 173 public byte getMode() 174 { 175 return JRStyleResolver.getMode(this, JRElement.MODE_TRANSPARENT); 176 } 177 178 181 public byte getPen() 182 { 183 return JRStyleResolver.getPen(this, JRGraphicElement.PEN_NONE); 184 } 185 186 189 public byte getScaleImage() 190 { 191 return JRStyleResolver.getScaleImage(this); 192 } 193 194 197 public Byte getOwnScaleImage() 198 { 199 return scaleImage; 200 } 201 202 205 protected void setScaleImage(byte scaleImage) 206 { 207 this.scaleImage = new Byte (scaleImage); 208 } 209 210 213 protected void setScaleImage(Byte scaleImage) 214 { 215 this.scaleImage = scaleImage; 216 } 217 218 221 public byte getHorizontalAlignment() 222 { 223 return JRStyleResolver.getHorizontalAlignment(this); 224 } 225 226 229 public Byte getOwnHorizontalAlignment() 230 { 231 return horizontalAlignment; 232 } 233 234 237 public void setHorizontalAlignment(byte horizontalAlignment) 238 { 239 this.horizontalAlignment = new Byte (horizontalAlignment); 240 } 241 242 245 public void setHorizontalAlignment(Byte horizontalAlignment) 246 { 247 this.horizontalAlignment = horizontalAlignment; 248 } 249 250 253 public byte getVerticalAlignment() 254 { 255 return JRStyleResolver.getVerticalAlignment(this); 256 } 257 258 261 public Byte getOwnVerticalAlignment() 262 { 263 return verticalAlignment; 264 } 265 266 269 public void setVerticalAlignment(byte verticalAlignment) 270 { 271 this.verticalAlignment = new Byte (verticalAlignment); 272 } 273 274 277 public void setVerticalAlignment(Byte verticalAlignment) 278 { 279 this.verticalAlignment = verticalAlignment; 280 } 281 282 285 public boolean isLazy() 286 { 287 return this.isLazy; 288 } 289 290 293 public void setLazy(boolean isLazy) 294 { 295 this.isLazy = isLazy; 296 } 297 298 301 public byte getOnErrorType() 302 { 303 return this.onErrorType; 304 } 305 306 309 public void setOnErrorType(byte onErrorType) 310 { 311 this.onErrorType = onErrorType; 312 } 313 314 317 public JRBox getBox() 318 { 319 return this; 320 } 321 322 323 334 public byte getHyperlinkType() 335 { 336 return JRHyperlinkHelper.getHyperlinkType(getLinkType()); 337 } 338 339 340 346 protected void setHyperlinkType(byte hyperlinkType) 347 { 348 setLinkType(JRHyperlinkHelper.getLinkType(hyperlinkType)); 349 } 350 351 354 public byte getHyperlinkTarget() 355 { 356 return this.hyperlinkTarget; 357 } 358 359 362 protected void setHyperlinkTarget(byte hyperlinkTarget) 363 { 364 this.hyperlinkTarget = hyperlinkTarget; 365 } 366 367 370 public byte getBorder() 371 { 372 return JRStyleResolver.getBorder(this); 373 } 374 375 public Byte getOwnBorder() 376 { 377 return border; 378 } 379 380 383 public void setBorder(byte border) 384 { 385 this.border = new Byte (border); 386 } 387 388 391 public Color getBorderColor() 392 { 393 return JRStyleResolver.getBorderColor(this, getForecolor()); 394 } 395 396 public Color getOwnBorderColor() 397 { 398 return borderColor; 399 } 400 401 404 public void setBorderColor(Color borderColor) 405 { 406 this.borderColor = borderColor; 407 } 408 409 412 public int getPadding() 413 { 414 return JRStyleResolver.getPadding(this); 415 } 416 417 public Integer getOwnPadding() 418 { 419 return padding; 420 } 421 422 425 public void setPadding(int padding) 426 { 427 this.padding = new Integer (padding); 428 } 429 430 433 public byte getTopBorder() 434 { 435 return JRStyleResolver.getTopBorder(this); 436 } 437 438 441 public Byte getOwnTopBorder() 442 { 443 return topBorder; 444 } 445 446 449 public void setTopBorder(byte topBorder) 450 { 451 this.topBorder = new Byte (topBorder); 452 } 453 454 457 public Color getTopBorderColor() 458 { 459 return JRStyleResolver.getTopBorderColor(this, getForecolor()); 460 } 461 462 465 public Color getOwnTopBorderColor() 466 { 467 return topBorderColor; 468 } 469 470 473 public void setTopBorderColor(Color topBorderColor) 474 { 475 this.topBorderColor = topBorderColor; 476 } 477 478 481 public int getTopPadding() 482 { 483 return JRStyleResolver.getTopPadding(this); 484 } 485 486 489 public Integer getOwnTopPadding() 490 { 491 return topPadding; 492 } 493 494 497 public void setTopPadding(int topPadding) 498 { 499 this.topPadding = new Integer (topPadding); 500 } 501 502 505 public byte getLeftBorder() 506 { 507 return JRStyleResolver.getLeftBorder(this); 508 } 509 510 513 public Byte getOwnLeftBorder() 514 { 515 return leftBorder; 516 } 517 518 521 public void setLeftBorder(byte leftBorder) 522 { 523 this.leftBorder = new Byte (leftBorder); 524 } 525 526 529 public Color getLeftBorderColor() 530 { 531 return JRStyleResolver.getLeftBorderColor(this, getForecolor()); 532 } 533 534 537 public Color getOwnLeftBorderColor() 538 { 539 return leftBorderColor; 540 } 541 542 545 public void setLeftBorderColor(Color leftBorderColor) 546 { 547 this.leftBorderColor = leftBorderColor; 548 } 549 550 553 public int getLeftPadding() 554 { 555 return JRStyleResolver.getLeftPadding(this); 556 } 557 558 561 public Integer getOwnLeftPadding() 562 { 563 return leftPadding; 564 } 565 566 569 public void setLeftPadding(int leftPadding) 570 { 571 this.leftPadding = new Integer (leftPadding); 572 } 573 574 577 public byte getBottomBorder() 578 { 579 return JRStyleResolver.getBottomBorder(this); 580 } 581 582 585 public Byte getOwnBottomBorder() 586 { 587 return bottomBorder; 588 } 589 590 593 public void setBottomBorder(byte bottomBorder) 594 { 595 this.bottomBorder = new Byte (bottomBorder); 596 } 597 598 601 public Color getBottomBorderColor() 602 { 603 return JRStyleResolver.getBottomBorderColor(this, getForecolor()); 604 } 605 606 609 public Color getOwnBottomBorderColor() 610 { 611 return bottomBorderColor; 612 } 613 614 617 public void setBottomBorderColor(Color bottomBorderColor) 618 { 619 this.bottomBorderColor = bottomBorderColor; 620 } 621 622 625 public int getBottomPadding() 626 { 627 return JRStyleResolver.getBottomPadding(this); 628 } 629 630 633 public Integer getOwnBottomPadding() 634 { 635 return bottomPadding; 636 } 637 638 641 public void setBottomPadding(int bottomPadding) 642 { 643 this.bottomPadding = new Integer (bottomPadding); 644 } 645 646 649 public byte getRightBorder() 650 { 651 return JRStyleResolver.getRightBorder(this); 652 } 653 654 657 public Byte getOwnRightBorder() 658 { 659 return rightBorder; 660 } 661 662 665 public void setRightBorder(byte rightBorder) 666 { 667 this.rightBorder = new Byte (rightBorder); 668 } 669 670 673 public Color getRightBorderColor() 674 { 675 return JRStyleResolver.getRightBorderColor(this, getForecolor()); 676 } 677 678 681 public Color getOwnRightBorderColor() 682 { 683 return rightBorderColor; 684 } 685 686 689 public void setRightBorderColor(Color rightBorderColor) 690 { 691 this.rightBorderColor = rightBorderColor; 692 } 693 694 697 public int getRightPadding() 698 { 699 return JRStyleResolver.getRightPadding(this); 700 } 701 702 705 public Integer getOwnRightPadding() 706 { 707 return rightPadding; 708 } 709 710 713 public void setRightPadding(int rightPadding) 714 { 715 this.rightPadding = new Integer (rightPadding); 716 } 717 718 721 public void setBorder(Byte border) 722 { 723 this.border = border; 724 } 725 726 729 public void setPadding(Integer padding) 730 { 731 this.padding = padding; 732 } 733 734 737 public void setTopBorder(Byte topBorder) 738 { 739 this.topBorder = topBorder; 740 } 741 742 745 public void setTopPadding(Integer topPadding) 746 { 747 this.topPadding = topPadding; 748 } 749 750 753 public void setLeftBorder(Byte leftBorder) 754 { 755 this.leftBorder = leftBorder; 756 } 757 758 761 public void setLeftPadding(Integer leftPadding) 762 { 763 this.leftPadding = leftPadding; 764 } 765 766 769 public void setBottomBorder(Byte bottomBorder) 770 { 771 this.bottomBorder = bottomBorder; 772 } 773 774 777 public void setBottomPadding(Integer bottomPadding) 778 { 779 this.bottomPadding = bottomPadding; 780 } 781 782 785 public void setRightBorder(Byte rightBorder) 786 { 787 this.rightBorder = rightBorder; 788 } 789 790 793 public void setRightPadding(Integer rightPadding) 794 { 795 this.rightPadding = rightPadding; 796 } 797 798 799 808 public String getLinkType() 809 { 810 return linkType; 811 } 812 813 814 823 public void setLinkType(String linkType) 824 { 825 this.linkType = linkType; 826 } 827 828 829 private void readObject(ObjectInputStream in) throws IOException , ClassNotFoundException 830 { 831 in.defaultReadObject(); 832 normalizeLinkType(); 833 } 834 835 836 protected void normalizeLinkType() 837 { 838 if (linkType == null) 839 { 840 linkType = JRHyperlinkHelper.getLinkType(hyperlinkType); 841 } 842 hyperlinkType = JRHyperlink.HYPERLINK_TYPE_NULL; 843 } 844 845 } 846 | Popular Tags |