Package com.lowagie.text

Examples of com.lowagie.text.ListItem


        Object list = stack.pop();
        if (!(list instanceof com.lowagie.text.List)) {
          stack.push(list);
          return;
        }
        ListItem item = (ListItem) obj;
        ((com.lowagie.text.List) list).add(item);
        ArrayList cks = item.getChunks();
        if (!cks.isEmpty())
          item.getListSymbol()
              .setFont(((Chunk) cks.get(0)).getFont());
        stack.push(list);
        return;
      }
      if (tag.equals("div") || tag.equals("body")) {
View Full Code Here


                }
                return;
            }
            case LwgElement.LISTITEM:
            {
                ListItem listItem = (ListItem) element;
                styleAttributes = new Properties();
                if (listItem.hasLeading()) styleAttributes.setProperty(Markup.CSS_KEY_LINEHEIGHT, listItem.getTotalLeading() + "pt");
               
                // start tag
                addTabs(indent);
                writeStart(HtmlTags.LISTITEM);
                writeMarkupAttributes(markup);
                write(listItem.getFont(), styleAttributes);
                os.write(GT);
                currentfont.push(listItem.getFont());
                // contents
                for (Iterator i = listItem.iterator(); i.hasNext(); ) {
                    write((LwgElement) i.next(), indent + 1);
                }
                // end tag
                addTabs(indent);
                writeEnd(HtmlTags.LISTITEM);
View Full Code Here

                return;
            }

            // listitems
            if (ElementTags.LISTITEM.equals(name)) {
                ListItem listItem = (ListItem) stack.pop();
                List list = (List) stack.pop();
                list.add(listItem);
                stack.push(list);
            }
View Full Code Here

            // step 4:

      // RomanList
      RomanList roman = new RomanList(35);
      roman.setLowercase(true);
      roman.add(new ListItem("first item"));
      roman.add(new ListItem("second item blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah"));
      for (int i = 3; i < 151; i++) {
        roman.add(i + "th item");
      }
      document.add(roman);
      document.newPage();
      RomanList roman2 = new RomanList(35);
      roman2.add(new ListItem("first item"));
      roman2.add(new ListItem("second item"));
      for (int i = 3; i < 11; i++) {
        roman2.add(i + "th item");
      }
      document.add(roman2);
      document.newPage();
     
      // GreekList
      GreekList greek = new GreekList(15);
      greek.setLowercase(true);
      greek.add(new ListItem("first item"));
      greek.add(new ListItem("second item"));
      for (int i = 3; i < 20; i++) {
        greek.add(i + "th item");
      }
      document.add(greek);
      document.newPage();
     
      // GreekList
      GreekList greek2 = new GreekList(15);
      greek2.setLowercase(false);
      greek2.add(new ListItem("first item"));
      greek2.add(new ListItem("second item"));
      for (int i = 3; i < 20; i++) {
        greek2.add(i + "th item");
      }
      document.add(greek2);
     
      // ZapfDingbatsList
      ZapfDingbatsList z = new ZapfDingbatsList(42,15);
      z.add(new ListItem("first item"));
      z.add(new ListItem("second item"));
      for (int i = 3; i < 20; i++) {
        z.add(i + "th item");
      }
      document.add(z);
      document.newPage();
     
      // ZapfDingbatsNumberList
      ZapfDingbatsNumberList z0 = new ZapfDingbatsNumberList(0, 15);
      z0.add(new ListItem("first item"));
      z0.add(new ListItem("second item"));
      for (int i = 3; i < 11; i++) {
        z0.add(i + "th item");
      }
      document.add(z0);
      ZapfDingbatsNumberList z1 = new ZapfDingbatsNumberList(1, 15);
      z1.add(new ListItem("first item"));
      z1.add(new ListItem("second item"));
      for (int i = 3; i < 11; i++) {
        z1.add(i + "th item");
      }
      document.add(z1);
      ZapfDingbatsNumberList z2 = new ZapfDingbatsNumberList(2, 15);
      z2.add(new ListItem("first item"));
      z2.add(new ListItem("second item"));
      for (int i = 3; i < 11; i++) {
        z2.add(i + "th item");
      }
      document.add(z2);
      ZapfDingbatsNumberList z3 = new ZapfDingbatsNumberList(3, 15);
      z3.add(new ListItem("first item"));
      z3.add(new ListItem("second item"));
      for (int i = 3; i < 11; i++) {
        z3.add(i + "th item");
      }
      document.add(z3);
