Example usage for com.lowagie.text List UNORDERED

List of usage examples for com.lowagie.text List UNORDERED

Introduction

In this page you can find the example usage for com.lowagie.text List UNORDERED.

Prototype

boolean UNORDERED

To view the source code for com.lowagie.text List UNORDERED.

Click Source Link

Document

a possible value for the numbered parameter

Usage

From source file:classroom.filmfestival_c.Movies17.java

@SuppressWarnings("unchecked")
protected static Element directors(FilmTitle movie) {
    Set<DirectorName> directors = movie.getDirectorNames();
    if (directors.size() == 0) {
        Paragraph p = new Paragraph("various directors");
        p.setLeading(16);//from  w  w  w. j  a  v a2s.  c om
        return p;
    }
    if (directors.size() == 1) {
        DirectorName name = directors.iterator().next();
        Paragraph p = new Paragraph(name.getName());
        p.setLeading(16);
        return p;
    }
    List list = new List(List.UNORDERED, 10);
    ListItem li;
    for (DirectorName director : directors) {
        li = new ListItem(director.getName());
        li.setLeading(16);
        list.add(li);
    }
    return list;
}

From source file:classroom.filmfestival_c.Movies17.java

@SuppressWarnings({ "unchecked", "deprecation" })
protected static Element screenings(FestivalScreening screening) {
    // the specific screening
    Paragraph p = getScreening(screening, BOLDSMALL);
    p.setLeading(16);//from w ww .  j  a va  2s. c  o  m

    FilmTitle movie = screening.getFilmTitle();
    Set<FestivalScreening> screenings = movie.getFestivalScreenings();
    if (screenings.size() == 1) {
        return p;
    }
    // the alternative screenings
    List list = new List(List.UNORDERED, 10);
    list.add(new ListItem(p));
    ListItem li;
    for (FestivalScreening ascreening : screenings) {
        if (ascreening.getId().equals(screening.getId()))
            continue;
        GregorianCalendar gc = new GregorianCalendar();
        gc.setTime(ascreening.getId().getDay());
        if (gc.get(GregorianCalendar.YEAR) != YEAR)
            continue;
        li = new ListItem(getScreening(ascreening, SMALL));
        li.setLeading(12);
        list.add(li);
    }
    return list;
}

From source file:com.amphisoft.epub2pdf.content.XhtmlHandler.java

License:Open Source License

