jeremias    2003/01/27 01:21:26

  Modified:    src/org/apache/fop/image ImageFactory.java ImageLoader.java
  Log:
  Separate baseURL parameter unnecessary as it comes from the user agent anyway.
  
  Revision  Changes    Path
  1.14      +7 -11     xml-fop/src/org/apache/fop/image/ImageFactory.java
  
  Index: ImageFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/ImageFactory.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ImageFactory.java 8 Jan 2003 13:55:01 -0000       1.13
  +++ ImageFactory.java 27 Jan 2003 09:21:26 -0000      1.14
  @@ -115,15 +115,13 @@
       /**
        * Create an FopImage objects.
        * @param href the url for the image
  -     * @param baseURL the base url
        * @param ua the user agent context
        * @return the fop image instance
        */
  -    protected static FopImage loadImage(String href, String baseURL,
  -                                        FOUserAgent ua) {
  +    protected static FopImage loadImage(String href, FOUserAgent ua) {
           Logger log = ua.getLogger();
   
  -        InputStream in = openStream(href, baseURL, ua);
  +        InputStream in = openStream(href, ua);
   
           if (in == null) {
               return null;
  @@ -202,12 +200,10 @@
       /**
        * Create an FopImage objects.
        * @param href image URL as a String
  -     * @param baseURL base URL for relative URLs
        * @param ua user agent
        * @return a new FopImage object
        */
  -    protected static InputStream openStream(String href, String baseURL,
  -                                        FOUserAgent ua) {
  +    protected static InputStream openStream(String href, FOUserAgent ua) {
           Logger log = ua.getLogger();
           // Get the absolute URL
           URL absoluteURL = null;
  @@ -237,13 +233,13 @@
                   return null;
               } catch (Exception e) {
                   // maybe relative
  -                if (baseURL == null) {
  +                if (ua.getBaseURL() == null) {
                       log.error("Error with image URL: " + e.getMessage() 
  -                            + " and no base directory is specified", e);
  +                            + " and no base URL is specified", e);
                       return null;
                   }
                   try {
  -                    absoluteURL = new URL(baseURL + absoluteURL.getFile());
  +                    absoluteURL = new URL(ua.getBaseURL() + absoluteURL.getFile());
                   } catch (MalformedURLException e_context) {
                       // pb context url
                       log.error("Invalid Image URL - error on relative URL: " 
  
  
  
  1.5       +23 -13    xml-fop/src/org/apache/fop/image/ImageLoader.java
  
  Index: ImageLoader.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/ImageLoader.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ImageLoader.java  1 Jul 2002 10:40:39 -0000       1.4
  +++ ImageLoader.java  27 Jan 2003 09:21:26 -0000      1.5
  @@ -1,6 +1,6 @@
   /*
    * $Id$
  - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  + * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
    */
  @@ -13,24 +13,34 @@
    * Class to load images.
    */
   class ImageLoader {
  -    String url;
  -    ImageCache cache;
  -    boolean valid = true;
  -    FOUserAgent userAgent;
  -    FopImage image = null;
  +    
  +    private String url;
  +    private ImageCache cache;
  +    private boolean valid = true;
  +    private FOUserAgent userAgent;
  +    private FopImage image = null;
   
  -    public ImageLoader(String u, ImageCache c, FOUserAgent ua) {
  -        url = u;
  -        cache = c;
  -        userAgent = ua;
  +    /**
  +     * Main constructor.
  +     * @param url URL to the image
  +     * @param cache Image cache
  +     * @param ua User agent
  +     */
  +    public ImageLoader(String url, ImageCache cache, FOUserAgent ua) {
  +        this.url = url;
  +        this.cache = cache;
  +        this.userAgent = ua;
       }
   
  +    /**
  +     * Loads the image.
  +     * @return the loaded image
  +     */
       public synchronized FopImage loadImage() {
           if (!valid || image != null) {
               return image;
           }
  -        String base = userAgent.getBaseURL();
  -        image = ImageFactory.loadImage(url, base, userAgent);
  +        image = ImageFactory.loadImage(url, userAgent);
           if (image == null) {
               cache.invalidateImage(url, userAgent);
               valid = false;
  
  
  

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

Reply via email to