Examples of CSSNumericValue


Examples of org.pentaho.reporting.libraries.css.values.CSSNumericValue

    final CSSValue value = layoutContext.getValue(key);
    if (value instanceof CSSNumericValue == false)
    {
      return; // do nothing
    }
    final CSSNumericValue nval = (CSSNumericValue) value;
    if (CSSNumericType.NUMBER.equals(nval.getType()) == false)
    {
      return; // syntax error, do nothing
    }
    final LayoutElement parent = currentNode.getParentLayoutElement();
    if (parent == null)
    {
      return; // no parent to resolve against ...
    }

    final double adjustFactor = nval.getValue();
    final FontMetrics fontMetrics = process.getOutputMetaData().getFontMetrics(layoutContext);
    if (fontMetrics == null)
    {
      return; // no font metrics means no valid font...
    }
View Full Code Here

Examples of org.pentaho.reporting.libraries.css.values.CSSNumericValue

      layoutContext.setValue(TextStyleKeys.X_OPTIMUM_LETTER_SPACING, CSSNumericValue.ZERO_LENGTH);
      return;
    }

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

    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

Examples of org.pentaho.reporting.libraries.css.values.CSSNumericValue

      final CSSValue value = layoutContext.getValue(FontStyleKeys.FONT_FAMILY);
      DebugLog.log ("FontFamily is " + value + " but has not been set?" + currentNode);
      return;
    }
    final double width = FontStrictGeomUtility.toExternalValue(fm.getCharWidth(0x20));
    final CSSNumericValue percentageBase =
            CSSNumericValue.createValue(CSSNumericType.PT, width);
    final CSSNumericValue min = StyleSheetUtility.convertLength
            (resolveValue(layoutContext, TextStyleKeys.X_MIN_WORD_SPACING), percentageBase, currentNode);
    final CSSNumericValue max = StyleSheetUtility.convertLength
            (resolveValue(layoutContext, TextStyleKeys.X_MAX_WORD_SPACING), percentageBase, currentNode);
    final CSSValue opt = StyleSheetUtility.convertLength
            (resolveValue(layoutContext, TextStyleKeys.X_OPTIMUM_WORD_SPACING), percentageBase, currentNode);

    layoutContext.setValue(TextStyleKeys.X_MIN_WORD_SPACING, min);
View Full Code Here