@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) {
    /*//from  w  w w  .ja va 2  s.  com
    if("ol".equals(qName) || "ul".equals(qName) || "li".equals(qName)) {
       System.err.print(qName + " ");
    }
     */
    currentSaxElemId = saxElemIdCounter;

    Map<String, String> attrMap = new HashMap<String, String>();
    // parse attributes
    for (int ai = 0; ai < attributes.getLength(); ai++) {
        attrMap.put(attributes.getQName(ai), attributes.getValue(ai));
    }
    String idAttr = attrMap.get("id");
    if (idAttr == null) {
        idAttr = "";
    }
    String className = attrMap.get("class");
    if (className == null) {
        className = "";
    }
    SaxElement sE = new SaxElement(qName, saxElemIdCounter++, className, idAttr, currentITextStyle);
    //printlnerr("startElement: " + sE.toString());
    saxElementStack.push(sE);

    try {
        if (attrMap.get("class") != null) {
            String[] elemClasses = attrMap.get("class").split(" ");

            for (String eClass : elemClasses) {

                StyleSpecText classTextStyles = styleMap.getTextStyleSpecFor(qName, eClass);
                if (classTextStyles != null) {
                    sE.applyTextStyles(classTextStyles);
                }

            }
        }
        if (attrMap.get("style") != null) {
            // TODO this needs more thought, and careful tracking of which tags are still open, etc.
            //String styleSource = attrMap.get("style");
            //CssStyleMap styleTagStyles = cssParser.getStylesFromStyleTag(styleSource);
            // ...
        }
        if (sE.textStyles == null) {
            try {
                int stackSize = saxElementStack.size();
                if (stackSize > 1) {
                    SaxElement enclosingElement = saxElementStack.elementAt(stackSize - 2);
                    StyleSpecText enclosingSST = enclosingElement.textStyles;
                    if (enclosingSST != null)
                        sE.applyTextStyles(enclosingSST);
                }
            } catch (Exception e) {
            }
        }

        StyleSpecText currentTextStyles = sE.textStyles;
        if (currentTextStyles != null) {
            if (currentTextStyles.isBold()) {
                currentITextStyle |= Font.BOLD;
            }
            if (currentTextStyles.isItalic()) {
                currentITextStyle |= Font.ITALIC;
            }
        }

        //System.err.println("PUSH -> " + saxElementStack);

        previousTag = currentTag;
        currentTag = qName;
        if (document.isOpen()) {
            if (XhtmlTags.NEWLINE.equals(qName)) {
                if (stack.size() > 0) {
                    TextElementArray currentTEA = (TextElementArray) stack.peek();
                    currentTEA.add(Chunk.NEWLINE);
                } else if (specialParagraph != null) {
                    specialParagraph.add(Chunk.NEWLINE);
                }
            }

            updateStack();

            String xmlElementId = attrMap.get("id");

            if (XhtmlTags.ANCHOR.equals(qName)) {
                //concession to nonconformists...
                if (xmlElementId == null) {
                    xmlElementId = attrMap.get("name");
                }
                Anchor anchor = textFactory.newAnchor();
                String ref = attrMap.get(XhtmlTags.REFERENCE);

                if (ref != null) {
                    int aNameStartIdx = ref.lastIndexOf("#") + 1;
                    ref = ref.substring(aNameStartIdx);
                    anchor.setReference(ref);
                }
                if (xmlElementId != null) {
                    anchor.setName(xmlElementId);
                }
                pushToStack(anchor);
            } else {
                if (xmlElementId != null) {
                    //flushStack();
                    Anchor dest = textFactory.newAnchor();
                    dest.setName(xmlElementId);
                    pushToStack(dest);
                    //flushStack();
                }
                for (int i = 0; i < 6; i++) {
                    if (XhtmlTags.H[i].equals(qName)) {
                        flushStack();
                        freshParagraph = true;
                        currentITextStyle |= Font.BOLD;
                        specialParagraph = textFactory.newHeadline(i + 1);
                        return;
                    }
                }
                if ("blockquote".equals(qName)) {
                    flushStack();
                    freshParagraph = true;
                    Paragraph p = textFactory.newParagraph();
                    p.setIndentationLeft(50);
                    p.setIndentationRight(20);
                    p.setAlignment(defaultAlignment);
                    pushToStack(p);
                } else if (XhtmlTags.PARAGRAPH.equals(qName)) {
                    flushStack();
                    freshParagraph = true;
                    Paragraph p = textFactory.newParagraph();
                    pushToStack(p);
                } else if (XhtmlTags.DIV.equals(qName)) {
                    if (stack.size() > 0 && stack.peek().getChunks().size() > 0) {
                        flushStack();
                    }
                    if (stack.size() == 0) {
                        Paragraph brandNewParagraph = textFactory.newParagraph();
                        pushToStack(brandNewParagraph);
                        freshParagraph = true;
                    }
                } else if (XhtmlTags.PRE.equals(qName)) {
                    flushStack();
                    freshParagraph = true;
                    Paragraph p = textFactory.newParagraphPre();
                    pushToStack(p);
                } else if (XhtmlTags.ORDEREDLIST.equals(qName)) {
                    flushStack();
                    List oList = new List(List.ORDERED, 10);
                    pushToStack(oList);
                } else if (XhtmlTags.UNORDEREDLIST.equals(qName)) {
                    flushStack();
                    List uList = new List(List.UNORDERED, 10);
                    pushToStack(uList);
                } else if (XhtmlTags.LISTITEM.equals(qName)) {
                    freshParagraph = true;
                    ListItem listItem = new ListItem();
                    pushToStack(listItem);
                } else if (XhtmlTags.IMAGE.equals(qName)) {
                    handleImage(attributes);
                } else if (qName != null && qName.endsWith("image")) {
                    handleSvgImage(attributes);
                } else if (XhtmlTags.LINK.equals(qName)) {
                    // if it's a stylesheet, parse it & update current-style
                    if ("stylesheet".equals(attrMap.get("rel")) && "text/css".equals(attrMap.get("type"))
                            && attrMap.get("href") != null) {
                        String cssHref = xhtmlDir.getAbsoluteFile().toURI().toString() + attrMap.get("href");
                        CssStyleMap stylesFromLink = cssParser.getStylesFromFileURI(cssHref);
                        if (stylesFromLink != null) {
                            styleMap.updateWith(stylesFromLink);
                        }
                    }
                } else if (XhtmlTags.STYLE.equals(qName)) {
                    inStyleTag = true;
                } else if (XhtmlTags.EM.equals(qName) || "I".equals(qName.toUpperCase())) {
                    currentITextStyle |= Font.ITALIC;
                } else if (XhtmlTags.STRONG.equals(currentTag) || "B".equals(qName.toUpperCase())) {
                    currentITextStyle |= Font.BOLD;
                }

            }

        } else if (XhtmlTags.BODY.equals(qName)) {
            document.open();
            freshParagraph = true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    //printlnerr("leaving startElement " + localName + "; stack: " + stackStatus());
}

From source file:com.bibisco.export.ITextExporter.java

License:GNU General Public License

@Override
public void startUnorderedList() {
    mList = new List(List.UNORDERED);
    mList.setIndentationLeft(LIST_INDENTATION_LEFT);
    mList.setAlignindent(true);//from  w ww  . ja v  a 2 s  . c o  m
    mList.setAutoindent(true);
    mList.setListSymbol("*");
}

From source file:org.activityinfo.server.report.renderer.itext.ItextMapRenderer.java

License:Open Source License

private void addIndicatorList(MapReportElement element, MapLayer layer, Cell descriptionCell) {
    com.lowagie.text.List list = new List(List.UNORDERED);

    for (int indicatorId : layer.getIndicatorIds()) {
        IndicatorDTO indicator = element.getContent().getIndicatorById(indicatorId);
        list.add(new ListItem(indicator.getName()));
    }//w  ww  .j a v  a2 s .co  m

    descriptionCell.add(list);
}

From source file:org.gbif.ipt.task.Eml2Rtf.java

License:Apache License

/**
 * Add methods section.//from w  ww . ja va 2  s  .c o  m
 * 
 * @param doc Document
 * @param eml EML
 * @throws DocumentException if problem occurs during add
 */
private void addMethods(Document doc, Eml eml) throws DocumentException {
    if (exists(eml.getMethodSteps()) && !eml.getMethodSteps().isEmpty() || exists(eml.getStudyExtent())
            || exists(eml.getStudyExtent()) || exists(eml.getStudyExtent())) {
        Paragraph p = new Paragraph();
        p.setAlignment(Element.ALIGN_JUSTIFIED);
        p.setFont(font);
        p.add(new Phrase(getText("rtf.methods"), fontTitle));
        p.add(Chunk.NEWLINE);
        p.add(Chunk.NEWLINE);
        if (exists(eml.getStudyExtent())) {
            p.add(new Phrase(getText("rtf.methods.studyExtent"), fontTitle));
            p.add(Chunk.NEWLINE);
            p.add(eml.getStudyExtent().replace("\r\n", "\n"));
            p.add(Chunk.NEWLINE);
            p.add(Chunk.NEWLINE);
        }
        if (exists(eml.getStudyExtent())) {
            p.add(new Phrase(getText("rtf.methods.sampling"), fontTitle));
            p.add(Chunk.NEWLINE);
            p.add(eml.getSampleDescription().replace("\r\n", "\n"));
            p.add(Chunk.NEWLINE);
            p.add(Chunk.NEWLINE);
        }
        if (exists(eml.getQualityControl())) {
            p.add(new Phrase(getText("rtf.methods.quality"), fontTitle));
            p.add(Chunk.NEWLINE);
            p.add(eml.getQualityControl().replace("\r\n", "\n"));
            p.add(Chunk.NEWLINE);
            p.add(Chunk.NEWLINE);
        }
        if (eml.getMethodSteps().size() == 1) {
            p.add(new Phrase(getText("rtf.methods.description"), fontTitle));
            p.add(Chunk.NEWLINE);
            p.add(eml.getMethodSteps().get(0).replace("\r\n", "\n"));
            p.add(Chunk.NEWLINE);
            p.add(Chunk.NEWLINE);
        } else if (eml.getMethodSteps().size() > 1) {
            p.add(new Phrase(getText("rtf.methods.description") + ". ", fontTitle));
            p.add(Chunk.NEWLINE);
            p.add(Chunk.NEWLINE);
            List list = new List(List.UNORDERED, 0);
            list.setIndentationLeft(20);
            for (String method : eml.getMethodSteps()) {
                list.add(new ListItem(method.replace("\r\n", "\n"), font));
            }
            p.add(list);
        }

        doc.add(p);
        p.clear();
    }
}

From source file:org.pz.platypus.plugin.pdf.PdfOutfile.java

License:Open Source License

/**
 * Adds a new bullet list to the stack of bulleted lists. (These are saved in a stack because
 * lists can nest)./*from   www .j  a v a  2s  . c om*/
 *
 * @param bulletSymbol symbol to be used as the bullet marker (an iText Chunk)
 */
public void startPlainBulletList(final Chunk bulletSymbol) {
    // set the skip to 0 lines, output old text, start a new paragraph.
    float initialParaSkip = pdfData.getParagraphSkip();
    int initialParaSkipSource = pdfData.getParagraphSkipLine();
    pdfData.setParagraphSkip(0f, new Source(0, initialParaSkipSource));
    startNewParagraph();

    // then reset the paragraph skip to the previous value.
    pdfData.setParagraphSkip(initialParaSkip, new Source(0, initialParaSkipSource));

    // create the bullet list
    Chunk bulletMarker = bulletSymbol;
    float indentMargin = 18f; // for the nonce, all indents are 1/4"

    List bulletList = new List(List.UNORDERED, indentMargin);
    if (bulletMarker == null || bulletMarker.isEmpty()) {
        bulletMarker = new Chunk(DefaultValues.BULLET);
    }
    bulletList.setListSymbol(bulletMarker);
    bulletLists.add(bulletList);
}