當前位置: 首頁>>代碼示例>>Java>>正文


Java Chunk.setTextRise方法代碼示例

本文整理匯總了Java中com.lowagie.text.Chunk.setTextRise方法的典型用法代碼示例。如果您正苦於以下問題:Java Chunk.setTextRise方法的具體用法?Java Chunk.setTextRise怎麽用?Java Chunk.setTextRise使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.lowagie.text.Chunk的用法示例。


在下文中一共展示了Chunk.setTextRise方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createChunk

import com.lowagie.text.Chunk; //導入方法依賴的package包/類
public Chunk createChunk(String text, ChainedProperties props) {
	Font font = getFont(props);
	float size = font.getSize();
	size /= 2;
	Chunk ck = new Chunk(text, font);
	if (props.hasProperty("sub"))
		ck.setTextRise(-size);
	else if (props.hasProperty("sup"))
		ck.setTextRise(size);
	ck.setHyphenation(getHyphenation(props));
	return ck;
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:13,代碼來源:FactoryProperties.java

示例2: main

import com.lowagie.text.Chunk; //導入方法依賴的package包/類
/**
 * Demonstrates some Chunk functionality.
 */
@Test
public void main() throws Exception {

	// step 1: creation of a document-object
	Document document = new Document();
	// step 2:
	// we create a writer that listens to the document
	PdfWriter.getInstance(document, PdfTestBase.getOutputStream("Chunks.pdf"));

	// step 3: we open the document
	document.open();
	// step 4:
	Chunk fox = new Chunk("quick brown fox");
	float superscript = 8.0f;
	fox.setTextRise(superscript);
	fox.setBackground(new Color(0xFF, 0xDE, 0xAD));
	Chunk jumps = new Chunk(" jumps over ");
	Chunk dog = new Chunk("the lazy dog");
	float subscript = -8.0f;
	dog.setTextRise(subscript);
	dog.setUnderline(new Color(0xFF, 0x00, 0x00), 3.0f, 0.0f, -5.0f + subscript, 0.0f,
			PdfContentByte.LINE_CAP_ROUND);
	document.add(fox);
	document.add(jumps);
	document.add(dog);

	// step 5: we close the document
	document.close();
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:33,代碼來源:ChunksTest.java

示例3: main

import com.lowagie.text.Chunk; //導入方法依賴的package包/類
/**
 * Demonstrates some Chunk functionality.
 * 
 * @param args
 *            no arguments needed here
 */
public static void main(String[] args) {

	System.out.println("the Chunk object");

	// step 1: creation of a document-object
	Document document = new Document();
	try {
		// step 2:
		// we create a writer that listens to the document
		PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "Chunks.pdf"));

		// step 3: we open the document
		document.open();
		// step 4:
		Chunk fox = new Chunk("quick brown fox");
		float superscript = 8.0f;
		fox.setTextRise(superscript);
		fox.setBackground(new Color(0xFF, 0xDE, 0xAD));
		Chunk jumps = new Chunk(" jumps over ");
		Chunk dog = new Chunk("the lazy dog");
		float subscript = -8.0f;
		dog.setTextRise(subscript);
		dog.setUnderline(new Color(0xFF, 0x00, 0x00), 3.0f, 0.0f, -5.0f + subscript, 0.0f,
				PdfContentByte.LINE_CAP_ROUND);
		document.add(fox);
		document.add(jumps);
		document.add(dog);
	} catch (DocumentException de) {
		System.err.println(de.getMessage());
	} catch (IOException ioe) {
		System.err.println(ioe.getMessage());
	}

	// step 5: we close the document
	document.close();
}
 
開發者ID:fc-dream,項目名稱:PDFTestForAndroid,代碼行數:43,代碼來源:Chunks.java

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

示例5: getChunk

import com.lowagie.text.Chunk; //導入方法依賴的package包/類
/**
 *
 */
protected Chunk getChunk(Map<Attribute,Object> attributes, String text, Locale locale)
{
	// underline and strikethrough are set on the chunk below
	Font font = getFont(attributes, locale, false);

	Chunk chunk = new Chunk(text, font);
	
	if (hasUnderline(attributes))
	{
		// using the same values as sun.font.Fond2D
		chunk.setUnderline(null, 0, 1f / 18, 0, -1f / 12, 0);
	}
	
	if (hasStrikethrough(attributes))
	{
		// using the same thickness as sun.font.Fond2D.
		// the position is calculated in Fond2D based on the ascent, defaulting 
		// to iText default position which depends on the font size
		chunk.setUnderline(null, 0, 1f / 18, 0, 1f / 3, 0);
	}

	Color backcolor = (Color)attributes.get(TextAttribute.BACKGROUND);
	if (backcolor != null)
	{
		chunk.setBackground(backcolor);
	}

	Object script = attributes.get(TextAttribute.SUPERSCRIPT);
	if (script != null)
	{
		if (TextAttribute.SUPERSCRIPT_SUPER.equals(script))
		{
			chunk.setTextRise(font.getCalculatedLeading(1f)/2);
		}
		else if (TextAttribute.SUPERSCRIPT_SUB.equals(script))
		{
			chunk.setTextRise(-font.getCalculatedLeading(1f)/2);
		}
	}

	if (splitCharacter != null)
	{
		//TODO use line break offsets if available?
		chunk.setSplitCharacter(splitCharacter);
	}

	return chunk;
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:52,代碼來源:JRPdfExporter.java


注:本文中的com.lowagie.text.Chunk.setTextRise方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。