Package org.jfree.layouting.layouter.context

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


   */
  public void resolve (final LayoutProcess process,
                       final LayoutElement currentNode,
                       final StyleKey key)
  {
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final CSSValue value = layoutContext.getValue(key);
    if (LineHeight.NONE.equals(value))
    {
      // query the anchestor, if there's one ..
      handleNone(currentNode);
      return;
    }

    if (LineHeight.NORMAL.equals(value))
    {
      handleNormal(currentNode);
      return;
    }

    if (value instanceof CSSNumericValue == false)
    {
      // fall back to normal ..
      handleNormal(currentNode);
      return;
    }
    final CSSNumericValue nval = (CSSNumericValue) value;

    if (CSSValueResolverUtility.isLengthValue(nval))
    {
      layoutContext.setValue(LineStyleKeys.LINE_HEIGHT, nval);
      return;
    }

    final double factor;
    if (nval.getType().equals(CSSNumericType.PERCENTAGE))
    {
      factor = nval.getValue() / 100d;
    }
    else if (nval.getType().equals(CSSNumericType.NUMBER))
    {
      factor = nval.getValue();
    }
    else
    {
      handleNormal(currentNode);
      return;
    }


    final double fontSize = layoutContext.getFontSpecification().getFontSize();
    layoutContext.setValue(LineStyleKeys.LINE_HEIGHT,
            CSSNumericValue.createValue(CSSNumericType.PT, fontSize * factor));

  }
View Full Code Here


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

    if (value instanceof CSSColorValue)
    {
      return;
    }


    // it might as well be a RGB- or HSL- function.
    if (value instanceof CSSFunctionValue)
    {
      final CSSFunctionValue functionValue = (CSSFunctionValue) value;
      final StyleValueFunction function =
              FunctionFactory.getInstance().getStyleFunction
                      (functionValue.getFunctionName());
      if (function == null)
      {
        value = HtmlColors.BLACK;
      }
      else
      {
        try
        {
          value = function.evaluate(process, currentNode, functionValue);
        }
        catch (FunctionEvaluationException e)
        {
          value = HtmlColors.BLACK;
        }
      }

      if (value instanceof CSSColorValue)
      {
        style.setValue(key, value);
        return;
      }
    }


    if (value instanceof CSSConstant == false)
    {
      style.setValue(key, HtmlColors.BLACK);
      return;
    }
    if (CSSSystemColors.CURRENT_COLOR.equals(value))
    {
      style.setValue(key, getCurrentColor(currentNode));
      return;
    }

    final CSSValue c = ColorUtil.parseIdentColor(value.getCSSText());
    if (c != null)
    {
      style.setValue(key, c);
    }
    else
    {
      style.setValue(key, HtmlColors.BLACK);
    }
  }
View Full Code Here

                               final ContentSpecification contentSpecification)
  {
    contentSpecification.setAllowContentProcessing(false);
    contentSpecification.setInhibitContent(false);

    final LayoutContext layoutContext = element.getLayoutContext();
    final CSSValue value =
        layoutContext.getValue(ListStyleKeys.LIST_STYLE_IMAGE);
    if (value != null)
    {
      final ContentToken token = createToken(process, element, value);
      if (token != null)
      {
View Full Code Here

    }
  }

  private boolean isListMarker (final LayoutElement element)
  {
    final LayoutContext layoutContext = element.getLayoutContext();
    if ("marker".equals(layoutContext.getPseudoElement()) == false)
    {
       return false;
    }
    final LayoutElement parent = element.getParent();
    if (parent == null)
View Full Code Here

  }

  private void handleNormal (final LayoutElement currentNode)
  {
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final double fontSize = layoutContext.getFontSpecification().getFontSize();
    if (fontSize < 10)
    {
      layoutContext.setValue(LineStyleKeys.LINE_HEIGHT,
              CSSNumericValue.createValue(CSSNumericType.PT, fontSize * 1.2));
    }
    else if (fontSize < 24)
    {
      layoutContext.setValue(LineStyleKeys.LINE_HEIGHT,
              CSSNumericValue.createValue(CSSNumericType.PT, fontSize * 1.1));
    }
    else
    {
      layoutContext.setValue(LineStyleKeys.LINE_HEIGHT,
              CSSNumericValue.createValue(CSSNumericType.PT, fontSize * 1.05));
    }

  }
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 CSSConstant == false)
    {
      // fine, we're done here ...
      return ;
    }
    final CSSConstant constant = (CSSConstant) value;
    final double parentFontSize =
            currentNode.getLayoutContext().getFontSpecification().getFontSize();
    if (RelativeFontSize.LARGER.equals(value))
    {
      final double scaleFactor = getScaleLargerFactor(parentFontSize);
      layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PERCENTAGE, scaleFactor));
    }
    else if (RelativeFontSize.SMALLER.equals(value))
    {
      final double scaleFactor = getScaleSmallerFactor(parentFontSize);
      layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PERCENTAGE, scaleFactor));
    }

    final CSSValue resolvedValue = lookupValue(constant);
    if (resolvedValue != null)
    {
      layoutContext.setValue(key, resolvedValue);
      return;
    }
    if (key.equals(FontStyleKeys.MAX_FONT_SIZE))
    {
      // there is no upper limit if the value is invalid
      layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PT, Short.MAX_VALUE));
    }
    else
    {
      // there is no lower limit if the value is invalid
      layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PT, 0));
    }
  }
View Full Code Here

  protected CSSColorValue getCurrentColor (final LayoutElement currentNode)
  {
    final LayoutElement parent = currentNode.getParent();
    if (parent != null)
    {
      final LayoutContext layoutContext = parent.getLayoutContext();
      final CSSValue value = layoutContext.getValue(ColorStyleKeys.COLOR);
      if (value instanceof CSSColorValue)
      {
        return (CSSColorValue) value;
      }
    }
View Full Code Here

  private void handleNone (final LayoutElement currentNode)
  {
    final double fontSize;
    final LayoutElement parent = currentNode.getParent();
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    if (parent == null)
    {
      // fall back to normal;
      fontSize = layoutContext.getFontSpecification().getFontSize();
    }
    else
    {
      fontSize = parent.getLayoutContext().getFontSpecification().getFontSize();
    }
    layoutContext.setValue(LineStyleKeys.LINE_HEIGHT, CSSNumericValue.createValue(CSSNumericType.PT, fontSize));
  }
View Full Code Here

    return new StyleKey[]{ColorStyleKeys.COLOR};
  }

  protected CSSColorValue getCurrentColor(final LayoutElement currentNode)
  {
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final CSSValue value = layoutContext.getValue(ColorStyleKeys.COLOR);
    if (value instanceof CSSColorValue)
    {
      return (CSSColorValue) value;
    }
    else
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 (FontVariant.SMALL_CAPS.equals(value))
    {
      layoutContext.setValue(key, FontVariant.SMALL_CAPS);
    }
    else
    {
      layoutContext.setValue(key, FontVariant.NORMAL);
    }
  }
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.