List of usage examples for com.lowagie.text ListItem setListSymbol
public void setListSymbol(Chunk symbol)
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.//w w w .java2 s . 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: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 ww.j a v a2s.com*/ 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); } }