gmazza      2003/08/02 14:26:53

  Modified:    src/java/org/apache/fop/apps Driver.java
               src/java/org/apache/fop/render/awt AWTPrintRenderer.java
               src/java/org/apache/fop/servlet FopPrintServlet.java
  Log:
  PrinterJob setup and construction moved from Driver to AWTPrintRenderer class.  
AWTPrintRenderer now be instantiated without a PrinterJob object.  (Pending: for 
embedded programming, may still wish to have a PrinterJob-based constructor for 
AWTPrintRenderer, or otherwise provide an accessor method to its PrinterJob object.)
  
  Revision  Changes    Path
  1.15      +2 -13     xml-fop/src/java/org/apache/fop/apps/Driver.java
  
  Index: Driver.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/Driver.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Driver.java       2 Aug 2003 01:15:20 -0000       1.14
  +++ Driver.java       2 Aug 2003 21:26:53 -0000       1.15
  @@ -50,9 +50,6 @@
    */
   package org.apache.fop.apps;
   
  -// Java
  -import java.awt.print.PrinterJob;
  -
   // FOP
   import org.apache.fop.fo.ElementMapping;
   import org.apache.fop.fo.FOTreeBuilder;
  @@ -391,6 +388,7 @@
        * <ul>
        * <li>RENDER_PDF</li>
        * <li>RENDER_AWT</li>
  +     * <li>RENDER_PRINT</li>
        * <li>RENDER_MIF</li>
        * <li>RENDER_XML</li>
        * <li>RENDER_PCL</li>
  @@ -411,16 +409,7 @@
           case RENDER_AWT:
               throw new IllegalArgumentException("Use renderer form of setRenderer() 
for AWT");
           case RENDER_PRINT:
  -            // a PrinterJob object is needed to create this renderer
  -            PrinterJob pj = PrinterJob.getPrinterJob();
  -            int copies = AWTPrintRenderer.getIntProperty("copies", 1);
  -            pj.setCopies(copies);
  -            if (System.getProperty("dialog") != null) {
  -                if (!pj.printDialog()) {
  -                    throw new IllegalArgumentException("Printing cancelled by 
operator");
  -                }
  -            }
  -            setRenderer(new AWTPrintRenderer(pj));
  +            setRenderer("org.apache.fop.render.awt.AWTPrintRenderer");
               break;
           case RENDER_PCL:
               setRenderer("org.apache.fop.render.pcl.PCLRenderer");
  
  
  
  1.3       +18 -15    xml-fop/src/java/org/apache/fop/render/awt/AWTPrintRenderer.java
  
  Index: AWTPrintRenderer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/render/awt/AWTPrintRenderer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AWTPrintRenderer.java     27 Jul 2003 20:16:03 -0000      1.2
  +++ AWTPrintRenderer.java     2 Aug 2003 21:26:53 -0000       1.3
  @@ -67,18 +67,30 @@
       private int copies = 1;
       private PrinterJob printerJob;
   
  -    public AWTPrintRenderer(PrinterJob printerJob) {
  +    public AWTPrintRenderer() {
           super(null);
  -        this.printerJob = printerJob;
  +        initialize();
  +    }
  +
  +    private void initialize() throws IllegalArgumentException {
  +        // read from command-line options
  +        copies = getIntProperty("copies", 1);
           startNumber = getIntProperty("start", 1) - 1;
           endNumber = getIntProperty("end", -1);
  -        printerJob.setPageable(this);
  -        mode = EVEN_AND_ALL;
           String str = System.getProperty("even");
           if (str != null) {
               mode = Boolean.valueOf(str).booleanValue() ? EVEN : ODD;
           }
  -    }
  +        
  +        printerJob = PrinterJob.getPrinterJob();
  +        printerJob.setCopies(copies);
  +        if (System.getProperty("dialog") != null) {
  +            if (!printerJob.printDialog()) {
  +                throw new IllegalArgumentException("Printing cancelled by 
operator");
  +            }
  +        }
  +        printerJob.setPageable(this);
  +    }   
   
       public void stopRenderer() throws IOException {
           super.stopRenderer();
  @@ -137,14 +149,5 @@
           }
           return vec;
       }
  -
  -    /* TODO: I'm not totally sure that this is necessary -Mark
  -     void setCopies(int val) {
  -             copies = val;
  -             Vector copie = tree.getPages();
  -             for (int i = 1; i < copies; i++) {
  -                     tree.getPages().addAll(copie);
  -             }
  -    } */
   } // class AWTPrintRenderer
   
  
  
  
  1.7       +2 -8      xml-fop/src/java/org/apache/fop/servlet/FopPrintServlet.java
  
  Index: FopPrintServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/servlet/FopPrintServlet.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FopPrintServlet.java      10 Jul 2003 23:49:55 -0000      1.6
  +++ FopPrintServlet.java      2 Aug 2003 21:26:53 -0000       1.7
  @@ -56,8 +56,6 @@
   import java.io.PrintWriter;
   import java.util.List;
   
  -import java.awt.print.PrinterJob;
  -
   import javax.servlet.ServletException;
   import javax.servlet.http.HttpServlet;
   import javax.servlet.http.HttpServletRequest;
  @@ -171,8 +169,7 @@
                            HttpServletResponse response) throws ServletException {
           try {
               Driver driver = new Driver(foFile, null);
  -            PrinterJob pj = PrinterJob.getPrinterJob();
  -            AWTPrintRenderer renderer = new AWTPrintRenderer(pj);
  +            AWTPrintRenderer renderer = new AWTPrintRenderer();
   
               driver.enableLogging(log);
               driver.setRenderer(renderer);
  @@ -194,10 +191,7 @@
                             HttpServletResponse response) throws ServletException {
           try {
               Driver driver = new Driver();
  -            PrinterJob pj = PrinterJob.getPrinterJob();
  -            AWTPrintRenderer renderer = new AWTPrintRenderer(pj);
  -
  -            pj.setCopies(1);
  +            AWTPrintRenderer renderer = new AWTPrintRenderer();
   
               driver.enableLogging(log);
               driver.setRenderer(renderer);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to