Package org.jfree.layouting.renderer.model

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


    //ComputedLayoutProperties nlp = new ComputedLayoutProperties()
    final RenderLength bcw = computeBlockContextWidth(box);
    final StaticBoxLayoutProperties blp = box.getStaticBoxLayoutProperties();
    final long rbcw = bcw.resolve(0);
    final BoxDefinition boxDefinition = box.getBoxDefinition();
    final ComputedLayoutProperties clp = new ComputedLayoutProperties();

    if (box instanceof TableCellRenderBox)
    {
      // Table cells have borders and paddings, but no margins ..
      computeBorder(boxDefinition, clp, rbcw);
      // the computed width of table-cells is not known yet ...
      // This is computed later ..

      // We have to check the column-model for that and have to see
      // whether that one has some hints. If the cell has an explicit
      // width, we can use that one.
      final RenderLength preferredWidth = boxDefinition.getPreferredWidth();
      if (preferredWidth == RenderLength.AUTO)
      {
        // The cell itself did not define anything. But maybe the column
        // had a definition?
        final TableCellRenderBox cellBox = (TableCellRenderBox) box;
        final TableColumnModel columnModel = cellBox.getTable().getColumnModel();
        final int colIdx = cellBox.getColumnIndex();
        if (colIdx < 0)
        {
          throw new IllegalStateException("Table has not been validated yet.");
        }

        final int maxIdx = colIdx + cellBox.getColSpan();
        if (maxIdx >= columnModel.getColumnCount())
        {
          // No definition. Therefore the cell will not have a computed width.
          // (The effective width will be auto-computed in later steps.)
          // Yeah, we *could* start guessing, but I dont support our user's
          // lazyness. Shall they suffer from their own mis-definitions.
          clp.setBlockContextWidth(bcw);
          clp.setComputedWidth(RenderLength.AUTO);
          box.setComputedLayoutProperties(clp);
        }
        else
        {
          long width = 0;
          for (int i = colIdx; i < maxIdx; i++)
          {
            // Check, whether one of the columns will have an autoWidth --
            final TableColumn column = columnModel.getColumn(i);
            final RenderLength definedWidth = column.getDefinedWidth();
            if (definedWidth == RenderLength.AUTO)
            {
              // No go.
              width = -1;
              break;
            }

            width += definedWidth.resolve(rbcw);
          }
          if (width > 0)
          {
            clp.setBlockContextWidth(bcw);
            clp.setComputedWidth(new RenderLength(width, false));
            box.setComputedLayoutProperties(clp);
          }
          else
          {
            clp.setBlockContextWidth(bcw);
            clp.setComputedWidth(RenderLength.AUTO);
            box.setComputedLayoutProperties(clp);
          }
        }
      }
      else
      {
        clp.setBlockContextWidth(bcw);
        clp.setComputedWidth(preferredWidth.resolveToRenderLength(rbcw));
        box.setComputedLayoutProperties(clp);
      }
      return true;
    }

    if (box instanceof TableRowRenderBox ||
        box instanceof TableSectionRenderBox)
    {
      // rows and sections have neither paddings, margins or borders ..
      // See 17.6.1 of [CSS21]
      clp.setBlockContextWidth(bcw);
      clp.setComputedWidth(bcw);
      box.setComputedLayoutProperties(clp);
      return true;
    }

    // Every other Block-Level-element.
    computeBorder(boxDefinition, clp, rbcw);

    // For reference: The following formula defines the behaviour on AUTO
    //
    // (width of containing block) =
    //          margin-left + border-left + padding-left + width +
    //          padding-right + border-right + margin-right

    // On horizontal flow: If margin-top or -bottom is auto, then
    // the margin resolves to zero
    clp.setMarginTop(boxDefinition.getMarginTop().resolve(rbcw));
    clp.setMarginBottom(boxDefinition.getMarginBottom().resolve(rbcw));

    // According to the box-model, there are five cases
    // Case1: None of Width and Margin-left-right is auto.
    final RenderLength marginLeft = boxDefinition.getMarginLeft();
    final RenderLength marginRight = boxDefinition.getMarginRight();
    final RenderLength preferredWidth = boxDefinition.getPreferredWidth();
    if (preferredWidth != RenderLength.AUTO)
    {
      if (marginLeft != RenderLength.AUTO &&
          marginRight != RenderLength.AUTO)
      {
        final long mlValue = marginLeft.resolve(rbcw);
        final long mrValue = marginRight.resolve(rbcw);
        final long pwValue = preferredWidth.resolve(rbcw);

        // Sub-Case 1: The defined values satisfy the constraints defined by
        //             the formula
        if (mlValue + mrValue + pwValue == rbcw)
        {
          // fine. Accept these values
          clp.setMarginLeft(mlValue);
          clp.setMarginRight(mrValue);
        }
        // Sub-Case 2: They dont ..
        else if (box.isDirectionLTR())
        {
          clp.setMarginLeft(mlValue);
          clp.setMarginRight(rbcw - mlValue - pwValue);
        }
        else
        {
          clp.setMarginLeft(rbcw - mrValue - pwValue);
          clp.setMarginRight(mrValue);
        }
        clp.setBlockContextWidth(bcw);
        clp.setComputedWidth(new RenderLength(pwValue, false));
        box.setComputedLayoutProperties(clp);
        return true;
      }

      // If exactly one of width, margin-left or margin-right is 'auto',
      // its value is computed from the equation.
      if (marginLeft == RenderLength.AUTO &&
          marginRight != RenderLength.AUTO)
      {
        final long mrValue = marginRight.resolve(rbcw);
        final long pwValue = preferredWidth.resolve(rbcw);

        clp.setMarginLeft(rbcw - mrValue - pwValue);
        clp.setMarginRight(mrValue);
        clp.setBlockContextWidth(bcw);
        clp.setComputedWidth(new RenderLength(pwValue, false));
        box.setComputedLayoutProperties(clp);
        return true;
      }

      if (marginLeft != RenderLength.AUTO &&
          marginRight == RenderLength.AUTO)
      {
        final long mlValue = marginLeft.resolve(rbcw);
        final long pwValue = preferredWidth.resolve(rbcw);

        clp.setMarginLeft(mlValue);
        clp.setMarginRight(rbcw - mlValue - pwValue);
        clp.setBlockContextWidth(bcw);
        clp.setComputedWidth(new RenderLength(pwValue, false));
        box.setComputedLayoutProperties(clp);
        return true;
      }
    }
    // If width and one or both margins are 'auto', the margins that
    // are 'auto' are set to 0 and the equation is solved for width.
    else // if (preferredWidth == RenderLength.AUTO)
    {
      final long mlValue = marginLeft.resolve(rbcw);
      final long mrValue = marginRight.resolve(rbcw);

      clp.setMarginLeft(mlValue);
      clp.setMarginRight(mrValue);
      if (box instanceof TableRenderBox)
      {
        clp.setBlockContextWidth(bcw);
        clp.setComputedWidth(RenderLength.AUTO);
        box.setComputedLayoutProperties(clp);
      }
      else if (bcw == RenderLength.AUTO)
      {
        clp.setBlockContextWidth(bcw);
        clp.setComputedWidth(RenderLength.AUTO);
        box.setComputedLayoutProperties(clp);
      }
      else
      {
        clp.setBlockContextWidth(bcw);
        clp.setComputedWidth(new RenderLength((rbcw - mlValue - mrValue), false));
        box.setComputedLayoutProperties(clp);
      }
      return true;
    }

    // If both margin-left and margin-right are 'auto', the equation is
    // solved under the extra constraint that margin-left = margin-right.
    final long pwValue = preferredWidth.resolve(rbcw);

    final long margins = rbcw - pwValue;
    final long mlValue = margins / 2;

    clp.setMarginLeft(mlValue);
    clp.setMarginRight(margins - mlValue);

    clp.setBlockContextWidth(bcw);
    clp.setComputedWidth(new RenderLength(pwValue, false));
    box.setComputedLayoutProperties(clp);
    return true;
  }
