Exemple #1
0
  /**
   * To put a table within the existing table at the given position generateTable will of course
   * re-arrange the widths of the columns.
   *
   * @param aTable the table you want to insert
   * @param aLocation a <CODE>Point</CODE>
   */
  public void insertTable(Table aTable, Point aLocation) {

    if (aTable == null)
      throw new NullPointerException(
          MessageLocalization.getComposedMessage("inserttable.table.has.null.value"));
    if (aLocation == null)
      throw new NullPointerException(
          MessageLocalization.getComposedMessage("inserttable.point.has.null.value"));
    mTableInserted = true;
    aTable.complete();

    if (aLocation.y > columns) {
      throw new IllegalArgumentException(
          MessageLocalization.getComposedMessage(
              "inserttable.wrong.columnposition.1.of.location.max.eq.2",
              String.valueOf(aLocation.y),
              String.valueOf(columns)));
    }

    int rowCount = aLocation.x + 1 - rows.size();
    int i = 0;
    if (rowCount > 0) { // create new rows ?
      for (; i < rowCount; i++) {
        rows.add(new Row(columns));
      }
    }

    ((Row) rows.get(aLocation.x)).setElement(aTable, aLocation.y);

    setCurrentLocationToNextValidPosition(aLocation);
  }
Exemple #2
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);
  }