Package org.pentaho.reporting.libraries.css.values

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


      return;
    }

    if (key != null)
    {
      CSSValue cssValue = createValue(key, value);
      if (cssValue != null)
      {
        rule.setPropertyValue(key, cssValue, important);
        //Log.debug ("Got value " + key.getName() + " = " + cssValue + "(" + cssValue.getClass() + ") - (important = " + important + ")");
        return;
      }
    }

    final CSSCompoundValueReadHandler module =
        (CSSCompoundValueReadHandler) compoundHandlers.get(normalizedName);
    if (module == null)
    {
      if (key == null)
      {
        logger.info("Unknown style-key: Neither compound handlers nor single-value handers are registered for " + normalizedName);
        return;
      }

      logger.warn("Unparsable value: Got no valid result for " + normalizedName + " (" + value + ')');
      return; // ignore this rule ..
    }

    Map map = module.createValues(value);
    if (map == null)
    {
      return;
    }
    Iterator iterator = map.entrySet().iterator();
    while (iterator.hasNext())
    {
      Map.Entry entry = (Map.Entry) iterator.next();
      StyleKey entryKey = (StyleKey) entry.getKey();
      CSSValue mapCssValue = (CSSValue) entry.getValue();

      rule.setPropertyValue(entryKey, mapCssValue, important);
      //Log.debug ("Got value " + entryKey.getName() + " = " + mapCssValue + "(" + mapCssValue.getClass() + ") - (important = " + important + ")");
    }
  }
View Full Code Here


    final boolean[] importantFlags = elementRule.getImportantValues();
    final CSSValue[] values = elementRule.getStyleValues();
    final StyleKey[] keys = elementRule.getPropertyKeysAsArray();
    for (int i = 0; i < values.length; i++)
    {
      final CSSValue cssValue = values[i];
      if (cssValue != null)
      {
        final StyleKey propertyName = keys[i];
        setPropertyValue(propertyName, cssValue, importantFlags[i] && isImportant(propertyName));
      }
View Full Code Here

      final boolean[] importantFlags = cssValues.getImportantValues();
      final CSSValue[] values = cssValues.getStyleValues();
      final StyleKey[] keys = cssValues.getPropertyKeysAsArray();
      for (int i = 0; i < values.length; i++)
      {
        final CSSValue cssValue = values[i];
        if (cssValue != null)
        {
          setPropertyValue(keys[i], cssValue, importantFlags[i]);
        }
      }
View Full Code Here

                       final StyleKey key)
  {
    final LayoutStyle layoutContext = element.getLayoutStyle();
    final ContentSpecification contentSpecification =
        (ContentSpecification) layoutContext.getValue(InternalStyleKeys.INTERNAL_CONTENT);
    final CSSValue value = layoutContext.getValue(key);
    if (value instanceof CSSConstant)
    {
      if (ContentValues.NONE.equals(value))
      {
        contentSpecification.setStrings(XAlternateTextResolveHandler.DEFAULT_CONTENT);
        return;
      }
    }

    contentSpecification.setStrings(XAlternateTextResolveHandler.DEFAULT_CONTENT);
    if (value instanceof CSSAttrFunction)
    {
      final ContentToken token =
              evaluateFunction((CSSFunctionValue) value, process, element);
      if (token == null)
      {
        return;
      }
      contentSpecification.setStrings(new ContentToken[]{token});
    }

    if (value instanceof CSSValueList == false)
    {
      return; // cant handle that one
    }

    final ArrayList tokens = new ArrayList();
    final CSSValueList list = (CSSValueList) value;
    final int size = list.getLength();
    for (int i = 0; i < size; i++)
    {
      final CSSValueList sequence = (CSSValueList) list.getItem(i);
      for (int j = 0; j < sequence.getLength(); j++)
      {
        final CSSValue content = sequence.getItem(j);
        final ContentToken token = createToken(process, element, content);
        if (token == null)
        {
          // ok, a failure. Skip to the next content spec ...
          tokens.clear();
View Full Code Here

  {
    final StyleValueFunction styleFunction =
            FunctionFactory.getInstance().getStyleFunction(function.getFunctionName());
    try
    {
      final CSSValue value = styleFunction.evaluate(process, element, function);
      if (value instanceof CSSResourceValue)
      {
        final CSSResourceValue refValue = (CSSResourceValue) value;
        return new ResourceContentToken(refValue.getValue());
      }
      else if (value instanceof CSSStringValue)
      {
        final CSSStringValue strval = (CSSStringValue) value;
        return new StaticTextToken(strval.getValue());
      }
      else if (value instanceof CSSRawValue)
      {
        final CSSRawValue rawValue = (CSSRawValue) value;
        return new ExternalContentToken(rawValue.getValue());
      }
      return new StaticTextToken(value.getCSSText());
    }
    catch (FunctionEvaluationException e)
    {
      DebugLog.log("Evaluation failed " + e);
      return null;
View Full Code Here

  public void resolve(final DocumentContext process,
                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    final LayoutStyle layoutContext = currentNode.getLayoutStyle();
    final CSSValue value = layoutContext.getValue(key);
    if (value instanceof CSSConstant == false)
    {
      // fine, we're done here ...
      return;
    }

    final LayoutOutputMetaData metaData = process.getOutputMetaData();
    final int resolution = (int) metaData.getNumericFeatureValue(OutputProcessorFeature.DEVICE_RESOLUTION);

    final CSSConstant constant = (CSSConstant) value;
    final LayoutElement parent = currentNode.getParentLayoutElement();
    if (parent != null)
    {
      final CSSValue parentFontSizeValue = parent.getLayoutStyle().getValue(FontStyleKeys.FONT_SIZE);

      final double parentFontSize = StyleSheetUtility.convertLengthToDouble(parentFontSizeValue, resolution);
      if (RelativeFontSize.LARGER.equals(value))
      {
        final double scaleFactor = getScaleLargerFactor(parentFontSize);
        layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PERCENTAGE, scaleFactor));
        return;
      }

      if (RelativeFontSize.SMALLER.equals(value))
      {
        final double scaleFactor = getScaleSmallerFactor(parentFontSize);
        layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PERCENTAGE, scaleFactor));
        return;
      }
    }
    else
    {
      // we might not have a parent, but that won't stop us ..
      if (RelativeFontSize.LARGER.equals(value))
      {
        layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PERCENTAGE, 120));
        return;
      }

      if (RelativeFontSize.SMALLER.equals(value))
      {
        layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PERCENTAGE, 85));
        return;
      }
    }

    final CSSValue resolvedValue = lookupValue(constant);
    if (resolvedValue != null)
    {
      layoutContext.setValue(key, resolvedValue);
    }
  }
