Beispiel #1
0
  /**
   * Adds a <CODE>Cell</CODE> to the <CODE>Table</CODE> at a certain location.
   *
   * @param aCell The <CODE>Cell</CODE> to add
   * @param aLocation The location where the <CODE>Cell</CODE> will be added
   * @throws BadElementException
   */
  public void addCell(Cell aCell, Point aLocation) throws BadElementException {
    if (aCell == null)
      throw new NullPointerException(
          MessageLocalization.getComposedMessage("addcell.cell.has.null.value"));
    if (aLocation == null)
      throw new NullPointerException(
          MessageLocalization.getComposedMessage("addcell.point.has.null.value"));
    if (aCell.isTable()) insertTable((Table) aCell.getElements().next(), aLocation);

    if (aLocation.x < 0)
      throw new BadElementException(
          MessageLocalization.getComposedMessage("row.coordinate.of.location.must.be.gt.eq.0"));
    if ((aLocation.y <= 0) && (aLocation.y > columns))
      throw new BadElementException(
          MessageLocalization.getComposedMessage(
              "column.coordinate.of.location.must.be.gt.eq.0.and.lt.nr.of.columns"));
    if (!isValidLocation(aCell, aLocation))
      throw new BadElementException(
          MessageLocalization.getComposedMessage(
              "adding.a.cell.at.the.location.1.2.with.a.colspan.of.3.and.a.rowspan.of.4.is.illegal.beyond.boundaries.overlapping",
              String.valueOf(aLocation.x),
              String.valueOf(aLocation.y),
              String.valueOf(aCell.getColspan()),
              String.valueOf(aCell.getRowspan())));

    if (aCell.getBorder() == UNDEFINED) aCell.setBorder(defaultCell.getBorder());
    aCell.fill();
    placeCell(rows, aCell, aLocation);
    setCurrentLocationToNextValidPosition(aLocation);
  }
Beispiel #2
0
 /**
  * Adds a <CODE>Cell</CODE> to the <CODE>Table</CODE>.
  *
  * <p>This is a shortcut for <CODE>addCell(Cell cell, Point location)</CODE>. The <CODE>Phrase
  * </CODE> will be converted to a <CODE>Cell</CODE>.
  *
  * @param content a <CODE>Phrase</CODE>
  * @param location a <CODE>Point</CODE>
  * @throws BadElementException this should never happen
  */
 public void addCell(Phrase content, Point location) throws BadElementException {
   Cell cell = new Cell(content);
   cell.setBorder(defaultCell.getBorder());
   cell.setBorderWidth(defaultCell.getBorderWidth());
   cell.setBorderColor(defaultCell.getBorderColor());
   cell.setBackgroundColor(defaultCell.getBackgroundColor());
   cell.setHorizontalAlignment(defaultCell.getHorizontalAlignment());
   cell.setVerticalAlignment(defaultCell.getVerticalAlignment());
   cell.setColspan(defaultCell.getColspan());
   cell.setRowspan(defaultCell.getRowspan());
   addCell(cell, location);
 }
Beispiel #3
0
  /**
   * Sets the unset cell properties to be the table defaults.
   *
   * @param aCell The cell to set to table defaults as necessary.
   */
  private void assumeTableDefaults(Cell aCell) {

    if (aCell.getBorder() == Rectangle.UNDEFINED) {
      aCell.setBorder(defaultCell.getBorder());
    }
    if (aCell.getBorderWidth() == Rectangle.UNDEFINED) {
      aCell.setBorderWidth(defaultCell.getBorderWidth());
    }
    if (aCell.getBorderColor() == null) {
      aCell.setBorderColor(defaultCell.getBorderColor());
    }
    if (aCell.getBackgroundColor() == null) {
      aCell.setBackgroundColor(defaultCell.getBackgroundColor());
    }
    if (aCell.getHorizontalAlignment() == Element.ALIGN_UNDEFINED) {
      aCell.setHorizontalAlignment(defaultCell.getHorizontalAlignment());
    }
    if (aCell.getVerticalAlignment() == Element.ALIGN_UNDEFINED) {
      aCell.setVerticalAlignment(defaultCell.getVerticalAlignment());
    }
  }