1 28 package net.sf.jasperreports.engine.base; 29 30 import java.awt.Color ; 31 import java.io.IOException ; 32 import java.io.ObjectInputStream ; 33 34 import net.sf.jasperreports.engine.JRAnchor; 35 import net.sf.jasperreports.engine.JRBox; 36 import net.sf.jasperreports.engine.JRConstants; 37 import net.sf.jasperreports.engine.JRDefaultStyleProvider; 38 import net.sf.jasperreports.engine.JRElement; 39 import net.sf.jasperreports.engine.JRGraphicElement; 40 import net.sf.jasperreports.engine.JRHyperlink; 41 import net.sf.jasperreports.engine.JRHyperlinkHelper; 42 import net.sf.jasperreports.engine.JRImage; 43 import net.sf.jasperreports.engine.JRPrintHyperlinkParameter; 44 import net.sf.jasperreports.engine.JRPrintHyperlinkParameters; 45 import net.sf.jasperreports.engine.JRPrintImage; 46 import net.sf.jasperreports.engine.JRRenderable; 47 import net.sf.jasperreports.engine.util.JRStyleResolver; 48 49 50 54 public class JRBasePrintImage extends JRBasePrintGraphicElement implements JRPrintImage 55 { 56 57 58 61 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 62 63 66 protected JRRenderable renderer = null; 67 protected Byte scaleImage = null; 68 protected Byte horizontalAlignment = null; 69 protected Byte verticalAlignment = null; 70 protected boolean isLazy = false; 71 protected byte onErrorType = JRImage.ON_ERROR_TYPE_ERROR; 72 protected String anchorName = null; 74 protected byte hyperlinkType = JRHyperlink.HYPERLINK_TYPE_NULL; 75 private String linkType; 76 protected byte hyperlinkTarget = JRHyperlink.HYPERLINK_TARGET_SELF; 77 protected String hyperlinkReference = null; 78 protected String hyperlinkAnchor = null; 79 protected Integer hyperlinkPage = null; 80 protected String hyperlinkTooltip; 81 protected JRPrintHyperlinkParameters hyperlinkParameters; 82 83 87 protected int bookmarkLevel = JRAnchor.NO_BOOKMARK; 88 89 92 protected Byte border; 93 protected Byte topBorder = null; 94 protected Byte leftBorder = null; 95 protected Byte bottomBorder = null; 96 protected Byte rightBorder = null; 97 protected Color borderColor = null; 98 protected Color topBorderColor = null; 99 protected Color leftBorderColor = null; 100 protected Color bottomBorderColor = null; 101 protected Color rightBorderColor = null; 102 protected Integer padding; 103 protected Integer topPadding = null; 104 protected Integer leftPadding = null; 105 protected Integer bottomPadding = null; 106 protected Integer rightPadding = null; 107 108 109 112 public JRBasePrintImage(JRDefaultStyleProvider defaultStyleProvider) 113 { 114 super(defaultStyleProvider); 115 } 116 117 118 121 public byte getMode() 122 { 123 return JRStyleResolver.getMode(this, JRElement.MODE_TRANSPARENT); 124 } 125 126 129 public byte getPen() 130 { 131 return JRStyleResolver.getPen(this, JRGraphicElement.PEN_NONE); 132 } 133 134 137 public JRRenderable getRenderer() 138 { 139 return renderer; 140 } 141 142 145 public void setRenderer(JRRenderable renderer) 146 { 147 this.renderer = renderer; 148 } 149 150 153 public byte getScaleImage() 154 { 155 return JRStyleResolver.getScaleImage(this); 156 } 157 158 161 public Byte getOwnScaleImage() 162 { 163 return scaleImage; 164 } 165 166 169 public void setScaleImage(byte scaleImage) 170 { 171 this.scaleImage = new Byte (scaleImage); 172 } 173 174 177 public void setScaleImage(Byte scaleImage) 178 { 179 this.scaleImage = scaleImage; 180 } 181 182 185 public byte getHorizontalAlignment() 186 { 187 return JRStyleResolver.getHorizontalAlignment(this); 188 } 189 190 193 public Byte getOwnHorizontalAlignment() 194 { 195 return horizontalAlignment; 196 } 197 198 201 public void setHorizontalAlignment(byte horizontalAlignment) 202 { 203 this.horizontalAlignment = new Byte (horizontalAlignment); 204 } 205 206 209 public void setHorizontalAlignment(Byte horizontalAlignment) 210 { 211 this.horizontalAlignment = horizontalAlignment; 212 } 213 214 217 public byte getVerticalAlignment() 218 { 219 return JRStyleResolver.getVerticalAlignment(this); 220 } 221 222 225 public Byte getOwnVerticalAlignment() 226 { 227 return verticalAlignment; 228 } 229 230 233 public void setVerticalAlignment(byte verticalAlignment) 234 { 235 this.verticalAlignment = new Byte (verticalAlignment); 236 } 237 238 241 public void setVerticalAlignment(Byte verticalAlignment) 242 { 243 this.verticalAlignment = verticalAlignment; 244 } 245 246 249 public boolean isLazy() 250 { 251 return isLazy; 252 } 253 254 257 public void setLazy(boolean isLazy) 258 { 259 this.isLazy = isLazy; 260 } 261 262 265 public byte getOnErrorType() 266 { 267 return onErrorType; 268 } 269 270 273 public void setOnErrorType(byte onErrorType) 274 { 275 this.onErrorType = onErrorType; 276 } 277 278 281 public JRBox getBox() 282 { 283 return this; 284 } 285 286 289 public void setBox(JRBox box) 290 { 291 border = box.getOwnBorder(); 292 topBorder = box.getOwnTopBorder(); 293 leftBorder = box.getOwnLeftBorder(); 294 bottomBorder = box.getOwnBottomBorder(); 295 rightBorder = box.getOwnRightBorder(); 296 borderColor = box.getOwnBorderColor(); 297 topBorderColor = box.getOwnTopBorderColor(); 298 leftBorderColor = box.getOwnLeftBorderColor(); 299 bottomBorderColor = box.getOwnBottomBorderColor(); 300 rightBorderColor = box.getOwnRightBorderColor(); 301 padding = box.getOwnPadding(); 302 topPadding = box.getOwnTopPadding(); 303 leftPadding = box.getOwnLeftPadding(); 304 bottomPadding = box.getOwnBottomPadding(); 305 rightPadding = box.getOwnRightPadding(); 306 } 307 308 311 public String getAnchorName() 312 { 313 return anchorName; 314 } 315 316 319 public void setAnchorName(String anchorName) 320 { 321 this.anchorName = anchorName; 322 } 323 324 327 public byte getHyperlinkType() 328 { 329 return JRHyperlinkHelper.getHyperlinkType(getLinkType()); 330 } 331 332 335 public void setHyperlinkType(byte hyperlinkType) 336 { 337 setLinkType(JRHyperlinkHelper.getLinkType(hyperlinkType)); 338 } 339 340 343 public byte getHyperlinkTarget() 344 { 345 return hyperlinkTarget; 346 } 347 348 351 public void setHyperlinkTarget(byte hyperlinkTarget) 352 { 353 this.hyperlinkTarget = hyperlinkTarget; 354 } 355 356 359 public String getHyperlinkReference() 360 { 361 return hyperlinkReference; 362 } 363 364 367 public void setHyperlinkReference(String hyperlinkReference) 368 { 369 this.hyperlinkReference = hyperlinkReference; 370 } 371 372 375 public String getHyperlinkAnchor() 376 { 377 return hyperlinkAnchor; 378 } 379 380 383 public void setHyperlinkAnchor(String hyperlinkAnchor) 384 { 385 this.hyperlinkAnchor = hyperlinkAnchor; 386 } 387 388 391 public Integer getHyperlinkPage() 392 { 393 return hyperlinkPage; 394 } 395 396 399 public void setHyperlinkPage(Integer hyperlinkPage) 400 { 401 this.hyperlinkPage = hyperlinkPage; 402 } 403 404 407 public void setHyperlinkPage(String hyperlinkPage) 408 { 409 this.hyperlinkPage = new Integer (hyperlinkPage); 410 } 411 412 413 public int getBookmarkLevel() 414 { 415 return bookmarkLevel; 416 } 417 418 419 public void setBookmarkLevel(int bookmarkLevel) 420 { 421 this.bookmarkLevel = bookmarkLevel; 422 } 423 424 425 428 public byte getBorder() 429 { 430 return JRStyleResolver.getBorder(this); 431 } 432 433 public Byte getOwnBorder() 434 { 435 return border; 436 } 437 438 441 public void setBorder(byte border) 442 { 443 this.border = new Byte (border); 444 } 445 446 449 public Color getBorderColor() 450 { 451 return JRStyleResolver.getBorderColor(this, getForecolor()); 452 } 453 454 public Color getOwnBorderColor() 455 { 456 return borderColor; 457 } 458 459 462 public void setBorderColor(Color borderColor) 463 { 464 this.borderColor = borderColor; 465 } 466 467 470 public int getPadding() 471 { 472 return JRStyleResolver.getPadding(this); 473 } 474 475 public Integer getOwnPadding() 476 { 477 return padding; 478 } 479 480 483 public void setPadding(int padding) 484 { 485 this.padding = new Integer (padding); 486 } 487 488 491 public byte getTopBorder() 492 { 493 return JRStyleResolver.getTopBorder(this); 494 } 495 496 499 public Byte getOwnTopBorder() 500 { 501 return topBorder; 502 } 503 504 507 public void setTopBorder(byte topBorder) 508 { 509 this.topBorder = new Byte (topBorder); 510 } 511 512 515 public Color getTopBorderColor() 516 { 517 return JRStyleResolver.getTopBorderColor(this, getForecolor()); 518 } 519 520 523 public Color getOwnTopBorderColor() 524 { 525 return topBorderColor; 526 } 527 528 531 public void setTopBorderColor(Color topBorderColor) 532 { 533 this.topBorderColor = topBorderColor; 534 } 535 536 539 public int getTopPadding() 540 { 541 return JRStyleResolver.getTopPadding(this); 542 } 543 544 547 public Integer getOwnTopPadding() 548 { 549 return topPadding; 550 } 551 552 555 public void setTopPadding(int topPadding) 556 { 557 this.topPadding = new Integer (topPadding); 558 } 559 560 563 public byte getLeftBorder() 564 { 565 return JRStyleResolver.getLeftBorder(this); 566 } 567 568 571 public Byte getOwnLeftBorder() 572 { 573 return leftBorder; 574 } 575 576 579 public void setLeftBorder(byte leftBorder) 580 { 581 this.leftBorder = new Byte (leftBorder); 582 } 583 584 587 public Color getLeftBorderColor() 588 { 589 return JRStyleResolver.getLeftBorderColor(this, getForecolor()); 590 } 591 592 595 public Color getOwnLeftBorderColor() 596 { 597 return leftBorderColor; 598 } 599 600 603 public void setLeftBorderColor(Color leftBorderColor) 604 { 605 this.leftBorderColor = leftBorderColor; 606 } 607 608 611 public int getLeftPadding() 612 { 613 return JRStyleResolver.getLeftPadding(this); 614 } 615 616 619 public Integer getOwnLeftPadding() 620 { 621 return leftPadding; 622 } 623 624 627 public void setLeftPadding(int leftPadding) 628 { 629 this.leftPadding = new Integer (leftPadding); 630 } 631 632 635 public byte getBottomBorder() 636 { 637 return JRStyleResolver.getBottomBorder(this); 638 } 639 640 643 public Byte getOwnBottomBorder() 644 { 645 return bottomBorder; 646 } 647 648 651 public void setBottomBorder(byte bottomBorder) 652 { 653 this.bottomBorder = new Byte (bottomBorder); 654 } 655 656 659 public Color getBottomBorderColor() 660 { 661 return JRStyleResolver.getBottomBorderColor(this, getForecolor()); 662 } 663 664 667 public Color getOwnBottomBorderColor() 668 { 669 return bottomBorderColor; 670 } 671 672 675 public void setBottomBorderColor(Color bottomBorderColor) 676 { 677 this.bottomBorderColor = bottomBorderColor; 678 } 679 680 683 public int getBottomPadding() 684 { 685 return JRStyleResolver.getBottomPadding(this); 686 } 687 688 691 public Integer getOwnBottomPadding() 692 { 693 return bottomPadding; 694 } 695 696 699 public void setBottomPadding(int bottomPadding) 700 { 701 this.bottomPadding = new Integer (bottomPadding); 702 } 703 704 707 public byte getRightBorder() 708 { 709 return JRStyleResolver.getRightBorder(this); 710 } 711 712 715 public Byte getOwnRightBorder() 716 { 717 return rightBorder; 718 } 719 720 723 public void setRightBorder(byte rightBorder) 724 { 725 this.rightBorder = new Byte (rightBorder); 726 } 727 728 731 public Color getRightBorderColor() 732 { 733 return JRStyleResolver.getRightBorderColor(this, getForecolor()); 734 } 735 736 739 public Color getOwnRightBorderColor() 740 { 741 return rightBorderColor; 742 } 743 744 747 public void setRightBorderColor(Color rightBorderColor) 748 { 749 this.rightBorderColor = rightBorderColor; 750 } 751 752 755 public int getRightPadding() 756 { 757 return JRStyleResolver.getRightPadding(this); 758 } 759 760 763 public Integer getOwnRightPadding() 764 { 765 return rightPadding; 766 } 767 768 771 public void setRightPadding(int rightPadding) 772 { 773 this.rightPadding = new Integer (rightPadding); 774 } 775 776 779 public void setBorder(Byte border) 780 { 781 this.border = border; 782 } 783 784 787 public void setPadding(Integer padding) 788 { 789 this.padding = padding; 790 } 791 792 795 public void setTopBorder(Byte topBorder) 796 { 797 this.topBorder = topBorder; 798 } 799 800 803 public void setTopPadding(Integer topPadding) 804 { 805 this.topPadding = topPadding; 806 } 807 808 811 public void setLeftBorder(Byte leftBorder) 812 { 813 this.leftBorder = leftBorder; 814 } 815 816 819 public void setLeftPadding(Integer leftPadding) 820 { 821 this.leftPadding = leftPadding; 822 } 823 824 827 public void setBottomBorder(Byte bottomBorder) 828 { 829 this.bottomBorder = bottomBorder; 830 } 831 832 835 public void setBottomPadding(Integer bottomPadding) 836 { 837 this.bottomPadding = bottomPadding; 838 } 839 840 843 public void setRightBorder(Byte rightBorder) 844 { 845 this.rightBorder = rightBorder; 846 } 847 848 851 public void setRightPadding(Integer rightPadding) 852 { 853 this.rightPadding = rightPadding; 854 } 855 856 857 public JRPrintHyperlinkParameters getHyperlinkParameters() 858 { 859 return hyperlinkParameters; 860 } 861 862 863 public void setHyperlinkParameters(JRPrintHyperlinkParameters hyperlinkParameters) 864 { 865 this.hyperlinkParameters = hyperlinkParameters; 866 } 867 868 869 876 public void addHyperlinkParameter(JRPrintHyperlinkParameter parameter) 877 { 878 if (hyperlinkParameters == null) 879 { 880 hyperlinkParameters = new JRPrintHyperlinkParameters(); 881 } 882 hyperlinkParameters.addParameter(parameter); 883 } 884 885 886 public String getLinkType() 887 { 888 return linkType; 889 } 890 891 892 public void setLinkType(String linkType) 893 { 894 this.linkType = linkType; 895 } 896 897 898 private void readObject(ObjectInputStream in) throws IOException , ClassNotFoundException 899 { 900 in.defaultReadObject(); 901 normalizeLinkType(); 902 } 903 904 905 protected void normalizeLinkType() 906 { 907 if (linkType == null) 908 { 909 linkType = JRHyperlinkHelper.getLinkType(hyperlinkType); 910 } 911 hyperlinkType = JRHyperlink.HYPERLINK_TYPE_NULL; 912 } 913 914 915 916 public String getHyperlinkTooltip() 917 { 918 return hyperlinkTooltip; 919 } 920 921 922 923 public void setHyperlinkTooltip(String hyperlinkTooltip) 924 { 925 this.hyperlinkTooltip = hyperlinkTooltip; 926 } 927 928 } 929 | Popular Tags |