cvs commit: xml-fop/src/org/apache/fop/image ImageFactory.java ImageLoader.java

2003-01-27 Thread jeremias
jeremias2003/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  ChangesPath
  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 -   1.13
  +++ ImageFactory.java 27 Jan 2003 09:21:26 -  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 -13xml-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 -   1.4
  +++ ImageLoader.java  27 Jan 2003 09:21:26 -  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;
  
  
  


cvs commit: xml-fop/src/org/apache/fop/image ImageFactory.java

2003-01-08 Thread jeremias
jeremias2003/01/08 05:55:01

  Modified:src/org/apache/fop/image ImageFactory.java
  Log:
  Lots of Javadocs
  Fixed Checkstyle errors
  
  Revision  ChangesPath
  1.13  +110 -104  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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ImageFactory.java 19 Dec 2002 08:13:18 -  1.12
  +++ ImageFactory.java 8 Jan 2003 13:55:01 -   1.13
  @@ -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.
*/
  @@ -10,36 +10,34 @@
   // Java
   import java.io.IOException;
   import java.io.InputStream;
  -import java.io.BufferedInputStream;
  -import java.io.File;
   import java.net.URL;
   import java.net.MalformedURLException;
   import java.lang.reflect.Constructor;
  -import java.util.HashMap;
  -import java.util.WeakHashMap;
   import java.util.Map;
  -import java.util.HashSet;
   import java.util.Set;
   import java.util.Collections;
   import java.util.Iterator;
   
  +// Avalon
  +import org.apache.avalon.framework.logger.Logger;
  +
   // FOP
   import org.apache.fop.image.analyser.ImageReaderFactory;
  -import org.apache.fop.image.analyser.ImageReader;
   import org.apache.fop.fo.FOUserAgent;
   
  -// Avalon
  -import org.apache.avalon.framework.logger.Logger;
   
   /**
  - * create FopImage objects (with a configuration file - not yet implemented).
  + * Create FopImage objects (with a configuration file - not yet implemented).
* @author Eric SCHAEFFER
*/
   public class ImageFactory {
  +
   private static ImageFactory factory = new ImageFactory();
  -ImageCache cache = new ContextImageCache(true);
  +
  +private ImageCache cache = new ContextImageCache(true);
   
  -private ImageFactory() {}
  +private ImageFactory() {
  +}
   
   /**
* Get static image factory instance.
  @@ -53,7 +51,7 @@
   /**
* Get the url string from a wrapped url.
*
  - * @href the input wrapped url
  + * @param href the input wrapped url
* @return the raw url
*/
   public static String getURL(String href) {
  @@ -64,8 +62,6 @@
* URI
* So handle both.
*/
  -// Get the absolute URL
  -URL absoluteURL = null;
   href = href.trim();
   if (href.startsWith(url()  (href.indexOf()) != -1)) {
   href = href.substring(4, href.indexOf())).trim();
  @@ -117,10 +113,7 @@
   }
   
   /**
  - * create an FopImage objects.
  - * @param href image URL as a String
  - * @return a new FopImage object
  - *
  + * Create an FopImage objects.
* @param href the url for the image
* @param baseURL the base url
* @param ua the user agent context
  @@ -130,9 +123,9 @@
   FOUserAgent ua) {
   Logger log = ua.getLogger();
   
  -InputStream imgIS = openStream(href, baseURL, ua);
  +InputStream in = openStream(href, baseURL, ua);
   
  -if (imgIS == null) {
  +if (in == null) {
   return null;
   }
   
  @@ -140,28 +133,29 @@
   FopImage.ImageInfo imgInfo = null;
   try {
   imgInfo = ImageReaderFactory.make(
  -  href, imgIS, ua);
  +  href, in, ua);
   } catch (Exception e) {
  -log.error(Error while recovering Image Informations ( +
  -  href + ) :  + e.getMessage(), e);
  +log.error(Error while recovering image information ( 
  ++ href + ) :  + e.getMessage(), e);
   return null;
   }
   if (imgInfo == null) {
   try {
  -imgIS.close();
  -imgIS = null;
  +in.close();
  +in = null;
   } catch (Exception e) {
  +log.debug(Error closing the InputStream for the image, e);
   }
  -log.error(No ImageReader for this type of image ( +
  -  href + ));
  +log.error(No ImageReader for this type of image ( 
  ++ href + ));
   return null;
   }
   // Associate mime-type to FopImage class
   String imgMimeType = imgInfo.mimeType;
   String imgClassName = getImageClassName(imgMimeType);
   if (imgClassName == null) {
  -log.error(Unsupported image type ( +
  -  href + ) :  + 

cvs commit: xml-fop/src/org/apache/fop/image ImageFactory.java

2002-12-19 Thread keiron
keiron  2002/12/19 00:13:18

  Modified:src/org/apache/fop/image ImageFactory.java
  Log:
  add method to remove context
  
  Revision  ChangesPath
  1.12  +10 -1 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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ImageFactory.java 29 Nov 2002 23:18:55 -  1.11
  +++ ImageFactory.java 19 Dec 2002 08:13:18 -  1.12
  @@ -108,6 +108,15 @@
   }
   
   /**
  + * Release the context and all images in the context.
  + *
  + * @param context the context to remove
  + */
  +public void removeContext(FOUserAgent context) {
  +cache.removeContext(context);
  +}
  +
  +/**
* create an FopImage objects.
* @param href image URL as a String
* @return a new FopImage object
  
  
  

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




cvs commit: xml-fop/src/org/apache/fop/image ImageFactory.java

2002-07-04 Thread keiron

keiron  2002/07/04 00:30:57

  Modified:src/org/apache/fop/image ImageFactory.java
  Log:
  removed repeated string
  
  Revision  ChangesPath
  1.8   +1 -2  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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ImageFactory.java 1 Jul 2002 10:40:39 -   1.7
  +++ ImageFactory.java 4 Jul 2002 07:30:57 -   1.8
  @@ -225,7 +225,6 @@
   }
   catch (Exception ex) {
   log.error(Error creating FopImage object ( +
  -  Error creating FopImage object ( +
 absoluteURL.toString() + ) :  + ex.getMessage(), ex);
   return null;
   }
  
  
  

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




cvs commit: xml-fop/src/org/apache/fop/image ImageFactory.java ImageLoader.java

2002-07-01 Thread keiron

keiron  2002/07/01 03:40:39

  Modified:src/org/apache/fop/image ImageFactory.java ImageLoader.java
  Log:
  minor cleanup
  
  Revision  ChangesPath
  1.7   +1 -3  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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ImageFactory.java 12 Jun 2002 15:18:56 -  1.6
  +++ ImageFactory.java 1 Jul 2002 10:40:39 -   1.7
  @@ -98,8 +98,6 @@
* create an FopImage objects.
* @param href image URL as a String
* @return a new FopImage object
  - * @exception java.net.MalformedURLException bad URL
  - * @exception FopImageException an error occured during construction
*/
   protected static FopImage loadImage(String href, String baseURL,
   FOUserAgent ua) {
  
  
  
  1.4   +1 -2  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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ImageLoader.java  21 Mar 2002 09:37:15 -  1.3
  +++ ImageLoader.java  1 Jul 2002 10:40:39 -   1.4
  @@ -7,7 +7,6 @@
   
   package org.apache.fop.image;
   
  -import org.apache.fop.configuration.Configuration;
   import org.apache.fop.fo.FOUserAgent;
   
   /**
  
  
  

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




cvs commit: xml-fop/src/org/apache/fop/image ImageFactory.java

2002-06-12 Thread keiron

keiron  2002/06/12 08:18:56

  Modified:src/org/apache/fop/image ImageFactory.java
  Log:
  added exception to log err message
  
  Revision  ChangesPath
  1.6   +2 -2  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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ImageFactory.java 11 Apr 2002 09:33:31 -  1.5
  +++ ImageFactory.java 12 Jun 2002 15:18:56 -  1.6
  @@ -127,7 +127,7 @@
   // maybe relative
   URL context_url = null;
   if (baseURL == null) {
  -log.error(Error with image URL:  + e.getMessage() +  and no base 
directory is specified);
  +log.error(Error with image URL:  + e.getMessage() +  and no base 
directory is specified, e);
   return null;
   }
   try {
  
  
  

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