Package com.lowagie.text

Examples of com.lowagie.text.Cell


      //table.setBorderColor(new Color(0, 0, 255));
      table.setPadding(4);
      table.setSpacing(0);

      // first cell has to be void
      table.addCell(new Cell("Options/\r\nWedges"),0,0);

      int row = 1;
      while (iActors.hasNext()){
    Cell app = new Cell(iActors.next().getTitle());
    //app.setNoWrap(true);
    app.setHorizontalAlignment(Element.ALIGN_CENTER);
    app.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(app,row++,0);
      }

      row = 1;
      int column = 1;

      while (iOptions.hasNext()){
    // working with a single option
    OptionData o = iOptions.next();

    String optionName = o.getTitle();
    if ((optionName==null)||(optionName.length()==0)) optionName = "No (Option) name provided.";
    //Paragraph optionNamePar = new Paragraph(optionName, fntRomanOptionTitle);
    Paragraph optionNamePar = new Paragraph(optionName, fntRomanOptionTitle);
    ListItem item = new ListItem(optionNamePar);

    String optionDescription = o.getDescription();
    if ((optionDescription!=null)&&(optionDescription.length()!=0)) {
        //Paragraph optionDescriptionPar = new Paragraph("\r\n" + optionDescription, fntRomanOptionDescription);
        Paragraph optionDescriptionPar = new Paragraph("\r\n" + optionDescription, fntRomanOptionDescription);
        optionDescriptionPar.setSpacingAfter(12);
        //optionDescriptionPar.setSpacingBefore(0);
        item.add(optionDescriptionPar);
    }

    itemize.add(item);

    // prepare the table
    iActors = data.getColumns().iterator();
    row = 0;
    //System.out.println("option: " + o.getTitle());
    Cell optionNameHeader = new Cell(o.getTitle());
    //optionNameHeader.rotate();
    optionNameHeader.setHeader(true);
    //cell.setColspan(3);
    table.addCell(optionNameHeader,row++,column);
    table.endHeaders();
    //table.addCell(new Cell(o.getTitle()),row++,column);
    while ((iActors.hasNext())) {
        ColumnData cd = iActors.next();
        WedgeData wd = cd.getWedge(o);
        Cell c;
        if(wd == null) {
      //c = new Cell("-");
      c = new Cell();
        } else {
      double coeff = wd.getCoefficient();
      c = new Cell(new Phrase(Double.toString(coeff),fntRomanTableAllFields));
        }
        c.setHorizontalAlignment(Element.ALIGN_CENTER);
        c.setVerticalAlignment(Element.ALIGN_CENTER);
        /*
        System.out.println("table: " + table.columns());
        System.out.println("x,y: " + row + " " + column);
        System.out.println("cell: " + c);
         */
        table.addCell(c,row++,column);
    }
    column++;

      }
      // areaSec.add(itemize);
      doc.add(itemize);

      // postprocess on table: to remove at next release...

      Iterator iRow = table.iterator();
      while (iRow.hasNext()) {
    Row r = (Row)iRow.next();
    Cell c = (Cell)r.getCell(1);
    if (c.isEmpty()) iRow.remove();
      }

      // deny row split
      table.setCellsFitPage(true);
      doc.add(table);
View Full Code Here


   * Creates a Cell object based on a list of properties.
   * @param attributes
   * @return a Cell
   */
  public static Cell getCell(Properties attributes) {
    Cell cell = new Cell();
    String value;

    cell.setHorizontalAlignment(attributes
        .getProperty(ElementTags.HORIZONTALALIGN));
    cell.setVerticalAlignment(attributes
        .getProperty(ElementTags.VERTICALALIGN));

    value = attributes.getProperty(ElementTags.WIDTH);
    if (value != null) {
      cell.setWidth(value);
    }
    value = attributes.getProperty(ElementTags.COLSPAN);
    if (value != null) {
      cell.setColspan(Integer.parseInt(value));
    }
    value = attributes.getProperty(ElementTags.ROWSPAN);
    if (value != null) {
      cell.setRowspan(Integer.parseInt(value));
    }
    value = attributes.getProperty(ElementTags.LEADING);
    if (value != null) {
      cell.setLeading(Float.parseFloat(value + "f"));
    }
    cell.setHeader(Utilities.checkTrueOrFalse(attributes,
        ElementTags.HEADER));
    if (Utilities.checkTrueOrFalse(attributes, ElementTags.NOWRAP)) {
      cell.setMaxLines(1);
    }
    setRectangleProperties(cell, attributes);
    return cell;
  }
