Package org.jfree.layouting.input.style.keys.page

Examples of org.jfree.layouting.input.style.keys.page.PageSize


      final String ident = value.getStringValue();
      if ("auto".equalsIgnoreCase(ident))
      {
        return CSSAutoValue.getInstance();
      }
      final PageSize ps = PageSizeFactory.getInstance().getPageSizeByName(ident);
      if (ps == null)
      {
        return null;
      }

      value = value.getNextLexicalUnit();
      int pageOrientation = PageFormat.PORTRAIT;
      if (value != null)
      {
        if (value.getLexicalUnitType() != LexicalUnit.SAC_IDENT)
        {
          return null;
        }

        if ("landscape".equalsIgnoreCase(value.getStringValue()))
        {
          pageOrientation = PageFormat.LANDSCAPE;
        }
        else if ("reverse-landscape".equalsIgnoreCase(value.getStringValue()))
        {
          pageOrientation = PageFormat.REVERSE_LANDSCAPE;
        }
        else if ("portrait".equalsIgnoreCase(value.getStringValue()))
        {
          pageOrientation = PageFormat.PORTRAIT;
        }
        else
        {
          return null;
        }
      }

      if (pageOrientation == PageFormat.LANDSCAPE ||
          pageOrientation == PageFormat.REVERSE_LANDSCAPE)
      {
        return new CSSValuePair(CSSNumericValue.createPtValue(ps.getHeight()),
                CSSNumericValue.createPtValue(ps.getWidth()));
      }
      else
      {
        return new CSSValuePair(CSSNumericValue.createPtValue(ps.getWidth()),
                CSSNumericValue.createPtValue(ps.getHeight()));
      }
    }
    else
    {
      final CSSNumericValue horizontalWidth = (CSSNumericValue) parseWidth(value);
View Full Code Here


   */
  public void resolve(final LayoutProcess process,
                      final LayoutElement currentNode,
                      final StyleKey key)
  {
    final PageSize ps = process.getOutputMetaData().getDefaultPageSize();
    final CSSValue page =
        new CSSValuePair(CSSNumericValue.createPtValue(ps.getWidth()),
            CSSNumericValue.createPtValue(ps.getHeight()));
    currentNode.getLayoutContext().setValue(PageStyleKeys.SIZE, page);
  }
View Full Code Here

                                         OutputProcessorMetaData metaData)
  {

    if (sizeVal instanceof CSSValuePair == false)
    {
      PageSize defaultVal = metaData.getDefaultPageSize();
      return defaultVal;
    }
    CSSValuePair valuePair = (CSSValuePair) sizeVal;
    final CSSValue firstValue = valuePair.getFirstValue();
    if (firstValue instanceof CSSNumericValue == false)
    {
      PageSize defaultVal = metaData.getDefaultPageSize();
      return defaultVal;
    }
    final CSSValue secondValue = valuePair.getSecondValue();
    if (secondValue instanceof CSSNumericValue == false)
    {
      PageSize defaultVal = metaData.getDefaultPageSize();
      return defaultVal;
    }

    double width = CSSValueResolverUtility.convertLengthToDouble
            (firstValue, null, metaData);
    double height = CSSValueResolverUtility.convertLengthToDouble
            (secondValue, null, metaData);
    if (width < 1 || height < 1)
    {
      PageSize defaultVal = metaData.getDefaultPageSize();
      return defaultVal;
    }
    return new PageSize(width, height);
  }
View Full Code Here

    this.pageContext = pageContext;

    final LayoutStyle areaDefinition =
        pageContext.getAreaDefinition(PageAreaType.CONTENT);
    final CSSValue pageValue = areaDefinition.getValue(PageStyleKeys.SIZE);
    final PageSize pageSize = PageGridUtility.lookupPageSize(pageValue, metaData);

    this.width = StrictGeomUtility.toInternalValue(pageSize.getWidth());
    this.height = StrictGeomUtility.toInternalValue(pageSize.getHeight());

    final CSSValue marginTopValue =
        areaDefinition.getValue(BoxStyleKeys.MARGIN_TOP);
    final CSSValue marginLeftValue =
        areaDefinition.getValue(BoxStyleKeys.MARGIN_LEFT);
View Full Code Here

    }



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

    CSSValue page =

        new CSSValuePair(CSSNumericValue.createPtValue(ps.getWidth()),

            CSSNumericValue.createPtValue(ps.getHeight()));

    layoutContext.setValue(PageStyleKeys.SIZE, page);

  }
