Package org.jfree.layouting.renderer.model

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


    if (breakState.getSuspendItem() == null)
    {
      breakState.setSuspendItem(box.getInstanceId());
    }

    final RenderBox child = (RenderBox) box.deriveFrozen(false);
    breakState.getInsertationPoint().addGeneratedChild(child);
    breakState.setInsertationPoint(child);

    return true;
  }
View Full Code Here


      if (box.getInstanceId() == suspender)
      {
        breakState.setSuspendItem(null);
      }

      final RenderBox parent = breakState.getInsertationPoint().getParent();
      breakState.setInsertationPoint(parent);
    }
  }
View Full Code Here

      return true;
    }


    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;
    while (true)
    {
      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;
      }

      marginBox = (RenderBox) node;
    }

    // If we are the first child on an infinite margin area, copy the
    // infinite area to yourself ..
    if (infiniteMarginTop)
    {
      for (int i = 0; i < marginCollection.size(); i++)
      {
        final RenderBox renderBox = (RenderBox) marginCollection.get(i);
        final BoxLayoutProperties cblp = renderBox.getBoxLayoutProperties();
        cblp.setEffectiveMarginTop(0);
        cblp.setInfiniteMarginTop(true);
        cblp.setMarginOpenState(marginChangeKey);
      }
      return true;
    }

    // Compute the top margin.
    long topMarginPositive = 0;
    long topMarginNegative = 0;
    final ComputedLayoutProperties sblp = box.getComputedLayoutProperties();
    final long marginTop = sblp.getMarginTop();
    if (marginTop < 0)
    {
      topMarginNegative = marginTop;
    }
    else
    {
      topMarginPositive = marginTop;
    }

    if (visiblePrev != null)
    {
      final long effectiveMarginBottom =
          visiblePrev.getEffectiveMarginBottom();

      if (effectiveMarginBottom < 0)
      {
        topMarginNegative = Math.min(topMarginNegative, effectiveMarginBottom);
      }
      else
      {
        topMarginPositive = Math.max(topMarginPositive, effectiveMarginBottom);
      }
    }

    // Dive into all other childs, and set their effective margin to zero.
    // Perform the collapsing, but the result only affects the first child.
    // The margin is already handled by the first element.
    for (int i = 1; i < marginCollection.size(); i++)
    {
      final RenderBox renderBox = (RenderBox) marginCollection.get(i);
      final BoxLayoutProperties cblp = renderBox.getBoxLayoutProperties();
      final ComputedLayoutProperties scblp = renderBox.getComputedLayoutProperties();
      final long childMarginTop = scblp.getMarginTop();

      if (childMarginTop < 0)
      {
        topMarginNegative = Math.min(topMarginNegative, childMarginTop);
View Full Code Here

      return;
    }

    // Collect all elements that will contribute to the margins.
    marginCollection.clear();
    RenderBox marginBox = box;
    while (true)
    {
      marginCollection.add(marginBox);
      if (marginBox.getNext() != null)
      {
        break;
      }

      final RenderBox parent = marginBox.getParent();
      if (parent == null)
      {
        break;
      }
      final ComputedLayoutProperties sblp = parent.getComputedLayoutProperties();
      if (sblp.getBorderBottom() != 0)
      {
        break;
      }
      if (sblp.getPaddingBottom() != 0)
      {
        break;
      }
      marginBox = parent;
    }

    // Check, whether we have an infinite margin ..
    final RenderBox lastBox = (RenderBox)
        marginCollection.get(marginCollection.size() - 1);
    if (lastBox.getParent() == null)
    {
      // Looks like that's it.
      // Strive for the simple solution here.
      for (int i = 0; i < marginCollection.size(); i++)
      {
        final RenderBox renderBox = (RenderBox) marginCollection.get(i);
        final BoxLayoutProperties cblp = renderBox.getBoxLayoutProperties();
        cblp.setMarginCloseState(marginChangeKey);
        cblp.setInfiniteMarginBottom(true);
        cblp.setEffectiveMarginBottom(0);
      }
      return;
    }

    long marginNegative = 0;
    long marginPositive = 0;

    // Collapsing the margins. Seek the big one ..
    for (int i = 0; i < marginCollection.size(); i++)
    {
      final RenderBox renderBox = (RenderBox) marginCollection.get(i);
      final BoxLayoutProperties cblp = renderBox.getBoxLayoutProperties();
      cblp.setMarginCloseState(marginChangeKey);
      cblp.setInfiniteMarginBottom(false);
      cblp.setEffectiveMarginBottom(0);

      final ComputedLayoutProperties sblp = renderBox.getComputedLayoutProperties();
      marginNegative = Math.min (marginNegative, sblp.getMarginBottom());
      marginPositive = Math.max (marginPositive, sblp.getMarginBottom());
    }

    final BoxLayoutProperties lblp = lastBox.getBoxLayoutProperties();
View Full Code Here

    }

    // now, build the line and update the array ..
    final ArrayList pendingElements = new ArrayList();
    final FastStack contexts = new FastStack();
    RenderBox firstBox = null;
    RenderBox box = null;
    for (int i = 0; i < lastPosition; i++)
    {
      final InlineSequenceElement element = sequenceElements[i];
      if (element instanceof EndSequenceElement)
      {
        contexts.pop();
        final long boxX2 = (elementPositions[i] + elementDimensions[i]);
        //noinspection ConstantConditions
        box.setWidth(boxX2 - box.getX());

        if (contexts.isEmpty())
        {
          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;
      }
    }

    // If there are open contexts, then add the split-result to the new line
    // and update the width of the current line
    final int openContexts = contexts.size();
    for (int i = 0; i < openContexts; i++)
    {
      final RenderBox renderBox = (RenderBox) contexts.get(i);
      renderBox.setWidth(getEndOfLine() - box.getX());

      final InlineRenderBox rightBox = (InlineRenderBox)
          renderBox.split(RenderNode.HORIZONTAL_AXIS);
      sequenceElements[i] = new StartSequenceElement(rightBox);
    }

    final int length = sequenceFill - lastPosition;
    System.arraycopy(sequenceElements, lastPosition,
View Full Code Here

      }
      finishBlockBox(box);
    }
    else if (node instanceof RenderBox)
    {
      final RenderBox box = (RenderBox) node;
      startOtherBox(box);
      processBoxChilds(box);
      finishOtherBox(box);
    }
    else
