当前位置: 首页>>代码示例>>Java>>正文


Java JRStyledText.getText方法代码示例

本文整理汇总了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;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:21,代码来源:JRXlsExporter.java

示例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);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:25,代码来源:TableBuilder.java

示例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;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:19,代码来源:JRXlsMetadataExporter.java

示例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);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:25,代码来源:JRPptxExporter.java

示例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);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:25,代码来源:JRXlsxExporter.java

示例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);
	}

}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:25,代码来源:LuceneUtil.java

示例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;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:24,代码来源:IconLabelElementCsvHandler.java

示例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);
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:12,代码来源:SimplePdfTextRenderer.java

示例9: getText

import net.sf.jasperreports.engine.util.JRStyledText; //导入方法依赖的package包/类
/**
 *
 */
public String getText()
{
	JRStyledText tmpStyledText = getStyledText();

	if (tmpStyledText == null)
	{
		return null;
	}

	return tmpStyledText.getText();
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:15,代码来源:JRFillTextElement.java

示例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);
			}
		}
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:52,代码来源:JROdsExporter.java

示例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>");
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:70,代码来源:HtmlExporter.java

示例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);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:53,代码来源:JRDocxExporter.java

示例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);
			}
		}
	}		
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:75,代码来源:JRCsvMetadataExporter.java

示例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());
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:59,代码来源:JRFillTextElement.java


注:本文中的net.sf.jasperreports.engine.util.JRStyledText.getText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。