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


Java Chunk.setFont方法代码示例

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


在下文中一共展示了Chunk.setFont方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: beforePropertyChange

import com.lowagie.text.Chunk; //导入方法依赖的package包/类
public void beforePropertyChange(String propertyName) {
	// do we have any text to do anything with?
	// if not, then just return without action.
	if(this.buffer.length() == 0) return;
	
	if(propertyName.startsWith(RtfProperty.CHARACTER)) {
		// this is a character change,
		// add a new chunk to the current paragraph using current character settings.
		Chunk chunk = new Chunk();
		chunk.append(this.buffer.toString());
		this.buffer = new StringBuffer(255);
		HashMap charProperties = this.rtfParser.getState().properties.getProperties(RtfProperty.CHARACTER);
		String defFont = (String)charProperties.get(RtfProperty.CHARACTER_FONT);
		if(defFont == null) defFont = "0";
		RtfDestinationFontTable fontTable = (RtfDestinationFontTable)this.rtfParser.getDestination("fonttbl");
		Font currFont = fontTable.getFont(defFont);
		int fs = Font.NORMAL;
		if(charProperties.containsKey(RtfProperty.CHARACTER_BOLD)) fs |= Font.BOLD; 
		if(charProperties.containsKey(RtfProperty.CHARACTER_ITALIC)) fs |= Font.ITALIC;
		if(charProperties.containsKey(RtfProperty.CHARACTER_UNDERLINE)) fs |= Font.UNDERLINE;
		Font useFont = FontFactory.getFont(currFont.getFamilyname(), 12, fs, new Color(0,0,0));
		
		
		chunk.setFont(useFont);
		if(iTextParagraph == null) this.iTextParagraph = new Paragraph();
		this.iTextParagraph.add(chunk);

	} else {
		if(propertyName.startsWith(RtfProperty.PARAGRAPH)) {
			// this is a paragraph change. what do we do?
		} else {
			if(propertyName.startsWith(RtfProperty.SECTION)) {
				
			} else {
				if(propertyName.startsWith(RtfProperty.DOCUMENT)) {

				}
			}
		}
	}		
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:42,代码来源:RtfDestinationDocument.java

示例2: getChunk

import com.lowagie.text.Chunk; //导入方法依赖的package包/类
/**
 * Creates a Chunk object based on a list of properties.
 * @param attributes
 * @return a Chunk
 */
public static Chunk getChunk(Properties attributes) {
	Chunk chunk = new Chunk();

	chunk.setFont(FontFactory.getFont(attributes));
	String value;

	value = attributes.getProperty(ElementTags.ITEXT);
	if (value != null) {
		chunk.append(value);
	}
	value = attributes.getProperty(ElementTags.LOCALGOTO);
	if (value != null) {
		chunk.setLocalGoto(value);
	}
	value = attributes.getProperty(ElementTags.REMOTEGOTO);
	if (value != null) {
		String page = attributes.getProperty(ElementTags.PAGE);
		if (page != null) {
			chunk.setRemoteGoto(value, Integer.parseInt(page));
		} else {
			String destination = attributes
					.getProperty(ElementTags.DESTINATION);
			if (destination != null) {
				chunk.setRemoteGoto(value, destination);
			}
		}
	}
	value = attributes.getProperty(ElementTags.LOCALDESTINATION);
	if (value != null) {
		chunk.setLocalDestination(value);
	}
	value = attributes.getProperty(ElementTags.SUBSUPSCRIPT);
	if (value != null) {
		chunk.setTextRise(Float.parseFloat(value + "f"));
	}
	value = attributes.getProperty(Markup.CSS_KEY_VERTICALALIGN);
	if (value != null && value.endsWith("%")) {
		float p = Float.parseFloat(value.substring(0, value.length() - 1)
				+ "f") / 100f;
		chunk.setTextRise(p * chunk.getFont().getSize());
	}
	value = attributes.getProperty(ElementTags.GENERICTAG);
	if (value != null) {
		chunk.setGenericTag(value);
	}
	value = attributes.getProperty(ElementTags.BACKGROUNDCOLOR);
	if (value != null) {
		chunk.setBackground(Markup.decodeColor(value));
	}
	return chunk;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:57,代码来源:ElementFactory.java

示例3: getNormalChunk

import com.lowagie.text.Chunk; //导入方法依赖的package包/类
protected Chunk getNormalChunk(String text) {
    Chunk chunk = new Chunk(StringUtils.defaultIfEmpty(text, ""));
    chunk.setFont(textFont);
    return chunk;
}
 
开发者ID:Biblivre,项目名称:Biblivre-3,代码行数:6,代码来源:BaseBiblivreReport.java

示例4: getBoldChunk

import com.lowagie.text.Chunk; //导入方法依赖的package包/类
protected Chunk getBoldChunk(String text) {
    Chunk chunk = new Chunk(StringUtils.defaultIfEmpty(text, ""));
    chunk.setFont(boldFont);
    return chunk;
}
 
开发者ID:Biblivre,项目名称:Biblivre-3,代码行数:6,代码来源:BaseBiblivreReport.java

示例5: getSmallFontChunk

import com.lowagie.text.Chunk; //导入方法依赖的package包/类
protected Chunk getSmallFontChunk(String text) {
    Chunk chunk = new Chunk(StringUtils.defaultIfEmpty(text, ""));
    chunk.setFont(smallFont);
    return chunk;
}
 
开发者ID:Biblivre,项目名称:Biblivre-3,代码行数:6,代码来源:BaseBiblivreReport.java

示例6: getHeaderChunk

import com.lowagie.text.Chunk; //导入方法依赖的package包/类
protected Chunk getHeaderChunk(String text) {
    Chunk chunk = new Chunk(StringUtils.defaultIfEmpty(text, ""));
    chunk.setFont(headerFont);
    return chunk;
}
 
开发者ID:Biblivre,项目名称:Biblivre-3,代码行数:6,代码来源:BaseBiblivreReport.java

示例7: createChunk

import com.lowagie.text.Chunk; //导入方法依赖的package包/类
/**
 * This creates a new chunk with the given text and font.
 * 
 * @param text
 *            The text.
 * @param font
 *            The font. Can be null.
 * @return an {@link Element}.
 */
public static Element createChunk(String text, Font font) {
    Chunk chunk = new Chunk(text);
    if (font != null) {
        chunk.setFont(font);
    }
    return chunk;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:17,代码来源:RtfElementFactory.java


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