Package org.jfree.layouting.renderer.border

Examples of org.jfree.layouting.renderer.border.RenderLength


  protected void finishBlockLevelBox(final RenderBox box)
  {
    // Check the height. Set the height.
    final ComputedLayoutProperties clp = box.getComputedLayoutProperties();
    final RenderLength computedWidth = clp.getComputedWidth();
    final RenderLength preferredHeight = box.getBoxDefinition().getPreferredHeight();
    final long computedHeight =
        preferredHeight.resolve(computedWidth.resolve(0));

    final ComputedLayoutProperties blp = box.getComputedLayoutProperties();
    final long insetBottom = blp.getBorderBottom() + blp.getPaddingBottom();

    final RenderNode lastChildNode = box.getLastChild();
View Full Code Here


    final ComputedLayoutProperties blp = inlineRenderBox.getComputedLayoutProperties();
    final long insetTop = (blp.getBorderTop() + blp.getPaddingTop());

    final long contentAreaY1 = inlineRenderBox.getY() + insetTop;
    final RenderLength lineHeight = inlineRenderBox.getLineHeight();
    final ComputedLayoutProperties clp = inlineRenderBox.getComputedLayoutProperties();
    final RenderLength bcw = clp.getBlockContextWidth();
    processor.align (boxAlignContext, contentAreaY1,
        lineHeight.resolve(bcw.resolve(0)));
  }
View Full Code Here

    else
    {
      final CSSNumericValue nval = (CSSNumericValue) widthValue;
      if (nval.getValue() > 0)
      {
        final RenderLength renderLength =
            RenderLength.convertToInternal(widthValue, null, metaData);
        if (renderLength.getValue() > 0)
        {
          return renderLength;
        }
      }
      return RenderLength.EMPTY;
View Full Code Here

    {
      return true;
    }

    //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

    return true;
  }

  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

    if (box.getComputedLayoutProperties() != null)
    {
      return true;
    }

    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);
View Full Code Here

    if (node.getComputedLayoutProperties() != null)
    {
      return;
    }

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

  {
    // grab the block-context width ..
    final RenderBox blockContext = node.getParentBlockContext();
    if (blockContext == null)
    {
      return new RenderLength(root.getPageWidth(), false);
    }
    else
    {
      final ComputedLayoutProperties layoutProperties =
              blockContext.getComputedLayoutProperties();
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);

    final long totalBorderSpacing = (colCount - 1) * borderSpacing;
    minimumChunkSize = totalBorderSpacing;
    maxBoxSize = totalBorderSpacing;
    preferredSize = totalBorderSpacing;

    // first, find out how much space is already used.
    final long[] minChunkSizes = new long[colCount];
    final long[] maxBoxSizes = new long[colCount];
    final long[] preferredSizes = new long[colCount];

    // For each colspan distribute the content.
    // The 1-column size also gets the preferred size ...
    for (int colIdx = 0; colIdx < minChunkSizes.length; colIdx++)
    {
      final TableColumn column = columns[colIdx];
      final long minimumChunkSize = column.getMinimumChunkSize(1);
      final long maxBoxSize = column.getMaximumBoxWidth(1);
      final long resolvedColWidth = column.getDefinedWidth().resolve(bcw);
      final long preferredSize = Math.max
          (resolvedColWidth, column.getPreferredWidth(1));

      minChunkSizes[colIdx] = minimumChunkSize;
      maxBoxSizes[colIdx] = maxBoxSize;
      preferredSizes[colIdx] = preferredSize;
    }

    for (int colspan = 2; colspan <= maxColSpan; colspan += 1)
    {
      for (int colIdx = 0; colIdx < minChunkSizes.length; colIdx++)
      {
        final TableColumn column = columns[colIdx];
        final long minimumChunkSize = column.getMinimumChunkSize(colspan);
        final long maxBoxSize = column.getMaximumBoxWidth(colspan);
        final long preferredSize = column.getPreferredWidth(colspan);

        distribute(minimumChunkSize, minChunkSizes, colIdx, colspan);
        distribute(preferredSize, preferredSizes, colIdx, colspan);
        distribute(maxBoxSize, maxBoxSizes, colIdx, colspan);
      }
    }

    for (int i = 0; i < minChunkSizes.length; i++)
    {
      final TableColumn column = columns[i];

      final long cmin = minChunkSizes[i];
      final long cpref = preferredSizes[i];
      final long cmax = maxBoxSizes[i];
      final long width = Math.max(cmin, cpref);

      minimumChunkSize += cmin;
      preferredSize += width;
      maxBoxSize += cmax;

      if (column.isValidated())
      {
        continue;
      }

      column.setComputedPreferredSize(cpref);
      column.setComputedMinChunkSize(cmin);
      column.setComputedMaximumWidth(cmax);
      column.setEffectiveSize(width);
      column.setValidated(true);
    }

    // Table-AutoWidth means, the tables width is based on the content of the
    // cells. The minimum chunk size and the preferred sizes are the only
    // metrics used in that computation.
    //
    // If the table's width is fixed, then we have to shrink or expand the
    // columns to fit that additional requirement.
    final RenderLength tableCWidth = table.getComputedLayoutProperties().getComputedWidth();
    if (tableCWidth != RenderLength.AUTO)
    {
      final long tableSize = Math.max(tableCWidth.resolve(0), minimumChunkSize);
      // the space we are able to distribute .. (This can be negative, if we
      // have to remove space to get to the defined table size!)
      // The space that is available for the content from the cells. The
      // border-spacing eats some space as well (already in the pref-size-value)
      final long extraSpace = tableSize - preferredSize;
View Full Code Here

        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)
      {
        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
            {
View Full Code Here

TOP

Related Classes of org.jfree.layouting.renderer.border.RenderLength

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.