View Full Code Here

            Chunk c = new Chunk("");
            c.setNewPage();
            doc.add(c);

            List subList = new List(true, 40);
            subList.add(new ListItem("Sub list 1"));
            subList.add(new ListItem("Sub list 2"));

            List list = new List(true, 20);
            list.add(new ListItem("Test line 1"));
            list
                    .add(new ListItem(
                            "Test line 2 - This is a really long test line to test that linebreaks are working the way they are supposed to work so a really really long line of drivel is required"));
            list.add(subList);
            list.add(new ListItem("Test line 3 - \t\u20ac\t 60,-"));
            doc.add(list);

            list = new List(false, 20);
            list.add(new ListItem("Bullet"));
            list.add(new ListItem("Another one"));
            doc.add(list);

            doc.newPage();

            Chapter chapter = new Chapter(new Paragraph("This is a Chapter"), 1);
View Full Code Here

        for(int i = 0; i < list.getItems().size(); i++) {
            try {
                LwgElement element = (LwgElement) list.getItems().get(i);
               
                if(element.type() == LwgElement.CHUNK) {
                    element = new ListItem((Chunk) element);
                }
                if(element instanceof ListItem) {
                    ll.setAlignment(((ListItem) element).getAlignment());
                }
                RtfBasicElement[] rtfElements = doc.getMapper().mapElement(element);
View Full Code Here

            // step 3: we open the document
            document.open();
           
            // step 4:
            List list = new List(true, 20);
            list.add(new ListItem("First line"));
            list.add(new ListItem("The second line is longer to see what happens once the end of the line is reached. Will it start on a new line?"));
            list.add(new ListItem("Third line"));
            document.add(list);
           
            document.add(new Paragraph("some books I really like:"));
            ListItem listItem;
            list = new List(true, 15);
            listItem = new ListItem("When Harlie was one", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12));
            listItem.add(new Chunk(" by David Gerrold", FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, LwgFont.ITALIC)));
            list.add(listItem);
            listItem = new ListItem("The World according to Garp", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12));
            listItem.add(new Chunk(" by John Irving", FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, LwgFont.ITALIC)));
            list.add(listItem);
            listItem = new ListItem("Decamerone", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12));
            listItem.add(new Chunk(" by Giovanni Boccaccio", FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, LwgFont.ITALIC)));
            list.add(listItem);
            document.add(list);
           
            Paragraph paragraph = new Paragraph("some movies I really like:");
            list = new List(false, 10);
            list.add("Wild At Heart");
            list.add("Casablanca");
            list.add("When Harry met Sally");
            list.add("True Romance");
            list.add("Le mari de la coiffeuse");
            paragraph.add(list);
            document.add(paragraph);
           
            document.add(new Paragraph("Some authors I really like:"));
            list = new List(false, 20);
            list.setListSymbol(new Chunk("\u2022", FontFactory.getFont(FontFactory.HELVETICA, 20, LwgFont.BOLD)));
            listItem = new ListItem("Isaac Asimov");
            list.add(listItem);
            List sublist;
            sublist = new List(false, true, 10);
            sublist.setListSymbol(new Chunk("", FontFactory.getFont(FontFactory.HELVETICA, 8)));
            sublist.add("The Foundation Trilogy");
            sublist.add("The Complete Robot");
            sublist.add("Caves of Steel");
            sublist.add("The Naked Sun");
            list.add(sublist);
            listItem = new ListItem("John Irving");
            list.add(listItem);
            sublist = new List(false, true, 10);
            sublist.setFirst('a');
            sublist.setListSymbol(new Chunk("", FontFactory.getFont(FontFactory.HELVETICA, 8)));
            sublist.add("The World according to Garp");
            sublist.add("Hotel New Hampshire");
            sublist.add("A prayer for Owen Meany");
            sublist.add("Widow for a year");
            list.add(sublist);
            listItem = new ListItem("Kurt Vonnegut");
            list.add(listItem);
            sublist = new List(false, true, 10);
            sublist.setListSymbol(new Chunk("", FontFactory.getFont(FontFactory.HELVETICA, 8)));
            sublist.add("Slaughterhouse 5");
            sublist.add("Welcome to the Monkey House");