View Full Code Here


  }

  protected void processBlockLevelNode(final RenderNode node)
  {
    final RenderLength bcw = computeBlockContextWidth(node);
    final ComputedLayoutProperties clp = new ComputedLayoutProperties();
    clp.setBlockContextWidth(bcw);
    clp.setComputedWidth(RenderLength.AUTO);
    node.setComputedLayoutProperties(clp);
  }
View Full Code Here

    final RenderLength bcw = computeBlockContextWidth(box);
    final StaticBoxLayoutProperties blp = box.getStaticBoxLayoutProperties();
    final long rbcw = bcw.resolve(0);
    final BoxDefinition boxDefinition = box.getBoxDefinition();

    final ComputedLayoutProperties clp = new ComputedLayoutProperties();
    computeBorder(boxDefinition, clp, rbcw);

    // as defined by the box-model
    clp.setMarginTop(0);
    clp.setMarginBottom(0);
    // margin-auto gets resolved to zero
    clp.setMarginLeft(boxDefinition.getMarginLeft().resolve(rbcw));
    clp.setMarginRight(boxDefinition.getMarginRight().resolve(rbcw));
    clp.setBlockContextWidth(bcw);
    clp.setComputedWidth(RenderLength.AUTO);
    box.setComputedLayoutProperties(clp);
    return true;
  }
