Java Doc 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 Reference  Class Diagram Java Document (Java Doc) 


java.awt.print.Printable

Printable
public interface Printable (Code)
The Printable interface is implemented by the print methods of the current page painter, which is called by the printing system to render a page. When building a Pageable , pairs of PageFormat instances and instances that implement this interface are used to describe each page. The instance implementing Printable is called to print the page's graphics.

A Printable(..) may be set on a PrinterJob. When the client subsequently initiates printing by calling PrinterJob.print(..) control

is handed to the printing system until all pages have been printed. It does this by calling Printable.print(..) until all pages in the document have been printed. In using the Printable interface the printing commits to image the contents of a page whenever requested by the printing system.

The parameters to Printable.print(..) include a PageFormat which describes the printable area of the page, needed for calculating the contents that will fit the page, and the page index, which specifies the zero-based print stream index of the requested page.

For correct printing behaviour, the following points should be observed:

  • The printing system may request a page index more than once. On each occasion equal PageFormat parameters will be supplied.
  • The printing system will call Printable.print(..) with page indexes which increase monotonically, although as noted above, the Printable should expect multiple calls for a page index and that page indexes may be skipped, when page ranges are specified by the client, or by a user through a print dialog.
  • If multiple collated copies of a document are requested, and the printer cannot natively support this, then the document may be imaged multiple times. Printing will start each copy from the lowest print stream page index page.
  • With the exception of re-imaging an entire document for multiple collated copies, the increasing page index order means that when page N is requested if a client needs to calculate page break position, it may safely discard any state related to pages < N, and make current that for page N. "State" usually is just the calculated position in the document that corresponds to the start of the page.
  • When called by the printing system the Printable must inspect and honour the supplied PageFormat parameter as well as the page index. The format of the page to be drawn is specified by the supplied PageFormat. The size, orientation and imageable area of the page is therefore already determined and rendering must be within this imageable area. This is key to correct printing behaviour, and it has the implication that the client has the responsibility of tracking what content belongs on the specified page.
  • When the Printable is obtained from a client-supplied Pageable then the client may provide different PageFormats for each page index. Calculations of page breaks must account for this.


See Also:   java.awt.print.Pageable
See Also:   java.awt.print.PageFormat
See Also:   java.awt.print.PrinterJob



Field Summary
 intNO_SUCH_PAGE
     Returned from print to signify that the pageIndex is too large and that the requested page does not exist.
 intPAGE_EXISTS
     Returned from Printable.print(Graphics,PageFormat,int) to signify that the requested page was rendered.


Method Summary
 intprint(Graphics graphics, PageFormat pageFormat, int pageIndex)
     Prints the page at the specified index into the specified Graphics context in the specified format.

Field Detail
NO_SUCH_PAGE
int NO_SUCH_PAGE(Code)
Returned from print to signify that the pageIndex is too large and that the requested page does not exist.



PAGE_EXISTS
int PAGE_EXISTS(Code)
Returned from Printable.print(Graphics,PageFormat,int) to signify that the requested page was rendered.





Method Detail
print
int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException(Code)
Prints the page at the specified index into the specified Graphics context in the specified format. A PrinterJob calls the Printable interface to request that a page be rendered into the context specified by graphics. The format of the page to be drawn is specified by pageFormat. The zero based index of the requested page is specified by pageIndex. If the requested page does not exist then this method returns NO_SUCH_PAGE; otherwise PAGE_EXISTS is returned. The Graphics class or subclass implements the PrinterGraphics interface to provide additional information. If the Printable object aborts the print job then it throws a PrinterException .
Parameters:
  graphics - the context into which the page is drawn
Parameters:
  pageFormat - the size and orientation of the page being drawn
Parameters:
  pageIndex - the zero based index of the page to be drawn PAGE_EXISTS if the page is rendered successfullyor NO_SUCH_PAGE if pageIndex specifies anon-existent page.
exception:
  java.awt.print.PrinterException - thrown when the print job is terminated.



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.