Changes between Version 6 and Version 7 of BOOK_PRINTING_R1


Ignore:
Timestamp:
10/08/09 15:03:02 (16 years ago)
Author:
kyli
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BOOK_PRINTING_R1

    v6 v7  
    2828 
    2929= Design = 
    30 The main idea is to make the printing draw the scene on the printer. The needed logic for this is already written for the needs of the PDF export. So, most of the current classes are useless. Remove: 
    31  * DefaultSophiePrintable 
    32  * AbstractPrintItem 
    33  * PrintExtensionPoint 
    34  * PageSophiePrintable 
    35  * PrintToFileItem 
    36  * SophiePrintable 
    37  * HotTextSophiePrintable 
    38  * PrintToFileDialog 
    39  * PrintToFileDialogInput   [[BR]] 
     30We will use the java.awt.print API. The simplest workflow for printing with this API consists of the following steps: 
    4031 
    41  * In the print logic, modify ON_PRINT, so that it should create a new printerJob, which will print a java.awt.print.Book. The book will consist of a PagePainter which can print a page by given index. The job will also set the default page orientation based on the book page size. 
    42  * Create PagePainter which implements Printable. Every pagePainter is constructed from the bookView the page is located in. It will have a print(...) method, which calculates the drawing rectangle and paints the scene (using SceneHelper) to the given graphics. It will also scale the page so that it will fit into the print format. 
     321. Obtain a java.awt.print.PrinterJob instance. 
     332. Pass a java.awt.print.Printable or java.awt.print.Pageable object to the PrinterJob instance (we will use Pageable since it fits our needs better). 
     343. Call PrinterJob.printDialog() and if it returns true, call PrinterJob.print(). 
    4335 
     36The only thing we need to do to make this work in Sophie2 is to create a custom Pageable object at step 2. We will create a java.awt.print.Book (which implements Pageable) by passing it a PagePainter (implements Printable) object which can print each page of a Sophie2 book. PagePainter's constructor will have one parameter of type BookView. The PagePainter.print method will draw a page from the BookView (by given page index) to a given Graphics2D object. The drawing will be done in the exact same way as "export to pdf". 
     37 
     38As a summary: 
     39 * The class PagePainter will be added 
     40 * The PrintLogic.ON_PRINT.handle method will be refactored to work according to the above workflow 
     41 * The following classes will be removed: 
     42  * DefaultSophiePrintable 
     43  * AbstractPrintItem 
     44  * PrintExtensionPoint 
     45  * PageSophiePrintable 
     46  * PrintToFileItem 
     47  * SophiePrintable 
     48  * HotTextSophiePrintable 
     49  * PrintToFileDialog 
     50  * PrintToFileDialogInput 
    4451 
    4552= Implementation =