Package org.jfree.layouting.renderer.model

Examples of org.jfree.layouting.renderer.model.RenderNode


        blp.getMarginLeft() + blp.getMarginRight();

    long minChunkWidth = 0;
    long maxBoxWidth = 0;

    RenderNode node = box.getVisibleFirst();
    while (node != null)
    {
      maxBoxWidth += node.getMaximumBoxWidth();

      final long childChunkWidth = node.getMinimumChunkWidth();
      if (childChunkWidth > minChunkWidth)
      {
        minChunkWidth = childChunkWidth;
      }
      node = node.getVisibleNext();
    }

    box.setMinimumChunkWidth(hbp + minChunkWidth);
    box.setMaximumBoxWidth(hbp + maxBoxWidth);
    box.setIcmMetricsFinished(box.isOpen() == false);
View Full Code Here


    if (box instanceof ParagraphRenderBox)
    {
      // No margins, no additional checks. And we can be sure that this one
      // is the only child. (This is a cheap shortcut).
      final ParagraphRenderBox paragraph = (ParagraphRenderBox) box;
      final RenderNode linebox = paragraph.getLineboxContainer();
      box.setMinimumChunkWidth(hbp + linebox.getMinimumChunkWidth());
      box.setMaximumBoxWidth(hbp + linebox.getMaximumBoxWidth());
      box.setIcmMetricsFinished(box.isOpen() == false);
      return;
    }

    long minChunkWidth = 0;
    long maxBoxWidth = 0;

    RenderNode node = box.getVisibleFirst();
    while (node != null)
    {
      final long childChunkWidth = node.getMinimumChunkWidth();
      if (childChunkWidth > minChunkWidth)
      {
        minChunkWidth = childChunkWidth;
      }

      final long childBoxWidth = node.getMaximumBoxWidth();
      if (childBoxWidth > maxBoxWidth)
      {
        maxBoxWidth = childBoxWidth;
      }

      node = node.getVisibleNext();
    }

    box.setMinimumChunkWidth(hbp + minChunkWidth);
    box.setMaximumBoxWidth(hbp + maxBoxWidth);
    box.setIcmMetricsFinished(box.isOpen() == false);
View Full Code Here

    }


    final boolean infiniteMarginTop;
    final RenderBox boxParent = box.getParent();
    final RenderNode visiblePrev = box.getVisiblePrev();
    if (boxParent == null)
    {
      infiniteMarginTop = (visiblePrev == null);
    }
    else
    {
      final ComputedLayoutProperties sBlp = boxParent.getComputedLayoutProperties();
      final BoxLayoutProperties pBlp = boxParent.getBoxLayoutProperties();
      infiniteMarginTop =
          (pBlp.isInfiniteMarginTop() && visiblePrev == null &&
          sBlp.getBorderTop() == 0 && sBlp.getPaddingTop() != 0);
    }

    marginCollection.clear();

    // Collect all elements that will contribute to the margins.
    RenderBox marginBox = box;
    for (;;)
    {
      marginCollection.add(marginBox);

      final ComputedLayoutProperties cblp = marginBox.getComputedLayoutProperties();
      if (cblp.getBorderBottom() != 0)
      {
        break;
      }
      if (cblp.getPaddingBottom() != 0)
      {
        break;
      }

      final RenderNode node = marginBox.getVisibleFirst();
      if (node instanceof RenderBox == false)
      {
        break;
      }
View Full Code Here

    shiftBoxInternal(box, amount);
  }

  private void shiftBoxInternal(final RenderBox box, final long amount)
  {
    RenderNode node = box.getFirstChild();
    while (node != null)
    {
      node.setY(node.getY() + amount);
      if (node instanceof RenderBox)
      {
        shiftBoxInternal((RenderBox) node, amount);
      }
      node = node.getNext();
    }
  }
View Full Code Here

  }

  public RenderNode findNodeById(final Object instanceId)
  {
    // quick check
    final RenderNode footerNode = footerArea.findNodeById(instanceId);
    if (footerNode != null)
    {
      return footerNode;
    }

    final RenderNode headerNode = headerArea.findNodeById(instanceId);
    if (headerNode != null)
    {
      return headerNode;
    }
    // then depth-first for ordinary content.
View Full Code Here

  private void validateFinalRows(final TableSectionRenderBox section)
  {
    // 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)
View Full Code Here

    }

    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;
        }

        if (section.isOpen() == false)
        {
View Full Code Here

    if (infoStruct.isValidationDone())
    {
      return infoStruct;
    }

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

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

      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();
        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!)
                ConflictingCell prevConflictCell = (ConflictingCell) prevCell;
                final int count = prevConflictCell.getConflictingCellCount();
                for (int x = 0; x < count; x++)
                {
                  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)
              {
                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);
View Full Code Here

    }

    final TableColumnModel columnModel = table.getColumnModel();

    int colCount = 0;
    RenderNode node = table.getFirstChild();
    while (node != null)
    {
      if (node instanceof TableColumnNode)
      {
        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)
      {
        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);
View Full Code Here

    printChilds(box, level);
  }

  private static void printChilds(final RenderBox box, final int level)
  {
    RenderNode childs = box.getFirstChild();
    while (childs != null)
    {
      if (childs instanceof RenderBox)
      {
        printBox((RenderBox) childs, level + 1);
      }
      else if (childs instanceof RenderableText)
      {
        printText((RenderableText) childs, level + 1);
      }
      else
      {
        printNode(childs, level + 1);
      }
      childs = childs.getNext();
    }
  }
View Full Code Here

TOP

Related Classes of org.jfree.layouting.renderer.model.RenderNode

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.