List of usage examples for com.lowagie.text List getIndentationLeft
public float getIndentationLeft()
From source file:com.aryjr.nheengatu.pdf.RomanList.java
License:Open Source License
/** * Adds an <CODE>Object</CODE> to the <CODE>List</CODE>. * * @param o the object to add./*from w ww . j a v a 2s.c o m*/ * @return true if adding the object succeeded */ public boolean add(Object o) { if (o instanceof ListItem) { ListItem item = (ListItem) o; final TagsManager tm = TagsManager.getInstance(); Chunk chunk; if (listStyleType != null && listStyleType.equals("lower-roman")) chunk = new Chunk(toRomanLowerCase(first + list.size()), tm.getFont()); else if (listStyleType != null && listStyleType.equals("upper-roman")) chunk = new Chunk(toRomanUppercase(first + list.size()), tm.getFont()); else if (listStyleType != null && listStyleType.equals("lower-alpha")) chunk = new Chunk(nextLetter(), tm.getFont()); else if (listStyleType != null && listStyleType.equals("upper-alpha")) chunk = new Chunk(nextLetter(), tm.getFont()); else chunk = new Chunk(String.valueOf(first + list.size()), tm.getFont()); chunk.append(" - "); item.setListSymbol(chunk); item.setIndentationLeft(symbolIndent); item.setIndentationRight(0); list.add(item); } else if (o instanceof List) { List nested = (List) o; nested.setIndentationLeft(nested.getIndentationLeft() + symbolIndent); first--; return list.add(nested); } else if (o instanceof String) { return this.add(new ListItem((String) o)); } return false; }
From source file:fr.opensagres.odfdom.converter.pdf.internal.stylable.StylableList.java
License:Open Source License
@SuppressWarnings("unchecked") private void addElement(Element element, boolean addLabel) { if (element instanceof Chunk) { // may it happen? Chunk ch = (Chunk) element;//ww w . j a v a2s. c o m StylableParagraph p = new StylableParagraph(null, null); p.setFont(ch.getFont()); p.addElement(ch); element = p.getElement(); } if (element instanceof Phrase) { Phrase p = (Phrase) element; StylableListItem li = new StylableListItem(p); // determine font, it may be set explicitly or use paragraph font Font symbolFont = symbol.getFont(); if (symbolFont.isStandardFont()) { ArrayList<Chunk> chunks = p.getChunks(); for (Chunk chunk : chunks) { // use first specified font if (!chunk.getFont().isStandardFont()) { symbolFont = chunk.getFont(); break; } } if (symbolFont.isStandardFont()) { // use paragraph font symbolFont = p.getFont(); } } // determine line height float lineHeight = StylableParagraph.DEFAULT_LINE_HEIGHT; boolean lineHeightProportional = true; if (element instanceof IStylableElement) { IStylableElement stylableElement = (IStylableElement) element; Style style = stylableElement.getLastStyleApplied(); if (style != null) { StyleParagraphProperties paragraphProperties = style.getParagraphProperties(); StyleLineHeight lineHeightObj = paragraphProperties.getLineHeight(); if (lineHeightObj != null && lineHeightObj.getLineHeight() != null) { lineHeight = lineHeightObj.getLineHeight(); lineHeightProportional = lineHeightObj.isLineHeightProportional(); } } } if (addLabel) { if (numbered || lettered || romanNumbered) { StringBuilder sbuf = new StringBuilder(preSymbol); int index = first + list.size(); if (lettered) { sbuf.append(RomanAlphabetFactory.getString(index, lowercase)); } else if (romanNumbered) { sbuf.append(RomanNumberFactory.getString(index, lowercase)); } else { sbuf.append(index); } sbuf.append(postSymbol); li.setListSymbol(sbuf.toString(), symbolFont, lineHeight, lineHeightProportional); } else { li.setListSymbol(symbol.getContent(), symbolFont, lineHeight, lineHeightProportional); } } else { li.setListSymbol("", symbolFont, lineHeight, lineHeightProportional); } li.setIndentationLeft(symbolIndent); li.setIndentationRight(0.0f); list.add(li); } else if (element instanceof List) { List l = (List) element; // open office specifies absolute list indentation // but iText computes indentation relative to parent list // so we have to set difference l.setIndentationLeft(l.getIndentationLeft() - this.getIndentationLeft()); first--; list.add(l); } }
From source file:org.odftoolkit.odfdom.converter.internal.itext.stylable.StylableList.java
License:Open Source License
@SuppressWarnings("unchecked") private void addElement(Element element, boolean addLabel) { if (element instanceof Paragraph) { Paragraph p = (Paragraph) element; ListItem li = new StylableListItem(p); if (addLabel) { if (numbered || lettered || romanNumbered) { Chunk chunk = new Chunk(preSymbol, symbol.getFont()); int index = first + list.size(); if (lettered) { chunk.append(RomanAlphabetFactory.getString(index, lowercase)); } else if (romanNumbered) { chunk.append(RomanNumberFactory.getString(index, lowercase)); } else { chunk.append(String.valueOf(index)); }//from w w w . ja v a 2s. c om chunk.append(postSymbol); li.setListSymbol(chunk); } else { li.setListSymbol(symbol); } } else { li.setListSymbol(new Chunk("", symbol.getFont())); } li.setIndentationLeft(symbolIndent, autoindent); li.setIndentationRight(0.0f); list.add(li); } else if (element instanceof List) { List l = (List) element; // open office specifies absolute list indentation // but iText computes indentation relative to parent list // so we have to set difference l.setIndentationLeft(l.getIndentationLeft() - this.getIndentationLeft()); first--; list.add(l); } }