Package org.jfree.layouting.layouter.context

Examples of org.jfree.layouting.layouter.context.LayoutContext


  }

  public void performResolve(final LayoutProcess process,
                             final LayoutElement node)
  {
    final LayoutContext layoutContext = node.getLayoutContext();
    for (int i = 0; i < handlers.length; i++)
    {
      final ResolveHandlerModule handler = handlers[i];
      final StyleKey key = handler.getKey();
      final CSSValue value = layoutContext.getValue(key);

      final ResolveHandler autoValueHandler = handler.getAutoValueHandler();
      if (autoValueHandler != null)
      {
        if (value instanceof CSSAutoValue)
View Full Code Here


                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    // Percentages get resolved against the width of a standard space (0x20)
    // character.
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final FontSpecification fontSpecification =
            layoutContext.getFontSpecification();
    final FontMetrics fm = process.getOutputMetaData().getFontMetrics(fontSpecification);
    if (fm == null)
    {
      // we have no font family, so return.
      layoutContext.setValue(TextStyleKeys.X_MIN_LETTER_SPACING, CSSNumericValue.ZERO_LENGTH);
      layoutContext.setValue(TextStyleKeys.X_MAX_LETTER_SPACING, CSSNumericValue.ZERO_LENGTH);
      layoutContext.setValue(TextStyleKeys.X_OPTIMUM_LETTER_SPACING, CSSNumericValue.ZERO_LENGTH);
      return;
    }

    final double width = StrictGeomUtility.toExternalValue(fm.getCharWidth(0x20));
    final CSSNumericValue percentageBase =
            CSSNumericValue.createValue(CSSNumericType.PT, width);
    final CSSNumericValue min = CSSValueResolverUtility.getLength
            (resolveValue(layoutContext, TextStyleKeys.X_MIN_LETTER_SPACING), percentageBase);
    final CSSNumericValue max = CSSValueResolverUtility.getLength
            (resolveValue(layoutContext, TextStyleKeys.X_MAX_LETTER_SPACING), percentageBase);
    final CSSNumericValue opt = CSSValueResolverUtility.getLength
            (resolveValue(layoutContext, TextStyleKeys.X_OPTIMUM_LETTER_SPACING), percentageBase);

    layoutContext.setValue(TextStyleKeys.X_MIN_LETTER_SPACING, min);
    layoutContext.setValue(TextStyleKeys.X_MAX_LETTER_SPACING, max);
    layoutContext.setValue(TextStyleKeys.X_OPTIMUM_LETTER_SPACING, opt);
  }
View Full Code Here

                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    // Percentages get resolved against the width of a standard space (0x20)
    // character.
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final FontSpecification fontSpecification =
            layoutContext.getFontSpecification();
    final FontMetrics fm = process.getOutputMetaData().getFontMetrics(fontSpecification);
    if (fm == null)
    {
      final CSSValue value = layoutContext.getValue(FontStyleKeys.FONT_FAMILY);
      DebugLog.log("FontFamily is " + value + " but has not been set?" + currentNode);
      return;
    }
    final double width = StrictGeomUtility.toExternalValue(fm.getCharWidth(0x20));
    final CSSNumericValue percentageBase =
            CSSNumericValue.createValue(CSSNumericType.PT, width);
    final CSSNumericValue min = CSSValueResolverUtility.getLength
            (resolveValue(layoutContext, TextStyleKeys.X_MIN_WORD_SPACING), percentageBase);
    final CSSNumericValue max = CSSValueResolverUtility.getLength
            (resolveValue(layoutContext, TextStyleKeys.X_MAX_WORD_SPACING), percentageBase);
    final CSSNumericValue opt = CSSValueResolverUtility.getLength
            (resolveValue(layoutContext, TextStyleKeys.X_OPTIMUM_WORD_SPACING), percentageBase);

    layoutContext.setValue(TextStyleKeys.X_MIN_WORD_SPACING, min);
    layoutContext.setValue(TextStyleKeys.X_MAX_WORD_SPACING, max);
    layoutContext.setValue(TextStyleKeys.X_OPTIMUM_WORD_SPACING, opt);
  }
View Full Code Here

   */
  public void resolve(final LayoutProcess process,
                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final CSSValue value = layoutContext.getValue(key);
    if (value instanceof CSSNumericValue == false)
    {
      return;
    }

    final double fontSize =
            (currentNode.getLayoutContext().getFontSpecification().getFontSize());
    final double length = CSSValueResolverUtility.convertLengthToDouble
            (value, currentNode.getLayoutContext(), process.getOutputMetaData());

    if (fontSize < length)
    {
      layoutContext.setValue(FontStyleKeys.X_FONT_SMOOTH_FLAG, FontSmooth.NEVER);
    }
    else
    {
      layoutContext.setValue(FontStyleKeys.X_FONT_SMOOTH_FLAG, FontSmooth.ALWAYS);
    }
  }
View Full Code Here

   */
  public void resolve(final LayoutProcess process,
                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final CSSValue value = layoutContext.getValue(key);
    if (value instanceof CSSNumericValue == false)
    {
      // no limit ..
      return;
    }

    final CSSNumericValue size = CSSValueResolverUtility.convertLength
          (value, layoutContext, process.getOutputMetaData());

    layoutContext.setValue(key, size);
  }
View Full Code Here

  protected CSSValue resolveValue (final LayoutProcess process,
                                   final LayoutElement currentNode,
                                   final StyleKey key)
  {
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final CSSValue value = layoutContext.getValue(key);
    if (value instanceof CSSConstant == false)
    {
      final CSSValue fallback = getFallback();
      if (fallback != null)
      {
View Full Code Here

  public void resolve(final LayoutProcess process,
                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final CSSValue value = layoutContext.getValue(key);
    if (value instanceof CSSNumericValue == false)
    {
      return; // do nothing
    }
    final CSSNumericValue nval = (CSSNumericValue) value;
View Full Code Here

   */
  public void resolve(final LayoutProcess process,
                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final CSSValue value = layoutContext.getValue(PageStyleKeys.SIZE);

    String name = null;
    if (value instanceof CSSStringValue)
    {
      final CSSStringValue sval = (CSSStringValue) value;
      name = sval.getValue();
    }
    else if (value instanceof CSSConstant)
    {
      name = value.toString();
    }

    PageSize ps = null;
    if (name != null)
    {
      ps = PageSizeFactory.getInstance().getPageSizeByName(name);
    }

    if (ps == null)
    {
      ps = process.getOutputMetaData().getDefaultPageSize();
    }
    // if it is stll null, then the output target is not valid.
    // We will crash in that case ..
    final CSSValue page =
        new CSSValuePair(CSSNumericValue.createPtValue(ps.getWidth()),
            CSSNumericValue.createPtValue(ps.getHeight()));
    layoutContext.setValue(PageStyleKeys.SIZE, page);
  }
View Full Code Here

    {
      // invalid
      throw new IllegalArgumentException("This is not a valid key: " + key);
    }

    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final CSSValue borderStyle = layoutContext.getValue(borderStyleKey);
    if (BorderStyle.NONE.equals(borderStyle))
    {
      return CSSNumericValue.ZERO_LENGTH;
    }

    final CSSValue value = layoutContext.getValue(key);
    if (value instanceof CSSConstant)
    {
      return super.resolveValue(process, currentNode, key);
    }
    return value;
View Full Code Here

    return new StyleKey[0];
  }

  private boolean isCounterUsed (final LayoutElement element, final String counter)
  {
    final LayoutContext layoutContext = element.getLayoutContext();
    final ContentSpecification contentSpecification =
        layoutContext.getContentSpecification();
    final ContentToken[] contents = contentSpecification.getContents();
    for (int i = 0; i < contents.length; i++)
    {
      ContentToken content = contents[i];
      if (content instanceof ResolvedCounterToken)
View Full Code Here

TOP

Related Classes of org.jfree.layouting.layouter.context.LayoutContext

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.