View Full Code Here

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

                       final StyleKey key)
  {
    final LayoutStyle layoutContext = element.getLayoutStyle();
    final ContentSpecification contentSpecification =
        (ContentSpecification) layoutContext.getValue(InternalStyleKeys.INTERNAL_CONTENT);
    final CSSValue value = layoutContext.getValue(key);
    if (value instanceof CSSConstant)
    {
      if (ContentValues.NONE.equals(value))
      {
        contentSpecification.setStrings(DEFAULT_CONTENT);
        return;
      }
    }

    contentSpecification.setStrings(DEFAULT_CONTENT);
    if (value instanceof CSSAttrFunction)
    {
      final ContentToken token =
              evaluateFunction((CSSFunctionValue) value, process, element);
      if (token == null)
      {
        return;
      }
      contentSpecification.setStrings(new ContentToken[]{token});
    }

    if (value instanceof CSSValueList == false)
    {
      return; // cant handle that one
    }

    final ArrayList tokens = new ArrayList();
    final CSSValueList list = (CSSValueList) value;
    final int size = list.getLength();
    for (int i = 0; i < size; i++)
    {
      final CSSValueList sequence = (CSSValueList) list.getItem(i);
      for (int j = 0; j < sequence.getLength(); j++)
      {
        final CSSValue content = sequence.getItem(j);
        final ContentToken token = createToken(process, element, content);
        if (token == null)
        {
          // ok, a failure. Skip to the next content spec ...
          tokens.clear();
View Full Code Here

  {
    final StyleValueFunction styleFunction =
            FunctionFactory.getInstance().getStyleFunction(function.getFunctionName());
    try
    {
      final CSSValue value = styleFunction.evaluate(process, element, function);
      if (value instanceof CSSResourceValue)
      {
        final CSSResourceValue refValue = (CSSResourceValue) value;
        return new ResourceContentToken(refValue.getValue());
      }
      else if (value instanceof CSSStringValue)
      {
        final CSSStringValue strval = (CSSStringValue) value;
        return new StaticTextToken(strval.getValue());
      }
      else if (value instanceof CSSRawValue)
      {
        final CSSRawValue rawValue = (CSSRawValue) value;
        return new ExternalContentToken(rawValue.getValue());
      }
      return new StaticTextToken(value.getCSSText());
    }
    catch (FunctionEvaluationException e)
    {
//      Log.debug ("Evaluation failed " + e);
      return null;
View Full Code Here

  public void resolve(final DocumentContext process,
                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    final LayoutStyle layoutContext = currentNode.getLayoutStyle();
    final CSSValue value = layoutContext.getValue(key);
    final int fontWeight;
    if (FontWeight.BOLD.equals(value))
    {
      // ask the parent ...
      fontWeight = 700;
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.libraries.css.values.CSSValue

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.