Package org.jfree.layouting.layouter.context

Examples of org.jfree.layouting.layouter.context.LayoutContext


   */
  public void resolve (final LayoutProcess process,
                       final LayoutElement element,
                       final StyleKey key)
  {
    final LayoutContext layoutContext = element.getLayoutContext();
    final CSSValue displayRole = layoutContext.getValue(BoxStyleKeys.DISPLAY_ROLE);
    if (DisplayRole.NONE.equals(displayRole))
    {
      // [GENERATED] 8.3. Counters in elements with 'display: none'
      //
      // An element that is not displayed ('display' set to 'none') cannot
      // increment or reset a counter.
      return;
    }

    final CSSValue value = layoutContext.getValue(key);
    if (value instanceof CSSValueList == false)
    {
      return; // do nothing.
    }

View Full Code Here


   */
  public void resolve(final LayoutProcess process,
                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final CSSValue value = layoutContext.getValue(key);
    if (FontSmooth.ALWAYS.equals(value))
    {
      layoutContext.setValue(FontStyleKeys.X_FONT_SMOOTH_FLAG, FontSmooth.ALWAYS);
    }
    else if (FontSmooth.NEVER.equals(value))
    {
      layoutContext.setValue(FontStyleKeys.X_FONT_SMOOTH_FLAG, FontSmooth.NEVER);
    }
  }
View Full Code Here

   */
  public void resolve(final LayoutProcess process,
                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final CSSValue value = layoutContext.getValue(key);
    final CSSConstant result;
    if (FontStretch.WIDER.equals(value))
    {
      // ask the parent ...
      final CSSConstant parentStretch = queryParent(currentNode.getParent());
      result = FontStretch.getByOrder(FontStretch.getOrder(parentStretch) + 1);
    }
    else if (FontStretch.NARROWER.equals(value))
    {
      // ask the parent ...
      final CSSConstant parentStretch = queryParent(currentNode.getParent());
      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 LayoutProcess process,
                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    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 LayoutProcess process,
                       final LayoutElement element,
                       final StyleKey key)
  {
    final LayoutContext layoutContext = element.getLayoutContext();
    final ContentSpecification contentSpecification =
            layoutContext.getContentSpecification();
    final CSSValue value = layoutContext.getValue(key);
    if (value instanceof CSSConstant)
    {
      if (ContentValues.NONE.equals(value))
      {
        contentSpecification.setStrings(XAlternateTextResolveHandler.DEFAULT_CONTENT);
View Full Code Here

   */
  public void resolve(final LayoutProcess process,
                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final CSSValue value = layoutContext.getValue(key);
    if (value instanceof CSSConstant == false)
    {
      // fine, we're done here ...
      return;
    }
    final CSSConstant constant = (CSSConstant) value;
    final LayoutElement parent = currentNode.getParent();
    if (parent != null)
    {
      final double parentFontSize =
              parent.getLayoutContext().getFontSpecification().getFontSize();
      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);
      return;
    }

    // do not change the font size..
    layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PERCENTAGE, 100));
  }
View Full Code Here

                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    // as this is an 'auto' handler, we can assume that 'auto' is the
    // current value
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final FontSpecification fs =
            layoutContext.getFontSpecification();
    final double threshold =
            process.getOutputMetaData().getNumericFeatureValue
            (OutputProcessorFeature.FONT_SMOOTH_THRESHOLD);
    if (fs.getFontSize() < threshold)
    {
      layoutContext.setValue(FontStyleKeys.X_FONT_SMOOTH_FLAG, FontSmooth.NEVER);
    }
    else
    {
      layoutContext.setValue(FontStyleKeys.X_FONT_SMOOTH_FLAG, FontSmooth.ALWAYS);
    }
  }
View Full Code Here

  public void resolve (final LayoutProcess process,
                       final LayoutElement currentNode,
                       final StyleKey key)
  {

    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final CSSValue displayModel = layoutContext.getValue(BoxStyleKeys.DISPLAY_MODEL);
    if (DisplayRole.NONE.equals(displayModel))
    {
      // skip ... the element will not be displayed ...
      layoutContext.setValue(PositioningStyleKeys.POSITION, Position.STATIC);
      return;
    }

    final CSSValue rawValue = layoutContext.getValue(key);
    if (rawValue instanceof CSSFunctionValue)
    {
      // OK; check for pending ..
      final CSSFunctionValue function = (CSSFunctionValue) rawValue;
      if ("running".equals(function.getFunctionName()))
      {
        // The element will be inside a block-context (same behaviour as
        // for floats)
        layoutContext.setValue(BoxStyleKeys.DISPLAY_MODEL, DisplayModel.BLOCK_INSIDE);
        layoutContext.setValue(BoxStyleKeys.DISPLAY_ROLE, DisplayRole.BLOCK);
        return;
      }
      layoutContext.setValue(PositioningStyleKeys.POSITION, Position.STATIC);
      return;
    }

    final CSSConstant value = (CSSConstant) resolveValue(process, currentNode, key);
    layoutContext.setValue(PositioningStyleKeys.POSITION, value);
    if (Position.ABSOLUTE.equals(value) ||
        Position.FIXED.equals(value))
    {
      // http://www.w3.org/TR/REC-CSS2/visuren.html#propdef-float
      // this is specified in 9.7: Relationships between 'display',
      // 'position', and 'float':

      // Quote: Otherwise, 'position' has the value 'absolute' or 'fixed',
      // 'display' is set to 'block' and 'float' is set to 'none'. The position
      // of the box will be determined by the 'top', 'right', 'bottom' and
      // 'left' properties and the box's containing block.
      layoutContext.setValue(BoxStyleKeys.DISPLAY_MODEL, DisplayModel.BLOCK_INSIDE);
      layoutContext.setValue(BoxStyleKeys.DISPLAY_ROLE, DisplayRole.BLOCK);
      layoutContext.setValue(BoxStyleKeys.FLOAT, Floating.NONE);
    }
  }
View Full Code Here

   */
  public void resolve(final LayoutProcess process,
                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final CSSValue value = layoutContext.getValue(key);
    final int fontWeight;
    if (FontWeight.BOLD.equals(value))
    {
      // ask the parent ...
      fontWeight = 700;
    }
    else if (FontWeight.NORMAL.equals(value))
    {
      // ask the parent ...
      fontWeight = 400;
    }
    else if (FontWeight.BOLDER.equals(value))
    {
      final int parentFontWeight = queryParent(currentNode.getParent());
      fontWeight = Math.max (900, parentFontWeight + 100);
    }
    else if (FontWeight.LIGHTER.equals(value))
    {
      final int parentFontWeight = queryParent(currentNode.getParent());
      fontWeight = Math.min (100, parentFontWeight - 100);
    }
    else if (value instanceof CSSNumericValue)
    {
      final CSSNumericValue nval = (CSSNumericValue) value;
      if (CSSNumericType.NUMBER.equals(nval.getType()) == false)
      {
        // preserve the parent's weight...
        fontWeight = queryParent(currentNode.getParent());
      }
      else
      {
        fontWeight = (int) nval.getValue();
      }
    }
    else
    {
      fontWeight = queryParent(currentNode.getParent());
    }

    layoutContext.setValue(FontStyleKeys.FONT_WEIGHT, CSSNumericValue.createValue(CSSNumericType.NUMBER, fontWeight));
  }
View Full Code Here

   */
  public void resolve (final LayoutProcess process,
                       final LayoutElement currentNode,
                       final StyleKey key)
  {
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    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()]);
    layoutContext.getContentSpecification().setQuotes(quotesArray);
  }
View Full Code Here

TOP

Related Classes of org.jfree.layouting.layouter.context.LayoutContext

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.