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


  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

                      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

  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

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

   */
  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 CSSStringValue)
    {
      // this is a sub-string alignment.
      return;
    }

    final CSSConstant alignValue =
            (CSSConstant) resolveValue(process, currentNode, key);
    layoutContext.setValue(TextStyleKeys.TEXT_ALIGN, alignValue);
  }
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 CSSConstant result;
    if (FontStretch.WIDER.equals(value))
    {
      // ask the parent ...
      final CSSConstant parentStretch = queryParent(currentNode.getParentLayoutElement());
      result = FontStretch.getByOrder(FontStretch.getOrder(parentStretch) + 1);
    }
    else if (FontStretch.NARROWER.equals(value))
    {
      // ask the parent ...
      final CSSConstant parentStretch = queryParent(currentNode.getParentLayoutElement());
      result = FontStretch.getByOrder(FontStretch.getOrder(parentStretch) - 1);
    }
    else if (value instanceof CSSConstant)
    {
      final CSSConstant stretch = (CSSConstant) lookupValue((CSSConstant) value);
      if (stretch != null)
      {
        result = stretch;
      }
      else
      {
        result = FontStretch.NORMAL;
      }
    }
    else
    {
      result = FontStretch.NORMAL;
    }
    layoutContext.setValue(key, result);
  }
View Full Code Here

   */
  public void resolve (final DocumentContext process,
                       final LayoutElement element,
                       final StyleKey key)
  {
    final LayoutStyle layoutContext = element.getLayoutStyle();
    final CSSValue value = layoutContext.getValue(key);
    if (value instanceof CSSValueList == false)
    {
      return; // do nothing.
    }

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.