View Full Code Here

        int cellWidth = 0;
        for(int i = 0; i < row.getColumns(); i++) {
            cellWidth = (int) (this.width * this.parentTable.getProportionalWidths()[i] / 100);
            cellRight = cellRight + cellWidth;
           
            Cell cell = (Cell) row.getCell(i);
            RtfCell rtfCell = new RtfCell(this.document, this, cell);
            rtfCell.setCellRight(cellRight);
            rtfCell.setCellWidth(cellWidth);
            this.cells.add(rtfCell);
        }
View Full Code Here

    int prevRows = rows();
    int rowNumber = 0;
    int groupNumber = 0;
    boolean groupChange;
    int firstDataRow = table.getLastHeaderRow() + 1;
    Cell cell;
    PdfCell currentCell;
    ArrayList newCells = new ArrayList();
    int rows = table.size() + 1;
    float[] offsets = new float[rows];
    for (int i = 0; i < rows; i++) {
      offsets[i] = getBottom();
    }
       
    // loop over all the rows
    for (Iterator rowIterator = table.iterator(); rowIterator.hasNext(); ) {
      groupChange = false;
      row = (Row) rowIterator.next();
      if (row.isEmpty()) {
        if (rowNumber < rows - 1 && offsets[rowNumber + 1] > offsets[rowNumber]) offsets[rowNumber + 1] = offsets[rowNumber];
      }
      else {
        for(int i = 0; i < row.getColumns(); i++) {
          cell = (Cell) row.getCell(i);
          if (cell != null) {
            currentCell = new PdfCell(cell, rowNumber+prevRows, positions[i], positions[i + cell.getColspan()], offsets[rowNumber], cellspacing(), cellpadding());
            if (rowNumber < firstDataRow) {
              currentCell.setHeader();
              headercells.add(currentCell);
              if (!table.isNotAddedYet())
                continue;
            }
            try {
              if (offsets[rowNumber] - currentCell.getHeight() - cellpadding() < offsets[rowNumber + currentCell.rowspan()]) {
                offsets[rowNumber + currentCell.rowspan()] = offsets[rowNumber] - currentCell.getHeight() - cellpadding();
              }
            }
            catch(ArrayIndexOutOfBoundsException aioobe) {
              if (offsets[rowNumber] - currentCell.getHeight() < offsets[rows - 1]) {
                offsets[rows - 1] = offsets[rowNumber] - currentCell.getHeight();
              }
            }
            currentCell.setGroupNumber(groupNumber);
            groupChange |= cell.getGroupChange();
            newCells.add(currentCell);
          }
        }
      }
      rowNumber++;
View Full Code Here

            // rows
            if (ElementTags.ROW.equals(name)) {
                ArrayList cells = new ArrayList();
                int columns = 0;
                Table table;
                Cell cell;
                while (true) {
                    Element element = (Element) stack.pop();
                    if (element.type() == Element.CELL) {
                        cell = (Cell) element;
                        columns += cell.getColspan();
                        cells.add(cell);
                    } else {
                        table = (Table) element;
                        break;
                    }
                }
                if (table.getColumns() < columns) {
                    table.addColumns(columns - table.getColumns());
                }
                Collections.reverse(cells);
                String width;
                float[] cellWidths = new float[columns];
                boolean[] cellNulls = new boolean[columns];
                for (int i = 0; i < columns; i++) {
                    cellWidths[i] = 0;
                    cellNulls[i] = true;
                }
                float total = 0;
                int j = 0;
                for (Iterator i = cells.iterator(); i.hasNext();) {
                    cell = (Cell) i.next();
                    width = cell.getWidthAsString();
                    if (cell.getWidth() == 0) {
                        if (cell.getColspan() == 1 && cellWidths[j] == 0) {
                            try {
                                cellWidths[j] = 100f / columns;
                                total += cellWidths[j];
                            } catch (Exception e) {
                                // empty on purpose
                            }
                        } else if (cell.getColspan() == 1) {
                            cellNulls[j] = false;
                        }
                    } else if (cell.getColspan() == 1 && width.endsWith("%")) {
                        try {
                            cellWidths[j] = Float.parseFloat(
                                    width.substring(0, width.length() - 1)
                                            + "f");
                            total += cellWidths[j];
                        } catch (Exception e) {
                            // empty on purpose
                        }
                    }
                    j += cell.getColspan();
                    table.addCell(cell);
                }
                float widths[] = table.getProportionalWidths();
                if (widths.length == columns) {
                    float left = 0.0f;
View Full Code Here

   * Creates a Cell object based on a list of properties.
   * @param attributes
   * @return a Cell
   */
  public static Cell getCell(Properties attributes) {
    Cell cell = new Cell();
    String value;

    cell.setHorizontalAlignment(attributes.getProperty(ElementTags.HORIZONTALALIGN));
    cell.setVerticalAlignment(attributes.getProperty(ElementTags.VERTICALALIGN));
   
    value = attributes.getProperty(ElementTags.WIDTH);
    if (value != null) {
      cell.setWidth(value);
    }
    value = attributes.getProperty(ElementTags.COLSPAN);
    if (value != null) {
      cell.setColspan(Integer.parseInt(value));
    }
    value = attributes.getProperty(ElementTags.ROWSPAN);
    if (value != null) {
      cell.setRowspan(Integer.parseInt(value));
    }
    value = attributes.getProperty(ElementTags.LEADING);
    if (value != null) {
      cell.setLeading(Float.parseFloat(value + "f"));
    }
    cell.setHeader(Utilities.checkTrueOrFalse(attributes, ElementTags.HEADER));
    if (Utilities.checkTrueOrFalse(attributes, ElementTags.NOWRAP)) {
      cell.setMaxLines(1);
    }
    setRectangleProperties(cell, attributes);
    return cell;
  }
View Full Code Here

        int cellWidth = 0;
        for(int i = 0; i < row.getColumns(); i++) {
            cellWidth = (int) (this.width * this.parentTable.getProportionalWidths()[i] / 100);
            cellRight = cellRight + cellWidth;
           
            Cell cell = (Cell) row.getCell(i);
            RtfCell rtfCell = new RtfCell(this.document, this, cell);
            rtfCell.setCellRight(cellRight);
            rtfCell.setCellWidth(cellWidth);
            this.cells.add(rtfCell);
        }
View Full Code Here

        // the upper left corner in such an col, row matrix is copied as first cell
        // in each row in this matrix
        int columns = row.getColumns();
        for (int i = 0; i < columns; i++) {
            RtfCell firstCell = (RtfCell) cells.get(i);
            Cell cell = firstCell.getStore();
            int cols = 0;
            if(cell != null) {
                cols = cell.getColspan();
            }
            if (cols > 1) {
                RtfCell lastCell = (RtfCell) cells.get(i + cols - 1);
                firstCell.setCellRight(lastCell.getCellRight());
                int width = firstCell.getCellWidth();
View Full Code Here

                currentfont.pop();
                return;
            }
            case Element.CELL:
            {
                Cell cell = (Cell) element;
               
                // start tag
                addTabs(indent);
                if (cell.isHeader()) {
                    writeStart(HtmlTags.HEADERCELL);
                }
                else {
                    writeStart(HtmlTags.CELL);
                }
                writeMarkupAttributes(markup);
                if (cell.getBorderWidth() != Rectangle.UNDEFINED) {
                    write(HtmlTags.BORDERWIDTH, String.valueOf(cell.getBorderWidth()));
                }
                if (cell.getBorderColor() != null) {
                    write(HtmlTags.BORDERCOLOR, HtmlEncoder.encode(cell.getBorderColor()));
                }
                if (cell.getBackgroundColor() != null) {
                    write(HtmlTags.BACKGROUNDCOLOR, HtmlEncoder.encode(cell.getBackgroundColor()));
                }
                String alignment = HtmlEncoder.getAlignment(cell.getHorizontalAlignment());
                if (!"".equals(alignment)) {
                    write(HtmlTags.HORIZONTALALIGN, alignment);
                }
                alignment = HtmlEncoder.getAlignment(cell.getVerticalAlignment());
                if (!"".equals(alignment)) {
                    write(HtmlTags.VERTICALALIGN, alignment);
                }
                if (cell.getWidthAsString() != null) {
                    write(HtmlTags.WIDTH, cell.getWidthAsString());
                }
                if (cell.getColspan() != 1) {
                    write(HtmlTags.COLSPAN, String.valueOf(cell.getColspan()));
                }
                if (cell.getRowspan() != 1) {
                    write(HtmlTags.ROWSPAN, String.valueOf(cell.getRowspan()));
                }
                if (cell.getMaxLines() == 1) {
                    write(HtmlTags.NOWRAP, String.valueOf(true));
                }
                os.write(GT);
                // contents
                if (cell.isEmpty()) {
                    write(NBSP);
                } else {
                    for (Iterator i = cell.getElements(); i.hasNext(); ) {
                        write((Element) i.next(), indent + 1);
                    }
                }
                // end tag
                addTabs(indent);
                if (cell.isHeader()) {
                    writeEnd(HtmlTags.HEADERCELL);
                }
                else {
                    writeEnd(HtmlTags.CELL);
                }
View Full Code Here

    int prevRows = rows();
    int rowNumber = 0;
    int groupNumber = 0;
    boolean groupChange;
    int firstDataRow = table.getLastHeaderRow() + 1;
    Cell cell;
    PdfCell currentCell;
    ArrayList newCells = new ArrayList();
    int rows = table.size() + 1;
    float[] offsets = new float[rows];
    for (int i = 0; i < rows; i++) {
      offsets[i] = getBottom();
    }
       
    // loop over all the rows
    for (Iterator rowIterator = table.iterator(); rowIterator.hasNext(); ) {
      groupChange = false;
      row = (Row) rowIterator.next();
      if (row.isEmpty()) {
        if (rowNumber < rows - 1 && offsets[rowNumber + 1] > offsets[rowNumber]) offsets[rowNumber + 1] = offsets[rowNumber];
      }
      else {
        for(int i = 0; i < row.getColumns(); i++) {
          cell = (Cell) row.getCell(i);
          if (cell != null) {
            currentCell = new PdfCell(cell, rowNumber+prevRows, positions[i], positions[i + cell.getColspan()], offsets[rowNumber], cellspacing(), cellpadding());
            try {
                     if (offsets[rowNumber] - currentCell.getHeight() - cellpadding() < offsets[rowNumber + currentCell.rowspan()]) {
                        offsets[rowNumber + currentCell.rowspan()] = offsets[rowNumber] - currentCell.getHeight() - cellpadding();
              }
            }
            catch(ArrayIndexOutOfBoundsException aioobe) {
              if (offsets[rowNumber] - currentCell.getHeight() < offsets[rows - 1]) {
                offsets[rows - 1] = offsets[rowNumber] - currentCell.getHeight();
              }
            }
            if (rowNumber < firstDataRow) {
              currentCell.setHeader();
              headercells.add(currentCell);
            }
            currentCell.setGroupNumber(groupNumber);
            groupChange |= cell.getGroupChange();
            newCells.add(currentCell);
          }
        }
      }
      rowNumber++;
View Full Code Here

TOP

Related Classes of com.lowagie.text.Cell

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.