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

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


                                         final OutputProcessorMetaData metaData)
  {

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

    final double width = CSSValueResolverUtility.convertLengthToDouble
            (firstValue, null, metaData);
    final double height = CSSValueResolverUtility.convertLengthToDouble
            (secondValue, null, metaData);
    if (width < 1 || height < 1)
    {
      final 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

      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

      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

    else if (value instanceof CSSConstant)
    {
      name = value.toString();
    }

    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 ..
    final CSSValue page =
        new CSSValuePair(CSSNumericValue.createPtValue(ps.getWidth()),
            CSSNumericValue.createPtValue(ps.getHeight()));
    layoutContext.setValue(PageStyleKeys.SIZE, page);
  }
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

                                         final OutputProcessorMetaData metaData)
  {

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

    final double width = CSSValueResolverUtility.convertLengthToDouble
            (firstValue, null, metaData);
    final double height = CSSValueResolverUtility.convertLengthToDouble
            (secondValue, null, metaData);
    if (width < 1 || height < 1)
    {
      final 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

      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

    else if (value instanceof CSSConstant)
    {
      name = value.toString();
    }

    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 ..
    final CSSValue page =
        new CSSValuePair(CSSNumericValue.createPtValue(ps.getWidth()),
            CSSNumericValue.createPtValue(ps.getHeight()));
    layoutContext.setValue(PageStyleKeys.SIZE, page);
  }
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.