Package org.jfree.layouting.renderer.model

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


    }

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

  protected abstract void processParagraphChilds(final ParagraphRenderBox box);

  protected void processBoxChilds(final RenderBox box)
  {
    RenderNode node = box.getFirstChild();
    while (node != null)
    {
      startProcessing(node);
      node = node.getNext();
    }
  }
View Full Code Here

    // Todo: Include orphan and widow stuff ..

    // First: Check the number of lines. (Should have been precomputed)
    // Second: Check whether and where the orphans- and widows-rules apply
    // Third: Shift the lines.
    RenderNode node = box.getVisibleFirst();
    while (node != null)
    {
      // all childs of the linebox container must be inline boxes. They
      // represent the lines in the paragraph. Any other element here is
      // a error that must be reported
      if (node instanceof ParagraphPoolBox == false)
      {
        throw new IllegalStateException("Encountered " + node.getClass());
      }
      final ParagraphPoolBox inlineRenderBox = (ParagraphPoolBox) node;
      if (startLine(inlineRenderBox))
      {
        processBoxChilds(inlineRenderBox);
      }
      finishLine(inlineRenderBox);

      node = node.getVisibleNext();
    }
  }
View Full Code Here

  }

  private void processTableSection(final TableRenderBox box,
                                   final CSSConstant role)
  {
    RenderNode rowGroupNode = box.getFirstChild();
    while (rowGroupNode != null)
    {
      if (rowGroupNode instanceof TableSectionRenderBox == false)
      {
        rowGroupNode = rowGroupNode.getNext();
        continue;
      }

      final TableSectionRenderBox sectionBox =
          (TableSectionRenderBox) rowGroupNode;
      if (role.equals
          (sectionBox.getDisplayRole()) == false)
      {
        // not a header ..
        rowGroupNode = rowGroupNode.getNext();
        continue;
      }

      startProcessing(rowGroupNode);
      rowGroupNode = rowGroupNode.getNext();
    }
  }
View Full Code Here

    long position = currentTable.getPosition();

    // Second step: Apply the row heights to all cells.
    // + Align all cells.
    final TableRow[] rows = rowModel.getRows();
    RenderNode rowNode = section.getFirstChild();
    boolean firstRow = true;
    while (rowNode != null)
    {
      if (rowNode instanceof TableRowRenderBox == false)
      {
        rowNode = rowNode.getNext();
        continue;
      }
      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.
    // We have to update our parent's height as well as we extended the height
    // of the table ..
    final long newHeight = position - section.getY();
    final long extendedHeight = newHeight - section.getHeight();
    section.setHeight(newHeight);
    if (extendedHeight != 0)
    {
      RenderNode parent = section.getParent();
      while (parent != null)
      {
        parent.setHeight(parent.getHeight() + extendedHeight);
        parent = parent.getParent();
      }

      shiftDistance += extendedHeight;
    }
View Full Code Here

      return;
    }

    // Argghhh, a render box. Shift all childs too..
    final RenderBox box = (RenderBox) node;
    RenderNode child = box.getFirstChild();
    while (child != null)
    {
      shift(child, shift);
      child = child.getNext();
    }
  }
View Full Code Here

        {
          box = null;
        }
        else
        {
          final RenderNode node = box;
          box = (RenderBox) contexts.peek();
          box.addGeneratedChild(node);
        }
        continue;
      }

      if (element instanceof StartSequenceElement)
      {
        final RenderNode node = element.getNode();
        box = (RenderBox) node.derive(false);
        box.setX(elementPositions[i]);
        contexts.push(box);
        if (firstBox == null)
        {
          firstBox = box;
        }
        continue;
      }

      if (box == null)
      {
        throw new IllegalStateException("Invalid sequence: " +
            "Cannot have elements before we open the box context.");
      }

      // Content element: Perform a deep-derive, so that we preserve the
      // possibly existing sub-nodes.
      final RenderNode child = element.getNode().derive(true);
      child.setX(elementPositions[i]);
      child.setWidth(elementDimensions[i]);
      if (box.isPreserveSpace() != false)
      {
        box.addGeneratedChild(child);
        continue;
      }

      if (child.isIgnorableForRendering())
      {
        pendingElements.add(child);
      }
      else
      {
        for (int j = 0; j < pendingElements.size(); j++)
        {
          final RenderNode node = (RenderNode) pendingElements.get(j);
          box.addGeneratedChild(node);
        }
        pendingElements.clear();
        box.addGeneratedChild(child);
      }
    }

    // Remove all spacers and other non printable content that might
    // look ugly at the beginning of a new line ..
    for (; lastPosition < sequenceFill; lastPosition++)
    {
      final RenderNode node = sequenceElements[lastPosition].getNode();
      if (node.isDiscardable() == false)
      {
        break;
      }
    }
View Full Code Here

      // gets fired, and only if all cells have been replaced by removed-
      // placeholders
      return startTableRow((TableRowRenderBox) box);
    }

    final RenderNode node = box.getVisibleFirst();
    if (node == null)
    {
      // The cell is empty ..
      return false;
    }
    if (node.isOpen())
    {
      return true;
    }

    final long nodeY = node.getY();
    if ((nodeY + node.getHeight()) > pageOffset)
    {
      // we cant handle that. At least parts of the node will be visible ..

      if (nodeY > pageOffset)
      {
        // all childs will be visible too, so why visiting them ...
        return false;
      }
      return true;
    }

    // Next, search the last node that is fully invisible. We collapse all
    // invisible node into one big box for efficiency reasons. They wont be
    // visible anyway and thus the result will be the same as if they were
    // still alive ..
    RenderNode last = node;
    while (true)
    {
      final RenderNode next = last.getVisibleNext();
      if (next == null)
      {
        break;
      }
      if (next.isOpen())
      {
        // as long as a box is open, it can grow and therefore it cannot be
        // removed ..
        break;
      }

      if ((next.getY() + next.getHeight()) > pageOffset)
      {
        // we cant handle that. This node will be visible. So the current last
        // node is the one we can shrink ..
        break;
      }
      last = next;
    }

    // So lets get started. We remove all nodes between (and inclusive)
    // node and last.
    final long width = box.getContentAreaX2() - box.getContentAreaX1();
    final long height = last.getY() + last.getHeight() - nodeY;

    // make sure that the finished-box inherits the margins ..
    final long marginsTop = node.getEffectiveMarginTop();
    final long marginsBottom = last.getEffectiveMarginBottom();
    final FinishedRenderNode replacement =
        new FinishedRenderNode(width, height, marginsTop, marginsBottom);

    RenderNode removeNode = node;
    while (removeNode != last)
    {
      final RenderNode next = removeNode.getNext();
      if (removeNode.isOpen())
      {
        throw new IllegalStateException();
      }
      box.remove(removeNode);
View Full Code Here

  }

  protected void processBoxChilds(final RenderBox box)
  {
    RenderNode node = box.getFirstChild();
    while (node != null)
    {
      startProcessing(node);
      node = node.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.