View Full Code Here

  {
    if (node instanceof RenderBox == false)
    {
      return false;
    }
    final RenderBox marginBox = (RenderBox) node;
    final ComputedLayoutProperties blp = marginBox.getComputedLayoutProperties();
    if (blp.getBorderTop() != 0)
    {
      return false;
    }
    if (blp.getPaddingTop() != 0)
View Full Code Here

  private void computeYPosition(final RenderNode node)
  {
    final long marginTop = node.getEffectiveMarginTop();

    // The y-position of a box depends on the parent.
    final RenderBox parent = node.getParent();

    // A table row is something special. Although it is a block box,
    // it layouts its children from left to right
    if (parent instanceof TableRowRenderBox)
    {
      // Node is a table-cell ..
      node.setDirty(true);
      node.setY(parent.getY());
    }
    // If the box's parent is a block box ..
    else if (parent instanceof BlockRenderBox)
    {
      final RenderNode prev = node.getVisiblePrev();
      if (prev != null)
      {
        // we have a silbling. Position yourself directly below your silbling ..
        node.setDirty(true);
        node.setY(marginTop + prev.getY() + prev.getHeight());
      }
      else
      {
        final ComputedLayoutProperties blp = parent.getComputedLayoutProperties();
        final long insetTop = (blp.getBorderTop() + blp.getPaddingTop());

        node.setDirty(true);
        node.setY(marginTop + insetTop + parent.getY());
      }
    }
    // The parent is a inline box.
    else if (parent != null)
    {
      final ComputedLayoutProperties blp = parent.getComputedLayoutProperties();
      final long insetTop = (blp.getBorderTop() + blp.getPaddingTop());

      node.setDirty(true);
      node.setY(marginTop + insetTop + parent.getY());
    }
    else
    {
      // there's no parent ..
      node.setDirty(true);
View Full Code Here

   */
  public long add (final InlineSequenceElement sequenceElement)
  {
    if (sequenceElement instanceof StartSequenceElement)
    {
      final RenderBox box = (RenderBox) sequenceElement.getNode();
      final ComputedLayoutProperties blp = box.getComputedLayoutProperties();
      offset = blp.getBorderTop() + blp.getPaddingTop();
      height = offset + blp.getBorderBottom() + blp.getPaddingBottom();
      return offset;
    }
    if (sequenceElement instanceof EndSequenceElement)
View Full Code Here

    final RenderLength computedWidth =
        box.getComputedLayoutProperties().getComputedWidth();
    if (computedWidth == RenderLength.AUTO)
    {
      final RenderBox parent = box.getParent();
      if (parent instanceof BlockRenderBox)
      {
        long rightPadding = blp.getMarginRight();
        rightPadding += blp.getBorderRight();
        rightPadding += blp.getPaddingRight();
View Full Code Here

TOP

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

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.