示例#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);
  }