Package org.jfree.layouting.renderer.model

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


   *
   * @param box
   */
  protected boolean startBlockLevelBox(final RenderBox box)
  {
    final BoxLayoutProperties blp = box.getBoxLayoutProperties();

    if (blp.getMarginOpenState() == marginChangeKey)
    {
      // no changes, but still, we have to dive deep ..
      return true;
    }

    // Inner table boxes have no margins at all ...
    if (box instanceof TableRowRenderBox ||
        box instanceof TableSectionRenderBox ||
        box instanceof TableCellRenderBox)
    {
      blp.setMarginOpenState(marginChangeKey);
      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);
      }
      else
      {
        topMarginPositive = Math.max(topMarginPositive, childMarginTop);
      }
      cblp.setMarginOpenState(marginChangeKey);
      cblp.setInfiniteMarginTop(false);
      cblp.setEffectiveMarginTop(0);
    }

    final long effectiveMargin = topMarginPositive + topMarginNegative;
    blp.setEffectiveMarginTop(effectiveMargin);
    blp.setInfiniteMarginTop(false);
View Full Code Here


   *
   * @param box
   */
  protected void finishBlockLevelBox(final RenderBox box)
  {
    final BoxLayoutProperties blp = box.getBoxLayoutProperties();

    if (blp.getMarginCloseState() == marginChangeKey)
    {
      return;
    }

    if (box instanceof TableCellRenderBox ||
        box instanceof TableRowRenderBox ||
        box instanceof TableSectionRenderBox)
    {
      // They do not have any margins at all  ..
      blp.setMarginCloseState(marginChangeKey);
      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();
    lblp.setEffectiveMarginBottom(marginPositive + marginNegative);
    lblp.setInfiniteMarginBottom(false);
    lblp.setMarginCloseState(marginChangeKey);
  }
View Full Code Here

   *
   * @param box
   */
  protected boolean startBlockLevelBox(final RenderBox box)
  {
    final BoxLayoutProperties blp = box.getBoxLayoutProperties();

    if (blp.getMarginOpenState() == marginChangeKey)
    {
      // no changes, but still, we have to dive deep ..
      return true;
    }

    // Inner table boxes have no margins at all ...
    if (box instanceof TableRowRenderBox ||
        box instanceof TableSectionRenderBox ||
        box instanceof TableCellRenderBox)
    {
      blp.setMarginOpenState(marginChangeKey);
      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;
    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;
      }

      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++)
      {
        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++)
    {
      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);
      }
      else
      {
        topMarginPositive = Math.max(topMarginPositive, childMarginTop);
      }
      cblp.setMarginOpenState(marginChangeKey);
      cblp.setInfiniteMarginTop(false);
      cblp.setEffectiveMarginTop(0);
    }

    final long effectiveMargin = topMarginPositive + topMarginNegative;
    blp.setEffectiveMarginTop(effectiveMargin);
    blp.setInfiniteMarginTop(false);
View Full Code Here

   *
   * @param box
   */
  protected void finishBlockLevelBox(final RenderBox box)
  {
    final BoxLayoutProperties blp = box.getBoxLayoutProperties();

    if (blp.getMarginCloseState() == marginChangeKey)
    {
      return;
    }

    if (box instanceof TableCellRenderBox ||
        box instanceof TableRowRenderBox ||
        box instanceof TableSectionRenderBox)
    {
      // They do not have any margins at all  ..
      blp.setMarginCloseState(marginChangeKey);
      return;
    }

    // Collect all elements that will contribute to the margins.
    marginCollection.clear();
    RenderBox marginBox = box;
    for (;;)
    {
      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++)
      {
        RenderBox renderBox = (RenderBox) marginCollection.get(i);
        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();
    lblp.setEffectiveMarginBottom(marginPositive + marginNegative);
    lblp.setInfiniteMarginBottom(false);
    lblp.setMarginCloseState(marginChangeKey);
  }
View Full Code Here

   *
   * @param box
   */
  protected boolean startBlockLevelBox(final RenderBox box)
  {
    final BoxLayoutProperties blp = box.getBoxLayoutProperties();

    if (blp.getMarginOpenState() == marginChangeKey)
    {
      // no changes, but still, we have to dive deep ..
      return true;
    }

    // Inner table boxes have no margins at all ...
    if (box instanceof TableRowRenderBox ||
        box instanceof TableSectionRenderBox ||
        box instanceof TableCellRenderBox)
    {
      blp.setMarginOpenState(marginChangeKey);
      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);
      }
      else
      {
        topMarginPositive = Math.max(topMarginPositive, childMarginTop);
      }
      cblp.setMarginOpenState(marginChangeKey);
      cblp.setInfiniteMarginTop(false);
      cblp.setEffectiveMarginTop(0);
    }

    final long effectiveMargin = topMarginPositive + topMarginNegative;
    blp.setEffectiveMarginTop(effectiveMargin);
    blp.setInfiniteMarginTop(false);
View Full Code Here

   *
   * @param box
   */
  protected void finishBlockLevelBox(final RenderBox box)
  {
    final BoxLayoutProperties blp = box.getBoxLayoutProperties();

    if (blp.getMarginCloseState() == marginChangeKey)
    {
      return;
    }

    if (box instanceof TableCellRenderBox ||
        box instanceof TableRowRenderBox ||
        box instanceof TableSectionRenderBox)
    {
      // They do not have any margins at all  ..
      blp.setMarginCloseState(marginChangeKey);
      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();
    lblp.setEffectiveMarginBottom(marginPositive + marginNegative);
    lblp.setInfiniteMarginBottom(false);
    lblp.setMarginCloseState(marginChangeKey);
  }
View Full Code Here

TOP

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

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.