1 28 package net.sf.jasperreports.engine.design; 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.JRDefaultStyleProvider; 35 import net.sf.jasperreports.engine.JRFont; 36 import net.sf.jasperreports.engine.JRReportFont; 37 import net.sf.jasperreports.engine.JRStyle; 38 import net.sf.jasperreports.engine.JRTextElement; 39 import net.sf.jasperreports.engine.util.JRStyleResolver; 40 41 42 49 public abstract class JRDesignTextElement extends JRDesignElement implements JRTextElement 50 { 51 52 53 56 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 57 58 61 protected Byte horizontalAlignment; 62 protected Byte verticalAlignment; 63 protected Byte rotation; 64 protected Byte lineSpacing; 65 protected Boolean isStyledText; 66 67 70 protected Byte border; 71 protected Byte topBorder = null; 72 protected Byte leftBorder = null; 73 protected Byte bottomBorder = null; 74 protected Byte rightBorder = null; 75 protected Color borderColor = null; 76 protected Color topBorderColor = null; 77 protected Color leftBorderColor = null; 78 protected Color bottomBorderColor = null; 79 protected Color rightBorderColor = null; 80 protected Integer padding; 81 protected Integer topPadding = null; 82 protected Integer leftPadding = null; 83 protected Integer bottomPadding = null; 84 protected Integer rightPadding = null; 85 86 protected JRReportFont reportFont = null; 87 protected String fontName = null; 88 protected Boolean isBold = null; 89 protected Boolean isItalic = null; 90 protected Boolean isUnderline = null; 91 protected Boolean isStrikeThrough = null; 92 protected Integer fontSize = null; 93 protected String pdfFontName = null; 94 protected String pdfEncoding = null; 95 protected Boolean isPdfEmbedded = null; 96 97 98 101 protected JRDesignTextElement(JRDefaultStyleProvider defaultStyleProvider) 102 { 103 super(defaultStyleProvider); 104 } 105 106 107 110 protected JRFont getBaseFont() 111 { 112 if (reportFont != null) 113 return reportFont; 114 if (defaultStyleProvider != null) 115 return defaultStyleProvider.getDefaultFont(); 116 return null; 117 } 118 119 120 123 public byte getMode() 124 { 125 return JRStyleResolver.getMode(this, MODE_TRANSPARENT); 126 } 127 128 129 132 public byte getTextAlignment() 133 { 134 if (horizontalAlignment == null) { 135 JRStyle style = getBaseStyle(); 136 if (style != null && style.getHorizontalAlignment() != null) 137 return style.getHorizontalAlignment().byteValue(); 138 return HORIZONTAL_ALIGN_LEFT; 139 } 140 return horizontalAlignment.byteValue(); 141 } 142 143 146 public void setTextAlignment(byte horizontalAlignment) 147 { 148 this.horizontalAlignment = new Byte (horizontalAlignment); 149 } 150 151 154 public byte getHorizontalAlignment() 155 { 156 return JRStyleResolver.getHorizontalAlignment(this); 157 } 158 159 public Byte getOwnHorizontalAlignment() 160 { 161 return horizontalAlignment; 162 } 163 164 167 public void setHorizontalAlignment(byte horizontalAlignment) 168 { 169 this.horizontalAlignment = new Byte (horizontalAlignment); 170 } 171 172 175 public void setHorizontalAlignment(Byte horizontalAlignment) 176 { 177 this.horizontalAlignment = horizontalAlignment; 178 } 179 180 183 public byte getVerticalAlignment() 184 { 185 return JRStyleResolver.getVerticalAlignment(this); 186 } 187 188 public Byte getOwnVerticalAlignment() 189 { 190 return verticalAlignment; 191 } 192 193 196 public void setVerticalAlignment(byte verticalAlignment) 197 { 198 this.verticalAlignment = new Byte (verticalAlignment); 199 } 200 201 204 public void setVerticalAlignment(Byte verticalAlignment) 205 { 206 this.verticalAlignment = verticalAlignment; 207 } 208 209 212 public byte getRotation() 213 { 214 return JRStyleResolver.getRotation(this); 215 } 216 217 public Byte getOwnRotation() 218 { 219 return rotation; 220 } 221 222 225 public void setRotation(byte rotation) 226 { 227 this.rotation = new Byte (rotation); 228 } 229 230 233 public void setRotation(Byte rotation) 234 { 235 this.rotation = rotation; 236 } 237 238 241 public byte getLineSpacing() 242 { 243 return JRStyleResolver.getLineSpacing(this); 244 } 245 246 public Byte getOwnLineSpacing() 247 { 248 return lineSpacing; 249 } 250 251 254 public void setLineSpacing(byte lineSpacing) 255 { 256 this.lineSpacing = new Byte (lineSpacing); 257 } 258 259 262 public void setLineSpacing(Byte lineSpacing) 263 { 264 this.lineSpacing = lineSpacing; 265 } 266 267 270 public boolean isStyledText() 271 { 272 return JRStyleResolver.isStyledText(this); 273 } 274 275 public Boolean isOwnStyledText() 276 { 277 return isStyledText; 278 } 279 280 283 public void setStyledText(boolean isStyledText) 284 { 285 setStyledText(isStyledText ? Boolean.TRUE : Boolean.FALSE); 286 } 287 288 291 public void setStyledText(Boolean isStyledText) 292 { 293 this.isStyledText = isStyledText; 294 } 295 296 299 public JRBox getBox() 300 { 301 return this; 302 } 303 304 307 public JRFont getFont() 308 { 309 return this; 310 } 311 312 313 316 public void setBox(JRBox box) 317 { 318 border = box.getOwnBorder(); 319 topBorder = box.getOwnTopBorder(); 320 leftBorder = box.getOwnLeftBorder(); 321 bottomBorder = box.getOwnBottomBorder(); 322 rightBorder = box.getOwnRightBorder(); 323 borderColor = box.getOwnBorderColor(); 324 topBorderColor = box.getOwnTopBorderColor(); 325 leftBorderColor = box.getOwnLeftBorderColor(); 326 bottomBorderColor = box.getOwnBottomBorderColor(); 327 rightBorderColor = box.getOwnRightBorderColor(); 328 padding = box.getOwnPadding(); 329 topPadding = box.getOwnTopPadding(); 330 leftPadding = box.getOwnLeftPadding(); 331 bottomPadding = box.getOwnBottomPadding(); 332 rightPadding = box.getOwnRightPadding(); 333 } 334 335 339 public void setFont(JRFont font) 340 { 341 reportFont = font.getReportFont(); 342 343 fontName = font.getOwnFontName(); 344 isBold = font.isOwnBold(); 345 isItalic = font.isOwnItalic(); 346 isUnderline = font.isOwnUnderline(); 347 isStrikeThrough = font.isOwnStrikeThrough(); 348 fontSize = font.getOwnSize(); 349 pdfFontName = font.getOwnPdfFontName(); 350 pdfEncoding = font.getOwnPdfEncoding(); 351 isPdfEmbedded = font.isOwnPdfEmbedded(); 352 } 353 354 357 public byte getBorder() 358 { 359 return JRStyleResolver.getBorder(this); 360 } 361 362 public Byte getOwnBorder() 363 { 364 return border; 365 } 366 367 370 public void setBorder(byte border) 371 { 372 this.border = new Byte (border); 373 } 374 375 378 public Color getBorderColor() 379 { 380 return JRStyleResolver.getBorderColor(this, getForecolor()); 381 } 382 383 public Color getOwnBorderColor() 384 { 385 return borderColor; 386 } 387 388 391 public void setBorderColor(Color borderColor) 392 { 393 this.borderColor = borderColor; 394 } 395 396 399 public int getPadding() 400 { 401 return JRStyleResolver.getPadding(this); 402 } 403 404 public Integer getOwnPadding() 405 { 406 return padding; 407 } 408 409 412 public void setPadding(int padding) 413 { 414 this.padding = new Integer (padding); 415 } 416 417 420 public byte getTopBorder() 421 { 422 return JRStyleResolver.getTopBorder(this); 423 } 424 425 428 public Byte getOwnTopBorder() 429 { 430 return topBorder; 431 } 432 433 436 public void setTopBorder(byte topBorder) 437 { 438 this.topBorder = new Byte (topBorder); 439 } 440 441 444 public Color getTopBorderColor() 445 { 446 return JRStyleResolver.getTopBorderColor(this, getForecolor()); 447 } 448 449 452 public Color getOwnTopBorderColor() 453 { 454 return topBorderColor; 455 } 456 457 460 public void setTopBorderColor(Color topBorderColor) 461 { 462 this.topBorderColor = topBorderColor; 463 } 464 465 468 public int getTopPadding() 469 { 470 return JRStyleResolver.getTopPadding(this); 471 } 472 473 476 public Integer getOwnTopPadding() 477 { 478 return topPadding; 479 } 480 481 484 public void setTopPadding(int topPadding) 485 { 486 this.topPadding = new Integer (topPadding); 487 } 488 489 492 public byte getLeftBorder() 493 { 494 return JRStyleResolver.getLeftBorder(this); 495 } 496 497 500 public Byte getOwnLeftBorder() 501 { 502 return leftBorder; 503 } 504 505 508 public void setLeftBorder(byte leftBorder) 509 { 510 this.leftBorder = new Byte (leftBorder); 511 } 512 513 516 public Color getLeftBorderColor() 517 { 518 return JRStyleResolver.getLeftBorderColor(this, getForecolor()); 519 } 520 521 524 public Color getOwnLeftBorderColor() 525 { 526 return leftBorderColor; 527 } 528 529 532 public void setLeftBorderColor(Color leftBorderColor) 533 { 534 this.leftBorderColor = leftBorderColor; 535 } 536 537 540 public int getLeftPadding() 541 { 542 return JRStyleResolver.getLeftPadding(this); 543 } 544 545 548 public Integer getOwnLeftPadding() 549 { 550 return leftPadding; 551 } 552 553 556 public void setLeftPadding(int leftPadding) 557 { 558 this.leftPadding = new Integer (leftPadding); 559 } 560 561 564 public byte getBottomBorder() 565 { 566 return JRStyleResolver.getBottomBorder(this); 567 } 568 569 572 public Byte getOwnBottomBorder() 573 { 574 return bottomBorder; 575 } 576 577 580 public void setBottomBorder(byte bottomBorder) 581 { 582 this.bottomBorder = new Byte (bottomBorder); 583 } 584 585 588 public Color getBottomBorderColor() 589 { 590 return JRStyleResolver.getBottomBorderColor(this, getForecolor()); 591 } 592 593 596 public Color getOwnBottomBorderColor() 597 { 598 return bottomBorderColor; 599 } 600 601 604 public void setBottomBorderColor(Color bottomBorderColor) 605 { 606 this.bottomBorderColor = bottomBorderColor; 607 } 608 609 612 public int getBottomPadding() 613 { 614 return JRStyleResolver.getBottomPadding(this); 615 } 616 617 620 public Integer getOwnBottomPadding() 621 { 622 return bottomPadding; 623 } 624 625 628 public void setBottomPadding(int bottomPadding) 629 { 630 this.bottomPadding = new Integer (bottomPadding); 631 } 632 633 636 public byte getRightBorder() 637 { 638 return JRStyleResolver.getRightBorder(this); 639 } 640 641 644 public Byte getOwnRightBorder() 645 { 646 return rightBorder; 647 } 648 649 652 public void setRightBorder(byte rightBorder) 653 { 654 this.rightBorder = new Byte (rightBorder); 655 } 656 657 660 public Color getRightBorderColor() 661 { 662 return JRStyleResolver.getRightBorderColor(this, getForecolor()); 663 } 664 665 668 public Color getOwnRightBorderColor() 669 { 670 return rightBorderColor; 671 } 672 673 676 public void setRightBorderColor(Color rightBorderColor) 677 { 678 this.rightBorderColor = rightBorderColor; 679 } 680 681 684 public int getRightPadding() 685 { 686 return JRStyleResolver.getRightPadding(this); 687 } 688 689 692 public Integer getOwnRightPadding() 693 { 694 return rightPadding; 695 } 696 697 700 public void setRightPadding(int rightPadding) 701 { 702 this.rightPadding = new Integer (rightPadding); 703 } 704 705 708 public JRReportFont getReportFont() 709 { 710 return reportFont; 711 } 712 713 716 public void setReportFont(JRReportFont reportFont) 717 { 718 this.reportFont = reportFont; 719 } 720 721 724 public String getFontName() 725 { 726 return JRStyleResolver.getFontName(this); 727 } 728 729 732 public String getOwnFontName() 733 { 734 return fontName; 735 } 736 737 740 public void setFontName(String fontName) 741 { 742 this.fontName = fontName; 743 } 744 745 746 749 public boolean isBold() 750 { 751 return JRStyleResolver.isBold(this); 752 } 753 754 757 public Boolean isOwnBold() 758 { 759 return isBold; 760 } 761 762 765 public void setBold(boolean isBold) 766 { 767 setBold(isBold ? Boolean.TRUE : Boolean.FALSE); 768 } 769 770 774 public void setBold(Boolean isBold) 775 { 776 this.isBold = isBold; 777 } 778 779 780 783 public boolean isItalic() 784 { 785 return JRStyleResolver.isItalic(this); 786 } 787 788 791 public Boolean isOwnItalic() 792 { 793 return isItalic; 794 } 795 796 799 public void setItalic(boolean isItalic) 800 { 801 setItalic(isItalic ? Boolean.TRUE : Boolean.FALSE); 802 } 803 804 808 public void setItalic(Boolean isItalic) 809 { 810 this.isItalic = isItalic; 811 } 812 813 816 public boolean isUnderline() 817 { 818 return JRStyleResolver.isUnderline(this); 819 } 820 821 824 public Boolean isOwnUnderline() 825 { 826 return isUnderline; 827 } 828 829 832 public void setUnderline(boolean isUnderline) 833 { 834 setUnderline(isUnderline ? Boolean.TRUE : Boolean.FALSE); 835 } 836 837 841 public void setUnderline(Boolean isUnderline) 842 { 843 this.isUnderline = isUnderline; 844 } 845 846 849 public boolean isStrikeThrough() 850 { 851 return JRStyleResolver.isStrikeThrough(this); 852 } 853 854 857 public Boolean isOwnStrikeThrough() 858 { 859 return isStrikeThrough; 860 } 861 862 865 public void setStrikeThrough(boolean isStrikeThrough) 866 { 867 setStrikeThrough(isStrikeThrough ? Boolean.TRUE : Boolean.FALSE); 868 } 869 870 874 public void setStrikeThrough(Boolean isStrikeThrough) 875 { 876 this.isStrikeThrough = isStrikeThrough; 877 } 878 879 882 public int getFontSize() 883 { 884 return JRStyleResolver.getFontSize(this); 885 } 886 887 890 public Integer getOwnFontSize() 891 { 892 return fontSize; 893 } 894 895 898 public void setFontSize(int fontSize) 899 { 900 setFontSize(new Integer (fontSize)); 901 } 902 903 907 public void setFontSize(Integer fontSize) 908 { 909 this.fontSize = fontSize; 910 } 911 912 915 public int getSize() 916 { 917 return getFontSize(); 918 } 919 920 923 public Integer getOwnSize() 924 { 925 return getOwnFontSize(); 926 } 927 928 931 public void setSize(int size) 932 { 933 setFontSize(size); 934 } 935 936 939 public void setSize(Integer size) 940 { 941 setFontSize(size); 942 } 943 944 947 public String getPdfFontName() 948 { 949 return JRStyleResolver.getPdfFontName(this); 950 } 951 952 955 public String getOwnPdfFontName() 956 { 957 return pdfFontName; 958 } 959 960 963 public void setPdfFontName(String pdfFontName) 964 { 965 this.pdfFontName = pdfFontName; 966 } 967 968 969 972 public String getPdfEncoding() 973 { 974 return JRStyleResolver.getPdfEncoding(this); 975 } 976 977 980 public String getOwnPdfEncoding() 981 { 982 return pdfEncoding; 983 } 984 985 988 public void setPdfEncoding(String pdfEncoding) 989 { 990 this.pdfEncoding = pdfEncoding; 991 } 992 993 994 997 public boolean isPdfEmbedded() 998 { 999 return JRStyleResolver.isPdfEmbedded(this); 1000 } 1001 1002 1005 public Boolean isOwnPdfEmbedded() 1006 { 1007 return isPdfEmbedded; 1008 } 1009 1010 1013 public void setPdfEmbedded(boolean isPdfEmbedded) 1014 { 1015 setPdfEmbedded(isPdfEmbedded ? Boolean.TRUE : Boolean.FALSE); 1016 } 1017 1018 1022 public void setPdfEmbedded(Boolean isPdfEmbedded) 1023 { 1024 this.isPdfEmbedded = isPdfEmbedded; 1025 } 1026 1027 1030 public void setBorder(Byte border) 1031 { 1032 this.border = border; 1033 } 1034 1035 1038 public void setPadding(Integer padding) 1039 { 1040 this.padding = padding; 1041 } 1042 1043 1046 public void setTopBorder(Byte topBorder) 1047 { 1048 this.topBorder = topBorder; 1049 } 1050 1051 1054 public void setTopPadding(Integer topPadding) 1055 { 1056 this.topPadding = topPadding; 1057 } 1058 1059 1062 public void setLeftBorder(Byte leftBorder) 1063 { 1064 this.leftBorder = leftBorder; 1065 } 1066 1067 1070 public void setLeftPadding(Integer leftPadding) 1071 { 1072 this.leftPadding = leftPadding; 1073 } 1074 1075 1078 public void setBottomBorder(Byte bottomBorder) 1079 { 1080 this.bottomBorder = bottomBorder; 1081 } 1082 1083 1086 public void setBottomPadding(Integer bottomPadding) 1087 { 1088 this.bottomPadding = bottomPadding; 1089 } 1090 1091 1094 public void setRightBorder(Byte rightBorder) 1095 { 1096 this.rightBorder = rightBorder; 1097 } 1098 1099 1102 public void setRightPadding(Integer rightPadding) 1103 { 1104 this.rightPadding = rightPadding; 1105 } 1106 1107 1108} 1109 | Popular Tags |