1 28 package net.sf.jasperreports.engine.base; 29 30 import java.awt.Color ; 31 32 import net.sf.jasperreports.engine.JRBox; 33 import net.sf.jasperreports.engine.JRConstants; 34 import net.sf.jasperreports.engine.JRFont; 35 import net.sf.jasperreports.engine.JRReportFont; 36 import net.sf.jasperreports.engine.JRStyle; 37 import net.sf.jasperreports.engine.JRTextElement; 38 import net.sf.jasperreports.engine.util.JRStyleResolver; 39 40 41 47 public abstract class JRBaseTextElement extends JRBaseElement implements JRTextElement 48 { 49 50 51 54 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 55 56 59 protected Byte horizontalAlignment; 60 protected Byte verticalAlignment; 61 protected Byte rotation; 62 protected Byte lineSpacing; 63 protected Boolean isStyledText; 64 65 68 protected Byte border; 69 protected Byte topBorder = null; 70 protected Byte leftBorder = null; 71 protected Byte bottomBorder = null; 72 protected Byte rightBorder = null; 73 protected Color borderColor = null; 74 protected Color topBorderColor = null; 75 protected Color leftBorderColor = null; 76 protected Color bottomBorderColor = null; 77 protected Color rightBorderColor = null; 78 protected Integer padding; 79 protected Integer topPadding = null; 80 protected Integer leftPadding = null; 81 protected Integer bottomPadding = null; 82 protected Integer rightPadding = null; 83 84 protected JRReportFont reportFont = null; 85 protected String fontName = null; 86 protected Boolean isBold = null; 87 protected Boolean isItalic = null; 88 protected Boolean isUnderline = null; 89 protected Boolean isStrikeThrough = null; 90 protected Integer fontSize = null; 91 protected String pdfFontName = null; 92 protected String pdfEncoding = null; 93 protected Boolean isPdfEmbedded = null; 94 95 96 104 protected JRBaseTextElement(JRTextElement textElement, JRBaseObjectFactory factory) 105 { 106 super(textElement, factory); 107 108 horizontalAlignment = textElement.getOwnHorizontalAlignment(); 109 verticalAlignment = textElement.getOwnVerticalAlignment(); 110 rotation = textElement.getOwnRotation(); 111 lineSpacing = textElement.getOwnLineSpacing(); 112 isStyledText = textElement.isOwnStyledText(); 113 114 border = textElement.getOwnBorder(); 115 topBorder = textElement.getOwnTopBorder(); 116 leftBorder = textElement.getOwnLeftBorder(); 117 bottomBorder = textElement.getOwnBottomBorder(); 118 rightBorder = textElement.getOwnRightBorder(); 119 borderColor = textElement.getOwnBorderColor(); 120 topBorderColor = textElement.getOwnTopBorderColor(); 121 leftBorderColor = textElement.getOwnLeftBorderColor(); 122 bottomBorderColor = textElement.getOwnBottomBorderColor(); 123 rightBorderColor = textElement.getOwnRightBorderColor(); 124 padding = textElement.getOwnPadding(); 125 topPadding = textElement.getOwnTopPadding(); 126 leftPadding = textElement.getOwnLeftPadding(); 127 bottomPadding = textElement.getOwnBottomPadding(); 128 rightPadding = textElement.getOwnRightPadding(); 129 130 reportFont = factory.getReportFont(textElement.getReportFont()); 131 132 fontName = textElement.getOwnFontName(); 133 isBold = textElement.isOwnBold(); 134 isItalic = textElement.isOwnItalic(); 135 isUnderline = textElement.isOwnUnderline(); 136 isStrikeThrough = textElement.isOwnStrikeThrough(); 137 fontSize = textElement.getOwnFontSize(); 138 pdfFontName = textElement.getOwnPdfFontName(); 139 pdfEncoding = textElement.getOwnPdfEncoding(); 140 isPdfEmbedded = textElement.isOwnPdfEmbedded(); 141 } 142 143 144 147 protected JRFont getBaseFont() 148 { 149 if (reportFont != null) 150 return reportFont; 151 if (defaultStyleProvider != null) 152 return defaultStyleProvider.getDefaultFont(); 153 return null; 154 } 155 156 157 160 public byte getTextAlignment() 161 { 162 if (horizontalAlignment == null) { 163 JRStyle style = getBaseStyle(); 164 if (style != null && style.getHorizontalAlignment() != null) 165 return style.getHorizontalAlignment().byteValue(); 166 return HORIZONTAL_ALIGN_LEFT; 167 } 168 return horizontalAlignment.byteValue(); 169 } 170 171 174 public void setTextAlignment(byte horizontalAlignment) 175 { 176 this.horizontalAlignment = new Byte (horizontalAlignment); 177 } 178 179 182 public byte getHorizontalAlignment() 183 { 184 return JRStyleResolver.getHorizontalAlignment(this); 185 } 186 187 public Byte getOwnHorizontalAlignment() 188 { 189 return horizontalAlignment; 190 } 191 192 195 public void setHorizontalAlignment(byte horizontalAlignment) 196 { 197 this.horizontalAlignment = new Byte (horizontalAlignment); 198 } 199 200 203 public void setHorizontalAlignment(Byte horizontalAlignment) 204 { 205 this.horizontalAlignment = horizontalAlignment; 206 } 207 208 211 public byte getVerticalAlignment() 212 { 213 return JRStyleResolver.getVerticalAlignment(this); 214 } 215 216 public Byte getOwnVerticalAlignment() 217 { 218 return verticalAlignment; 219 } 220 221 224 public void setVerticalAlignment(byte verticalAlignment) 225 { 226 this.verticalAlignment = new Byte (verticalAlignment); 227 } 228 229 232 public void setVerticalAlignment(Byte verticalAlignment) 233 { 234 this.verticalAlignment = verticalAlignment; 235 } 236 237 240 public byte getRotation() 241 { 242 return JRStyleResolver.getRotation(this); 243 } 244 245 public Byte getOwnRotation() 246 { 247 return rotation; 248 } 249 250 253 public void setRotation(byte rotation) 254 { 255 this.rotation = new Byte (rotation); 256 } 257 258 261 public void setRotation(Byte rotation) 262 { 263 this.rotation = rotation; 264 } 265 266 269 public byte getLineSpacing() 270 { 271 return JRStyleResolver.getLineSpacing(this); 272 } 273 274 public Byte getOwnLineSpacing() 275 { 276 return lineSpacing; 277 } 278 279 282 public void setLineSpacing(byte lineSpacing) 283 { 284 this.lineSpacing = new Byte (lineSpacing); 285 } 286 287 290 public void setLineSpacing(Byte lineSpacing) 291 { 292 this.lineSpacing = lineSpacing; 293 } 294 295 298 public boolean isStyledText() 299 { 300 return JRStyleResolver.isStyledText(this); 301 } 302 303 public Boolean isOwnStyledText() 304 { 305 return isStyledText; 306 } 307 308 311 public void setStyledText(boolean isStyledText) 312 { 313 setStyledText(isStyledText ? Boolean.TRUE : Boolean.FALSE); 314 } 315 316 319 public void setStyledText(Boolean isStyledText) 320 { 321 this.isStyledText = isStyledText; 322 } 323 324 327 public JRBox getBox() 328 { 329 return this; 330 } 331 332 335 public JRFont getFont() 336 { 337 return this; 338 } 339 340 343 public byte getMode() 344 { 345 return JRStyleResolver.getMode(this, MODE_TRANSPARENT); 346 } 347 348 351 public byte getBorder() 352 { 353 return JRStyleResolver.getBorder(this); 354 } 355 356 359 public Byte getOwnBorder() 360 { 361 return border; 362 } 363 364 367 public void setBorder(byte border) 368 { 369 this.border = new Byte (border); 370 } 371 372 375 public void setBorder(Byte border) 376 { 377 this.border = border; 378 } 379 380 383 public Color getBorderColor() 384 { 385 return JRStyleResolver.getBorderColor(this, getForecolor()); 386 } 387 388 public Color getOwnBorderColor() 389 { 390 return borderColor; 391 } 392 393 396 public void setBorderColor(Color borderColor) 397 { 398 this.borderColor = borderColor; 399 } 400 401 404 public int getPadding() 405 { 406 return JRStyleResolver.getPadding(this); 407 } 408 409 public Integer getOwnPadding() 410 { 411 return padding; 412 } 413 414 417 public void setPadding(int padding) 418 { 419 this.padding = new Integer (padding); 420 } 421 422 425 public void setPadding(Integer padding) 426 { 427 this.padding = 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 void setTopBorder(Byte topBorder) 458 { 459 this.topBorder = topBorder; 460 } 461 462 465 public Color getTopBorderColor() 466 { 467 return JRStyleResolver.getTopBorderColor(this, getForecolor()); 468 } 469 470 473 public Color getOwnTopBorderColor() 474 { 475 return topBorderColor; 476 } 477 478 481 public void setTopBorderColor(Color topBorderColor) 482 { 483 this.topBorderColor = topBorderColor; 484 } 485 486 489 public int getTopPadding() 490 { 491 return JRStyleResolver.getTopPadding(this); 492 } 493 494 497 public Integer getOwnTopPadding() 498 { 499 return topPadding; 500 } 501 502 505 public void setTopPadding(int topPadding) 506 { 507 this.topPadding = new Integer (topPadding); 508 } 509 510 513 public void setTopPadding(Integer topPadding) 514 { 515 this.topPadding = topPadding; 516 } 517 518 521 public byte getLeftBorder() 522 { 523 return JRStyleResolver.getLeftBorder(this); 524 } 525 526 529 public Byte getOwnLeftBorder() 530 { 531 return leftBorder; 532 } 533 534 537 public void setLeftBorder(byte leftBorder) 538 { 539 this.leftBorder = new Byte (leftBorder); 540 } 541 542 545 public void setLeftBorder(Byte leftBorder) 546 { 547 this.leftBorder = leftBorder; 548 } 549 550 553 public Color getLeftBorderColor() 554 { 555 return JRStyleResolver.getLeftBorderColor(this, getForecolor()); 556 } 557 558 561 public Color getOwnLeftBorderColor() 562 { 563 return leftBorderColor; 564 } 565 566 569 public void setLeftBorderColor(Color leftBorderColor) 570 { 571 this.leftBorderColor = leftBorderColor; 572 } 573 574 577 public int getLeftPadding() 578 { 579 return JRStyleResolver.getLeftPadding(this); 580 } 581 582 585 public Integer getOwnLeftPadding() 586 { 587 return leftPadding; 588 } 589 590 593 public void setLeftPadding(int leftPadding) 594 { 595 this.leftPadding = new Integer (leftPadding); 596 } 597 598 601 public void setLeftPadding(Integer leftPadding) 602 { 603 this.leftPadding = leftPadding; 604 } 605 606 609 public byte getBottomBorder() 610 { 611 return JRStyleResolver.getBottomBorder(this); 612 } 613 614 617 public Byte getOwnBottomBorder() 618 { 619 return bottomBorder; 620 } 621 622 625 public void setBottomBorder(byte bottomBorder) 626 { 627 this.bottomBorder = new Byte (bottomBorder); 628 } 629 630 633 public void setBottomBorder(Byte bottomBorder) 634 { 635 this.bottomBorder = bottomBorder; 636 } 637 638 641 public Color getBottomBorderColor() 642 { 643 return JRStyleResolver.getBottomBorderColor(this, getForecolor()); 644 } 645 646 649 public Color getOwnBottomBorderColor() 650 { 651 return bottomBorderColor; 652 } 653 654 657 public void setBottomBorderColor(Color bottomBorderColor) 658 { 659 this.bottomBorderColor = bottomBorderColor; 660 } 661 662 665 public int getBottomPadding() 666 { 667 return JRStyleResolver.getBottomPadding(this); 668 } 669 670 673 public Integer getOwnBottomPadding() 674 { 675 return bottomPadding; 676 } 677 678 681 public void setBottomPadding(int bottomPadding) 682 { 683 this.bottomPadding = new Integer (bottomPadding); 684 } 685 686 689 public void setBottomPadding(Integer bottomPadding) 690 { 691 this.bottomPadding = bottomPadding; 692 } 693 694 697 public byte getRightBorder() 698 { 699 return JRStyleResolver.getRightBorder(this); 700 } 701 702 705 public Byte getOwnRightBorder() 706 { 707 return rightBorder; 708 } 709 710 713 public void setRightBorder(byte rightBorder) 714 { 715 this.rightBorder = new Byte (rightBorder); 716 } 717 718 721 public void setRightBorder(Byte rightBorder) 722 { 723 this.rightBorder = rightBorder; 724 } 725 726 729 public Color getRightBorderColor() 730 { 731 return JRStyleResolver.getRightBorderColor(this, getForecolor()); 732 } 733 734 737 public Color getOwnRightBorderColor() 738 { 739 return rightBorderColor; 740 } 741 742 745 public void setRightBorderColor(Color rightBorderColor) 746 { 747 this.rightBorderColor = rightBorderColor; 748 } 749 750 753 public int getRightPadding() 754 { 755 return JRStyleResolver.getRightPadding(this); 756 } 757 758 761 public Integer getOwnRightPadding() 762 { 763 return rightPadding; 764 } 765 766 769 public void setRightPadding(int rightPadding) 770 { 771 this.rightPadding = new Integer (rightPadding); 772 } 773 774 777 public void setRightPadding(Integer rightPadding) 778 { 779 this.rightPadding = rightPadding; 780 } 781 782 785 public JRReportFont getReportFont() 786 { 787 return reportFont; 788 } 789 790 793 public void setReportFont(JRReportFont reportFont) 794 { 795 this.reportFont = reportFont; 796 } 797 798 801 public String getFontName() 802 { 803 return JRStyleResolver.getFontName(this); 804 } 805 806 809 public String getOwnFontName() 810 { 811 return fontName; 812 } 813 814 817 public void setFontName(String fontName) 818 { 819 this.fontName = fontName; 820 } 821 822 823 826 public boolean isBold() 827 { 828 return JRStyleResolver.isBold(this); 829 } 830 831 834 public Boolean isOwnBold() 835 { 836 return isBold; 837 } 838 839 842 public void setBold(boolean isBold) 843 { 844 setBold(isBold ? Boolean.TRUE : Boolean.FALSE); 845 } 846 847 851 public void setBold(Boolean isBold) 852 { 853 this.isBold = isBold; 854 } 855 856 857 860 public boolean isItalic() 861 { 862 return JRStyleResolver.isItalic(this); 863 } 864 865 868 public Boolean isOwnItalic() 869 { 870 return isItalic; 871 } 872 873 876 public void setItalic(boolean isItalic) 877 { 878 setItalic(isItalic ? Boolean.TRUE : Boolean.FALSE); 879 } 880 881 885 public void setItalic(Boolean isItalic) 886 { 887 this.isItalic = isItalic; 888 } 889 890 893 public boolean isUnderline() 894 { 895 return JRStyleResolver.isUnderline(this); 896 } 897 898 901 public Boolean isOwnUnderline() 902 { 903 return isUnderline; 904 } 905 906 909 public void setUnderline(boolean isUnderline) 910 { 911 setUnderline(isUnderline ? Boolean.TRUE : Boolean.FALSE); 912 } 913 914 918 public void setUnderline(Boolean isUnderline) 919 { 920 this.isUnderline = isUnderline; 921 } 922 923 926 public boolean isStrikeThrough() 927 { 928 return JRStyleResolver.isStrikeThrough(this); 929 } 930 931 934 public Boolean isOwnStrikeThrough() 935 { 936 return isStrikeThrough; 937 } 938 939 942 public void setStrikeThrough(boolean isStrikeThrough) 943 { 944 setStrikeThrough(isStrikeThrough ? Boolean.TRUE : Boolean.FALSE); 945 } 946 947 951 public void setStrikeThrough(Boolean isStrikeThrough) 952 { 953 this.isStrikeThrough = isStrikeThrough; 954 } 955 956 959 public int getFontSize() 960 { 961 return JRStyleResolver.getFontSize(this); 962 } 963 964 967 public Integer getOwnFontSize() 968 { 969 return fontSize; 970 } 971 972 975 public void setFontSize(int fontSize) 976 { 977 setFontSize(new Integer (fontSize)); 978 } 979 980 984 public void setFontSize(Integer fontSize) 985 { 986 this.fontSize = fontSize; 987 } 988 989 992 public int getSize() 993 { 994 return getFontSize(); 995 } 996 997 1000 public Integer getOwnSize() 1001 { 1002 return getOwnFontSize(); 1003 } 1004 1005 1008 public void setSize(int size) 1009 { 1010 setFontSize(size); 1011 } 1012 1013 1016 public void setSize(Integer size) 1017 { 1018 setFontSize(size); 1019 } 1020 1021 1024 public String getPdfFontName() 1025 { 1026 return JRStyleResolver.getPdfFontName(this); 1027 } 1028 1029 1032 public String getOwnPdfFontName() 1033 { 1034 return pdfFontName; 1035 } 1036 1037 1040 public void setPdfFontName(String pdfFontName) 1041 { 1042 this.pdfFontName = pdfFontName; 1043 } 1044 1045 1046 1049 public String getPdfEncoding() 1050 { 1051 return JRStyleResolver.getPdfEncoding(this); 1052 } 1053 1054 1057 public String getOwnPdfEncoding() 1058 { 1059 return pdfEncoding; 1060 } 1061 1062 1065 public void setPdfEncoding(String pdfEncoding) 1066 { 1067 this.pdfEncoding = pdfEncoding; 1068 } 1069 1070 1071 1074 public boolean isPdfEmbedded() 1075 { 1076 return JRStyleResolver.isPdfEmbedded(this); 1077 } 1078 1079 1082 public Boolean isOwnPdfEmbedded() 1083 { 1084 return isPdfEmbedded; 1085 } 1086 1087 1090 public void setPdfEmbedded(boolean isPdfEmbedded) 1091 { 1092 setPdfEmbedded(isPdfEmbedded ? Boolean.TRUE : Boolean.FALSE); 1093 } 1094 1095 1099 public void setPdfEmbedded(Boolean isPdfEmbedded) 1100 { 1101 this.isPdfEmbedded = isPdfEmbedded; 1102 } 1103 1104 1105} 1106 | Popular Tags |