View Full Code Here

    {
      validationTrack = table.getChangeTracker();
      return;
    }

    final ComputedLayoutProperties nlp = table.getComputedLayoutProperties();
    final RenderLength blockContextWidth = nlp.getBlockContextWidth();
    final long bcw = blockContextWidth.resolve(0);

    final RenderLength borderSpacingLength = table.getBorderSpacing();
    borderSpacing = borderSpacingLength.resolve(bcw);
View Full Code Here

    builder.append(TextStyleKeys.TEXT_ALIGN, layoutContext.getValue(TextStyleKeys.TEXT_ALIGN));
    builder.append(TextStyleKeys.TEXT_ALIGN_LAST, layoutContext.getValue(TextStyleKeys.TEXT_ALIGN_LAST));

    final NodeLayoutProperties nlp = box.getNodeLayoutProperties();
    //final BoxLayoutProperties blp = box.getBoxLayoutProperties();
    final ComputedLayoutProperties sblp = box.getComputedLayoutProperties();
    builder.append(LineStyleKeys.VERTICAL_ALIGN, nlp.getVerticalAlignment());

    if (sblp.getPaddingTop() > 0 ||
        sblp.getPaddingLeft() > 0 ||
        sblp.getPaddingBottom() > 0 ||
        sblp.getPaddingRight() > 0)
    {
      if (sblp.getPaddingTop() > 0 || assumeZeroPaddings == false)
      {
        builder.append(BoxStyleKeys.PADDING_TOP,
            toPointString(sblp.getPaddingTop()), "pt");
      }
      if (sblp.getPaddingLeft() > 0 || assumeZeroPaddings == false)
      {
        builder.append(BoxStyleKeys.PADDING_LEFT,
            toPointString(sblp.getPaddingLeft()), "pt");
      }
      if (sblp.getPaddingBottom() > 0 || assumeZeroPaddings == false)
      {
        builder.append(BoxStyleKeys.PADDING_BOTTOM,
            toPointString(sblp.getPaddingBottom()), "pt");
      }
      if (sblp.getPaddingRight() > 0 || assumeZeroPaddings == false)
      {
        builder.append(BoxStyleKeys.PADDING_RIGHT,
            toPointString(sblp.getPaddingRight()), "pt");
      }
    }
    else if (assumeZeroPaddings == false)
    {
      builder.append("padding", false, "0");
    }

    if (sblp.getMarginLeft() != 0 ||
        sblp.getMarginRight() != 0 ||
        sblp.getMarginTop() != 0 ||
        sblp.getMarginBottom() != 0)
    {
      if (sblp.getMarginLeft() > 0 || assumeZeroMargins == false)
      {
        builder.append(BoxStyleKeys.MARGIN_LEFT,
            toPointString(sblp.getMarginLeft()), "pt");
      }
      if (sblp.getMarginRight() > 0 || assumeZeroMargins == false)
      {
        builder.append(BoxStyleKeys.MARGIN_RIGHT,
            toPointString(sblp.getMarginRight()), "pt");
      }
      if (sblp.getMarginTop() > 0 || assumeZeroMargins == false)
      {
        builder.append(BoxStyleKeys.MARGIN_TOP,
            toPointString(sblp.getMarginTop()), "pt");
      }
      if (sblp.getMarginBottom() > 0 || assumeZeroMargins == false)
      {
        builder.append(BoxStyleKeys.MARGIN_BOTTOM,
            toPointString(sblp.getMarginBottom()), "pt");
      }
    }
    else if (assumeZeroMargins == false)
    {
      builder.append("margin", false, "0");
    }

    final String bgColor = toColorString(layoutContext.getValue
        (BorderStyleKeys.BACKGROUND_COLOR));
    if (bgColor != null)
    {
      builder.append(BorderStyleKeys.BACKGROUND_COLOR, bgColor);
    }
    final String fgColor = toColorString(layoutContext.getValue(ColorStyleKeys.COLOR));
    if (fgColor != null)
    {
      builder.append(ColorStyleKeys.COLOR, fgColor);
    }

    if (sblp.getBorderTop() > 0 || sblp.getBorderLeft() > 0 ||
        sblp.getBorderBottom() > 0 || sblp.getBorderRight() > 0)
    {
      if (sblp.getBorderTop() > 0)
      {
        builder.append(BorderStyleKeys.BORDER_TOP_COLOR, layoutContext.getValue(BorderStyleKeys.BORDER_TOP_COLOR));
        builder.append(BorderStyleKeys.BORDER_TOP_STYLE, layoutContext.getValue(BorderStyleKeys.BORDER_TOP_STYLE));
        builder.append(BorderStyleKeys.BORDER_TOP_WIDTH, toPointString(sblp.getBorderTop()), "pt");
      }
      else if (assumeZeroBorders == false)
      {
        builder.append(BorderStyleKeys.BORDER_TOP_STYLE, BorderStyle.NONE);
      }

      if (sblp.getBorderLeft() > 0)
      {
        builder.append(BorderStyleKeys.BORDER_LEFT_COLOR, layoutContext.getValue(BorderStyleKeys.BORDER_LEFT_COLOR));
        builder.append(BorderStyleKeys.BORDER_LEFT_STYLE, layoutContext.getValue(BorderStyleKeys.BORDER_LEFT_STYLE));
        builder.append(BorderStyleKeys.BORDER_LEFT_WIDTH, toPointString(sblp.getBorderLeft()), "pt");
      }
      else if (assumeZeroBorders == false)
      {
        builder.append(BorderStyleKeys.BORDER_LEFT_STYLE, BorderStyle.NONE);
      }

      if (sblp.getBorderBottom() > 0)
      {
        builder.append(BorderStyleKeys.BORDER_BOTTOM_COLOR, layoutContext.getValue(BorderStyleKeys.BORDER_BOTTOM_COLOR));
        builder.append(BorderStyleKeys.BORDER_BOTTOM_STYLE, layoutContext.getValue(BorderStyleKeys.BORDER_BOTTOM_STYLE));
        builder.append(BorderStyleKeys.BORDER_BOTTOM_WIDTH, toPointString(sblp.getBorderBottom()), "pt");
      }
      else if (assumeZeroBorders == false)
      {
        builder.append(BorderStyleKeys.BORDER_BOTTOM_STYLE, BorderStyle.NONE);
      }

      if (sblp.getBorderRight() > 0)
      {
        builder.append(BorderStyleKeys.BORDER_RIGHT_COLOR, layoutContext.getValue(BorderStyleKeys.BORDER_RIGHT_COLOR));
        builder.append(BorderStyleKeys.BORDER_RIGHT_STYLE, layoutContext.getValue(BorderStyleKeys.BORDER_RIGHT_STYLE));
        builder.append(BorderStyleKeys.BORDER_RIGHT_WIDTH, toPointString(sblp.getBorderRight()), "pt");
      }
      else if (assumeZeroBorders == false)
      {
        builder.append(BorderStyleKeys.BORDER_RIGHT_STYLE, BorderStyle.NONE);
      }
View Full Code Here

    final CSSValue dominantBaselineValue = box.getDominantBaseline();
    setDominantBaseline(TextUtility.translateDominantBaseline
        (dominantBaselineValue, baselineInfo.getDominantBaseline()));

    final ComputedLayoutProperties blp = box.getComputedLayoutProperties();
    insetsTop = blp.getBorderTop() + blp.getPaddingTop();
    insetsBottom = blp.getBorderBottom() + blp.getPaddingBottom();

    baselines = (long[]) baselineInfo.getBaselines().clone();
    for (int i = 1; i < baselines.length; i++)
    {
      baselines[i] += insetsTop;
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)
    {
      return offset;
View Full Code Here

    final long effectiveCellPosition = column.getEffectiveCellPosition();
    cellRenderBox.setX(effectiveCellPosition);
    cellRenderBox.setWidth(effectiveSize);

    final ComputedLayoutProperties blp = cellRenderBox.getComputedLayoutProperties();
    // next, compute the width ...

    long leftPadding = blp.getBorderLeft();
    leftPadding += blp.getPaddingLeft();
    cellRenderBox.setContentAreaX1(effectiveCellPosition + leftPadding);

    long rightPadding = blp.getBorderRight();
    rightPadding += blp.getPaddingRight();
    final long contentWidth = effectiveSize - rightPadding;
    cellRenderBox.setContentAreaX2(effectiveCellPosition + contentWidth);
  }
View Full Code Here

    if (box == continuedElement)
    {
      return;
    }

    final ComputedLayoutProperties blp = box.getComputedLayoutProperties();
    final long x = computeX(box) + blp.getMarginLeft();
    box.setX(x);
    // next, compute the width ...

    long leftPadding = blp.getBorderLeft();
    leftPadding += blp.getPaddingLeft();
    box.setContentAreaX1(x + leftPadding);

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

        final BlockRenderBox blockParent = (BlockRenderBox) parent;
        box.setContentAreaX2(blockParent.getContentAreaX2() - rightPadding);
      }
      else
View Full Code Here

   */
  private void verifyContentWidth(final RenderBox box)
  {
    final long x = box.getX();
    final long contentEnd = box.getContentAreaX2();
    final ComputedLayoutProperties blp = box.getComputedLayoutProperties();
    final long boxEnd = contentEnd + blp.getBorderRight() + blp.getPaddingRight();
    box.setWidth(boxEnd - x);
  }
View Full Code Here

TOP

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

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.