gmazza      2003/08/10 08:43:13

  Modified:    src/java/org/apache/fop/apps AWTStarter.java
               src/java/org/apache/fop/render/awt AWTPrintRenderer.java
                        AWTRenderer.java
               src/java/org/apache/fop/viewer PreviewDialog.java
  Log:
  Moved the Translator (resource bundle) creation from AWTStarter to AWTRenderer.
  Gave the AWTRenderer access to the PrintViewer frame that displays the document.
  Moved rendering status messages from AWTStarter to AWTRenderer and PrintDialog.
  
  Revision  Changes    Path
  1.8       +5 -13     xml-fop/src/java/org/apache/fop/apps/AWTStarter.java
  
  Index: AWTStarter.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/AWTStarter.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AWTStarter.java   8 Aug 2003 22:56:15 -0000       1.7
  +++ AWTStarter.java   10 Aug 2003 15:43:13 -0000      1.8
  @@ -53,14 +53,12 @@
   //FOP
   import org.apache.fop.render.awt.AWTRenderer;
   import org.apache.fop.viewer.PreviewDialog;
  -import org.apache.fop.viewer.Translator;
   
   //Java
   import java.awt.Dimension;
   import java.awt.Toolkit;
   import java.awt.event.WindowAdapter;
   import java.awt.event.WindowEvent;
  -import java.util.Locale;
   
   /**
    * AWT Viewer starter.
  @@ -72,7 +70,6 @@
    */
   public class AWTStarter extends CommandLineStarter {
       private PreviewDialog frame;
  -    private Translator translator;
       private Driver driver;
   
       /**
  @@ -87,10 +84,9 @@
       }
   
       private void init() throws FOPException {
  -        translator = new Translator();
  -        AWTRenderer renderer = new AWTRenderer(translator);
  -        frame = createPreviewDialog(renderer, translator);
  -        renderer.setComponent(frame);
  +        AWTRenderer renderer = new AWTRenderer();
  +        frame = createPreviewDialog(renderer);
  +        renderer.setPreviewDialog(frame);
           renderer.setOptions(commandLineOptions.getRendererOptions());
           driver = new Driver();
           driver.setRenderer(renderer);
  @@ -103,18 +99,14 @@
       public void run() throws FOPException {
           driver.reset();
           try {
  -            frame.setStatus(translator.getString("Status.Build.FO.tree"));
               driver.render(inputHandler);
  -            frame.setStatus(translator.getString("Status.Show"));
  -            frame.showPage();
           } catch (Exception e) {
               frame.reportException(e);
           }
       }
   
  -    private PreviewDialog createPreviewDialog(AWTRenderer renderer,
  -            Translator res) {
  -        PreviewDialog frame = new PreviewDialog(this, renderer, res);
  +    private PreviewDialog createPreviewDialog(AWTRenderer renderer) {
  +        PreviewDialog frame = new PreviewDialog(this, renderer);
           frame.addWindowListener(new WindowAdapter() {
               public void windowClosed(WindowEvent we) {
                   System.exit(0);
  
  
  
  1.4       +2 -2      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AWTPrintRenderer.java     2 Aug 2003 21:26:53 -0000       1.3
  +++ AWTPrintRenderer.java     10 Aug 2003 15:43:13 -0000      1.4
  @@ -68,7 +68,7 @@
       private PrinterJob printerJob;
   
       public AWTPrintRenderer() {
  -        super(null);
  +        super();
           initialize();
       }
   
  
  
  
  1.3       +25 -15    xml-fop/src/java/org/apache/fop/render/awt/AWTRenderer.java
  
  Index: AWTRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/awt/AWTRenderer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AWTRenderer.java  8 Aug 2003 20:43:25 -0000       1.2
  +++ AWTRenderer.java  10 Aug 2003 15:43:13 -0000      1.3
  @@ -72,6 +72,7 @@
   
   import org.apache.fop.layout.FontInfo;
   import org.apache.fop.render.AbstractRenderer;
  +import org.apache.fop.viewer.PreviewDialog;
   import org.apache.fop.viewer.Translator;
   
   /**
  @@ -85,7 +86,11 @@
       protected int pageNumber = 0;
       protected List pageList = new java.util.Vector();
       //protected ProgressListener progressListener = null;
  -    protected Translator res = null;
  +
  +    /**
  +     * The resource bundle used for AWT messages.
  +     */
  +    protected Translator translator = null;
   
       protected Map fontNames = new java.util.Hashtable();
       protected Map fontStyles = new java.util.Hashtable();
  @@ -100,7 +105,7 @@
   
       /**
        * The current (internal) font name
  -     */
  +    */
       protected String currentFontName;
   
       /**
  @@ -116,14 +121,18 @@
       protected float currentBlue = 0;
   
       /**
  -     * The parent component, used to set up the font.
  -     * This is needed as FontSetup needs a live AWT component
  -     * in order to generate valid font measures.
  -     */
  -    protected Component parent;
  +     * The preview dialog frame used for display of the documents.
  +     * Also used as the AWT Component for FontSetup in generating
  +     * valid font measures.
  +     */
  +    protected PreviewDialog frame;
  +    
  +    public AWTRenderer() {
  +        translator = new Translator();
  +    }
   
  -    public AWTRenderer(Translator aRes) {
  -        res = aRes;
  +    public Translator getTranslator() {
  +        return translator;
       }
   
       public int getPageCount() {
  @@ -138,13 +147,12 @@
       }
   
       /**
  -     * Sets parent component which is  used to set up the font.
  -     * This is needed as FontSetup needs a live AWT component
  -     * in order to generate valid font measures.
  -     * @param parent the live AWT component reference
  +     * Sets the preview dialog frame used for display of the documents.
  +     * @param frame the PreviewDialog frame
        */
  -    public void setComponent(Component parent) {
  -        this.parent = parent;
  +    public void setPreviewDialog(PreviewDialog frame) {
  +        this.frame = frame;
  +        frame.setStatus(translator.getString("Status.Build.FO.tree"));
       }
   
       public int getPageNumber() {
  @@ -173,6 +181,8 @@
   
       public void stopRenderer()
       throws IOException {
  +        frame.setStatus(translator.getString("Status.Show"));
  +        frame.showPage();
       }
   
       // Printable Interface
  
  
  
  1.2       +8 -8      xml-fop/src/java/org/apache/fop/viewer/PreviewDialog.java
  
  Index: PreviewDialog.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/viewer/PreviewDialog.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PreviewDialog.java        11 Mar 2003 13:05:42 -0000      1.1
  +++ PreviewDialog.java        10 Aug 2003 15:43:13 -0000      1.2
  @@ -106,24 +106,22 @@
       private JLabel infoStatus;
   
       /**
  -     *  Creates a new PreviewDialog that uses the given starter, renderer and 
translator.
  +     *  Creates a new PreviewDialog that uses the given starter and renderer.
        *  @param aStarter the to use starter
        *  @param aRenderer the to use renderer
  -     *  @param aRes the to use translator
        */
  -    public PreviewDialog(AWTStarter aStarter, AWTRenderer aRenderer, Translator 
aRes) {
  -        this(aRenderer, aRes);
  +    public PreviewDialog(AWTStarter aStarter, AWTRenderer aRenderer) {
  +        this(aRenderer);
           starter = aStarter;
       }
   
       /**
  -     * Creates a new PreviewDialog that uses the given renderer and translator.
  +     * Creates a new PreviewDialog that uses the given renderer.
        * @param aRenderer the to use renderer
  -     * @param aRes the to use translator
        */
  -    public PreviewDialog(AWTRenderer aRenderer, Translator aRes) {
  -        translator = aRes;
  +    public PreviewDialog(AWTRenderer aRenderer) {
           renderer = aRenderer;
  +        translator = renderer.getTranslator();
   
           //Commands aka Actions
           Command printAction = new Command(translator.getString("Menu.Print"), 
"Print") {
  @@ -424,7 +422,9 @@
               //while (renderer.getPageCount() != 0)
               //    renderer.removePage(0);
               try {
  +                setStatus(translator.getString("Status.Build.FO.tree"));
                   starter.run();
  +                setStatus(translator.getString("Status.Show"));
               } catch (FOPException e) {
                   reportException(e);
               }
  
  
  

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

Reply via email to