View Full Code Here

      String ident = value.getStringValue();
      if (ident.equalsIgnoreCase("auto"))
      {
        return CSSAutoValue.getInstance();
      }
      final PageSize ps = PageSizeFactory.getInstance().getPageSizeByName(ident);
      if (ps == null)
      {
        return null;
      }

      value = value.getNextLexicalUnit();
      int pageOrientation = PageFormat.PORTRAIT;
      if (value != null)
      {
        if (value.getLexicalUnitType() != LexicalUnit.SAC_IDENT)
        {
          return null;
        }

        if (value.getStringValue().equalsIgnoreCase("landscape"))
        {
          pageOrientation = PageFormat.LANDSCAPE;
        }
        else if (value.getStringValue().equalsIgnoreCase("reverse-landscape"))
        {
          pageOrientation = PageFormat.REVERSE_LANDSCAPE;
        }
        else if (value.getStringValue().equalsIgnoreCase("portrait"))
        {
          pageOrientation = PageFormat.PORTRAIT;
        }
        else
        {
          return null;
        }
      }

      if (pageOrientation == PageFormat.LANDSCAPE ||
          pageOrientation == PageFormat.REVERSE_LANDSCAPE)
      {
        return new CSSValuePair(CSSNumericValue.createPtValue(ps.getHeight()),
                CSSNumericValue.createPtValue(ps.getWidth()));
      }
      else
      {
        return new CSSValuePair(CSSNumericValue.createPtValue(ps.getWidth()),
                CSSNumericValue.createPtValue(ps.getHeight()));
      }
    }
    else
    {
      final CSSNumericValue horizontalWidth = (CSSNumericValue) parseWidth(value);
View Full Code Here

   */
  public void resolve(LayoutProcess process,
                      LayoutElement currentNode,
                      StyleKey key)
  {
    final PageSize ps = process.getOutputMetaData().getDefaultPageSize();
    CSSValue page =
        new CSSValuePair(CSSNumericValue.createPtValue(ps.getWidth()),
            CSSNumericValue.createPtValue(ps.getHeight()));
    currentNode.getLayoutContext().setValue(PageStyleKeys.SIZE, page);
  }
View Full Code Here

      double width = 0;
      double height = 0;

      if(size instanceof PageSize)
      {
        final PageSize pageSize = (PageSize)size;
        width = pageSize.getWidth();
        height = pageSize.getHeight();
      }
      else if(RTF_LANDSCAPE.equals(size))
      {
        if (styleKey.equals(RTF_PAGEWIDTH))
        {
          height = twipToInt(floatValue);
        }
        else
        {
          width = twipToInt(floatValue);
        }
      }
      else
      {
        if (styleKey.equals(RTF_PAGEWIDTH))
        {
          width = twipToInt(floatValue);
        }
        else
        {
          height = twipToInt(floatValue);
        }
      }

      attr.addAttribute(PAGE_RULE_TYPE, PageStyleKeys.SIZE.getName(), new PageSize(width, height));
    }
    else if(styleKey.equals(RTF_MARGINLEFT))
    {
      final float floatValue = ((Float) value).floatValue();
      attr.addAttribute(PAGE_RULE_TYPE, BoxStyleKeys.MARGIN_LEFT.getName(), CSSNumericValue.createValue(CSSNumericType.PT, floatValue));
    }
    else if(styleKey.equals(RTF_MARGINRIGHT))
    {
      final float floatValue = ((Float) value).floatValue();
      attr.addAttribute(PAGE_RULE_TYPE, BoxStyleKeys.MARGIN_RIGHT.getName(), CSSNumericValue.createValue(CSSNumericType.PT, floatValue));
    }
    else if(styleKey.equals(RTF_MARGINTOP))
    {
      final float floatValue = ((Float) value).floatValue();
      attr.addAttribute(PAGE_RULE_TYPE, BoxStyleKeys.MARGIN_TOP.getName(), CSSNumericValue.createValue(CSSNumericType.PT, floatValue));
    }
    else if(styleKey.equals(RTF_MARGINBOTTOM))
    {
      final float floatValue = ((Float) value).floatValue();
      attr.addAttribute(PAGE_RULE_TYPE, BoxStyleKeys.MARGIN_BOTTOM.getName(), CSSNumericValue.createValue(CSSNumericType.PT, floatValue));
    }
    else if(styleKey.equals(RTF_LANDSCAPE))
    {
      final Object size = cssAttr.getAttribute(PageStyleKeys.SIZE.getName());
      if(size instanceof PageSize)
      {
        final PageSize pageSize = (PageSize)size;
        attr.addAttribute(PAGE_RULE_TYPE, PageStyleKeys.SIZE.getName(), new PageSize(pageSize.getHeight(), pageSize.getWidth()));
      }
      else
      {
        attr.addAttribute(PAGE_RULE_TYPE, PageStyleKeys.SIZE.getName(), RTF_LANDSCAPE);
      }
View Full Code Here

TOP

Related Classes of org.jfree.layouting.input.style.keys.page.PageSize

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.