本文整理汇总了Java中net.sf.jasperreports.engine.util.JRStyledText.getText方法的典型用法代码示例。如果您正苦于以下问题:Java JRStyledText.getText方法的具体用法?Java JRStyledText.getText怎么用?Java JRStyledText.getText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.jasperreports.engine.util.JRStyledText
的用法示例。
在下文中一共展示了JRStyledText.getText方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRichTextString
import net.sf.jasperreports.engine.util.JRStyledText; //导入方法依赖的package包/类
protected HSSFRichTextString getRichTextString(JRStyledText styledText, short forecolor, JRFont defaultFont, Locale locale)
{
String text = styledText.getText();
HSSFRichTextString richTextStr = new HSSFRichTextString(text);
int runLimit = 0;
AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();
while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
{
Map<Attribute,Object> attributes = iterator.getAttributes();
JRFont runFont = attributes.isEmpty()? defaultFont : new JRBaseFont(attributes);
short runForecolor = attributes.get(TextAttribute.FOREGROUND) != null ?
getWorkbookColor((Color)attributes.get(TextAttribute.FOREGROUND)).getIndex() :
forecolor;
HSSFFont font = getLoadedFont(runFont, runForecolor, attributes, locale);
richTextStr.applyFont(iterator.getIndex(), runLimit, font);
iterator.setIndex(runLimit);
}
return richTextStr;
}
示例2: exportStyledText
import net.sf.jasperreports.engine.util.JRStyledText; //导入方法依赖的package包/类
/**
*
*/
protected void exportStyledText(JRStyledText styledText, Locale locale, boolean startedHyperlink, boolean isIgnoreTextFormatting)
{
String text = styledText.getText();
int runLimit = 0;
AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();
while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
{
exportStyledTextRun(
iterator.getAttributes(),
text.substring(iterator.getIndex(), runLimit),
locale,
startedHyperlink,
isIgnoreTextFormatting
);
iterator.setIndex(runLimit);
}
}
示例3: getRichTextString
import net.sf.jasperreports.engine.util.JRStyledText; //导入方法依赖的package包/类
protected HSSFRichTextString getRichTextString(JRStyledText styledText, short forecolor, JRFont defaultFont, Locale locale) {
String text = styledText.getText();
HSSFRichTextString richTextStr = new HSSFRichTextString(text);
int runLimit = 0;
AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();
while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length()) {
Map<Attribute,Object> attributes = iterator.getAttributes();
JRFont runFont = attributes.isEmpty()? defaultFont : new JRBaseFont(attributes);
short runForecolor = attributes.get(TextAttribute.FOREGROUND) != null
? getWorkbookColor((Color)attributes.get(TextAttribute.FOREGROUND)).getIndex()
: forecolor;
HSSFFont font = getLoadedFont(runFont, runForecolor, attributes, locale);
richTextStr.applyFont(iterator.getIndex(), runLimit, font);
iterator.setIndex(runLimit);
}
return richTextStr;
}
示例4: exportStyledText
import net.sf.jasperreports.engine.util.JRStyledText; //导入方法依赖的package包/类
/**
*
*/
protected void exportStyledText(JRStyle style, JRStyledText styledText, Locale locale)
{
String text = styledText.getText();
int runLimit = 0;
AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();
while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
{
runHelper.export(
style,
iterator.getAttributes(),
text.substring(iterator.getIndex(), runLimit),
locale,
invalidCharReplacement
);
iterator.setIndex(runLimit);
}
}
示例5: exportStyledText
import net.sf.jasperreports.engine.util.JRStyledText; //导入方法依赖的package包/类
/**
*
*/
protected void exportStyledText(JRStyle style, JRStyledText styledText, Locale locale, boolean isStyledText)
{
String text = styledText.getText();
int runLimit = 0;
AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();
while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
{
runHelper.export(
style, iterator.getAttributes(),
text.substring(iterator.getIndex(), runLimit),
locale,
invalidCharReplacement,
isStyledText
);
iterator.setIndex(runLimit);
}
}
示例6: addContentField
import net.sf.jasperreports.engine.util.JRStyledText; //导入方法依赖的package包/类
protected void addContentField(int pageNo, JRPrintText element) throws IOException {
String allText;
JRStyledText styledText = getStyledText(element);
if (styledText == null) {
allText = "";
} else {
allText = styledText.getText();
}
if (allText != null && allText.length() > 0) {
Field tf = new Field(CONTENT_FIELD, allText, fieldType);
Document doc = new Document();
doc.add(new IntField("pageNo", pageNo, Field.Store.YES));
PrintElementId peid = PrintElementId.forElement(element);
doc.add(new StringField("uid", peid.toString(), Field.Store.YES));
displayTokens(allText, peid.toString());
doc.add(tf);
writer.addDocument(doc);
}
}
示例7: getTextValue
import net.sf.jasperreports.engine.util.JRStyledText; //导入方法依赖的package包/类
@Override
public String getTextValue(JRCsvExporterContext exporterContext, JRGenericPrintElement element)
{
JRPrintText labelPrintText = (JRPrintText)element.getParameterValue(IconLabelElement.PARAMETER_LABEL_TEXT_ELEMENT);
if (labelPrintText == null)
{
return null;
}
String text = null;
JRStyledText styledText = ((JRCsvExporter)exporterContext.getExporterRef()).getStyledText(labelPrintText);
if (styledText == null)
{
text = "";
}
else
{
text = styledText.getText();
}
return text;
}
示例8: getPhrase
import net.sf.jasperreports.engine.util.JRStyledText; //导入方法依赖的package包/类
/**
*
*/
protected Phrase getPhrase(JRStyledText styledText, JRPrintText textElement)
{
String text = styledText.getText();
AttributedString as = styledText.getAttributedString();
return pdfExporter.getPhrase(as, text, textElement);
}
示例9: getText
import net.sf.jasperreports.engine.util.JRStyledText; //导入方法依赖的package包/类
/**
*
*/
public String getText()
{
JRStyledText tmpStyledText = getStyledText();
if (tmpStyledText == null)
{
return null;
}
return tmpStyledText.getText();
}
示例10: exportTextContents
import net.sf.jasperreports.engine.util.JRStyledText; //导入方法依赖的package包/类
@Override
protected void exportTextContents(JRPrintText textElement)
{
String href = null;
String ignLnkPropName = getIgnoreHyperlinkProperty();
Boolean ignoreHyperlink = HyperlinkUtil.getIgnoreHyperlink(ignLnkPropName, textElement);
boolean isIgnoreTextFormatting = isIgnoreTextFormatting(textElement);
if (ignoreHyperlink == null)
{
ignoreHyperlink = getPropertiesUtil().getBooleanProperty(jasperPrint, ignLnkPropName, false);
}
if (!ignoreHyperlink)
{
href = documentBuilder.getHyperlinkURL(textElement, getCurrentItemConfiguration().isOnePagePerSheet());
}
if (href == null)
{
exportStyledText(textElement, false, isIgnoreTextFormatting);
}
else
{
JRStyledText styledText = getStyledText(textElement);
if (styledText != null && styledText.length() > 0)
{
String text = styledText.getText();
Locale locale = getTextLocale(textElement);
int runLimit = 0;
AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();
while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
{
// ODS does not like text:span inside text:a
// writing one text:a inside text:span for each style run
String runText = text.substring(iterator.getIndex(), runLimit);
startTextSpan(
iterator.getAttributes(),
runText,
locale,
isIgnoreTextFormatting);
writeHyperlink(textElement, href, true);
writeText(runText);
endHyperlink(true);
endTextSpan();
iterator.setIndex(runLimit);
}
}
}
}
示例11: exportStyledText
import net.sf.jasperreports.engine.util.JRStyledText; //导入方法依赖的package包/类
protected void exportStyledText(JRPrintText printText, JRStyledText styledText, String tooltip, boolean hyperlinkStarted) throws IOException
{
Locale locale = getTextLocale(printText);
LineSpacingEnum lineSpacing = printText.getParagraph().getLineSpacing();
Float lineSpacingSize = printText.getParagraph().getLineSpacingSize();
float lineSpacingFactor = printText.getLineSpacingFactor();
Color backcolor = printText.getBackcolor();
String text = styledText.getText();
int runLimit = 0;
addSearchAttributes(styledText, printText);
AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();
boolean first = true;
boolean startedSpan = false;
boolean highlightStarted = false;
while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
{
//if there are several text runs, write the tooltip into a parent <span>
if (first && runLimit < styledText.length() && tooltip != null)
{
startedSpan = true;
writer.write("<span title=\"");
writer.write(JRStringUtil.xmlEncode(tooltip));
writer.write("\">");
//reset the tooltip so that inner <span>s to not use it
tooltip = null;
}
first = false;
Map<Attribute,Object> attributes = iterator.getAttributes();
Color highlightColor = (Color) attributes.get(JRTextAttribute.SEARCH_HIGHLIGHT);
if (highlightColor != null && !highlightStarted) {
highlightStarted = true;
writer.write("<span class=\"jr_search_result\">");
} else if (highlightColor == null && highlightStarted) {
highlightStarted = false;
writer.write("</span>");
}
exportStyledTextRun(
attributes,
text.substring(iterator.getIndex(), runLimit),
tooltip,
locale,
lineSpacing,
lineSpacingSize,
lineSpacingFactor,
backcolor,
hyperlinkStarted
);
iterator.setIndex(runLimit);
}
if (highlightStarted) {
writer.write("</span>");
}
if (startedSpan)
{
writer.write("</span>");
}
}
示例12: exportStyledText
import net.sf.jasperreports.engine.util.JRStyledText; //导入方法依赖的package包/类
/**
*
*/
protected void exportStyledText(JRStyle style, JRStyledText styledText, Locale locale, boolean hiddenText, boolean startedHyperlink, boolean isNewLineJustified)
{
Color elementBackcolor = null;
Map<AttributedCharacterIterator.Attribute, Object> globalAttributes = styledText.getGlobalAttributes();
if (globalAttributes != null)
{
elementBackcolor = (Color)styledText.getGlobalAttributes().get(TextAttribute.BACKGROUND);
}
String text = styledText.getText();
int runLimit = 0;
AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();
while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
{
Map<Attribute,Object> attributes = iterator.getAttributes();
boolean localHyperlink = false;
if (!startedHyperlink)
{
JRPrintHyperlink hyperlink = (JRPrintHyperlink)attributes.get(JRTextAttribute.HYPERLINK);
if (hyperlink != null)
{
localHyperlink = startHyperlink(hyperlink, true);
}
}
runHelper.export(
style,
iterator.getAttributes(),
text.substring(iterator.getIndex(), runLimit),
locale,
hiddenText,
invalidCharReplacement,
elementBackcolor,
isNewLineJustified
);
if (localHyperlink)
{
endHyperlink(true);
}
iterator.setIndex(runLimit);
}
}
示例13: exportText
import net.sf.jasperreports.engine.util.JRStyledText; //导入方法依赖的package包/类
protected void exportText(
JRPrintText textElement,
CsvMetadataReportConfiguration configuration,
Map<String, String> currentRow,
Map<String, String> repeatedValues,
boolean hasDefinedColumns) throws IOException
{
String currentTextValue = null;
if (textElement.getPropertiesMap().getPropertyNames().length > 0)
{
String currentColumnName = textElement.getPropertiesMap().getProperty(PROPERTY_COLUMN_NAME);
String currentColumnData = textElement.getPropertiesMap().getProperty(PROPERTY_DATA);
boolean repeatValue = getPropertiesUtil().getBooleanProperty(textElement, PROPERTY_REPEAT_VALUE, false);
if (textElement.getPropertiesMap().containsProperty(PROPERTY_DATA))
{
currentTextValue = currentColumnData;
} else
{
JRStyledText styledText = getStyledText(textElement);
if (styledText != null)
{
currentTextValue = styledText.getText();
} else
{
currentTextValue = "";
}
}
// when no columns are provided, build the column names list as they are retrieved from the report element property
if (!hasDefinedColumns)
{
if (columnNames == null)
{
columnNames = new ArrayList<String>();
}
if (currentColumnName != null && currentColumnName.length() > 0 && !columnNames.contains(currentColumnName))
{
columnNames.add(currentColumnName);
}
}
if (columnNames.size() > 0)
{
if (columnNames.contains(currentColumnName) && !currentRow.containsKey(currentColumnName) && isColumnReadOnTime(currentRow, currentColumnName)) // the column is for export but was not read yet and comes in the expected order
{
currentRow.put(currentColumnName, currentTextValue);
} else if ( (columnNames.contains(currentColumnName) && !currentRow.containsKey(currentColumnName) && !isColumnReadOnTime(currentRow, currentColumnName)) // the column is for export, was not read yet, but it is read after it should be
|| (columnNames.contains(currentColumnName) && currentRow.containsKey(currentColumnName)) ) // the column is for export and was already read
{
// write header
if (isFirstRow && configuration.isWriteHeader())
{
writeReportHeader();
}
isFirstRow = false;
writeCurrentRow(currentRow, repeatedValues);
currentRow.clear();
currentRow.put(currentColumnName, currentTextValue);
}
// set auto fill columns
if (repeatValue && currentColumnName != null && currentColumnName.length() > 0 && currentTextValue.length() > 0)
{
repeatedValues.put(currentColumnName, currentTextValue);
}
}
}
}
示例14: setPrintText
import net.sf.jasperreports.engine.util.JRStyledText; //导入方法依赖的package包/类
protected void setPrintText(JRPrintText printText)
{
int startIndex = getTextStart();
int endIndex = getTextEnd();
JRStyledText fullStyledText = getStyledText();
String fullText = fullStyledText.getText();
boolean keepAllText = !canOverflow() && keepFullText();
if (keepAllText)
{
//assert getTextStart() == 0
if (startIndex != 0)
{
throw
new JRRuntimeException(
EXCEPTION_MESSAGE_KEY_INVALID_START_INDEX,
(Object[])null
);
}
if (!JRCommonText.MARKUP_NONE.equals(getMarkup()))
{
//rewrite as styled text
String styledText = filler.getStyledTextParser().write(
fullStyledText);
setPrintText(printText, styledText);
}
else
{
setPrintText(printText, fullText);
}
if (endIndex < fullText.length())
{
printText.setTextTruncateIndex(Integer.valueOf(endIndex));
}
}
else
{
String printedText;
if (!JRCommonText.MARKUP_NONE.equals(getMarkup()))
{
printedText = filler.getStyledTextParser().write(
fullStyledText,
startIndex, endIndex);
}
else
{
// relying on substring to return the same String object when whole substring
printedText = fullText.substring(startIndex, endIndex);
}
setPrintText(printText, printedText);
}
printText.setTextTruncateSuffix(getTextTruncateSuffix());
printText.setLineBreakOffsets(getLineBreakOffsets());
}