Package org.jfree.layouting.renderer.model.table

Examples of org.jfree.layouting.renderer.model.table.TableRowRenderBox


      finishTable(table);
      return;
    }
    else if (box instanceof TableRowRenderBox)
    {
      final TableRowRenderBox row = (TableRowRenderBox) box;
      finishTableRow(row);
      return;
    }

    // do something ..
View Full Code Here


          continue;
        }

        expectedRows -= 1;

        final TableRowRenderBox row = (TableRowRenderBox) node;
        final TableRowInfoStructure rowInfoStructure = row.getRowInfoStructure();
        if (rowInfoStructure.isValidationDone())
        {
          // ok, we can take the shortcut ..
          final int cellCount = rowInfoStructure.getCellCount();
          for (int i = 0; i < cellCount; i++)
          {
            final TableCell cellAt = rowInfoStructure.getCellAt(i);
            expectedRows = Math.max (expectedRows, cellAt.getRowSpan() - 1);
          }
        }
        else
        {
          // the slow-lane: Look at the already declared cells ..
          RenderNode nodeCell = row.getFirstChild();
          while (nodeCell != null)
          {
            if (nodeCell instanceof TableCellRenderBox)
            {
              final TableCellRenderBox cellBox = (TableCellRenderBox) nodeCell;
View Full Code Here

        return false;
      }
    }
    else if (box instanceof TableRowRenderBox)
    {
      final TableRowRenderBox row = (TableRowRenderBox) box;
      final TableSectionRenderBox section = (TableSectionRenderBox) row.getParent();
      if (DisplayRole.TABLE_ROW_GROUP.equals(section.getDisplayRole()))
      {
        // we need to have at least one complete row of data (not counting header
        // and footer sections. The first row has no prev-element, so we simply
        // test whether there is one ..
        if (row.getVisiblePrev() == null)
        {
          layoutFailureNodeId = box.getInstanceId();
          layoutFailureResolution = BOX_MUST_BE_CLOSED;
          return false;
        }
View Full Code Here

    this.pageContext = pageContext.update(context);

    final BoxDefinition definition =
        boxDefinitionFactory.createBlockBoxDefinition
            (context, layoutProcess.getOutputMetaData());
    final TableRowRenderBox tableRenderBox = new TableRowRenderBox(definition, false);
    tableRenderBox.appyStyle(context, layoutProcess.getOutputMetaData());
    tableRenderBox.setPageContext(pageContext.getPageContext());
    getInsertationPoint().addChild(tableRenderBox);

    // tryValidateOutput();

  }
View Full Code Here

      if (rowNode.isDirty() == false)
      {
        throw new IllegalStateException("The row is not dirty?");
      }

      final TableRowRenderBox rowBox = (TableRowRenderBox) rowNode;
      final int rowNumber = rowBox.getRowInfoStructure().getRowNumber();
      final TableRow row = rows[rowNumber];
      final long validatedRowHeight = row.getValidateSize();

      if (firstRow)
      {
        firstRow = false;
      }
      else
      {
        position += rowModel.getRowSpacing();
      }

      final long oldPosition = rowBox.getY();
      final long shift = position - oldPosition;
      if (shift < 0)
      {
        throw new IllegalStateException("Shift-back is not allowed.");
      }

      shift(rowBox, shift);
      shiftDistance += shift;

      RenderNode cellNode = rowBox.getFirstChild();
      while (cellNode != null)
      {
        if (cellNode instanceof TableCellRenderBox == false)
        {
          cellNode = cellNode.getNext();
          continue;
        }

        final TableCellRenderBox cellBox = (TableCellRenderBox) cellNode;
        final long cellShift = position - cellBox.getY();
        if (cellShift != 0)
        {
          shift(cellBox, cellShift);
          // this is an inner shift and therefore it has no influence on the
          // global shiftdistance
        }

        cellBox.setHeight(validatedRowHeight);
        // Todo: now align all the childs of the cellbox.

        cellNode = cellNode.getNext();
      }

      rowBox.setHeight(validatedRowHeight);
      rowBox.setDirty(false);
      position += validatedRowHeight;
      rowNode = rowNode.getNext();
    }

    // finally shift down all the content that comes afterwards.
View Full Code Here

  {
    // check the last row for row-spanning cells ..

    // first, find the last row of the section ..
    RenderNode rowNode = section.getLastChild();
    TableRowRenderBox lastRow = null;
    while (rowNode != null)
    {
      if (rowNode instanceof TableRowRenderBox)
      {
        lastRow = (TableRowRenderBox) rowNode;
        break;
      }
      rowNode = rowNode.getVisiblePrev();
    }

    final TableRowModel rowModel = section.getRowModel();
    // There is no last row - so this sections is empty.
    while (lastRow != null)
    {

      TableRowRenderBox autoGeneratedRow = null;
      TableRowInfoStructure autoRowInfo = null;

      final TableRowInfoStructure rowInfo = lastRow.getRowInfoStructure();
      for (int i = 0; i < rowInfo.getCellCount(); i++)
      {
        // seek row-spanning cells ..
        final TableCell cell = rowInfo.getCellAt(i);
        if (cell.getRowSpan() > 1)
        {
          // that's one, for instance ...
          if (autoGeneratedRow == null)
          {
            autoGeneratedRow =
                    new TableRowRenderBox(EmptyBoxDefinition.getInstance(), true);
            rowModel.addRow(new TableRow());

            autoRowInfo = autoGeneratedRow.getRowInfoStructure();
            for (int emptyCellCnt = 0; emptyCellCnt < i; emptyCellCnt += 1)
            {
              final TableCellRenderBox autoCell =
                      new TableCellRenderBox(EmptyBoxDefinition.getInstance(), true);
              autoCell.close();
              autoCell.setColumnIndex(emptyCellCnt);
              final DataCell dataCell = new DataCell
                  (1, 1, autoCell.getInstanceId());
              autoRowInfo.addCell(dataCell);
              autoGeneratedRow.addChild(autoCell);
            }
          }

          final PlaceHolderCell placeHolder;
          if (cell instanceof DataCell)
          {
            placeHolder = new PlaceHolderCell
                    ((DataCell) cell, cell.getRowSpan() - 1, cell.getColSpan());
          }
          else if (cell instanceof PlaceHolderCell)
          {
            final PlaceHolderCell prevCell = (PlaceHolderCell) cell;
            placeHolder = new PlaceHolderCell
                    (prevCell.getSourceCell(), cell.getRowSpan() - 1, cell.getColSpan());
          }
          else
          {
            throw new IllegalStateException("Unexpected cell type.");
          }
          autoRowInfo.addCell(placeHolder);
        }
        else if (autoGeneratedRow != null)
        {
          // only add, if the auto-row-box has been already generated ..
          // this prevents the generation of totally empty rows ..
          final TableCellRenderBox autoCell =
                  new TableCellRenderBox(EmptyBoxDefinition.getInstance(), true);
          autoCell.close();
          autoCell.setColumnIndex(i);
          final DataCell dataCell = new DataCell
              (1, 1, autoCell.getInstanceId());
          autoRowInfo.addCell(dataCell);
          autoGeneratedRow.addChild(autoCell);
        }
      }

      if (autoGeneratedRow != null)
      {
        autoGeneratedRow.close();
        autoRowInfo.setValidationDone(true);
        section.addGeneratedChild(autoGeneratedRow);
      }

      // no matter what we do, this one can never generate new columns;
View Full Code Here

  private TableRowInfoStructure validateRow(final TableSectionRenderBox section,
                                            final RenderNode rowNode,
                                            final TableRowInfoStructure prevInfoStruct)
  {
    final TableRowRenderBox rowBox = (TableRowRenderBox) rowNode;
    final TableRowInfoStructure infoStruct =
            rowBox.getRowInfoStructure();

    // As we validate only closed table-rows (and as we do not allow changes once
    // the rows are closed (except for adding auto-cells, of course, which is
    // a necessary evil exception to the rule), we have to do this only once
    // per row ..
    if (infoStruct.isValidationDone())
    {
      return infoStruct;
    }

    RenderNode cellNode = rowBox.getFirstChild();
    int cellPosition = 0;

    while (cellNode != null)
    {
      if (cellNode instanceof TableCellRenderBox == false)
      {
        cellNode = cellNode.getNext();
        continue;
      }

      final TableCellRenderBox cellBox = (TableCellRenderBox) cellNode;
      // we got a cell. Now check our info-struct ..
      if (cellPosition >= prevInfoStruct.getCellCount())
      {
        cellBox.setColumnIndex(cellPosition);
        cellPosition = validateSafeCellPos(cellBox, infoStruct, cellPosition);
      }
      else
      {
        cellPosition = findCellPosition(cellPosition, prevInfoStruct, infoStruct);

        // OK, so we have the insertation point. Lets add our cell there ..
        final int colSpan = cellBox.getColSpan();
        final int rowSpan = cellBox.getRowSpan();
        final DataCell dataCell = new DataCell
            (rowSpan, colSpan, cellBox.getInstanceId());
        infoStruct.addCell(dataCell);
        cellBox.setColumnIndex(cellPosition);

        cellPosition += 1;
        for (int i = 1; i < colSpan; i++)
        {
          // if there's a previous cell at the current position - check it
          // maybe we have a conflicting instruction here

          if (cellPosition < prevInfoStruct.getCellCount())
          {
            final TableCell prevCell = prevInfoStruct.getCellAt(cellPosition);
            if (prevCell.getRowSpan() > 1)
            {
              // thats a conflict. Oh, no!
              final ConflictingCell conflictingCell =
                      new ConflictingCell(dataCell, rowSpan, colSpan - i);
              if (prevCell instanceof ConflictingCell)
              {
                // Oh, there's already a conflict? Coooool...
                // (damn, users, fix your table definitions!)
                final ConflictingCell prevConflictCell = (ConflictingCell) prevCell;
                final int count = prevConflictCell.getConflictingCellCount();
                for (int x = 0; x < count; x++)
                {
                  final PlaceHolderCell phc = prevConflictCell.getConflictingCell(x);
                  if (phc.getRowSpan() > 1)
                  {
                    final PlaceHolderCell placeHolderCell =
                            new PlaceHolderCell(phc.getSourceCell(),
                                    phc.getRowSpan() - 1,
                                    phc.getColSpan());
                    conflictingCell.addConflictingCell(placeHolderCell);
                  }
                }
              }
              else if (prevCell instanceof PlaceHolderCell)
              {
                final PlaceHolderCell prevPHCell = (PlaceHolderCell) prevCell;
                // a new conflict ...
                final PlaceHolderCell placeHolderCell =
                        new PlaceHolderCell(prevPHCell.getSourceCell(),
                                prevCell.getRowSpan() - 1,
                                prevCell.getColSpan());
                conflictingCell.addConflictingCell(placeHolderCell);
              }
              else if (prevCell instanceof DataCell)
              {
                final PlaceHolderCell placeHolderCell =
                        new PlaceHolderCell((DataCell) prevCell,
                                prevCell.getRowSpan() - 1,
                                prevCell.getColSpan());
                conflictingCell.addConflictingCell(placeHolderCell);
              }
              else
              {
                throw new IllegalStateException("Unexpected cell type.");
              }

              infoStruct.addCell(conflictingCell);
            }
            else
            {
              final PlaceHolderCell placeHolderCell =
                      new PlaceHolderCell(dataCell, rowSpan, colSpan - i);
              // a safe position. No conflicts ..
              infoStruct.addCell(placeHolderCell);
            }
          }
          else
          {
            final PlaceHolderCell placeHolderCell =
                    new PlaceHolderCell(dataCell, rowSpan, colSpan - i);
            // no cells means: no conflicts. Thats always the easiest thing
            infoStruct.addCell(placeHolderCell);
          }
          cellPosition += 1;
        }
      }

      cellNode = cellNode.getNext();
    }

    final TableRow row = new TableRow(rowBox.getBorder());
    section.getRowModel().addRow(row);

    infoStruct.setValidationDone(true);

    return infoStruct;
View Full Code Here

    b.append(box.getBoxLayoutProperties());
    logger.debug(b.toString());

    if (box instanceof TableRowRenderBox)
    {
      final TableRowRenderBox row = (TableRowRenderBox) box;
      final TableRowInfoStructure rowInfoStructure = row.getRowInfoStructure();

      for (int i = 0; i < rowInfoStructure.getCellCount(); i++)
      {
        final TableCell cell = rowInfoStructure.getCellAt(i);
        logger.debug ("CELL: " + i + " = " + cell.getRowSpan() + ' ' + cell.getColSpan() + ' ' + cell);
View Full Code Here

    this.pageContext = pageContext.update(context);

    final BoxDefinition definition =
        boxDefinitionFactory.createBlockBoxDefinition
            (context, layoutProcess.getOutputMetaData());
    final TableRowRenderBox tableRenderBox = new TableRowRenderBox(definition, false);
    tableRenderBox.appyStyle(context, layoutProcess.getOutputMetaData());
    tableRenderBox.setPageContext(pageContext.getPageContext());
    getInsertationPoint().addChild(tableRenderBox);

    // tryValidateOutput();

  }
View Full Code Here

    b.append(box.getBoxLayoutProperties());
    Log.debug(b.toString());

    if (box instanceof TableRowRenderBox)
    {
      final TableRowRenderBox row = (TableRowRenderBox) box;
      final TableRowInfoStructure rowInfoStructure = row.getRowInfoStructure();

      for (int i = 0; i < rowInfoStructure.getCellCount(); i++)
      {
        final TableCell cell = rowInfoStructure.getCellAt(i);
        Log.debug ("CELL: " + i + " = " + cell.getRowSpan() + ' ' + cell.getColSpan() + ' ' + cell);
View Full Code Here

TOP

Related Classes of org.jfree.layouting.renderer.model.table.TableRowRenderBox

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.