Source Code Cross Referenced for Printable.java in  » 6.0-JDK-Core » AWT » java » awt » print » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt.print 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1997-2005 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package java.awt.print;
027
028        import java.awt.Graphics;
029
030        /**
031         * The <code>Printable</code> interface is implemented 
032         * by the <code>print</code> methods of the current
033         * page painter, which is called by the printing
034         * system to render a page.  When building a 
035         * {@link Pageable}, pairs of {@link PageFormat}
036         * instances and instances that implement
037         * this interface are used to describe each page. The 
038         * instance implementing <code>Printable</code> is called to 
039         * print the page's graphics.
040         * <p>
041         * A <code>Printable(..)</code> may be set on a <code>PrinterJob</code>.
042         * When the client subsequently initiates printing by calling
043         * <code>PrinterJob.print(..)</code> control
044         * <p>
045         * is handed to the printing system until all pages have been printed.
046         * It does this by calling <code>Printable.print(..)</code> until
047         * all pages in the document have been printed.
048         * In using the <code>Printable</code> interface the printing
049         * commits to image the contents of a page whenever
050         * requested by the printing system.
051         * <p>
052         * The parameters to <code>Printable.print(..)</code> include a
053         * <code>PageFormat</code> which describes the printable area of
054         * the page, needed for calculating the contents that will fit the
055         * page, and the page index, which specifies the zero-based print
056         * stream index of the requested page.
057         * <p>
058         * For correct printing behaviour, the following points should be
059         * observed:
060         * <ul>
061         * <li> The printing system may request a page index more than once.
062         * On each occasion equal PageFormat parameters will be supplied.
063         *
064         * <li>The printing system will call <code>Printable.print(..)</code>
065         * with page indexes which increase monotonically, although as noted above,
066         * the <code>Printable</code> should expect multiple calls for a page index
067         * and that page indexes may be skipped, when page ranges are specified
068         * by the client, or by a user through a print dialog.
069         *  
070         * <li>If multiple collated copies of a document are requested, and the
071         * printer cannot natively support this, then the document may be imaged
072         * multiple times. Printing will start each copy from the lowest print
073         * stream page index page.
074         * 
075         * <li>With the exception of re-imaging an entire document for multiple
076         * collated copies, the increasing page index order means that when
077         * page N is requested if a client needs to calculate page break position,
078         * it may safely discard any state related to pages < N, and make current
079         * that for page N. "State" usually is just the calculated position in the
080         * document that corresponds to the start of the page.
081         *  
082         * <li>When called by the printing system the <code>Printable</code> must
083         * inspect and honour the supplied PageFormat parameter as well as the
084         * page index.  The format of the page to be drawn is specified by the 
085         * supplied PageFormat. The size, orientation and imageable area of the page 
086         * is therefore already determined and rendering must be within this 
087         * imageable area.
088         * This is key to correct printing behaviour, and it has the
089         * implication that the client has the responsibility of tracking
090         * what content belongs on the specified page.
091         *  
092         * <li>When the <code>Printable</code> is obtained from a client-supplied
093         * <code>Pageable</code> then the client may provide different PageFormats
094         * for each page index. Calculations of page breaks must account for this.
095         * </ul>
096         * <p>
097         * @see java.awt.print.Pageable
098         * @see java.awt.print.PageFormat
099         * @see java.awt.print.PrinterJob
100         */
101        public interface Printable {
102
103            /**
104             * Returned from {@link #print(Graphics, PageFormat, int)} 
105             * to signify that the requested page was rendered.
106             */
107            int PAGE_EXISTS = 0;
108
109            /**
110             * Returned from <code>print</code> to signify that the
111             * <code>pageIndex</code> is too large and that the requested page
112             * does not exist.
113             */
114            int NO_SUCH_PAGE = 1;
115
116            /**
117             * Prints the page at the specified index into the specified 
118             * {@link Graphics} context in the specified
119             * format.  A <code>PrinterJob</code> calls the 
120             * <code>Printable</code> interface to request that a page be
121             * rendered into the context specified by 
122             * <code>graphics</code>.  The format of the page to be drawn is
123             * specified by <code>pageFormat</code>.  The zero based index
124             * of the requested page is specified by <code>pageIndex</code>. 
125             * If the requested page does not exist then this method returns
126             * NO_SUCH_PAGE; otherwise PAGE_EXISTS is returned.
127             * The <code>Graphics</code> class or subclass implements the
128             * {@link PrinterGraphics} interface to provide additional
129             * information.  If the <code>Printable</code> object
130             * aborts the print job then it throws a {@link PrinterException}.
131             * @param graphics the context into which the page is drawn 
132             * @param pageFormat the size and orientation of the page being drawn
133             * @param pageIndex the zero based index of the page to be drawn
134             * @return PAGE_EXISTS if the page is rendered successfully
135             *         or NO_SUCH_PAGE if <code>pageIndex</code> specifies a
136             *	       non-existent page.
137             * @exception java.awt.print.PrinterException
138             *         thrown when the print job is terminated.
139             */
140            int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
141                    throws PrinterException;
142
143        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.