Package org.pentaho.reporting.libraries.css.dom

Examples of org.pentaho.reporting.libraries.css.dom.LayoutStyle


   */
  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 CSSNumericValue == false)
    {
      return;
    }

    final LayoutOutputMetaData metaData = process.getOutputMetaData();
    final int resolution = (int) metaData.getNumericFeatureValue(OutputProcessorFeature.DEVICE_RESOLUTION);
    final double fontSize = StyleSheetUtility.convertLengthToDouble(value, resolution);
    final double length = StyleSheetUtility.convertFontSizeToDouble(value, resolution, currentNode);

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


  public void resolve(final DocumentContext process,
                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    //Log.debug ("Processing: " + currentNode);
    final LayoutStyle layoutContext = currentNode.getLayoutStyle();
    final LayoutOutputMetaData outputMetaData = process.getOutputMetaData();
    final CSSValue cssValue = layoutContext.getValue(key);
    if (cssValue instanceof CSSValueList)
    {

      final CSSValueList list = (CSSValueList) cssValue;
      for (int i = 0; i < list.getLength(); i++)
      {
        final CSSValue item = list.getItem(i);
        if (item instanceof CSSConstant)
        {
          final CSSConstant c = (CSSConstant) lookupValue((CSSConstant) item);
          final CSSValue family = outputMetaData.getNormalizedFontFamilyName(c);
          if (family != null)
          {
            layoutContext.setValue(key, family);
            return;
          }
          // Ignore, although this is not ok.
          DebugLog.log("Invalid state after setting predefined font family.");
        }
        else if (item instanceof CSSStringValue)
        {
          final CSSStringValue sval = (CSSStringValue) item;
          final CSSValue value = process.getOutputMetaData().getNormalizedFontFamilyName(sval);
          if (value != null)
          {
            layoutContext.setValue(key, value);
            return;
          }
        }
      }
    }
    else if (cssValue instanceof CSSConstant)
    {
      if (FontFamilyValues.NONE.equals(cssValue))
      {
        // that means: No text at all.
        return;
      }
    }


    layoutContext.setValue(key, outputMetaData.getDefaultFontFamily());
  }
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(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

   */
  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)
    {
      super.resolve(process, currentNode, key);
    }
    else if (value instanceof CSSStringValue)
    {
      // do nothing, accept it as is...
    }
    else
    {
      layoutContext.setValue(key, getFallback());
    }
  }
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 CSSNumericValue == false)
    {
      // no limit ..
      return;
    }

    final int resolution = (int)
        process.getOutputMetaData().getNumericFeatureValue(OutputProcessorFeature.DEVICE_RESOLUTION);
    layoutContext.setValue(key, StyleSheetUtility.convertFontSize(value, resolution, currentNode));
  }
View Full Code Here

                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    // Percentages get resolved against the width of a standard space (0x20)
    // character.
    final LayoutStyle layoutContext = currentNode.getLayoutStyle();
    final FontMetrics fm = process.getOutputMetaData().getFontMetrics(layoutContext);
    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 = 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

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

    final LayoutStyle layoutContext = currentNode.getLayoutStyle();
    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

  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 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...
    }

    final double actualFontXHeight = FontStrictGeomUtility.toExternalValue(fontMetrics.getXHeight());
    final double fontSize = fontMetrics.getAscent();
    final double aspectRatio = actualFontXHeight / fontSize;
    final double result = (fontSize * (adjustFactor / aspectRatio));

    layoutContext.setValue(FontStyleKeys.FONT_SIZE, CSSNumericValue.createPtValue(result));
  }
View Full Code Here

    return new StyleKey[0];
  }

  private boolean isCounterUsed(final LayoutElement element, final String counter)
  {
    final LayoutStyle layoutContext = element.getLayoutStyle();
    final ContentSpecification contentSpecification =
        (ContentSpecification) layoutContext.getValue(InternalStyleKeys.INTERNAL_CONTENT);
    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

   */
  public void resolve(final DocumentContext process,
                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    final LayoutStyle layoutContext = currentNode.getLayoutStyle();
    final CSSValue value = layoutContext.getValue(ContentStyleKeys.MOVE_TO);

    // Maybe this is a 'normal'.
    if (MoveToValues.NORMAL.equals(value))
    {
      // todo: Some creepy special cases that require information about pseudo-elements.
//      if ("alternate".equals(layoutContext.getPseudoElement()))
//      {
//        // For '::alternate' pseudo-elements, if the superior parent uses
//        // the 'footnote' counter in its 'content' property then the computed
//        // value of 'move-to' is 'footnotes'.
//        if (isCounterUsed(currentNode.getParentLayoutElement(), "footnote"))
//        {
//          layoutContext.setValue(ContentStyleKeys.MOVE_TO,
//              new CSSStringValue(CSSStringType.STRING, "footnotes"));
//          return;
//        }
//
//        // For '::alternate' pseudo-elements, if the superior parent uses
//        // the 'endnote' counter in its 'content' property then the computed
//        // value of 'move-to' is 'endnotes'.
//        if (isCounterUsed(currentNode.getParentLayoutElement(), "endnote"))
//        {
//          layoutContext.setValue(ContentStyleKeys.MOVE_TO,
//              new CSSStringValue(CSSStringType.STRING, "endnotes"));
//          return;
//        }
//
//        // For '::alternate' pseudo-elements, if the superior parent uses
//        // the 'section-note' counter in its 'content' property then the
//        // computed value of 'move-to' is 'section-notes'.
//        if (isCounterUsed(currentNode.getParentLayoutElement(), "section-note"))
//        {
//          layoutContext.setValue(ContentStyleKeys.MOVE_TO,
//              new CSSStringValue(CSSStringType.STRING, "section-notes"));
//          return;
//        }
//      }
      layoutContext.setValue(ContentStyleKeys.MOVE_TO, MoveToValues.HERE);
    }
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.libraries.css.dom.LayoutStyle

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.