Package java.awt.print

Examples of java.awt.print.Paper


      throw new ParseException("Orientation value in REPORT-Tag is invalid.",
          getRootHandler().getDocumentLocator());
    }
    if (pageformatName != null)
    {
      final Paper p = PageFormatFactory.getInstance().createPaper(pageformatName);
      if (p == null)
      {
        PageReadHandler.logger.warn("Unable to create the requested Paper. " + pageformatName);
        return format;
      }
      return PageFormatFactory.getInstance().createPageFormat(p, orientationVal);
    }

    if (atts.getValue(getUri(), PageReadHandler.WIDTH_ATT) != null && atts.getValue(getUri(),
        PageReadHandler.HEIGHT_ATT) != null)
    {
      final int[] pageformatData = new int[2];
      pageformatData[0] = ParserUtil.parseInt(atts.getValue(getUri(), PageReadHandler.WIDTH_ATT), "No Width set",
          getLocator());
      pageformatData[1] = ParserUtil.parseInt(atts.getValue(getUri(), PageReadHandler.HEIGHT_ATT), "No Height set",
          getLocator());
      final Paper p = PageFormatFactory.getInstance().createPaper(pageformatData);
      if (p == null)
      {
        PageReadHandler.logger.warn("Unable to create the requested Paper. Paper={" + pageformatData[0] + ", "
            + pageformatData[1] + '}');
        return format;
View Full Code Here


      orientationVal = PageFormat.PORTRAIT;
    }

    if (pageformatName != null)
    {
      final Paper p = PageFormatFactory.getInstance().createPaper(pageformatName);
      if (p == null)
      {
        PageDefinitionReadHandler.logger.warn("Paper size '" + pageformatName + "' is not regognized.");
        return defaultPageFormat;
      }
      return PageFormatFactory.getInstance().createPageFormat(p, orientationVal);
    }

    if (atts.getValue(getUri(), "width") != null && atts.getValue(getUri(), "height") != null)
    {
      final int[] pageformatData = new int[2];
      pageformatData[0] = ParserUtil.parseInt(atts.getValue(getUri(), "width"),
          "Specified attribute 'width' is not valid", getLocator());
      pageformatData[1] = ParserUtil.parseInt(atts.getValue(getUri(), "height"),
          "Specified attribute 'height' is not valid", getLocator());
      final Paper p = PageFormatFactory.getInstance().createPaper(pageformatData);
      if (p == null)
      {
        PageDefinitionReadHandler.logger.warn("Unable to create the requested Paper size with width " +
            pageformatData[0] + " and height " + pageformatData[1]);
        return defaultPageFormat;
View Full Code Here

    defTopMargin = ParserUtil.parseFloat(atts.getValue(getUri(), "margin-top"), defTopMargin);
    defBottomMargin = ParserUtil.parseFloat(atts.getValue(getUri(), "margin-bottom"), defBottomMargin);
    defLeftMargin = ParserUtil.parseFloat(atts.getValue(getUri(), "margin-left"), defLeftMargin);
    defRightMargin = ParserUtil.parseFloat(atts.getValue(getUri(), "margin-right"), defRightMargin);

    final Paper p = format.getPaper();
    switch (format.getOrientation())
    {
      case PageFormat.PORTRAIT:
        PageFormatFactory.getInstance().setBorders(p, defTopMargin, defLeftMargin,
            defBottomMargin, defRightMargin);
View Full Code Here

    if (retval == null)
    {
      throw new NullPointerException();
    }

    final Paper paper = fmt.getPaper();
    final int w = (int) paper.getWidth();
    final int h = (int) paper.getHeight();

    final String pageDefinition = PageFormatFactory.getInstance().getPageFormatName(w, h);
    if (pageDefinition != null)
    {
      retval.setAttribute(BundleNamespaces.STYLE, "pageformat", pageDefinition);
View Full Code Here

      defLeftMargin = ParserUtil.parseFloat(attrs.getValue(getUri(), JFreeReportReadHandler.LEFTMARGIN_ATT),
          defLeftMargin);
      defRightMargin = ParserUtil.parseFloat(attrs.getValue(getUri(), JFreeReportReadHandler.RIGHTMARGIN_ATT),
          defRightMargin);

      final Paper p = format.getPaper();
      switch (format.getOrientation())
      {
        case PageFormat.PORTRAIT:
          PageFormatFactory.getInstance().setBorders(p, defTopMargin, defLeftMargin,
              defBottomMargin, defRightMargin);
View Full Code Here

      throw new ParseException("Orientation value in REPORT-Tag is invalid.",
          getRootHandler().getDocumentLocator());
    }
    if (pageformatName != null)
    {
      final Paper p = PageFormatFactory.getInstance().createPaper(pageformatName);
      if (p == null)
      {
        JFreeReportReadHandler.logger.warn("Unable to create the requested Paper. " + pageformatName);
        return format;
      }
      return PageFormatFactory.getInstance().createPageFormat(p, orientationVal);
    }

    if (atts.getValue(getUri(), JFreeReportReadHandler.WIDTH_ATT) != null &&
        atts.getValue(getUri(), JFreeReportReadHandler.HEIGHT_ATT) != null)
    {
      final int[] pageformatData = new int[2];
      pageformatData[0] = ParserUtil.parseInt(atts.getValue(getUri(), JFreeReportReadHandler.WIDTH_ATT), "No Width set",
          getLocator());
      pageformatData[1] = ParserUtil.parseInt(atts.getValue(getUri(), JFreeReportReadHandler.HEIGHT_ATT),
          "No Height set", getLocator());
      final Paper p = PageFormatFactory.getInstance().createPaper(pageformatData);
      if (p == null)
      {
        JFreeReportReadHandler.logger.warn("Unable to create the requested Paper. Paper={" + pageformatData[0] + ", "
            + pageformatData[1] + '}');
        return format;
View Full Code Here

    this.pageDrawable = pageDrawable;

    this.globalX = page.getGlobalX();
    this.globalY = page.getGlobalY();

    final Paper p = new Paper();

    final float marginLeft = (float) StrictGeomUtility.toExternalValue(page.getImageableX());
    final float marginRight = (float) StrictGeomUtility.toExternalValue
        (page.getWidth() - page.getImageableWidth() - page.getImageableX());
    final float marginTop = (float) StrictGeomUtility.toExternalValue(page.getImageableY());
    final float marginBottom = (float) StrictGeomUtility.toExternalValue
        (page.getHeight() - page.getImageableHeight() - page.getImageableY());
    switch (page.getOrientation())
    {
      case PageFormat.PORTRAIT:
        p.setSize(StrictGeomUtility.toExternalValue(page.getWidth()),
            StrictGeomUtility.toExternalValue(page.getHeight()));
        PageFormatFactory.getInstance().setBorders(p, marginTop, marginLeft,
            marginBottom, marginRight);
        break;
      case PageFormat.LANDSCAPE:
        // right, top, left, bottom
        p.setSize(StrictGeomUtility.toExternalValue(page.getHeight()),
            StrictGeomUtility.toExternalValue(page.getWidth()));
        PageFormatFactory.getInstance().setBorders(p, marginRight, marginTop,
            marginLeft, marginBottom);
        break;
      case PageFormat.REVERSE_LANDSCAPE:
        p.setSize(StrictGeomUtility.toExternalValue(page.getHeight()),
            StrictGeomUtility.toExternalValue(page.getWidth()));
        PageFormatFactory.getInstance().setBorders(p, marginLeft, marginBottom,
            marginRight, marginTop);
        break;
      default:
View Full Code Here

  }

  public void testPageSize () throws IOException
  {
    final TextFilePrinterDriver pc = new TextFilePrinterDriver(new NullOutputStream(), 12, 12);
    final Paper paper = PageFormatFactory.getInstance().createPaper(PageSize.A4);
    pc.startPage(paper, "ASCII");

    final PlainTextPage page = new PlainTextPage(paper, pc, "ASCII");
    final int width = page.getWidth();
    final int height = page.getHeight();
View Full Code Here

   * @param height the height of the paper in points
   * @return the created paper
   */
  public Paper createPaper(final double width, final double height)
  {
    final Paper p = new Paper();
    p.setSize(width, height);
    setBorders(p, 0, 0, 0, 0);
    return p;
  }
View Full Code Here

    if (pf1.getOrientation() != pf2.getOrientation())
    {
      return false;
    }
    final Paper p1 = pf1.getPaper();
    final Paper p2 = pf2.getPaper();

    if (p1.getWidth() != p2.getWidth())
    {
      return false;
    }
    if (p1.getHeight() != p2.getHeight())
    {
      return false;
    }
    if (p1.getImageableX() != p2.getImageableX())
    {
      return false;
    }
    if (p1.getImageableY() != p2.getImageableY())
    {
      return false;
    }
    if (p1.getImageableWidth() != p2.getImageableWidth())
    {
      return false;
    }
    if (p1.getImageableHeight() != p2.getImageableHeight())
    {
      return false;
    }
    return true;
  }
View Full Code Here

TOP

Related Classes of java.awt.print.Paper

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.