Examples of LayoutStyle


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

                      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

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

    {
      // 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

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; // 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

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

    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

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(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

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 displayRole = layoutContext.getValue(BoxStyleKeys.DISPLAY_ROLE);
    final CSSValue floating;
    if (DisplayRole.NONE.equals(displayRole))
    {
      floating = Floating.NONE;
    }
    else
    {
      floating = resolveValue(process, currentNode, key);
    }

    if (Floating.NONE.equals(floating) == false)
    {
      //  Otherwise, if 'float' has a value other than 'none', 'display'
      // is set to 'block' and the box is floated.
      layoutContext.setValue(BoxStyleKeys.DISPLAY_MODEL, DisplayModel.BLOCK_INSIDE);
      layoutContext.setValue(BoxStyleKeys.DISPLAY_ROLE, DisplayRole.BLOCK);
    }

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

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 CSSConstant == false)
    {
      // fine, we're done here ...
      return;
    }
    final CSSConstant constant = (CSSConstant) value;
    // parent font size has been resolved already. Parent is the resolved font size of this element.


    final LayoutOutputMetaData metaData = process.getOutputMetaData();
    final int resolution = (int) metaData.getNumericFeatureValue(OutputProcessorFeature.DEVICE_RESOLUTION);
    final CSSValue fontSizeValue = currentNode.getLayoutStyle().getValue(FontStyleKeys.FONT_SIZE);
    final double fontSize = StyleSheetUtility.convertLengthToDouble(fontSizeValue, resolution);
    if (RelativeFontSize.LARGER.equals(value))
    {
      final double scaleFactor = getScaleLargerFactor(fontSize);
      layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PERCENTAGE, scaleFactor));
    }
    else if (RelativeFontSize.SMALLER.equals(value))
    {
      final double scaleFactor = getScaleSmallerFactor(fontSize);
      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

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

                      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)
    {
      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);
    layoutContext.setValue(TextStyleKeys.X_MAX_WORD_SPACING, max);
    layoutContext.setValue(TextStyleKeys.X_OPTIMUM_WORD_SPACING, opt);
  }
View Full Code Here

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);
    final LayoutElement parent = currentNode.getParentLayoutElement();

    if (value instanceof CSSNumericValue == false)
    {
      if (parent == null)
      {
        layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PT, baseFontSize));
      }
      else
      {
        final LayoutStyle parentContext = parent.getLayoutStyle();
        layoutContext.setValue(key, parentContext.getValue(key));
      }
      return;
    }

    final int resolution = (int)
View Full Code Here

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 rawValue = layoutContext.getValue(key);
    if (rawValue instanceof CSSValueList == false)
    {
      return;
    }
    final ArrayList quotes = new ArrayList();
    final CSSValueList list = (CSSValueList) rawValue;
    final int length = (list.getLength() % 2);
    for (int i = 0; i < length; i++)
    {
      final CSSValue openValue = list.getItem(i * 2);
      final CSSValue closeValue = list.getItem(i * 2 + 1);

      if (openValue instanceof CSSStringValue == false)
      {
        continue;
      }
      if (closeValue instanceof CSSStringValue == false)
      {
        continue;
      }

      final CSSStringValue openQuote = (CSSStringValue) openValue;
      final CSSStringValue closeQuote = (CSSStringValue) closeValue;
      quotes.add(new QuotesPair(openQuote.getValue(), closeQuote.getValue()));
    }

    if (quotes.isEmpty())
    {
      return;
    }

    final QuotesPair[] quotesArray =
        (QuotesPair[]) quotes.toArray(new QuotesPair[quotes.size()]);
    final ContentSpecification contentSpecification =
        (ContentSpecification) layoutContext.getValue(InternalStyleKeys.INTERNAL_CONTENT);
    contentSpecification.setQuotes(quotesArray);
  }
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.