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.JRAbstractObjectFactory; 35 import net.sf.jasperreports.engine.JRAnchor; 36 import net.sf.jasperreports.engine.JRBox; 37 import net.sf.jasperreports.engine.JRChild; 38 import net.sf.jasperreports.engine.JRConstants; 39 import net.sf.jasperreports.engine.JRExpression; 40 import net.sf.jasperreports.engine.JRExpressionCollector; 41 import net.sf.jasperreports.engine.JRGroup; 42 import net.sf.jasperreports.engine.JRHyperlink; 43 import net.sf.jasperreports.engine.JRHyperlinkHelper; 44 import net.sf.jasperreports.engine.JRHyperlinkParameter; 45 import net.sf.jasperreports.engine.JRImage; 46 import net.sf.jasperreports.engine.util.JRStyleResolver; 47 import net.sf.jasperreports.engine.xml.JRXmlWriter; 48 49 50 55 public class JRBaseImage extends JRBaseGraphicElement implements JRImage 56 { 57 58 59 62 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 63 64 67 protected Byte scaleImage; 68 protected Byte horizontalAlignment; 69 protected Byte verticalAlignment; 70 protected Boolean isUsingCache = null; 71 protected boolean isLazy = false; 72 protected byte onErrorType = ON_ERROR_TYPE_ERROR; 73 protected byte evaluationTime = JRExpression.EVALUATION_TIME_NOW; 74 protected byte hyperlinkType = JRHyperlink.HYPERLINK_TYPE_NULL; 75 protected String linkType; 76 protected byte hyperlinkTarget = JRHyperlink.HYPERLINK_TARGET_SELF; 77 private JRHyperlinkParameter[] hyperlinkParameters; 78 79 82 protected Byte border; 83 protected Byte topBorder = null; 84 protected Byte leftBorder = null; 85 protected Byte bottomBorder = null; 86 protected Byte rightBorder = null; 87 protected Color borderColor = null; 88 protected Color topBorderColor = null; 89 protected Color leftBorderColor = null; 90 protected Color bottomBorderColor = null; 91 protected Color rightBorderColor = null; 92 protected Integer padding; 93 protected Integer topPadding = null; 94 protected Integer leftPadding = null; 95 protected Integer bottomPadding = null; 96 protected Integer rightPadding = null; 97 98 101 103 106 protected JRGroup evaluationGroup = null; 107 protected JRExpression expression = null; 108 protected JRExpression anchorNameExpression = null; 109 protected JRExpression hyperlinkReferenceExpression = null; 110 protected JRExpression hyperlinkAnchorExpression = null; 111 protected JRExpression hyperlinkPageExpression = null; 112 private JRExpression hyperlinkTooltipExpression; 113 114 118 protected int bookmarkLevel = JRAnchor.NO_BOOKMARK; 119 120 137 protected JRBaseImage(JRImage image, JRBaseObjectFactory factory) 138 { 139 super(image, factory); 140 141 scaleImage = image.getOwnScaleImage(); 142 horizontalAlignment = image.getOwnHorizontalAlignment(); 143 verticalAlignment = image.getOwnVerticalAlignment(); 144 isUsingCache = image.isOwnUsingCache(); 145 isLazy = image.isLazy(); 146 onErrorType = image.getOnErrorType(); 147 evaluationTime = image.getEvaluationTime(); 148 linkType = image.getLinkType(); 149 hyperlinkTarget = image.getHyperlinkTarget(); 150 hyperlinkParameters = JRBaseHyperlink.copyHyperlinkParameters(image, factory); 151 152 154 border = image.getOwnBorder(); 155 topBorder = image.getOwnTopBorder(); 156 leftBorder = image.getOwnLeftBorder(); 157 bottomBorder = image.getOwnBottomBorder(); 158 rightBorder = image.getOwnRightBorder(); 159 borderColor = image.getOwnBorderColor(); 160 topBorderColor = image.getOwnTopBorderColor(); 161 leftBorderColor = image.getOwnLeftBorderColor(); 162 bottomBorderColor = image.getOwnBottomBorderColor(); 163 rightBorderColor = image.getOwnRightBorderColor(); 164 padding = image.getOwnPadding(); 165 topPadding = image.getOwnTopPadding(); 166 leftPadding = image.getOwnLeftPadding(); 167 bottomPadding = image.getOwnBottomPadding(); 168 rightPadding = image.getOwnRightPadding(); 169 170 evaluationGroup = factory.getGroup(image.getEvaluationGroup()); 171 expression = factory.getExpression(image.getExpression()); 172 anchorNameExpression = factory.getExpression(image.getAnchorNameExpression()); 173 hyperlinkReferenceExpression = factory.getExpression(image.getHyperlinkReferenceExpression()); 174 hyperlinkAnchorExpression = factory.getExpression(image.getHyperlinkAnchorExpression()); 175 hyperlinkPageExpression = factory.getExpression(image.getHyperlinkPageExpression()); 176 hyperlinkTooltipExpression = factory.getExpression(image.getHyperlinkTooltipExpression()); 177 bookmarkLevel = image.getBookmarkLevel(); 178 } 179 180 181 184 public byte getMode() 185 { 186 return JRStyleResolver.getMode(this, MODE_TRANSPARENT); 187 } 188 189 192 public byte getPen() 193 { 194 return JRStyleResolver.getPen(this, PEN_NONE); 195 } 196 197 200 public byte getScaleImage() 201 { 202 return JRStyleResolver.getScaleImage(this); 203 } 204 205 public Byte getOwnScaleImage() 206 { 207 return scaleImage; 208 } 209 210 213 public void setScaleImage(byte scaleImage) 214 { 215 this.scaleImage = new Byte (scaleImage); 216 } 217 218 221 public void setScaleImage(Byte scaleImage) 222 { 223 this.scaleImage = scaleImage; 224 } 225 226 229 public byte getHorizontalAlignment() 230 { 231 return JRStyleResolver.getHorizontalAlignment(this); 232 } 233 234 public Byte getOwnHorizontalAlignment() 235 { 236 return horizontalAlignment; 237 } 238 239 242 public void setHorizontalAlignment(byte horizontalAlignment) 243 { 244 this.horizontalAlignment = new Byte (horizontalAlignment); 245 } 246 247 250 public void setHorizontalAlignment(Byte horizontalAlignment) 251 { 252 this.horizontalAlignment = horizontalAlignment; 253 } 254 255 258 public byte getVerticalAlignment() 259 { 260 return JRStyleResolver.getVerticalAlignment(this); 261 } 262 263 public Byte getOwnVerticalAlignment() 264 { 265 return verticalAlignment; 266 } 267 268 271 public void setVerticalAlignment(byte verticalAlignment) 272 { 273 this.verticalAlignment = new Byte (verticalAlignment); 274 } 275 276 279 public void setVerticalAlignment(Byte verticalAlignment) 280 { 281 this.verticalAlignment = verticalAlignment; 282 } 283 284 287 public boolean isUsingCache() 288 { 289 if (isUsingCache == null) 290 { 291 if (getExpression() != null) 292 { 293 return String .class.getName().equals(getExpression().getValueClassName()); 294 } 295 return true; 296 } 297 return isUsingCache.booleanValue(); 298 } 299 300 303 public Boolean isOwnUsingCache() 304 { 305 return isUsingCache; 306 } 307 308 311 public void setUsingCache(boolean isUsingCache) 312 { 313 setUsingCache(isUsingCache ? Boolean.TRUE : Boolean.FALSE); 314 } 315 316 319 public void setUsingCache(Boolean isUsingCache) 320 { 321 this.isUsingCache = isUsingCache; 322 } 323 324 327 public boolean isLazy() 328 { 329 return isLazy; 330 } 331 332 335 public void setLazy(boolean isLazy) 336 { 337 this.isLazy = isLazy; 338 } 339 340 343 public byte getOnErrorType() 344 { 345 return onErrorType; 346 } 347 348 351 public void setOnErrorType(byte onErrorType) 352 { 353 this.onErrorType = onErrorType; 354 } 355 356 359 public byte getEvaluationTime() 360 { 361 return evaluationTime; 362 } 363 364 367 public JRBox getBox() 368 { 369 return this; 370 } 371 372 375 public byte getHyperlinkType() 376 { 377 return JRHyperlinkHelper.getHyperlinkType(this); 378 } 379 380 383 public byte getHyperlinkTarget() 384 { 385 return hyperlinkTarget; 386 } 387 388 391 public JRGroup getEvaluationGroup() 392 { 393 return evaluationGroup; 394 } 395 396 399 public JRExpression getExpression() 400 { 401 return expression; 402 } 403 404 407 public JRExpression getAnchorNameExpression() 408 { 409 return anchorNameExpression; 410 } 411 412 415 public JRExpression getHyperlinkReferenceExpression() 416 { 417 return hyperlinkReferenceExpression; 418 } 419 420 423 public JRExpression getHyperlinkAnchorExpression() 424 { 425 return hyperlinkAnchorExpression; 426 } 427 428 431 public JRExpression getHyperlinkPageExpression() 432 { 433 return hyperlinkPageExpression; 434 } 435 436 439 public JRChild getCopy(JRAbstractObjectFactory factory) 440 { 441 return factory.getImage(this); 442 } 443 444 447 public void collectExpressions(JRExpressionCollector collector) 448 { 449 collector.collect(this); 450 } 451 452 455 public void writeXml(JRXmlWriter xmlWriter) throws IOException 456 { 457 xmlWriter.writeImage(this); 458 } 459 460 461 public int getBookmarkLevel() 462 { 463 return bookmarkLevel; 464 } 465 466 469 public byte getBorder() 470 { 471 return JRStyleResolver.getBorder(this); 472 } 473 474 public Byte getOwnBorder() 475 { 476 return border; 477 } 478 479 482 public void setBorder(byte border) 483 { 484 this.border = new Byte (border); 485 } 486 487 490 public Color getBorderColor() 491 { 492 return JRStyleResolver.getBorderColor(this, getForecolor()); 493 } 494 495 public Color getOwnBorderColor() 496 { 497 return borderColor; 498 } 499 500 503 public void setBorderColor(Color borderColor) 504 { 505 this.borderColor = borderColor; 506 } 507 508 511 public int getPadding() 512 { 513 return JRStyleResolver.getPadding(this); 514 } 515 516 public Integer getOwnPadding() 517 { 518 return padding; 519 } 520 521 524 public void setPadding(int padding) 525 { 526 this.padding = new Integer (padding); 527 } 528 529 532 public byte getTopBorder() 533 { 534 return JRStyleResolver.getTopBorder(this); 535 } 536 537 540 public Byte getOwnTopBorder() 541 { 542 return topBorder; 543 } 544 545 548 public void setTopBorder(byte topBorder) 549 { 550 this.topBorder = new Byte (topBorder); 551 } 552 553 556 public Color getTopBorderColor() 557 { 558 return JRStyleResolver.getTopBorderColor(this, getForecolor()); 559 } 560 561 564 public Color getOwnTopBorderColor() 565 { 566 return topBorderColor; 567 } 568 569 572 public void setTopBorderColor(Color topBorderColor) 573 { 574 this.topBorderColor = topBorderColor; 575 } 576 577 580 public int getTopPadding() 581 { 582 return JRStyleResolver.getTopPadding(this); 583 } 584 585 588 public Integer getOwnTopPadding() 589 { 590 return topPadding; 591 } 592 593 596 public void setTopPadding(int topPadding) 597 { 598 this.topPadding = new Integer (topPadding); 599 } 600 601 604 public byte getLeftBorder() 605 { 606 return JRStyleResolver.getLeftBorder(this); 607 } 608 609 612 public Byte getOwnLeftBorder() 613 { 614 return leftBorder; 615 } 616 617 620 public void setLeftBorder(byte leftBorder) 621 { 622 this.leftBorder = new Byte (leftBorder); 623 } 624 625 628 public Color getLeftBorderColor() 629 { 630 return JRStyleResolver.getLeftBorderColor(this, getForecolor()); 631 } 632 633 636 public Color getOwnLeftBorderColor() 637 { 638 return leftBorderColor; 639 } 640 641 644 public void setLeftBorderColor(Color leftBorderColor) 645 { 646 this.leftBorderColor = leftBorderColor; 647 } 648 649 652 public int getLeftPadding() 653 { 654 return JRStyleResolver.getLeftPadding(this); 655 } 656 657 660 public Integer getOwnLeftPadding() 661 { 662 return leftPadding; 663 } 664 665 668 public void setLeftPadding(int leftPadding) 669 { 670 this.leftPadding = new Integer (leftPadding); 671 } 672 673 676 public byte getBottomBorder() 677 { 678 return JRStyleResolver.getBottomBorder(this); 679 } 680 681 684 public Byte getOwnBottomBorder() 685 { 686 return bottomBorder; 687 } 688 689 692 public void setBottomBorder(byte bottomBorder) 693 { 694 this.bottomBorder = new Byte (bottomBorder); 695 } 696 697 700 public Color getBottomBorderColor() 701 { 702 return JRStyleResolver.getBottomBorderColor(this, getForecolor()); 703 } 704 705 708 public Color getOwnBottomBorderColor() 709 { 710 return bottomBorderColor; 711 } 712 713 716 public void setBottomBorderColor(Color bottomBorderColor) 717 { 718 this.bottomBorderColor = bottomBorderColor; 719 } 720 721 724 public int getBottomPadding() 725 { 726 return JRStyleResolver.getBottomPadding(this); 727 } 728 729 732 public Integer getOwnBottomPadding() 733 { 734 return bottomPadding; 735 } 736 737 740 public void setBottomPadding(int bottomPadding) 741 { 742 this.bottomPadding = new Integer (bottomPadding); 743 } 744 745 748 public byte getRightBorder() 749 { 750 return JRStyleResolver.getRightBorder(this); 751 } 752 753 756 public Byte getOwnRightBorder() 757 { 758 return rightBorder; 759 } 760 761 764 public void setRightBorder(byte rightBorder) 765 { 766 this.rightBorder = new Byte (rightBorder); 767 } 768 769 772 public Color getRightBorderColor() 773 { 774 return JRStyleResolver.getRightBorderColor(this, getForecolor()); 775 } 776 777 780 public Color getOwnRightBorderColor() 781 { 782 return rightBorderColor; 783 } 784 785 788 public void setRightBorderColor(Color rightBorderColor) 789 { 790 this.rightBorderColor = rightBorderColor; 791 } 792 793 796 public int getRightPadding() 797 { 798 return JRStyleResolver.getRightPadding(this); 799 } 800 801 804 public Integer getOwnRightPadding() 805 { 806 return rightPadding; 807 } 808 809 812 public void setRightPadding(int rightPadding) 813 { 814 this.rightPadding = new Integer (rightPadding); 815 } 816 817 818 821 public void setBorder(Byte border) 822 { 823 this.border = border; 824 } 825 826 829 public void setPadding(Integer padding) 830 { 831 this.padding = padding; 832 } 833 834 837 public void setTopBorder(Byte topBorder) 838 { 839 this.topBorder = topBorder; 840 } 841 842 845 public void setTopPadding(Integer topPadding) 846 { 847 this.topPadding = topPadding; 848 } 849 850 853 public void setLeftBorder(Byte leftBorder) 854 { 855 this.leftBorder = leftBorder; 856 } 857 858 861 public void setLeftPadding(Integer leftPadding) 862 { 863 this.leftPadding = leftPadding; 864 } 865 866 869 public void setBottomBorder(Byte bottomBorder) 870 { 871 this.bottomBorder = bottomBorder; 872 } 873 874 877 public void setBottomPadding(Integer bottomPadding) 878 { 879 this.bottomPadding = bottomPadding; 880 } 881 882 885 public void setRightBorder(Byte rightBorder) 886 { 887 this.rightBorder = rightBorder; 888 } 889 890 893 public void setRightPadding(Integer rightPadding) 894 { 895 this.rightPadding = rightPadding; 896 } 897 898 899 public String getLinkType() 900 { 901 return linkType; 902 } 903 904 905 public JRHyperlinkParameter[] getHyperlinkParameters() 906 { 907 return hyperlinkParameters; 908 } 909 910 911 private void readObject(ObjectInputStream in) throws IOException , ClassNotFoundException 912 { 913 in.defaultReadObject(); 914 normalizeLinkType(); 915 } 916 917 918 protected void normalizeLinkType() 919 { 920 if (linkType == null) 921 { 922 linkType = JRHyperlinkHelper.getLinkType(hyperlinkType); 923 } 924 hyperlinkType = JRHyperlink.HYPERLINK_TYPE_NULL; 925 } 926 927 928 public JRExpression getHyperlinkTooltipExpression() 929 { 930 return hyperlinkTooltipExpression; 931 } 932 933 } 934 | Popular Tags |