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

Examples of org.jfree.layouting.renderer.model.table.cols.TableColumnModel


    // In a perfect world, we would start to take pagebreaks into account
    // and would try to distribute the table columns in a way, so that they
    // do not cross inner page boundaries.

    // But for the first release, our world is not perfect!
    final TableColumnModel model = tableBox.getColumnModel();
    long position = 0;
    final int columnCount = model.getColumnCount();
    for (int i = 0; i < columnCount; i++)
    {
      final TableColumn column = model.getColumn(i);
      column.setEffectiveCellPosition(position);
      position += column.getEffectiveSize() + model.getBorderSpacing();
    }
  }
View Full Code Here


  private void computeCellArea(final TableCellRenderBox cellRenderBox)
  {
    // This is slightly different for table cells ...
    final int columnIndex = cellRenderBox.getColumnIndex();
    final TableRenderBox table = cellRenderBox.getTable();
    final TableColumnModel columnModel = table.getColumnModel();
    final TableColumn column = columnModel.getColumn(columnIndex);
    long effectiveSize = column.getEffectiveSize();

    final int colSpan = cellRenderBox.getColSpan();
    if (colSpan > 1)
    {
      for (int i = 1; i < colSpan; i++)
      {
        final TableColumn spannedColumn = columnModel.getColumn(columnIndex + i);
        effectiveSize += spannedColumn.getEffectiveSize();
        effectiveSize += columnModel.getBorderSpacing();
      }
    }

    final long effectiveCellPosition = column.getEffectiveCellPosition();
    cellRenderBox.setX(effectiveCellPosition);
View Full Code Here

  }

  private void finishTableRow(final TableRowRenderBox box)
  {
    final TableRenderBox table = currentTable.getTable();
    final TableColumnModel columnModel = table.getColumnModel();

    final TableSectionRenderBox section = (TableSectionRenderBox) box.getParent();
    final TableRowModel rowModel = section.getRowModel();

    final TableRowInfoStructure rowInfoStructure = box.getRowInfoStructure();
    final int rowNumber = currentTable.getRowNumber();
    rowInfoStructure.setRowNumber(rowNumber);
    final TableRow row = rowModel.getRow(rowNumber);

    final BoxDefinition boxDefinition = box.getBoxDefinition();
    final RenderLength preferredHeight = boxDefinition.getPreferredHeight();
    final ComputedLayoutProperties rowNlp = box.getComputedLayoutProperties();
    final RenderLength rowComputedWidth = rowNlp.getComputedWidth();
    row.clearSizes();
    row.setPreferredSize(preferredHeight.resolve(rowComputedWidth.resolve(0)));

    final int cellCount = rowInfoStructure.getCellCount();
    for (int i = 0; i < cellCount; i++)
    {
      final TableCell cellAt = rowInfoStructure.getCellAt(i);
      if (cellAt instanceof DataCell == false)
      {
        continue;
      }

      // We dont handle spanned cells here; thats done indirectly by the
      // column model itself.
      final DataCell dataCell = (DataCell) cellAt;

      final RenderNode cell = findCellInRow(box, dataCell.getCellRenderBox());
      if (cell == null)
      {
        throw new IllegalStateException
            ("No such cell: " + dataCell.getCellRenderBox());
      }
      final TableColumn column = columnModel.getColumn(i);
      final int colSpan = dataCell.getColSpan();

      column.updateMinimumChunkSize(colSpan, cell.getMinimumChunkWidth());
      column.updateMaxBoxSize(colSpan, cell.getMaximumBoxWidth());
View Full Code Here

    {
      // the predefined columns must be validated first ...
      return;
    }

    final TableColumnModel columnModel = currentTable.getColumnModel();
    // ok, the real work starts here. Forward-Traverse the table by its table-
    // sections.
    RenderNode node = table.getFirstChild();
    while (node != null)
    {
      if (node instanceof TableSectionRenderBox == false)
      {
        node = node.getNext();
        continue;
      }
      // OK; nice we are done. All other column definitions will be ignored
      final TableSectionRenderBox section = (TableSectionRenderBox) node;

      if (section.isStructureValidated() == false)
      {
        // we start with an empty prev-struct; that signals that there are no
        // spanned cells in a first row.
        TableRowInfoStructure prevInfoStruct =
                new TableRowInfoStructure();
        RenderNode rowNode = section.getFirstChild();
        while (rowNode != null)
        {
          if (rowNode.isOpen())
          {
            throw new IllegalStateException
                    ("An open row cannot be part of a layoutable model.");
          }

          // OK, we got a non open row. Now we traverse through the table from
          // top to bottom building the validated row model.
          if (rowNode instanceof TableRowRenderBox == false)
          {
            rowNode = rowNode.getNext();
            continue;
          }

          final TableRowInfoStructure infoStruct =
                  validateRow(section, rowNode, prevInfoStruct);
          final int cellCount = infoStruct.getCellCount();
          if (currentTable.getColumns() < cellCount)
          {
            currentTable.setColumns(cellCount);
          }
          // And finally ... add the new columns to the model ..
          while (cellCount > columnModel.getColumnCount())
          {
            columnModel.addAutoColumn();
          }

          rowNode = rowNode.getNext();
          prevInfoStruct = infoStruct;
        }
View Full Code Here

    {
      // all work as been done already ...
      return;
    }

    final TableColumnModel columnModel = table.getColumnModel();

    int colCount = 0;
    RenderNode node = table.getFirstChild();
    while (node != null)
    {
      if (node instanceof TableColumnNode)
      {
        final TableColumnNode columnNode = (TableColumnNode) node;
        if (colCount >= columnModel.getColumnCount())
        {
          // No column exists at that position ..
          final BoxDefinition boxDefinition = columnNode.getBoxDefinition();
          final Border border = boxDefinition.getBorder();
          final RenderLength width = boxDefinition.getPreferredWidth();
          final TableColumn column = new TableColumn(border, width, false);
          final TableColumnGroup group = new TableColumnGroup();
          group.addColumn(column);
          columnModel.addColumnGroup(group);
          colCount += 1;
        }
        else
        {
          // We do not change existing columns. That validation should be the
          // first that checks column definitions, so that state should always
          // be correct.
        }
      }
      else if (node instanceof TableColumnGroupNode)
      {
        final TableColumnGroupNode groupNode = (TableColumnGroupNode) node;

        final boolean newGroupGenerated;
        final TableColumnGroup group;
        if (colCount >= columnModel.getColumnCount())
        {
          group = new TableColumnGroup(groupNode.getBorder());
          newGroupGenerated = true;
        }
        else
        {
          group = columnModel.getGroupForIndex(colCount);
          newGroupGenerated = false;
        }

        RenderNode groupColNode = groupNode.getFirstChild();
        while (groupColNode != null)
        {
          if (groupColNode instanceof TableColumnNode)
          {
            final TableColumnNode columnNode = (TableColumnNode) groupColNode;
            if (colCount >= columnModel.getColumnCount())
            {
              final BoxDefinition boxDefinition = columnNode.getBoxDefinition();
              final Border border = boxDefinition.getBorder();
              final RenderLength width = boxDefinition.getPreferredWidth();
              final TableColumn column = new TableColumn(border, width, false);
              group.addColumn(column);
            }
            else
            {
              colCount += 1;
            }
          }
          else
          {
            // ignore silently ..
          }
          groupColNode = groupColNode.getNext();
        }

        if (newGroupGenerated)
        {
          columnModel.addColumnGroup(group);
          colCount += group.getColumnCount();
        }

      }
      else if (node instanceof TableSectionRenderBox)
View Full Code Here

      }
    }
    else if (box instanceof TableRenderBox)
    {
      final TableRenderBox table = (TableRenderBox) box;
      final TableColumnModel columnModel = table.getColumnModel();
      for (int i = 0; i < columnModel.getColumnCount(); i++)
      {
        final TableColumn col = columnModel.getColumn(i);
        logger.debug ("COLUMN: EffectiveSize: " + col.getEffectiveSize() " Computed Max Width: " + col.getComputedMaximumWidth() + " Computed ChunkSize: " + col.getComputedMinChunkSize());
//        for (int cs = 1; cs < 3; cs++)
//        {
//          Log.debug ("* COLUMN: " + i + "(" + cs + ") " +
//                  col.getPreferredSize(cs) + " " +
View Full Code Here

      if (preferredWidth == RenderLength.AUTO)
      {
        // The cell itself did not define anything. But maybe the column
        // had a definition?
        final TableCellRenderBox cellBox = (TableCellRenderBox) box;
        final TableColumnModel columnModel = cellBox.getTable().getColumnModel();
        final int colIdx = cellBox.getColumnIndex();
        if (colIdx < 0)
        {
          throw new IllegalStateException("Table has not been validated yet.");
        }

        final int maxIdx = colIdx + cellBox.getColSpan();
        if (maxIdx >= columnModel.getColumnCount())
        {
          // No definition. Therefore the cell will not have a computed width.
          // (The effective width will be auto-computed in later steps.)
          // Yeah, we *could* start guessing, but I dont support our user's
          // lazyness. Shall they suffer from their own mis-definitions.
          clp.setBlockContextWidth(bcw);
          clp.setComputedWidth(RenderLength.AUTO);
          box.setComputedLayoutProperties(clp);
        }
        else
        {
          long width = 0;
          for (int i = colIdx; i < maxIdx; i++)
          {
            // Check, whether one of the columns will have an autoWidth --
            final TableColumn column = columnModel.getColumn(i);
            final RenderLength definedWidth = column.getDefinedWidth();
            if (definedWidth == RenderLength.AUTO)
            {
              // No go.
              width = -1;
View Full Code Here

    xmlWriter.writeTag(Namespaces.XHTML_NAMESPACE,
        "table", attList, XmlWriter.OPEN);

    xmlWriter.writeTag(Namespaces.XHTML_NAMESPACE, "colgroup", XmlWriter.OPEN);

    final TableColumnModel columnModel = box.getColumnModel();
    final int columnCount = columnModel.getColumnCount();
    for (int i = 0; i < columnCount; i++)
    {
      final TableColumn column = columnModel.getColumn(i);
      final long effectiveSize = column.getEffectiveSize();
      final StyleBuilder colbuilder = new StyleBuilder(true);
      colbuilder.append(BoxStyleKeys.WIDTH, toPointString(effectiveSize), "pt");
      xmlWriter.writeTag(Namespaces.XHTML_NAMESPACE,
          "col", "style", colbuilder.toString(), XmlWriter.CLOSE);
View Full Code Here

    xmlWriter.writeTag(Namespaces.XHTML_NAMESPACE,
        "table", attList, XmlWriter.OPEN);

    xmlWriter.writeTag(Namespaces.XHTML_NAMESPACE, "colgroup", XmlWriter.OPEN);

    final TableColumnModel columnModel = box.getColumnModel();
    final int columnCount = columnModel.getColumnCount();
    for (int i = 0; i < columnCount; i++)
    {
      final TableColumn column = columnModel.getColumn(i);
      final long effectiveSize = column.getEffectiveSize();
      final StyleBuilder colbuilder = new StyleBuilder(true);
      colbuilder.append(BoxStyleKeys.WIDTH, toPointString(effectiveSize), "pt");
      xmlWriter.writeTag(Namespaces.XHTML_NAMESPACE,
          "col", "style", colbuilder.toString(), XmlWriter.CLOSE);
View Full Code Here

      }
    }
    else if (box instanceof TableRenderBox)
    {
      final TableRenderBox table = (TableRenderBox) box;
      final TableColumnModel columnModel = table.getColumnModel();
      for (int i = 0; i < columnModel.getColumnCount(); i++)
      {
        final TableColumn col = columnModel.getColumn(i);
        Log.debug ("COLUMN: EffectiveSize: " + col.getEffectiveSize() " Computed Max Width: " + col.getComputedMaximumWidth() + " Computed ChunkSize: " + col.getComputedMinChunkSize());
//        for (int cs = 1; cs < 3; cs++)
//        {
//          Log.debug ("* COLUMN: " + i + "(" + cs + ") " +
//                  col.getPreferredSize(cs) + " " +
View Full Code Here

TOP

Related Classes of org.jfree.layouting.renderer.model.table.cols.TableColumnModel

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.