aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/image
diff options
context:
space:
mode:
authorGlen Mazza <gmazza@apache.org>2004-01-25 14:40:14 +0000
committerGlen Mazza <gmazza@apache.org>2004-01-25 14:40:14 +0000
commita539d8af4c422676cb89fa27bcb8d17496b6801c (patch)
tree27d39971882d9e094123ccf71f6c3d4a4a84d9e7 /src/java/org/apache/fop/image
parentcd3a9ec3112fdec56e42a3bb90f8bc6c1b55d035 (diff)
downloadxmlgraphics-fop-a539d8af4c422676cb89fa27bcb8d17496b6801c.tar.gz
xmlgraphics-fop-a539d8af4c422676cb89fa27bcb8d17496b6801c.zip
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. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197259 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/image')
-rw-r--r--src/java/org/apache/fop/image/AbstractFopImage.java16
-rw-r--r--src/java/org/apache/fop/image/BmpImage.java20
-rw-r--r--src/java/org/apache/fop/image/FopImage.java6
-rw-r--r--src/java/org/apache/fop/image/GifImage.java16
-rw-r--r--src/java/org/apache/fop/image/JimiImage.java13
-rw-r--r--src/java/org/apache/fop/image/JpegImage.java26
6 files changed, 47 insertions, 50 deletions
diff --git a/src/java/org/apache/fop/image/AbstractFopImage.java b/src/java/org/apache/fop/image/AbstractFopImage.java
index 8824c8cd0..cd4016906 100644
--- a/src/java/org/apache/fop/image/AbstractFopImage.java
+++ b/src/java/org/apache/fop/image/AbstractFopImage.java
@@ -57,7 +57,7 @@ import java.io.InputStream;
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 @@ public abstract class AbstractFopImage implements FopImage {
* @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 @@ public abstract class AbstractFopImage implements FopImage {
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 @@ public abstract class AbstractFopImage implements FopImage {
* @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 @@ public abstract class AbstractFopImage implements FopImage {
* @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 @@ public abstract class AbstractFopImage implements FopImage {
* @param ua the user agent
* @return true if the loading was successful
*/
- protected boolean loadOriginalData(FOUserAgent ua) {
+ protected boolean loadOriginalData(Logger logger) {
return false;
}
diff --git a/src/java/org/apache/fop/image/BmpImage.java b/src/java/org/apache/fop/image/BmpImage.java
index 4e724af3e..0e8655179 100644
--- a/src/java/org/apache/fop/image/BmpImage.java
+++ b/src/java/org/apache/fop/image/BmpImage.java
@@ -55,7 +55,7 @@ import java.io.IOException;
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 @@ public class BmpImage extends AbstractFopImage {
* @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 @@ public class BmpImage extends AbstractFopImage {
}
}
} 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 @@ public class BmpImage extends AbstractFopImage {
} 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 @@ public class BmpImage extends AbstractFopImage {
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;
}
diff --git a/src/java/org/apache/fop/image/FopImage.java b/src/java/org/apache/fop/image/FopImage.java
index 4fadd564a..76b509d99 100644
--- a/src/java/org/apache/fop/image/FopImage.java
+++ b/src/java/org/apache/fop/image/FopImage.java
@@ -55,7 +55,7 @@ import java.awt.color.ColorSpace;
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 @@ public interface FopImage {
* 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.
diff --git a/src/java/org/apache/fop/image/GifImage.java b/src/java/org/apache/fop/image/GifImage.java
index 8d4d4735b..1237348a5 100644
--- a/src/java/org/apache/fop/image/GifImage.java
+++ b/src/java/org/apache/fop/image/GifImage.java
@@ -61,7 +61,7 @@ import java.io.IOException;
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 @@ public class GifImage extends AbstractFopImage {
* @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 @@ public class GifImage extends AbstractFopImage {
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 @@ public class GifImage extends AbstractFopImage {
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;
}
diff --git a/src/java/org/apache/fop/image/JimiImage.java b/src/java/org/apache/fop/image/JimiImage.java
index 417ccb40d..7a6f65763 100644
--- a/src/java/org/apache/fop/image/JimiImage.java
+++ b/src/java/org/apache/fop/image/JimiImage.java
@@ -63,9 +63,6 @@ import com.sun.jimi.core.Jimi;
// 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 @@ public class JimiImage extends AbstractFopImage {
}
}
- 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;
diff --git a/src/java/org/apache/fop/image/JpegImage.java b/src/java/org/apache/fop/image/JpegImage.java
index 05265baf2..f3425980b 100644
--- a/src/java/org/apache/fop/image/JpegImage.java
+++ b/src/java/org/apache/fop/image/JpegImage.java
@@ -56,7 +56,7 @@ import java.awt.color.ColorSpace;
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 @@ public class JpegImage extends AbstractFopImage {
* @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 @@ public class JpegImage extends AbstractFopImage {
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 @@ public class JpegImage extends AbstractFopImage {
*/
this.colorSpace = CMYKColorSpace.getInstance();
} else {
- ua.getLogger().error("Unknown ColorSpace for image: "
+ logger.error("Unknown ColorSpace for image: "
+ "");
return false;
}
@@ -189,8 +189,8 @@ public class JpegImage extends AbstractFopImage {
}
}
} 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 @@ public class JpegImage extends AbstractFopImage {
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;