View Full Code Here

                }
            }
            else if (element.type() == LwgElement.LIST) {
                com.lowagie.text.List list = (com.lowagie.text.List)element;
                ArrayList items = list.getItems();
                ListItem item = null;
                float listIndentation = list.getIndentationLeft();
                int count = 0;
                Stack stack = new Stack();
                for (int k = 0; k < items.size(); ++k) {
                    Object obj = items.get(k);
                    if (obj instanceof ListItem) {
                        if (count == listIdx) {
                            item = (ListItem)obj;
                            break;
                        }
                        else ++count;
                    }
                    else if (obj instanceof com.lowagie.text.List) {
                        stack.push(new Object[]{list, new Integer(k), new Float(listIndentation)});
                        list = (com.lowagie.text.List)obj;
                        items = list.getItems();
                        listIndentation += list.getIndentationLeft();
                        k = -1;
                        continue;
                    }
                    if (k == items.size() - 1) {
                        if (!stack.isEmpty()) {
                            Object objs[] = (Object[])stack.pop();
                            list = (com.lowagie.text.List)objs[0];
                            items = list.getItems();
                            k = ((Integer)objs[1]).intValue();
                            listIndentation = ((Float)objs[2]).floatValue();
                        }
                    }
                }
                int status = 0;
                for (int keep = 0; keep < 2; ++keep) {
                    float lastY = yLine;
                    boolean createHere = false;
                    if (compositeColumn == null) {
                        if (item == null) {
                            listIdx = 0;
                            compositeElements.removeFirst();
                            continue main_loop;
                        }
                        compositeColumn = new ColumnText(canvas);
                        compositeColumn.setUseAscender(firstPass ? useAscender : false);
                        compositeColumn.setAlignment(item.getAlignment());
                        compositeColumn.setIndent(item.getIndentationLeft() + listIndentation + item.getFirstLineIndent());
                        compositeColumn.setExtraParagraphSpace(item.getExtraParagraphSpace());
                        compositeColumn.setFollowingIndent(compositeColumn.getIndent());
                        compositeColumn.setRightIndent(item.getIndentationRight() + list.getIndentationRight());
                        compositeColumn.setLeading(item.getLeading(), item.getMultipliedLeading());
                        compositeColumn.setRunDirection(runDirection);
                        compositeColumn.setArabicOptions(arabicOptions);
                        compositeColumn.setSpaceCharRatio(spaceCharRatio);
                        compositeColumn.addText(item);
                        if (!firstPass) {
                            yLine -= item.getSpacingBefore();
                        }
                        createHere = true;
                    }
                    compositeColumn.leftX = leftX;
                    compositeColumn.rightX = rightX;
                    compositeColumn.yLine = yLine;
                    compositeColumn.rectangularWidth = rectangularWidth;
                    compositeColumn.rectangularMode = rectangularMode;
                    compositeColumn.minY = minY;
                    compositeColumn.maxY = maxY;
                    boolean keepCandidate = (item.getKeepTogether() && createHere && !firstPass);
                    status = compositeColumn.go(simulate || (keepCandidate && keep == 0));
                    updateFilledWidth(compositeColumn.filledWidth);
                    if ((status & NO_MORE_TEXT) == 0 && keepCandidate) {
                        compositeColumn = null;
                        yLine = lastY;
                        return NO_MORE_COLUMN;
                    }
                    if (simulate || !keepCandidate)
                        break;
                    if (keep == 0) {
                        compositeColumn = null;
                        yLine = lastY;
                    }
                }
                firstPass = false;
                yLine = compositeColumn.yLine;
                linesWritten += compositeColumn.linesWritten;
                descender = compositeColumn.descender;
                if (!Float.isNaN(compositeColumn.firstLineY) && !compositeColumn.firstLineYDone) {
                    if (!simulate)
                        showTextAligned(canvas, LwgElement.ALIGN_LEFT, new LwgPhrase(item.getListSymbol()), compositeColumn.leftX + listIndentation, compositeColumn.firstLineY, 0);
                    compositeColumn.firstLineYDone = true;
                }
                if ((status & NO_MORE_TEXT) != 0) {
                    compositeColumn = null;
                    ++listIdx;
                    yLine -= item.getSpacingAfter();
                }
                if ((status & NO_MORE_COLUMN) != 0)
                    return NO_MORE_COLUMN;
            }
            else if (element.type() == LwgElement.PTABLE) {
View Full Code Here

   * Creates a ListItem object based on a list of properties.
   * @param attributes
   * @return a ListItem
   */
  public static ListItem getListItem(Properties attributes) {
    ListItem item = new ListItem(getParagraph(attributes));
    return item;
  }
View Full Code Here

                    break;
                }
                case LwgElement.LISTITEM: {
                  leadingCount++;
                    // we cast the element to a ListItem
                    ListItem listItem = (ListItem) element;

                    addSpacing(listItem.getSpacingBefore(), leading, listItem.getFont());

                    // we adjust the document
                    alignment = listItem.getAlignment();
                    indentation.listIndentLeft += listItem.getIndentationLeft();
                    indentation.indentRight += listItem.getIndentationRight();
                    leading = listItem.getTotalLeading();
                    carriageReturn();

                    // we prepare the current line to be able to show us the listsymbol
                    line.setListItem(listItem);
                    // we process the item
                    element.process(this);

                    addSpacing(listItem.getSpacingAfter(), listItem.getTotalLeading(), listItem.getFont());

                    // if the last line is justified, it should be aligned to the left
                    if (line.hasToBeJustified()) {
                      line.resetAlignment();
                    }
                    // some parameters are set back to normal again
                    carriageReturn();
                    indentation.listIndentLeft -= listItem.getIndentationLeft();
                    indentation.indentRight -= listItem.getIndentationRight();
                    leadingCount--;
                    break;
                }
                case LwgElement.RECTANGLE: {
                    LwgRectangle rectangle = (LwgRectangle) element;
View Full Code Here

TOP

Related Classes of com.lowagie.text.ListItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.