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


Java Chunk.setGenericTag方法代碼示例

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


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

示例1: getPhrase

import com.lowagie.text.Chunk; //導入方法依賴的package包/類
/**
 * Creates a Phrase object based on a list of properties.
 * @param attributes
 * @return a Phrase
 */
public static Phrase getPhrase(Properties attributes) {
	Phrase phrase = new Phrase();
	phrase.setFont(FontFactory.getFont(attributes));
	String value;
	value = attributes.getProperty(ElementTags.LEADING);
	if (value != null) {
		phrase.setLeading(Float.parseFloat(value + "f"));
	}
	value = attributes.getProperty(Markup.CSS_KEY_LINEHEIGHT);
	if (value != null) {
		phrase.setLeading(Markup.parseLength(value,
				Markup.DEFAULT_FONT_SIZE));
	}
	value = attributes.getProperty(ElementTags.ITEXT);
	if (value != null) {
		Chunk chunk = new Chunk(value);
		if ((value = attributes.getProperty(ElementTags.GENERICTAG)) != null) {
			chunk.setGenericTag(value);
		}
		phrase.add(chunk);
	}
	return phrase;
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:29,代碼來源:ElementFactory.java

示例2: create

import com.lowagie.text.Chunk; //導入方法依賴的package包/類
/**
 * Create an index entry.
 *
 * @param text  The text for the Chunk.
 * @param in1   The first level.
 * @param in2   The second level.
 * @param in3   The third level.
 * @return Returns the Chunk.
 */
public Chunk create(final String text, final String in1, final String in2,
        final String in3) {

    Chunk chunk = new Chunk(text);
    String tag = "idx_" + (indexcounter++);
    chunk.setGenericTag(tag);
    chunk.setLocalDestination(tag);
    Entry entry = new Entry(in1, in2, in3, tag);
    indexentry.add(entry);
    return chunk;
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:21,代碼來源:IndexEvents.java

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

示例4: main

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

	System.out.println("Generic");

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

		// step 3: we open the document
		document.open();
		// step 4:
		Paragraph p = new Paragraph("Generic page event");
		document.add(p);
		Chunk box = new Chunk("box");
		box.setGenericTag("box");
		Chunk ellipse = new Chunk("ellipse");
		ellipse.setGenericTag("ellipse");
		p = new Paragraph("In this example, we will add chunks that are tagged as an ");
		p.add(ellipse);
		p.add(" and chunks that are tagged as a ");
		p.add(box);
		p.add(". Can you see the difference between ");
		Chunk c1 = new Chunk("this");
		c1.setGenericTag("box");
		Chunk c2 = new Chunk("that");
		c2.setGenericTag("ellipse");
		p.add(c1);
		p.add(" and ");
		p.add(c2);
		p.add("? One is a ");
		p.add(box);
		p.add("; the other an ");
		p.add(ellipse);
		document.add(p);
	} 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,代碼行數:54,代碼來源:Generic.java


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