Package org.jfree.layouting.layouter.context

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


        (WhitespaceCollapse.PRESERVE.equals
            (context.getValue(TextStyleKeys.WHITE_SPACE_COLLAPSE)));
    staticBoxLayoutProperties.setDominantBaseline
        (context.getValue(LineStyleKeys.DOMINANT_BASELINE));

    final FontSpecification fontSpecification = context.getFontSpecification();
    final FontMetrics fontMetrics = metaData.getFontMetrics(fontSpecification);
    staticBoxLayoutProperties.setNominalBaselineInfo
        (TextUtility.createBaselineInfo('x', fontMetrics));

    final CSSValue widowsValue = context.getValue(PageStyleKeys.WIDOWS);
View Full Code Here


    LibLayoutBoot.getInstance().start();
    DefaultLayoutContext layoutContext =
            new DefaultLayoutContext
                    (new ContextId(0, 0,0), "Bah", "buh", null, new AttributeMap());
    layoutContext.getStyle().setValue(FontStyleKeys.FONT_FAMILY, new CSSConstant("helvetica"));
    final FontSpecification fontSpecification = layoutContext.getFontSpecification();
    fontSpecification.setFontFamily("Arial");
    fontSpecification.setFontSize(12);

    final FlowHtmlOutputProcessor out =
        new FlowHtmlOutputProcessor(LibLayoutBoot.getInstance().getGlobalConfig());
    final DefaultLayoutProcess layoutProcess = new DefaultLayoutProcess(out);
    TestRenderableTextFactory tr = new TestRenderableTextFactory(layoutProcess);
View Full Code Here

                      final StyleKey key)
  {
    // Percentages get resolved against the width of a standard space (0x20)
    // character.
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final FontSpecification fontSpecification =
            layoutContext.getFontSpecification();
    final FontMetrics fm = process.getOutputMetaData().getFontMetrics(fontSpecification);
    if (fm == null)
    {
      // we have no font family, so return.
View Full Code Here

    {
      return; // no parent to resolve against ...
    }

    final double adjustFactor = nval.getValue();
    final FontSpecification fontSpecification =
        currentNode.getLayoutContext().getFontSpecification();
    final FontMetrics fontMetrics =
        process.getOutputMetaData().getFontMetrics(fontSpecification);
    if (fontMetrics == null)
    {
      return; // no font metrics means no valid font...
    }

    final double actualFontXHeight = StrictGeomUtility.toExternalValue(fontMetrics.getXHeight());

    final double fontSize = fontSpecification.getFontSize();
    final double aspectRatio = actualFontXHeight / fontSize;
    final double result = (fontSize * (adjustFactor / aspectRatio));
    fontSpecification.setFontSize(result);
  }
View Full Code Here

                      final StyleKey key)
  {
    // Percentages get resolved against the width of a standard space (0x20)
    // character.
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final FontSpecification fontSpecification =
            layoutContext.getFontSpecification();
    final FontMetrics fm = process.getOutputMetaData().getFontMetrics(fontSpecification);
    if (fm == null)
    {
      final CSSValue value = layoutContext.getValue(FontStyleKeys.FONT_FAMILY);
View Full Code Here

                      final StyleKey key)
  {
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final CSSValue value = layoutContext.getValue(key);
    final LayoutElement parent = currentNode.getParent();
    final FontSpecification fontSpecification =
        currentNode.getLayoutContext().getFontSpecification();

    if (value instanceof CSSNumericValue == false)
    {
      if (parent == null)
      {
        fontSpecification.setFontSize(this.baseFontSize);
        layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PT, baseFontSize));
      }
      else
      {
        final LayoutContext parentContext = parent.getLayoutContext();
        final FontSpecification parentFont = parentContext.getFontSpecification();
        final double fontSize = parentFont.getFontSize();
        fontSpecification.setFontSize(fontSize);
        layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PT, fontSize));
      }
      return;
    }

    final CSSNumericValue nval = (CSSNumericValue) value;
    if (CSSValueResolverUtility.isAbsoluteValue(nval))
    {
      final CSSNumericValue fsize = CSSValueResolverUtility.convertLength
          (nval, currentNode.getLayoutContext(), process.getOutputMetaData());
      final double fontSize = fsize.getValue();
      fontSpecification.setFontSize(fontSize);
      layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PT, fontSize));
    }
    // we encountered one of the relative values.
    else if (CSSNumericType.EM.equals(nval.getType()))
    {
      final double parentSize;
      if (parent == null)
      {
        parentSize = this.baseFontSize;
      }
      else
      {
        final LayoutContext parentContext = parent.getLayoutContext();
        final FontSpecification parentFont = parentContext.getFontSpecification();
        parentSize = parentFont.getFontSize();
      }
      final double fontSize = parentSize * nval.getValue();
      fontSpecification.setFontSize(fontSize);
      layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PT, fontSize));
    }
    else if (CSSNumericType.EX.equals(nval.getType()))
    {
      final double parentSize;
      if (parent == null)
      {
        // if we have no parent, we create a fixed default value.
        parentSize = this.baseFontSize * LibFontsDefaults.DEFAULT_XHEIGHT_SIZE / LibFontsDefaults.DEFAULT_ASCENT_SIZE;
      }
      else
      {
        final LayoutContext parentContext = parent.getLayoutContext();
        final FontSpecification parentFont = parentContext.getFontSpecification();
        parentSize = parentFont.getFontSize();
      }
      final double fontSize = parentSize * nval.getValue();
      layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PT, fontSize));
      fontSpecification.setFontSize(fontSize);
    }
    else if (CSSNumericType.PERCENTAGE.equals(nval.getType()))
    {
      final double parentSize;
      if (parent == null)
      {
        // if we have no parent, we create a fixed default value.
        parentSize = this.baseFontSize;
      }
      else
      {
        final LayoutContext parentContext = parent.getLayoutContext();
        final FontSpecification parentFont = parentContext.getFontSpecification();
        parentSize = parentFont.getFontSize();
      }
      final double fontSize = parentSize * nval.getValue() / 100.0d;
      fontSpecification.setFontSize(fontSize);
      layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PT, fontSize));
    }