Examples of org.pentaho.reporting.libraries.css.values.CSSNumericValue

  public double getScaleLargerFactor(final double parentSize)
  {
    for (int i = 0; i < predefinedSizes.length; i++)
    {
      final CSSNumericValue size = predefinedSizes[i];
      if (parentSize < size.getValue())
      {
        return predefinedScalingFactors[i];
      }
    }
    return predefinedScalingFactors[6];
View Full Code Here

Examples of org.pentaho.reporting.libraries.css.values.CSSNumericValue

  public double getScaleSmallerFactor(final double parentSize)
  {
    for (int i = predefinedSizes.length; i >= 0; i--)
    {
      final CSSNumericValue size = predefinedSizes[i];
      if (parentSize > size.getValue())
      {
        return predefinedScalingFactors[i];
      }
    }
    return predefinedScalingFactors[0];
View Full Code Here

Examples of org.pentaho.reporting.libraries.css.values.CSSNumericValue

    if (value instanceof String)
    {
      final String strVal = (String) value;
      if ("length".equals(type))
      {
        final CSSNumericValue cssNumericValue = FunctionUtilities.parseNumberValue(strVal);
        return new StaticTextToken(cssNumericValue.getCSSText());
      }
      else if ("url".equals(type))
      {
        final CSSResourceValue cssResourceValue = FunctionUtilities.loadResource(layoutProcess, strVal);
        final Resource resource = cssResourceValue.getValue();
View Full Code Here

Examples of org.pentaho.reporting.libraries.css.values.CSSNumericValue

                                final LayoutElement element)
  {

    if (rawValue instanceof CSSNumericValue)
    {
      final CSSNumericValue nval = (CSSNumericValue) rawValue;
      return (int) nval.getValue();
    }
    if (rawValue instanceof CSSAttrFunction)
    {
      final CSSAttrFunction attrFunction = (CSSAttrFunction) rawValue;
      final String attrName = attrFunction.getName();
View Full Code Here

Examples of org.pentaho.reporting.libraries.css.values.CSSNumericValue

    if (rawValue instanceof CSSNumericValue == false)
    {
      return 0;
    }

    final CSSNumericValue value = (CSSNumericValue) rawValue;
    if (CSSNumericType.PT.equals(value.getType()))
    {
      return value.getValue();
    }
    if (CSSNumericType.PC.equals(value.getType()))
    {
      return (value.getValue() / 12.0d);
    }
    if (CSSNumericType.INCH.equals(value.getType()))
    {
      return (value.getValue() / 72.0d);
    }
    if (CSSNumericType.CM.equals(value.getType()))
    {
      return ((value.getValue() * 100 * 72.0d) / 254.0d);
    }
    if (CSSNumericType.MM.equals(value.getType()))
    {
      return ((value.getValue() * 10 * 72.0d) / 254.0d);
    }

    if (CSSNumericType.PX.equals(value.getType()))
    {
      // todo Read from a configuration file or so ..
      if (resolution <= 0)
      {
        // we assume 72 pixel per inch ...
        return value.getValue();
      }
      return value.getValue() * 72d / resolution;
    }

    return 0;
  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.css.values.CSSNumericValue

    if (rawValue instanceof CSSNumericValue == false)
    {
      return 0;
    }

    final CSSNumericValue value = (CSSNumericValue) rawValue;
    if (CSSNumericType.PT.equals(value.getType()))
    {
      return value.getValue();
    }
    if (CSSNumericType.PC.equals(value.getType()))
    {
      return (value.getValue() / 12.0d);
    }
    if (CSSNumericType.INCH.equals(value.getType()))
    {
      return (value.getValue() / 72.0d);
    }
    if (CSSNumericType.CM.equals(value.getType()))
    {
      return ((value.getValue() * 100 * 72.0d) / 254.0d);
    }
    if (CSSNumericType.MM.equals(value.getType()))
    {
      return ((value.getValue() * 10 * 72.0d) / 254.0d);
    }

    if (CSSNumericType.PX.equals(value.getType()))
    {
      // todo Read from a configuration file or so ..
      if (resolution <= 0)
      {
        // we assume 72 pixel per inch ...
        return value.getValue();
      }
      return value.getValue() * 72d / resolution;
    }

    if (baseElement != null)
    {

      if (CSSNumericType.EM.equals(value.getType()))
      {
        // base is the font-size
        final CSSValue baseVal = baseElement.getLayoutStyle().getValue(FontStyleKeys.FONT_SIZE);
        return value.getValue() * convertLengthToDouble(baseVal, resolution);
      }
      if (CSSNumericType.EX.equals(value.getType()))
      {
        // base is the parent font's x-height.
        final CSSValue baseVal = baseElement.getLayoutStyle().getValue(FontStyleKeys.FONT_SIZE);
        // todo: cheating for now: We assume a sensible default and do not ask the font system.
        return value.getValue() * convertLengthToDouble(baseVal, resolution) * 0.58;
      }
      if (CSSNumericType.PERCENTAGE.equals(value.getType()))
      {
        final CSSValue baseVal = baseElement.getLayoutStyle().getValue(FontStyleKeys.FONT_SIZE);
        return value.getValue() * convertLengthToDouble(baseVal, resolution) / 100d;
      }

    }

    return 0;
View Full Code Here

Examples of org.pentaho.reporting.libraries.css.values.CSSNumericValue

  {
    if (rawValue instanceof CSSNumericValue == false)
    {
      return rawValue;
    }
    final CSSNumericValue value = (CSSNumericValue) rawValue;
    if (baseElement != null)
    {

      final CSSValue baseVal = baseElement.getLayoutStyle().getValue(FontStyleKeys.FONT_SIZE);
      if (baseVal instanceof CSSNumericValue == false)
      {
        return CSSNumericValue.ZERO_LENGTH;
      }
     
      final CSSNumericValue baseNValue = (CSSNumericValue) baseVal;
      if (CSSNumericType.EM.equals(value.getType()))
      {
        // base is the font-size
        return CSSNumericValue.createValue(baseNValue.getNumericType(), value.getValue() * baseNValue.getValue());
      }
      if (CSSNumericType.EX.equals(value.getType()))
      {
        // base is the parent font's x-height.
        // todo: cheating for now: We assume a sensible default and do not ask the font system.
        return CSSNumericValue.createValue(baseNValue.getNumericType(), value.getValue() * baseNValue.getValue() * 0.58);
      }
      if (CSSNumericType.PERCENTAGE.equals(value.getType()))
      {
        return CSSNumericValue.createValue(baseNValue.getNumericType(), value.getValue() * baseNValue.getValue() / 100d);
      }

    }

    return rawValue;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.