gmazza      2004/01/25 06:40:14

  Modified:    src/java/org/apache/fop/fo/flow ExternalGraphic.java
               src/java/org/apache/fop/image AbstractFopImage.java
                        BmpImage.java FopImage.java GifImage.java
                        JimiImage.java JpegImage.java
               src/java/org/apache/fop/render/awt AWTRenderer.java
               src/java/org/apache/fop/render/pdf PDFRenderer.java
               src/java/org/apache/fop/render/ps PSRenderer.java
               src/java/org/apache/fop/svg PDFImageElementBridge.java
  Log:
  Switching from passing the FOUserAgent for several of the image
  functions to its internal Avalon logger instead.  (Only object used within
  FOUserAgent parameter, plus this library is also used for the PDFTranscoder, plus
  FOUserAgent not always available from everywhere anymore.)  Holding off making
  a complete switch in this package (FOUserAgent still used in a few more
  places, albeit only its logger is being requested)
  until others comment.
  
  Revision  Changes    Path
  1.18      +1 -1      xml-fop/src/java/org/apache/fop/fo/flow/ExternalGraphic.java
  
  Index: ExternalGraphic.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/ExternalGraphic.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ExternalGraphic.java      17 Jan 2004 19:29:46 -0000      1.17
  +++ ExternalGraphic.java      25 Jan 2004 14:40:14 -0000      1.18
  @@ -158,7 +158,7 @@
                   return;
               }
               // load dimensions
  -            if (!fopimage.load(FopImage.DIMENSIONS, getUserAgent())) {
  +            if (!fopimage.load(FopImage.DIMENSIONS, getUserAgent().getLogger())) {
                   // error
                   url = null;
                   return;
  
  
  
  1.4       +8 -8      xml-fop/src/java/org/apache/fop/image/AbstractFopImage.java
  
  Index: AbstractFopImage.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/image/AbstractFopImage.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractFopImage.java     30 Aug 2003 17:59:53 -0000      1.3
  +++ AbstractFopImage.java     25 Jan 2004 14:40:14 -0000      1.4
  @@ -57,7 +57,7 @@
   import java.awt.Color;
   
   // FOP
  -import org.apache.fop.apps.FOUserAgent;
  +import org.apache.avalon.framework.logger.Logger;
   
   /**
    * Base class to implement the FopImage interface.
  @@ -157,13 +157,13 @@
        * @param ua the user agent for handling logging etc.
        * @return true if the loading was successful
        */
  -    public synchronized boolean load(int type, FOUserAgent ua) {
  +    public synchronized boolean load(int type, Logger logger) {
           if ((loaded & type) != 0) {
               return true;
           }
           boolean success = true;
           if (((type & DIMENSIONS) != 0) && ((loaded & DIMENSIONS) == 0)) {
  -            success = success && loadDimensions(ua);
  +            success = success && loadDimensions(logger);
   
               if (!success) {
                   return false;
  @@ -171,13 +171,13 @@
               loaded = loaded | DIMENSIONS;
           }
           if (((type & BITMAP) != 0) && ((loaded & BITMAP) == 0)) {
  -            success = success && loadBitmap(ua);
  +            success = success && loadBitmap(logger);
               if (success) {
                   loaded = loaded | BITMAP;
               }
           }
           if (((type & ORIGINAL_DATA) != 0) && ((loaded & ORIGINAL_DATA) == 0)) {
  -            success = success && loadOriginalData(ua);
  +            success = success && loadOriginalData(logger);
               if (success) {
                   loaded = loaded | ORIGINAL_DATA;
               }
  @@ -193,7 +193,7 @@
        * @param ua the user agent
        * @return true if the loading was successful
        */
  -    protected boolean loadDimensions(FOUserAgent ua) {
  +    protected boolean loadDimensions(Logger logger) {
           return false;
       }
   
  @@ -205,7 +205,7 @@
        * @param ua the user agent
        * @return true if the loading was successful
        */
  -    protected boolean loadBitmap(FOUserAgent ua) {
  +    protected boolean loadBitmap(Logger logger) {
           return false;
       }
   
  @@ -217,7 +217,7 @@
        * @param ua the user agent
        * @return true if the loading was successful
        */
  -    protected boolean loadOriginalData(FOUserAgent ua) {
  +    protected boolean loadOriginalData(Logger logger) {
           return false;
       }
   
  
  
  
  1.3       +10 -10    xml-fop/src/java/org/apache/fop/image/BmpImage.java
  
  Index: BmpImage.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/image/BmpImage.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BmpImage.java     22 Aug 2003 17:42:41 -0000      1.2
  +++ BmpImage.java     25 Jan 2004 14:40:14 -0000      1.3
  @@ -55,7 +55,7 @@
   import java.awt.color.ColorSpace;
   
   // FOP
  -import org.apache.fop.apps.FOUserAgent;
  +import org.apache.avalon.framework.logger.Logger;
   
   /**
    * Bitmap image.
  @@ -82,7 +82,7 @@
        * @param ua the user agent
        * @return true if it was loaded successfully
        */
  -    protected boolean loadBitmap(FOUserAgent ua) {
  +    protected boolean loadBitmap(Logger logger) {
           int wpos = 18;
           int hpos = 22; // offset positioning for w and height in  bmp files
           int[] headermap = new int[54];
  @@ -120,7 +120,7 @@
                   }
               }
           } catch (IOException e) {
  -            ua.getLogger().error("Error while loading image "
  +            logger.error("Error while loading image "
                                            + "" + " : "
                                            + e.getClass() + " - "
                                            + e.getMessage(), e);
  @@ -150,9 +150,9 @@
           } else if (this.bitsPerPixel == 4 || this.bitsPerPixel == 8) {
               bytes = this.width / (8 / this.bitsPerPixel);
           } else {
  -            ua.getLogger().error("Image (" + ""
  -                                         + ") has " + this.bitsPerPixel
  -                                         + " which is not a supported BMP format.");
  +            logger.error("Image (" + ""
  +                          + ") has " + this.bitsPerPixel
  +                          + " which is not a supported BMP format.");
               return false;
           }
           if ((bytes & 0x03) != 0) {
  @@ -175,10 +175,10 @@
               inputStream.close();
               inputStream = null;
           } catch (IOException e) {
  -            ua.getLogger().error("Error while loading image "
  -                                         + "" + " : "
  -                                         + e.getClass() + " - "
  -                                         + e.getMessage(), e);
  +            logger.error("Error while loading image "
  +                          + "" + " : "
  +                          + e.getClass() + " - "
  +                          + e.getMessage(), e);
               return false;
           }
   
  
  
  
  1.6       +3 -3      xml-fop/src/java/org/apache/fop/image/FopImage.java
  
  Index: FopImage.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/image/FopImage.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FopImage.java     30 Aug 2003 18:05:24 -0000      1.5
  +++ FopImage.java     25 Jan 2004 14:40:14 -0000      1.6
  @@ -55,7 +55,7 @@
   import java.awt.color.ICC_Profile;
   import java.awt.Color;
   
  -import org.apache.fop.apps.FOUserAgent;
  +import org.apache.avalon.framework.logger.Logger;
   
   /**
    * Fop image interface for loading images.
  @@ -93,10 +93,10 @@
        * the information.
        *
        * @param type the type of loading required
  -     * @param ua the user agent
  +     * @param logger the Avalon logger
        * @return boolean true if the information could be loaded
        */
  -    boolean load(int type, FOUserAgent ua);
  +    boolean load(int type, Logger logger);
   
       /**
        * Returns the image width.
  
  
  
  1.4       +8 -8      xml-fop/src/java/org/apache/fop/image/GifImage.java
  
  Index: GifImage.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/image/GifImage.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- GifImage.java     30 Aug 2003 17:59:53 -0000      1.3
  +++ GifImage.java     25 Jan 2004 14:40:14 -0000      1.4
  @@ -61,7 +61,7 @@
   import java.net.URLConnection;
   
   // FOP
  -import org.apache.fop.apps.FOUserAgent;
  +import org.apache.avalon.framework.logger.Logger;
   
   /**
    * FopImage object for GIF images, using Java native classes.
  @@ -90,7 +90,7 @@
        * @param ua the user agent for loading
        * @return True if the load process succeeded
        */
  -    protected boolean loadBitmap(FOUserAgent ua) {
  +    protected boolean loadBitmap(Logger logger) {
           int[] tmpMap = null;
           try {
               URLConnection con = new DummyConnection(inputStream);
  @@ -113,8 +113,8 @@
               try {
                   tmpMap = consumer.getImage();
               } catch (Exception ex) {
  -                ua.getLogger().error("Image grabbing interrupted : "
  -                                             + ex.getMessage(), ex);
  +                logger.error("Image grabbing interrupted : "
  +                              + ex.getMessage(), ex);
                   return false;
               }
   
  @@ -178,10 +178,10 @@
                   this.isTransparent = false;
               }
           } catch (Exception ex) {
  -            ua.getLogger().error("Error while loading image "
  -                                         + "" + " : "
  -                                         + ex.getClass() + " - "
  -                                         + ex.getMessage(), ex);
  +            logger.error("Error while loading image "
  +                          + "" + " : "
  +                          + ex.getClass() + " - "
  +                          + ex.getMessage(), ex);
               return false;
           }
   
  
  
  
  1.4       +5 -8      xml-fop/src/java/org/apache/fop/image/JimiImage.java
  
  Index: JimiImage.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/image/JimiImage.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JimiImage.java    30 Aug 2003 17:59:53 -0000      1.3
  +++ JimiImage.java    25 Jan 2004 14:40:14 -0000      1.4
  @@ -63,9 +63,6 @@
   // Avalon
   import org.apache.avalon.framework.logger.Logger;
   
  -// FOP
  -import org.apache.fop.apps.FOUserAgent;
  -
   /**
    * FopImage object for several images types, using Jimi.
    * See Jimi documentation for supported image types.
  @@ -84,20 +81,20 @@
           }
       }
   
  -    protected boolean loadDimensions(FOUserAgent ua) {
  +    protected boolean loadDimensions(Logger logger) {
           if (this.bitmaps == null) {
  -            loadImage(ua.getLogger());
  +            loadImage(logger);
           }
   
           return this.bitmaps != null;
       }
   
       /**
  -     * @see org.apache.fop.image.AbstractFopImage#loadBitmap(FOUserAgent)
  +     * @see org.apache.fop.image.AbstractFopImage#loadBitmap(Logger)
        */
  -    protected boolean loadBitmap(FOUserAgent ua) {
  +    protected boolean loadBitmap(Logger logger) {
           if (this.bitmaps == null) {
  -            loadImage(ua.getLogger());
  +            loadImage(logger);
           }
   
           return this.bitmaps != null;
  
  
  
  1.4       +13 -13    xml-fop/src/java/org/apache/fop/image/JpegImage.java
  
  Index: JpegImage.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/image/JpegImage.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JpegImage.java    22 Aug 2003 17:42:41 -0000      1.3
  +++ JpegImage.java    25 Jan 2004 14:40:14 -0000      1.4
  @@ -56,7 +56,7 @@
   import java.awt.color.ICC_Profile;
   
   // FOP
  -import org.apache.fop.apps.FOUserAgent;
  +import org.apache.avalon.framework.logger.Logger;
   import org.apache.fop.util.CMYKColorSpace;
   
   /**
  @@ -87,7 +87,7 @@
        * @param ua the user agent
        * @return true if loaded false for any error
        */
  -    protected boolean loadOriginalData(FOUserAgent ua) {
  +    protected boolean loadOriginalData(Logger logger) {
           ByteArrayOutputStream baos = new ByteArrayOutputStream();
           ByteArrayOutputStream iccStream = new ByteArrayOutputStream();
           int index = 0;
  @@ -102,9 +102,9 @@
               inputStream.close();
               inputStream = null;
           } catch (java.io.IOException ex) {
  -            ua.getLogger().error("Error while loading image "
  -                                         + " : " + ex.getClass()
  -                                         + " - " + ex.getMessage(), ex);
  +            logger.error("Error while loading image "
  +                          + " : " + ex.getClass()
  +                          + " - " + ex.getMessage(), ex);
               return false;
           }
   
  @@ -147,7 +147,7 @@
                               */
                               this.colorSpace = CMYKColorSpace.getInstance();
                           } else {
  -                            ua.getLogger().error("Unknown ColorSpace for image: "
  +                            logger.error("Unknown ColorSpace for image: "
                                                      + "");
                               return false;
                           }
  @@ -189,8 +189,8 @@
                   }
               }
           } else {
  -            ua.getLogger().error("Error while loading "
  -                                          + "JpegImage - Invalid JPEG Header.");
  +            logger.error("Error while loading "
  +                         + "JpegImage - Invalid JPEG Header.");
               return false;
           }
           if (iccStream.size() > 0) {
  @@ -198,19 +198,19 @@
               try {
                   iccStream.write(align);
               } catch (Exception e) {
  -                ua.getLogger().error("Error while loading image "
  -                                              + " : "
  -                                              + e.getMessage(), e);
  +                logger.error("Error while loading image "
  +                              + " : "
  +                              + e.getMessage(), e);
                   return false;
               }
               try {
                   iccProfile = ICC_Profile.getInstance(iccStream.toByteArray());
               } catch (Exception e) {
  -                ua.getLogger().error("Invalid ICC profile: " + e, e);
  +                logger.error("Invalid ICC profile: " + e, e);
                   return false;
               }
           } else if (this.colorSpace == null) {
  -            ua.getLogger().error("ColorSpace not specified for JPEG image");
  +            logger.error("ColorSpace not specified for JPEG image");
               return false;
           }
           return true;
  
  
  
  1.20      +1 -1      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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- AWTRenderer.java  24 Jan 2004 16:09:47 -0000      1.19
  +++ AWTRenderer.java  25 Jan 2004 14:40:14 -0000      1.20
  @@ -409,7 +409,7 @@
               if (back.getURL() != null) {  // TODO: implement
                   ImageFactory fact = ImageFactory.getInstance();
                   FopImage fopimage = fact.getImage(back.getURL(), userAgent);
  -                if (fopimage != null && fopimage.load(FopImage.DIMENSIONS, 
userAgent)) {
  +                if (fopimage != null && fopimage.load(FopImage.DIMENSIONS, 
userAgent.getLogger())) {
                       if (back.getRepeat() == BackgroundRepeat.REPEAT) {
                           // create a pattern for the image
                       } else {
  
  
  
  1.29      +7 -7      xml-fop/src/java/org/apache/fop/render/pdf/PDFRenderer.java
  
  Index: PDFRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/pdf/PDFRenderer.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- PDFRenderer.java  24 Jan 2004 16:09:48 -0000      1.28
  +++ PDFRenderer.java  25 Jan 2004 14:40:14 -0000      1.29
  @@ -595,7 +595,7 @@
               if (back.getURL() != null) {
                   ImageFactory fact = ImageFactory.getInstance();
                   FopImage fopimage = fact.getImage(back.getURL(), userAgent);
  -                if (fopimage != null && fopimage.load(FopImage.DIMENSIONS, 
userAgent)) {
  +                if (fopimage != null && fopimage.load(FopImage.DIMENSIONS, 
userAgent.getLogger())) {
                       if (back.getRepeat() == BackgroundRepeat.REPEAT) {
                           // create a pattern for the image
                       } else {
  @@ -1102,12 +1102,12 @@
           if (fopimage == null) {
               return;
           }
  -        if (!fopimage.load(FopImage.DIMENSIONS, userAgent)) {
  +        if (!fopimage.load(FopImage.DIMENSIONS, userAgent.getLogger())) {
               return;
           }
           String mime = fopimage.getMimeType();
           if ("text/xml".equals(mime)) {
  -            if (!fopimage.load(FopImage.ORIGINAL_DATA, userAgent)) {
  +            if (!fopimage.load(FopImage.ORIGINAL_DATA, userAgent.getLogger())) {
                   return;
               }
               Document doc = ((XMLImage) fopimage).getDocument();
  @@ -1115,7 +1115,7 @@
   
               renderDocument(doc, ns, pos);
           } else if ("image/svg+xml".equals(mime)) {
  -            if (!fopimage.load(FopImage.ORIGINAL_DATA, userAgent)) {
  +            if (!fopimage.load(FopImage.ORIGINAL_DATA, userAgent.getLogger())) {
                   return;
               }
               Document doc = ((XMLImage) fopimage).getDocument();
  @@ -1123,14 +1123,14 @@
   
               renderDocument(doc, ns, pos);
           } else if ("image/eps".equals(mime)) {
  -            if (!fopimage.load(FopImage.ORIGINAL_DATA, userAgent)) {
  +            if (!fopimage.load(FopImage.ORIGINAL_DATA, userAgent.getLogger())) {
                   return;
               }
               FopPDFImage pdfimage = new FopPDFImage(fopimage, url);
               int xobj = pdfDoc.addImage(currentContext, pdfimage).getXNumber();
               fact.releaseImage(url, userAgent);
           } else if ("image/jpeg".equals(mime)) {
  -            if (!fopimage.load(FopImage.ORIGINAL_DATA, userAgent)) {
  +            if (!fopimage.load(FopImage.ORIGINAL_DATA, userAgent.getLogger())) {
                   return;
               }
               FopPDFImage pdfimage = new FopPDFImage(fopimage, url);
  @@ -1142,7 +1142,7 @@
               placeImage((int) pos.getX() / 1000,
                          (int) pos.getY() / 1000, w, h, xobj);
           } else {
  -            if (!fopimage.load(FopImage.BITMAP, userAgent)) {
  +            if (!fopimage.load(FopImage.BITMAP, userAgent.getLogger())) {
                   return;
               }
               FopPDFImage pdfimage = new FopPDFImage(fopimage, url);
  
  
  
  1.22      +1 -1      xml-fop/src/java/org/apache/fop/render/ps/PSRenderer.java
  
  Index: PSRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/ps/PSRenderer.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- PSRenderer.java   24 Jan 2004 16:09:48 -0000      1.21
  +++ PSRenderer.java   25 Jan 2004 14:40:14 -0000      1.22
  @@ -730,7 +730,7 @@
               if (back.getURL() != null) {
                   ImageFactory fact = ImageFactory.getInstance();
                   FopImage fopimage = fact.getImage(back.getURL(), userAgent);
  -                if (fopimage != null && fopimage.load(FopImage.DIMENSIONS, 
userAgent)) {
  +                if (fopimage != null && fopimage.load(FopImage.DIMENSIONS, 
userAgent.getLogger())) {
                       if (back.getRepeat() == BackgroundRepeat.REPEAT) {
                           // create a pattern for the image
                       } else {
  
  
  
  1.6       +3 -1      xml-fop/src/java/org/apache/fop/svg/PDFImageElementBridge.java
  
  Index: PDFImageElementBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/svg/PDFImageElementBridge.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PDFImageElementBridge.java        22 Jan 2004 22:40:51 -0000      1.5
  +++ PDFImageElementBridge.java        25 Jan 2004 14:40:14 -0000      1.6
  @@ -62,6 +62,7 @@
   
   import org.w3c.dom.Element;
   
  +import org.apache.avalon.framework.logger.ConsoleLogger;
   import org.apache.batik.bridge.BridgeContext;
   import org.apache.batik.gvt.AbstractGraphicsNode;
   import org.apache.batik.gvt.GraphicsNode;
  @@ -97,7 +98,8 @@
                   (purl.toString(), purl.openStream(), null);
               if (ii.mimeType.toLowerCase() == "image/jpeg") {
                   JpegImage jpeg = new JpegImage(ii);
  -                jpeg.load(FopImage.ORIGINAL_DATA, null);
  +                ConsoleLogger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
  +                jpeg.load(FopImage.ORIGINAL_DATA, logger);
                   PDFJpegNode node = new PDFJpegNode(jpeg, origGN);
   
                   Rectangle2D imgBounds = getImageBounds(ctx, e);
  
  
  

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

Reply via email to