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


Java JRStyledText.length方法代码示例

本文整理汇总了Java中net.sf.jasperreports.engine.util.JRStyledText.length方法的典型用法代码示例。如果您正苦于以下问题:Java JRStyledText.length方法的具体用法?Java JRStyledText.length怎么用?Java JRStyledText.length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.jasperreports.engine.util.JRStyledText的用法示例。


在下文中一共展示了JRStyledText.length方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: canUseGlyphRendering

import net.sf.jasperreports.engine.util.JRStyledText; //导入方法依赖的package包/类
protected boolean canUseGlyphRendering(JRPrintText text, JRStyledText styledText)
{
	Locale locale = getTextLocale(text);
	AttributedCharacterIterator attributesIterator = styledText.getAttributedString().getIterator();
	int index = 0;
	while (index < styledText.length())
	{
		FontKey fontKey = extractFontKey(attributesIterator.getAttributes(), locale);
		if (!fontKey.fontAttribute.hasAttribute())
		{
			return false;
		}
		
		Boolean canUse = glyphRendererFonts.get(fontKey);
		if (canUse == null)
		{
			canUse = canUseGlyphRendering(fontKey);
			glyphRendererFonts.put(fontKey, canUse);
		}
		
		if (!canUse)
		{
			return false;
		}
		
		index = attributesIterator.getRunLimit();
		attributesIterator.setIndex(index);
	}
	return true;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:31,代码来源:JRPdfExporter.java

示例7: 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

示例8: 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

示例9: exportText

import net.sf.jasperreports.engine.util.JRStyledText; //导入方法依赖的package包/类
/**
	 *
	 */
	public void exportText(DocxTableHelper tableHelper, JRPrintText text, JRExporterGridCell gridCell)
	{
		tableHelper.getCellHelper().exportHeader(text, gridCell);

		JRStyledText styledText = getStyledText(text);

		int textLength = 0;

		if (styledText != null)
		{
			textLength = styledText.length();
		}

//		if (styleBuffer.length() > 0)
//		{
//			writer.write(" style=\"");
//			writer.write(styleBuffer.toString());
//			writer.write("\"");
//		}
//
//		writer.write(">");
		docHelper.write("     <w:p>\n");

		tableHelper.getParagraphHelper().exportProps(text);
		if (startPage)
		{
			insertBookmark(pageAnchor, docHelper);
		}
		if (text.getAnchorName() != null)
		{
			insertBookmark(text.getAnchorName(), docHelper);
		}

		boolean startedHyperlink = startHyperlink(text, true);
		boolean isNewLineAsParagraph = false;
		if (HorizontalTextAlignEnum.JUSTIFIED.equals(text.getHorizontalTextAlign()))
		{
			if (text.hasProperties() && text.getPropertiesMap().containsProperty(DocxReportConfiguration.PROPERTY_NEW_LINE_AS_PARAGRAPH))
			{
				isNewLineAsParagraph = getPropertiesUtil().getBooleanProperty(text, DocxReportConfiguration.PROPERTY_NEW_LINE_AS_PARAGRAPH, false);
			}
			else
			{
				isNewLineAsParagraph = getCurrentItemConfiguration().isNewLineAsParagraph();
			}
		}

		if (textLength > 0)
		{
			exportStyledText(
				getCurrentJasperPrint().getDefaultStyleProvider().getStyleResolver().getBaseStyle(text), 
				styledText, 
				getTextLocale(text),
				getPropertiesUtil().getBooleanProperty(text, PROPERTY_HIDDEN_TEXT, false),
				startedHyperlink, 
				isNewLineAsParagraph
				);
		}

		if (startedHyperlink)
		{
			endHyperlink(true);
		}

		docHelper.write("     </w:p>\n");

		tableHelper.getCellHelper().exportFooter();
	}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:72,代码来源:JRDocxExporter.java

示例10: 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


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