View Full Code Here

                         final LayoutElement currentNode,
                         final StyleKey key)
  {
    //Log.debug ("Processing: " + currentNode);
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final FontSpecification fs =
            layoutContext.getFontSpecification();
    final OutputProcessorMetaData 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 FontFamily family = outputMetaData.getFontFamilyForGenericName(c);
          fs.setFontFamily(family.getFamilyName());
          if (process.getOutputMetaData().isValid(fs))
          {
            return;
          }
          // Ignore, although this is not ok.
          Log.warn ("Invalid state after setting predefined font family.");
        }
        else if (item instanceof CSSStringValue)
        {
          final CSSStringValue sval = (CSSStringValue) item;
          final String fontName = sval.getValue();
          fs.setFontFamily(fontName);
          if (process.getOutputMetaData().isValid(fs))
          {
            return;
          }
        }
      }
    }
    else if (cssValue instanceof CSSConstant)
    {
      if (FontFamilyValues.NONE.equals(cssValue))
      {
        Log.info ("Font family has been set to 'none'.");
        fs.setFontFamily(null);
        return;
      }
    }

    final FontFamily family = outputMetaData.getDefaultFontFamily();
    fs.setFontFamily(family.getFamilyName());
    if (process.getOutputMetaData().isValid(fs) == false)
    {
      throw new IllegalStateException
              ("Invalid state after setting the default font family.");
    }
View Full Code Here

                      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
    {
View Full Code Here

        (WhitespaceCollapse.PRESERVE.equals
            (context.getValue(TextStyleKeys.WHITE_SPACE_COLLAPSE)));
    staticBoxLayoutProperties.setDominantBaseline
        (context.getValue(LineStyleKeys.DOMINANT_BASELINE));

    final FontSpecification fontSpecification = context.getFontSpecification();
    final FontMetrics fontMetrics = metaData.getFontMetrics(fontSpecification);
    staticBoxLayoutProperties.setNominalBaselineInfo
        (TextUtility.createBaselineInfo('x', fontMetrics));

    final CSSValue widowsValue = context.getValue(PageStyleKeys.WIDOWS);
View Full Code Here

    //Log.debug ("Processing: " + currentNode);

    final LayoutContext layoutContext = currentNode.getLayoutContext();

    final FontSpecification fs =

            layoutContext.getFontSpecification();

    final OutputProcessorMetaData outputMetaData = process.getOutputMetaData();

    final CSSValue cssValue = layoutContext.getValue(key);

    if (cssValue instanceof CSSValueList)

    {



      CSSValueList list = (CSSValueList) cssValue;

      for (int i = 0; i < list.getLength(); i++)

      {

        CSSValue item = list.getItem(i);

        if (item instanceof CSSConstant)

        {

          final CSSConstant c = (CSSConstant) lookupValue((CSSConstant) item);

          final FontFamily family = outputMetaData.getFontFamily(c);

          fs.setFontFamily(family.getFamilyName());

          if (process.getOutputMetaData().isValid(fs))

          {

            return;

          }

          // Ignore, although this is not ok.

          Log.warn ("Invalid state after setting predefined font family.");

        }

        else if (item instanceof CSSStringValue)

        {

          final CSSStringValue sval = (CSSStringValue) item;

          final String fontName = sval.getValue();

          fs.setFontFamily(fontName);

          if (process.getOutputMetaData().isValid(fs))

          {

            return;

          }

        }

      }

    }

    else if (cssValue instanceof CSSConstant)

    {

      if (FontFamilyValues.NONE.equals(cssValue))

      {

        Log.info ("Font family has been set to 'none'.");

        fs.setFontFamily(null);

        return;

      }

    }



    final FontFamily family = outputMetaData.getDefaultFontFamily();

    fs.setFontFamily(family.getFamilyName());

    if (process.getOutputMetaData().isValid(fs) == false)

    {
View Full Code Here

TOP

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

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.