src/share/classes/java/awt/print/Printable.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.awt.print;
  27 
  28 import java.awt.Graphics;
  29 
  30 import javax.tools.annotation.GenerateNativeHeader;
  31 
  32 /**
  33  * The <code>Printable</code> interface is implemented
  34  * by the <code>print</code> methods of the current
  35  * page painter, which is called by the printing
  36  * system to render a page.  When building a
  37  * {@link Pageable}, pairs of {@link PageFormat}
  38  * instances and instances that implement
  39  * this interface are used to describe each page. The
  40  * instance implementing <code>Printable</code> is called to
  41  * print the page's graphics.
  42  * <p>
  43  * A <code>Printable(..)</code> may be set on a <code>PrinterJob</code>.
  44  * When the client subsequently initiates printing by calling
  45  * <code>PrinterJob.print(..)</code> control
  46  * <p>
  47  * is handed to the printing system until all pages have been printed.
  48  * It does this by calling <code>Printable.print(..)</code> until
  49  * all pages in the document have been printed.
  50  * In using the <code>Printable</code> interface the printing


  83  *
  84  * <li>When called by the printing system the <code>Printable</code> must
  85  * inspect and honour the supplied PageFormat parameter as well as the
  86  * page index.  The format of the page to be drawn is specified by the
  87  * supplied PageFormat. The size, orientation and imageable area of the page
  88  * is therefore already determined and rendering must be within this
  89  * imageable area.
  90  * This is key to correct printing behaviour, and it has the
  91  * implication that the client has the responsibility of tracking
  92  * what content belongs on the specified page.
  93  *
  94  * <li>When the <code>Printable</code> is obtained from a client-supplied
  95  * <code>Pageable</code> then the client may provide different PageFormats
  96  * for each page index. Calculations of page breaks must account for this.
  97  * </ul>
  98  * <p>
  99  * @see java.awt.print.Pageable
 100  * @see java.awt.print.PageFormat
 101  * @see java.awt.print.PrinterJob
 102  */
 103 /* No native methods here, but the constants are needed in the supporting JNI code */
 104 @GenerateNativeHeader
 105 public interface Printable {
 106 
 107     /**
 108      * Returned from {@link #print(Graphics, PageFormat, int)}
 109      * to signify that the requested page was rendered.
 110      */
 111     int PAGE_EXISTS = 0;
 112 
 113     /**
 114      * Returned from <code>print</code> to signify that the
 115      * <code>pageIndex</code> is too large and that the requested page
 116      * does not exist.
 117      */
 118     int NO_SUCH_PAGE = 1;
 119 
 120     /**
 121      * Prints the page at the specified index into the specified
 122      * {@link Graphics} context in the specified
 123      * format.  A <code>PrinterJob</code> calls the
 124      * <code>Printable</code> interface to request that a page be


   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.awt.print;
  27 
  28 import java.awt.Graphics;
  29 

  30 
  31 /**
  32  * The <code>Printable</code> interface is implemented
  33  * by the <code>print</code> methods of the current
  34  * page painter, which is called by the printing
  35  * system to render a page.  When building a
  36  * {@link Pageable}, pairs of {@link PageFormat}
  37  * instances and instances that implement
  38  * this interface are used to describe each page. The
  39  * instance implementing <code>Printable</code> is called to
  40  * print the page's graphics.
  41  * <p>
  42  * A <code>Printable(..)</code> may be set on a <code>PrinterJob</code>.
  43  * When the client subsequently initiates printing by calling
  44  * <code>PrinterJob.print(..)</code> control
  45  * <p>
  46  * is handed to the printing system until all pages have been printed.
  47  * It does this by calling <code>Printable.print(..)</code> until
  48  * all pages in the document have been printed.
  49  * In using the <code>Printable</code> interface the printing


  82  *
  83  * <li>When called by the printing system the <code>Printable</code> must
  84  * inspect and honour the supplied PageFormat parameter as well as the
  85  * page index.  The format of the page to be drawn is specified by the
  86  * supplied PageFormat. The size, orientation and imageable area of the page
  87  * is therefore already determined and rendering must be within this
  88  * imageable area.
  89  * This is key to correct printing behaviour, and it has the
  90  * implication that the client has the responsibility of tracking
  91  * what content belongs on the specified page.
  92  *
  93  * <li>When the <code>Printable</code> is obtained from a client-supplied
  94  * <code>Pageable</code> then the client may provide different PageFormats
  95  * for each page index. Calculations of page breaks must account for this.
  96  * </ul>
  97  * <p>
  98  * @see java.awt.print.Pageable
  99  * @see java.awt.print.PageFormat
 100  * @see java.awt.print.PrinterJob
 101  */


 102 public interface Printable {
 103 
 104     /**
 105      * Returned from {@link #print(Graphics, PageFormat, int)}
 106      * to signify that the requested page was rendered.
 107      */
 108     int PAGE_EXISTS = 0;
 109 
 110     /**
 111      * Returned from <code>print</code> to signify that the
 112      * <code>pageIndex</code> is too large and that the requested page
 113      * does not exist.
 114      */
 115     int NO_SUCH_PAGE = 1;
 116 
 117     /**
 118      * Prints the page at the specified index into the specified
 119      * {@link Graphics} context in the specified
 120      * format.  A <code>PrinterJob</code> calls the
 121      * <code>Printable</code> interface to request that a page be