Package org.pentaho.reporting.engine.classic.core.layout.model

Examples of org.pentaho.reporting.engine.classic.core.layout.model.RenderNode


  private SequenceList createHorizontalSequenceList(final InlineRenderBox box)
  {
    final SequenceList sequenceList = new SequenceList();
    sequenceList.add(StartSequenceElement.INSTANCE, box);

    RenderNode next = box.getFirstChild();
    RenderBox context = box;

    final FastStack contextStack = new FastStack(50);
    boolean containsContent = false;

    while (next != null)
    {
      // process next
      if ((next.getNodeType() & LayoutNodeTypes.MASK_BOX_INLINE) == LayoutNodeTypes.MASK_BOX_INLINE)
      {
        final RenderBox nBox = (RenderBox) next;
        final RenderNode firstChild = nBox.getFirstChild();
        if (firstChild != null)
        {
          // Open a non-empty box context
          contextStack.push(context);
          next = firstChild;
View Full Code Here


    boolean needToAddSpacing = true;

    // do the merging ..
    final FastStack contextStack = new FastStack(50);
    RenderNode next = nextBox.getFirstChild();
    MergeContext context = new MergeContext(lineBox, nextBox);
    while (next != null)
    {
      // process next
      final RenderBox writeContext = context.getWriteContext();
      final StaticBoxLayoutProperties staticBoxLayoutProperties = writeContext.getStaticBoxLayoutProperties();
      long spaceWidth = staticBoxLayoutProperties.getSpaceWidth();
      if (spaceWidth == 0)
      {
        // Space has not been computed yet.
        final FontMetrics fontMetrics = metaData.getFontMetrics(writeContext.getStyleSheet());
        spaceWidth = fontMetrics.getCharWidth(' ');
        staticBoxLayoutProperties.setSpaceWidth(spaceWidth);
      }

      if ((next.getNodeType() & LayoutNodeTypes.MASK_BOX) == LayoutNodeTypes.MASK_BOX)
      {
        final RenderBox nBox = (RenderBox) next;
        final RenderNode firstChild = nBox.getFirstChild();
        if (firstChild != null)
        {
          contextStack.push(context);
          next = firstChild;

          final RenderNode writeContextLastChild = writeContext.getLastChild();
          if ((writeContextLastChild.getNodeType() & LayoutNodeTypes.MASK_BOX) == LayoutNodeTypes.MASK_BOX)
          {
            if (writeContextLastChild.getInstanceId() == nBox.getInstanceId())
            {
              context = new MergeContext((RenderBox) writeContextLastChild, nBox);
            }
            else
            {
              if (needToAddSpacing)
              {
                if (spaceWidth > 0)
                {
                  // docmark: Used zero as new height
                  final SpacerRenderNode spacer = new SpacerRenderNode(spaceWidth, 0, false, 1);
                  spacer.setVirtualNode(true);
                  writeContext.addGeneratedChild(spacer);
                }
                needToAddSpacing = false;
              }
              final RenderBox newWriter = (RenderBox) nBox.derive(false);
              newWriter.setVirtualNode(true);
              writeContext.addGeneratedChild(newWriter);
              context = new MergeContext(newWriter, nBox);
            }
          }
          else
          {
            if (needToAddSpacing)
            {
              if (spaceWidth > 0)
              {
                // docmark: Used zero as new height
                final SpacerRenderNode spacer = new SpacerRenderNode(spaceWidth, 0, false, 1);
                spacer.setVirtualNode(true);
                writeContext.addGeneratedChild(spacer);
              }
              needToAddSpacing = false;
            }

            final RenderBox newWriter = (RenderBox) nBox.derive(false);
            newWriter.setVirtualNode(true);
            writeContext.addGeneratedChild(newWriter);
            context = new MergeContext(newWriter, nBox);
          }
        }
        else
        {
          if (needToAddSpacing)
          {
            if (spaceWidth > 0)
            {
              // docmark: Used zero as new height
              final SpacerRenderNode spacer = new SpacerRenderNode(spaceWidth, 0, false, 1);
              spacer.setVirtualNode(true);
              writeContext.addGeneratedChild(spacer);
            }
            needToAddSpacing = false;
          }

          final RenderNode box = nBox.derive(true);
          box.setVirtualNode(true);
          writeContext.addGeneratedChild(box);
          next = nBox.getNext();
        }
      }
      else
      {
        if (needToAddSpacing)
        {
          final RenderNode lastChild = writeContext.getLastChild();
          if (spaceWidth > 0 && lastChild != null &&
              (lastChild.getNodeType() != LayoutNodeTypes.TYPE_NODE_SPACER))
          {
            // docmark: Used zero as new height
            final SpacerRenderNode spacer = new SpacerRenderNode(spaceWidth, 0, false, 1);
            spacer.setVirtualNode(true);
            writeContext.addGeneratedChild(spacer);
          }
          needToAddSpacing = false;
        }

        final RenderNode child = next.derive(true);
        child.setVirtualNode(true);
        writeContext.addGeneratedChild(child);
        next = next.getNext();
      }

      while (next == null && contextStack.isEmpty() == false)
View Full Code Here

    }
  }

  private static void shiftBoxInternal(final RenderBox box, final long amount)
  {
    RenderNode node = box.getFirstChild();
    while (node != null)
    {
      node.shift(amount);
      if ((node.getNodeType() & LayoutNodeTypes.MASK_BOX) == LayoutNodeTypes.MASK_BOX)
      {
        shiftBoxInternal((RenderBox) node, amount);
      }
      node = node.getNext();
    }
  }
View Full Code Here

    CacheBoxShifter.shiftBoxInternal(box, amount);
  }

  private static void shiftBoxInternal(final RenderBox box, final long amount)
  {
    RenderNode node = box.getFirstChild();
    while (node != null)
    {
      node.shiftCached(amount);
      if ((node.getNodeType() & LayoutNodeTypes.MASK_BOX) == LayoutNodeTypes.MASK_BOX)
      {
        CacheBoxShifter.shiftBoxInternal((RenderBox) node, amount);
      }
      node = node.getNext();
    }
  }
View Full Code Here

  protected abstract void processParagraphChilds(final ParagraphRenderBox box);

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

    breakUtility = new PageBreakPositionList();
  }

  public PaginationResult performPagebreak(final LogicalPageBox pageBox)
  {
    final RenderNode lastChild = pageBox.getLastChild();
    if (lastChild != null)
    {
      final long lastChildY2 = lastChild.getY() + lastChild.getHeight();
      if (lastChildY2 < pageBox.getHeight())
      {
        //ModelPrinter.print(pageBox);
        throw new IllegalStateException
            ("Assertation failed: Block layouting did not proceed: " + lastChildY2 + " < " + pageBox.getHeight());
      }
    }

    this.pageHeight = pageBox.getPageHeight();
    this.breakIndicatorEncountered = null;

    try
    {
      final long[] allCurrentBreaks = pageBox.getPhysicalBreaks(RenderNode.VERTICAL_AXIS);
      final long pageOffset = pageBox.getPageOffset();

      if (allCurrentBreaks.length == 0)
      {
        // No maximum height.
        throw new IllegalStateException("No page given. This is really bad.");
      }

      // Note: For now, we limit both the header and footer to a single physical
      // page. This safes me a lot of trouble for now.

      final BlockRenderBox headerArea = pageBox.getHeaderArea();
      final long headerHeight = Math.min(headerArea.getHeight(), allCurrentBreaks[0]);
      headerArea.setHeight(headerHeight);

      final long lastBreakLocal = allCurrentBreaks[allCurrentBreaks.length - 1];
      final BlockRenderBox footerArea = pageBox.getFooterArea();
      long footerHeight = footerArea.getHeight();
      if (allCurrentBreaks.length > 1)
      {
        final long lastPageHeight = lastBreakLocal - allCurrentBreaks[allCurrentBreaks.length - 2];
        footerHeight = Math.min(footerHeight, lastPageHeight);
        footerArea.setHeight(footerHeight);
      }

      // Assertation: Make sure that we do not run into a infinite loop..
      if (headerHeight + footerHeight >= lastBreakLocal)
      {
        // This is also bad. There will be no space left to print a single element.
        throw new IllegalStateException("Header and footer consume the whole page. No space left for normal-flow.");
      }

      final PageBreakPositionList allPreviousBreak = pageBox.getAllVerticalBreaks();
      breakUtility.copyFrom(allPreviousBreak);

      // Then add all new breaks (but take the header and footer-size into account) ..
      if (allCurrentBreaks.length == 1)
      {
        breakUtility.addMajorBreak(pageOffset, headerHeight);
        breakUtility.addMajorBreak((lastBreakLocal - footerHeight - headerHeight) + pageOffset, headerHeight);
      }
      else // more than one physical page; therefore header and footer are each on a separate canvas ..
      {
        breakUtility.addMajorBreak(pageOffset, headerHeight);
        final int breakCount = allCurrentBreaks.length - 1;
        for (int i = 1; i < breakCount; i++)
        {
          final long aBreak = allCurrentBreaks[i];
          breakUtility.addMinorBreak(pageOffset + (aBreak - headerHeight));
        }
        breakUtility.addMajorBreak(pageOffset + (lastBreakLocal - headerHeight - footerHeight), headerHeight);
      }

      pageEnd = breakUtility.getLastMasterBreak();
      visualState = null;

      this.pageStart = pageBox.getPageOffset();

      // now process all the other content (excluding the header and footer area)
      if (startBlockLevelBox(pageBox))
      {
        processBoxChilds(pageBox);
      }
      finishBlockLevelBox(pageBox);

      if (lastChild != null)
      {
        final long lastChildY2 = lastChild.getY() + lastChild.getHeight();
        if (lastChildY2 < pageBox.getHeight())
        {
          throw new IllegalStateException
              ("Assertation failed: Pagination violated block-constraints: " + lastChildY2 + " < " + pageBox.getHeight());
        }
View Full Code Here

        this.visualState = stateKey;
        return true;
      }
      else
      {
        RenderNode lastChild = box.getLastChild();
        while (lastChild != null)
        {
          if ((lastChild.getNodeType() & LayoutNodeTypes.MASK_BOX) != LayoutNodeTypes.MASK_BOX)
          {
            lastChild = lastChild.getPrev();
            continue;
          }
          final RenderBox lastBox = (RenderBox) lastChild;
          if (updateStateKeyDeep(lastBox))
          {
View Full Code Here

      // Widows and orphans will be ignored if both of them are zero.
      return 0;
    }

    int counter = 0;
    RenderNode child = box.getFirstChild();
    while (child != null && counter < orphans)
    {
      counter += 1;
      child = child.getNext();
    }

    final long orphanHeight;
    if (child == null)
    {
      orphanHeight = 0;
    }
    else
    {
      orphanHeight = box.getY() - (child.getY() + child.getHeight());
    }

    counter = 0;
    child = box.getLastChild();
    while (child != null && counter < orphans)
    {
      counter += 1;
      child = child.getPrev();
    }

    final long widowHeight;
    if (child == null)
    {
      widowHeight = 0;
    }
    else
    {
      widowHeight = (box.getY() + box.getHeight()) - (child.getY());
    }

    // todo: Compute the height the orphans and widows consume.
    return Math.max(orphanHeight, widowHeight);
  }
View Full Code Here

  }

  public void addEmptyRootLevelBand(final RenderBox parent,
                                    final ReportStateKey stateKey) throws ReportProcessingException
  {
    final RenderNode child = parent.getLastChild();
    if (isCollapseProgressMarker() && child != null &&
        child.getNodeType() == LayoutNodeTypes.TYPE_BOX_PROGRESS_MARKER)
    {
      final ProgressMarkerRenderBox markerRenderBox = (ProgressMarkerRenderBox) child;
      markerRenderBox.setStateKey(stateKey);
    }
    else
View Full Code Here

      box.getStaticBoxLayoutProperties().setPlaceholderBox(true);
      addBox(box);
    }
    else
    {
      final RenderNode maybeBox = pageBox.findNodeById(insertationPoint);
      if (maybeBox == null || (maybeBox.getNodeType() & LayoutNodeTypes.MASK_BOX) != LayoutNodeTypes.MASK_BOX)
      {
        box = null;
      }
      else
      {
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.layout.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.