Changes between Version 4 and Version 5 of BOOK_PRINTING_R0


Ignore:
Timestamp:
03/26/09 14:13:51 (16 years ago)
Author:
nenko
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BOOK_PRINTING_R0

    v4 v5  
    2727http://java.sun.com/docs/books/tutorial/2d/printing/ 
    2828 
     29http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6633656 
     30 
    2931== How to demo == 
    3032Print a book from Sophie2 
    3133 
    3234= Design = 
    33 ^(Describe your design here.)^ 
     35Printing support should be easy to maintain and easy to extend and something extra to the functionality of Sophie2. That's why a new module will be created. This module will define a new extension point. This extension point will define the relations between the Book model and its printing presentation. Also it will add a new menu item - Print..., which will be in the File menu. 
    3436 
     37The extenstion point will have two properties - id and a model for which it will print. The id is important because you can have many presentations of one and the same model. 
     38Also the printing support will use JPS (Java Printing Service). This API gives us functionality for querying printers, dialogs for print preferences, print to file (in postscript format of course) and so on. There are two major interfaces that are used for printing.  
     39 
     40The first one is java.awt.printPrintable which has one print method with graphic context and page format as arguments. This interface is very powerfull because you can make pagination (separating graphics in pages) by hand. 
     41 
     42The other one is java.awt.print.Pageable which is a little more complicated but working with it is more straightforward.  
     43 
     44However there's a class which implements and extends java.awt.print.Pageable, and its name is java.awt.print.Book. It adds append methods, which add a new (logical) page to the book, with its presentation (java.awt.print.Printable instance). This is the most convenient class for our purposes because it lets us to add a presentation for every Resource we have in a Book, and this presentation to be independent. By independent I mean that one page can be A4 with landscape orientation and the next - B4 with portraint orientation. 
     45 
     46[[Image(source:trunk/sophie2-platform/doc/uml-design-diagrams/printDesgin.png)]] 
     47 
     48When print is invoked it should: 
     49* Collect all the Resources of the Book 
     50* Find print presentation of each Resource (if more than one to choose the most appropriate) 
     51* Create a java.awt.print.Book instance with pages and presentations 
     52* Create a PrintJob with the java.awt.print.Book instance (PrintJob#setPageable) 
     53* Open the dialog for the PrintJob and print 
     54 
     55The current desing allows to make only one presentation for the whole Book itself and to handle pagination in it, but I think it's a better way to create separate presentations for each Resource. However the choise is up to the implementor. 
     56 
     57It's important to know that when using JRE that is lower than Java 6 update 10, NullPointerException will be thrown. That's why a try/catch should be used to alert the user if this happens and to ask to use at least JRE 6 update 10. 
    3558= Implementation = 
    3659^(Describe and link the implementation results here (from the wiki or the repository).)^