Example usage for com.itextpdf.text ZapfDingbatsList ZapfDingbatsList

List of usage examples for com.itextpdf.text ZapfDingbatsList ZapfDingbatsList

Introduction

In this page you can find the example usage for com.itextpdf.text ZapfDingbatsList ZapfDingbatsList.

Prototype

public ZapfDingbatsList(int zn) 

Source Link

Document

Creates a ZapfDingbatsList

Usage

From source file:com.masscustsoft.service.ToPdf.java

License:Open Source License

private com.itextpdf.text.List getList(Map row) throws Exception {
    String type = (String) row.get("type");
    com.itextpdf.text.List list = null;
    if ("greek".equals(type))
        list = new GreekList();
    else if ("roman".equals(type))
        list = new RomanList();
    else if ("zd".equals(type))
        list = new ZapfDingbatsList(1);
    else if ("zd#".equals(type))
        list = new ZapfDingbatsNumberList(1);
    else//from  w  w w  .  j  av  a2 s.  com
        list = new com.itextpdf.text.List();

    Integer charNumber = (Integer) row.get("charNumber");
    if (charNumber != null) {
        if (list instanceof ZapfDingbatsList) {
            ((ZapfDingbatsList) list).setCharNumber(charNumber);
        }
        if (list instanceof ZapfDingbatsNumberList) {
            ((ZapfDingbatsNumberList) list).setType(charNumber);
        }
    }
    Boolean lowercase = (Boolean) row.get("lowercase");
    if (lowercase != null)
        list.setLowercase(lowercase);
    Boolean numbered = (Boolean) row.get("numbered");
    if (numbered != null)
        list.setNumbered(numbered);
    Boolean lettered = (Boolean) row.get("lettered");
    if (lettered != null)
        list.setLettered(lettered);
    Integer first = (Integer) row.get("first");
    if (first != null)
        list.setFirst(first);
    String symbol = (String) row.get("symbol");
    if (symbol != null) {
        Paragraph p = new Paragraph();
        getChunks(p, row, symbol);
        if (p.size() > 0) {
            Object sym = p.get(0);
            if (sym instanceof Chunk) {
                list.setListSymbol((Chunk) sym);
            }
        }
    }
    Float ident = (Float) row.get("ident");
    if (ident == null)
        ident = 10f;
    list.setSymbolIndent(ident);
    List<Map> lst = (List) row.get("items");
    if (lst != null) {
        for (Map item : lst) {
            Element el = getElement(item);
            if (el != null) {
                ListItem li = new ListItem();
                li.add(el);
                list.add(li);
            }
        }
    }
    if (list.size() > 0) {
        Object o = list.getItems().get(0);
        if (o instanceof Paragraph) {
            Paragraph p = (Paragraph) o;
            Float spaceBefore = (Float) row.get("spaceBefore");
            if (spaceBefore != null)
                p.setSpacingBefore(spaceBefore);
        }
        o = list.getItems().get(list.getItems().size() - 1);
        if (o instanceof Paragraph) {
            Paragraph p = (Paragraph) o;
            Float spaceAfter = (Float) row.get("spaceAfter");
            if (spaceAfter != null)
                p.setSpacingAfter(spaceAfter);
        }
    }
    return list;
}