package net.sf.jasperreports.engine.fill; import java.awt.Color; import net.sf.jasperreports.engine.JRBox; import net.sf.jasperreports.engine.JRFont; import net.sf.jasperreports.engine.JRLineBox; import net.sf.jasperreports.engine.JRPrintHyperlinkParameters; import net.sf.jasperreports.engine.JRPrintText; import net.sf.jasperreports.engine.JRReportFont; import net.sf.jasperreports.engine.JRStyledTextAttributeSelector; import net.sf.jasperreports.engine.util.JRBoxUtil; import net.sf.jasperreports.engine.util.JRStyledText; import net.sf.jasperreports.engine.util.JRStyledTextParser; import net.sf.jasperreports.engine.util.LineBoxWrapper; public class JRTemplatePrintText extends JRTemplatePrintElement implements JRPrintText { private static final long serialVersionUID = 10200L; private String text = ""; private Integer textTruncateIndex; private String textTruncateSuffix; private transient String truncatedText; private float lineSpacingFactor = 0.0F; private float leadingOffset = 0.0F; private byte runDirection = 0; private float textHeight = 0.0F; private String anchorName = null; private String hyperlinkReference = null; private String hyperlinkAnchor = null; private Integer hyperlinkPage = null; private String hyperlinkTooltip; private JRPrintHyperlinkParameters hyperlinkParameters; protected int bookmarkLevel = 0; public JRTemplatePrintText(JRTemplateText text) { super(text); } public String getText() { if (this.truncatedText == null && this.text != null) { if (getTextTruncateIndex() == null) { this.truncatedText = this.text; } else if (!"none".equals(getMarkup())) { this.truncatedText = JRStyledTextParser.getInstance().write(getFullStyledText(JRStyledTextAttributeSelector.ALL), 0, getTextTruncateIndex().intValue()); } else { this.truncatedText = this.text.substring(0, getTextTruncateIndex().intValue()); } if (this.textTruncateSuffix != null) this.truncatedText += this.textTruncateSuffix; } return this.truncatedText; } public void setText(String text) { this.text = text; this.truncatedText = null; } public Integer getTextTruncateIndex() { return this.textTruncateIndex; } public void setTextTruncateIndex(Integer textTruncateIndex) { this.textTruncateIndex = textTruncateIndex; this.truncatedText = null; } public String getTextTruncateSuffix() { return this.textTruncateSuffix; } public void setTextTruncateSuffix(String textTruncateSuffix) { this.textTruncateSuffix = textTruncateSuffix; this.truncatedText = null; } public String getFullText() { String fullText = this.text; if (this.textTruncateIndex == null && this.textTruncateSuffix != null) fullText = fullText + this.textTruncateSuffix; return fullText; } public String getOriginalText() { return this.text; } public JRStyledText getStyledText(JRStyledTextAttributeSelector attributeSelector) { if (getText() == null) return null; return JRStyledTextParser.getInstance().getStyledText(attributeSelector.getStyledTextAttributes(this), getText(), !"none".equals(getMarkup())); } public JRStyledText getFullStyledText(JRStyledTextAttributeSelector attributeSelector) { if (getFullText() == null) return null; return JRStyledTextParser.getInstance().getStyledText(attributeSelector.getStyledTextAttributes(this), getFullText(), !"none".equals(getMarkup())); } public float getLineSpacingFactor() { return this.lineSpacingFactor; } public void setLineSpacingFactor(float lineSpacingFactor) { this.lineSpacingFactor = lineSpacingFactor; } public float getLeadingOffset() { return this.leadingOffset; } public void setLeadingOffset(float leadingOffset) { this.leadingOffset = leadingOffset; } public byte getTextAlignment() { return getHorizontalAlignment(); } public void setTextAlignment(byte horizontalAlignment) {} public byte getHorizontalAlignment() { return ((JRTemplateText)this.template).getHorizontalAlignment(); } public Byte getOwnHorizontalAlignment() { return ((JRTemplateText)this.template).getOwnHorizontalAlignment(); } public void setHorizontalAlignment(byte horizontalAlignment) {} public void setHorizontalAlignment(Byte horizontalAlignment) {} public byte getVerticalAlignment() { return ((JRTemplateText)this.template).getVerticalAlignment(); } public Byte getOwnVerticalAlignment() { return ((JRTemplateText)this.template).getOwnVerticalAlignment(); } public void setVerticalAlignment(byte verticalAlignment) {} public void setVerticalAlignment(Byte verticalAlignment) {} public byte getRotation() { return ((JRTemplateText)this.template).getRotation(); } public Byte getOwnRotation() { return ((JRTemplateText)this.template).getOwnRotation(); } public void setRotation(byte rotation) {} public void setRotation(Byte rotation) {} public byte getRunDirection() { return this.runDirection; } public void setRunDirection(byte runDirection) { this.runDirection = runDirection; } public float getTextHeight() { return this.textHeight; } public void setTextHeight(float textHeight) { this.textHeight = textHeight; } public byte getLineSpacing() { return ((JRTemplateText)this.template).getLineSpacing(); } public Byte getOwnLineSpacing() { return ((JRTemplateText)this.template).getOwnLineSpacing(); } public void setLineSpacing(byte lineSpacing) {} public void setLineSpacing(Byte lineSpacing) {} public boolean isStyledText() { return "styled".equals(getMarkup()); } public Boolean isOwnStyledText() { String mkp = getOwnMarkup(); return "styled".equals(mkp) ? Boolean.TRUE : ((mkp == null) ? null : Boolean.FALSE); } public void setStyledText(boolean isStyledText) {} public void setStyledText(Boolean isStyledText) {} public String getMarkup() { return ((JRTemplateText)this.template).getMarkup(); } public String getOwnMarkup() { return ((JRTemplateText)this.template).getOwnMarkup(); } public void setMarkup(String markup) {} public JRBox getBox() { return (JRBox)new LineBoxWrapper(getLineBox()); } public JRLineBox getLineBox() { return ((JRTemplateText)this.template).getLineBox(); } public void setBox(JRBox box) { JRBoxUtil.setBoxToLineBox(box, getLineBox()); } public JRFont getFont() { return (JRTemplateText)this.template; } public void setFont(JRFont font) {} public String getAnchorName() { return this.anchorName; } public void setAnchorName(String anchorName) { this.anchorName = anchorName; } public byte getHyperlinkType() { return ((JRTemplateText)this.template).getHyperlinkType(); } public void setHyperlinkType(byte hyperlinkType) {} public byte getHyperlinkTarget() { return ((JRTemplateText)this.template).getHyperlinkTarget(); } public void setHyperlinkTarget(byte hyperlinkTarget) {} public String getHyperlinkReference() { return this.hyperlinkReference; } public void setHyperlinkReference(String hyperlinkReference) { this.hyperlinkReference = hyperlinkReference; } public String getHyperlinkAnchor() { return this.hyperlinkAnchor; } public void setHyperlinkAnchor(String hyperlinkAnchor) { this.hyperlinkAnchor = hyperlinkAnchor; } public Integer getHyperlinkPage() { return this.hyperlinkPage; } public void setHyperlinkPage(Integer hyperlinkPage) { this.hyperlinkPage = hyperlinkPage; } public int getBookmarkLevel() { return this.bookmarkLevel; } public void setBookmarkLevel(int bookmarkLevel) { this.bookmarkLevel = bookmarkLevel; } public byte getBorder() { return getBox().getBorder(); } public Byte getOwnBorder() { return getBox().getOwnBorder(); } public void setBorder(byte border) { getBox().setBorder(border); } public void setBorder(Byte border) { getBox().setBorder(border); } public Color getBorderColor() { return getBox().getBorderColor(); } public Color getOwnBorderColor() { return getBox().getOwnBorderColor(); } public void setBorderColor(Color borderColor) { getBox().setBorderColor(borderColor); } public int getPadding() { return getBox().getPadding(); } public Integer getOwnPadding() { return getBox().getOwnPadding(); } public void setPadding(int padding) { getBox().setPadding(padding); } public void setPadding(Integer padding) { getBox().setPadding(padding); } public byte getTopBorder() { return getBox().getTopBorder(); } public Byte getOwnTopBorder() { return getBox().getOwnTopBorder(); } public void setTopBorder(byte topBorder) { getBox().setTopBorder(topBorder); } public void setTopBorder(Byte topBorder) { getBox().setTopBorder(topBorder); } public Color getTopBorderColor() { return getBox().getTopBorderColor(); } public Color getOwnTopBorderColor() { return getBox().getOwnTopBorderColor(); } public void setTopBorderColor(Color topBorderColor) { getBox().setTopBorderColor(topBorderColor); } public int getTopPadding() { return getBox().getTopPadding(); } public Integer getOwnTopPadding() { return getBox().getOwnTopPadding(); } public void setTopPadding(int topPadding) { getBox().setTopPadding(topPadding); } public void setTopPadding(Integer topPadding) { getBox().setTopPadding(topPadding); } public byte getLeftBorder() { return getBox().getLeftBorder(); } public Byte getOwnLeftBorder() { return getBox().getOwnLeftBorder(); } public void setLeftBorder(byte leftBorder) { getBox().setLeftBorder(leftBorder); } public void setLeftBorder(Byte leftBorder) { getBox().setLeftBorder(leftBorder); } public Color getLeftBorderColor() { return getBox().getLeftBorderColor(); } public Color getOwnLeftBorderColor() { return getBox().getOwnLeftBorderColor(); } public void setLeftBorderColor(Color leftBorderColor) { getBox().setLeftBorderColor(leftBorderColor); } public int getLeftPadding() { return getBox().getLeftPadding(); } public Integer getOwnLeftPadding() { return getBox().getOwnLeftPadding(); } public void setLeftPadding(int leftPadding) { getBox().setLeftPadding(leftPadding); } public void setLeftPadding(Integer leftPadding) { getBox().setLeftPadding(leftPadding); } public byte getBottomBorder() { return getBox().getBottomBorder(); } public Byte getOwnBottomBorder() { return getBox().getOwnBottomBorder(); } public void setBottomBorder(byte bottomBorder) { getBox().setBottomBorder(bottomBorder); } public void setBottomBorder(Byte bottomBorder) { getBox().setBottomBorder(bottomBorder); } public Color getBottomBorderColor() { return getBox().getBottomBorderColor(); } public Color getOwnBottomBorderColor() { return getBox().getOwnBottomBorderColor(); } public void setBottomBorderColor(Color bottomBorderColor) { getBox().setBottomBorderColor(bottomBorderColor); } public int getBottomPadding() { return getBox().getBottomPadding(); } public Integer getOwnBottomPadding() { return getBox().getOwnBottomPadding(); } public void setBottomPadding(int bottomPadding) { getBox().setBottomPadding(bottomPadding); } public void setBottomPadding(Integer bottomPadding) { getBox().setBottomPadding(bottomPadding); } public byte getRightBorder() { return getBox().getRightBorder(); } public Byte getOwnRightBorder() { return getBox().getOwnRightBorder(); } public void setRightBorder(byte rightBorder) { getBox().setRightBorder(rightBorder); } public void setRightBorder(Byte rightBorder) { getBox().setRightBorder(rightBorder); } public Color getRightBorderColor() { return getBox().getRightBorderColor(); } public Color getOwnRightBorderColor() { return getBox().getOwnRightBorderColor(); } public void setRightBorderColor(Color rightBorderColor) { getBox().setRightBorderColor(rightBorderColor); } public int getRightPadding() { return getBox().getRightPadding(); } public Integer getOwnRightPadding() { return getBox().getOwnRightPadding(); } public void setRightPadding(int rightPadding) { getBox().setRightPadding(rightPadding); } public void setRightPadding(Integer rightPadding) { getBox().setRightPadding(rightPadding); } public JRReportFont getReportFont() { return ((JRTemplateText)this.template).getReportFont(); } public void setReportFont(JRReportFont reportFont) {} public String getFontName() { return ((JRTemplateText)this.template).getFontName(); } public String getOwnFontName() { return ((JRTemplateText)this.template).getOwnFontName(); } public void setFontName(String fontName) {} public boolean isBold() { return ((JRTemplateText)this.template).isBold(); } public Boolean isOwnBold() { return ((JRTemplateText)this.template).isOwnBold(); } public void setBold(boolean isBold) {} public void setBold(Boolean isBold) {} public boolean isItalic() { return ((JRTemplateText)this.template).isItalic(); } public Boolean isOwnItalic() { return ((JRTemplateText)this.template).isOwnItalic(); } public void setItalic(boolean isItalic) {} public void setItalic(Boolean isItalic) {} public boolean isUnderline() { return ((JRTemplateText)this.template).isUnderline(); } public Boolean isOwnUnderline() { return ((JRTemplateText)this.template).isOwnUnderline(); } public void setUnderline(boolean isUnderline) {} public void setUnderline(Boolean isUnderline) {} public boolean isStrikeThrough() { return ((JRTemplateText)this.template).isStrikeThrough(); } public Boolean isOwnStrikeThrough() { return ((JRTemplateText)this.template).isOwnStrikeThrough(); } public void setStrikeThrough(boolean isStrikeThrough) { setStrikeThrough(isStrikeThrough ? Boolean.TRUE : Boolean.FALSE); } public void setStrikeThrough(Boolean isStrikeThrough) {} public int getFontSize() { return ((JRTemplateText)this.template).getFontSize(); } public Integer getOwnFontSize() { return ((JRTemplateText)this.template).getOwnFontSize(); } public void setFontSize(int fontSize) {} public void setFontSize(Integer fontSize) {} public int getSize() { return getFontSize(); } public Integer getOwnSize() { return getOwnFontSize(); } public void setSize(int size) {} public void setSize(Integer size) {} public String getPdfFontName() { return ((JRTemplateText)this.template).getPdfFontName(); } public String getOwnPdfFontName() { return ((JRTemplateText)this.template).getOwnPdfFontName(); } public void setPdfFontName(String pdfFontName) {} public String getPdfEncoding() { return ((JRTemplateText)this.template).getPdfEncoding(); } public String getOwnPdfEncoding() { return ((JRTemplateText)this.template).getOwnPdfEncoding(); } public void setPdfEncoding(String pdfEncoding) {} public boolean isPdfEmbedded() { return ((JRTemplateText)this.template).isPdfEmbedded(); } public Boolean isOwnPdfEmbedded() { return ((JRTemplateText)this.template).isOwnPdfEmbedded(); } public void setPdfEmbedded(boolean isPdfEmbedded) {} public void setPdfEmbedded(Boolean isPdfEmbedded) {} public String getValueClassName() { return ((JRTemplateText)this.template).getValueClassName(); } public String getPattern() { return ((JRTemplateText)this.template).getPattern(); } public String getFormatFactoryClass() { return ((JRTemplateText)this.template).getFormatFactoryClass(); } public String getLocaleCode() { return ((JRTemplateText)this.template).getLocaleCode(); } public String getTimeZoneId() { return ((JRTemplateText)this.template).getTimeZoneId(); } public JRPrintHyperlinkParameters getHyperlinkParameters() { return this.hyperlinkParameters; } public void setHyperlinkParameters(JRPrintHyperlinkParameters hyperlinkParameters) { this.hyperlinkParameters = hyperlinkParameters; } public String getLinkType() { return ((JRTemplateText)this.template).getLinkType(); } public void setLinkType(String type) {} public String getHyperlinkTooltip() { return this.hyperlinkTooltip; } public void setHyperlinkTooltip(String hyperlinkTooltip) { this.hyperlinkTooltip = hyperlinkTooltip; } }