import org.apache.commons.logging.LogFactory;
import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.ElementMappingRegistry;
+import org.apache.fop.image.ImageFactory;
import org.apache.fop.layoutmgr.LayoutManagerMaker;
import org.apache.fop.render.RendererFactory;
import org.apache.fop.render.XMLHandlerRegistry;
private ContentHandlerFactoryRegistry contentHandlerFactoryRegistry
= new ContentHandlerFactoryRegistry();
+ private ImageFactory imageFactory = new ImageFactory();
+
/** user configuration */
private Configuration userConfig = null;
return this.contentHandlerFactoryRegistry;
}
+ /** @return the image factory */
+ public ImageFactory getImageFactory() {
+ return this.imageFactory;
+ }
+
/**
* Add the element mapping with the given class name.
* @param elementMapping the class name representing the element mapping.
if (url != null) {
bkg.setURL(url);
- ImageFactory fact = ImageFactory.getInstance();
+ ImageFactory fact = userAgent.getFactory().getImageFactory();
FopImage img = fact.getImage(url, userAgent);
if (img == null) {
log.error("Background image not available: " + url);
foEventHandler.endDocument();
//Notify the image factory that this user agent has expired.
- ImageFactory.getInstance().removeContext(this.userAgent);
+ ImageFactory imageFactory = userAgent.getFactory().getImageFactory();
+ imageFactory.removeContext(this.userAgent);
}
/**
package org.apache.fop.fo.flow;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
//Additional processing: preload image
url = ImageFactory.getURL(getSrc());
- ImageFactory fact = ImageFactory.getInstance();
- fopimage = fact.getImage(url, getUserAgent());
+ FOUserAgent userAgent = getUserAgent();
+ ImageFactory fact = userAgent.getFactory().getImageFactory();
+ fopimage = fact.getImage(url, userAgent);
if (fopimage == null) {
getLogger().error("Image not available: " + getSrc());
} else {
package org.apache.fop.fo.properties;
+import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.datatypes.ColorType;
import org.apache.fop.datatypes.Length;
import org.apache.fop.datatypes.PercentBaseContext;
//Additional processing: preload image
String url = ImageFactory.getURL(backgroundImage);
- ImageFactory fact = ImageFactory.getInstance();
- fopimage = fact.getImage(url, fobj.getUserAgent());
+ FOUserAgent userAgent = fobj.getUserAgent();
+ ImageFactory fact = userAgent.getFactory().getImageFactory();
+ fopimage = fact.getImage(url, userAgent);
if (fopimage == null) {
fobj.getLogger().error("Background image not available: " + backgroundImage);
} else {
*/
protected static Log log = LogFactory.getLog(FopImage.class);
- private static ImageFactory factory = new ImageFactory();
+ //private static ImageFactory factory = new ImageFactory();
private HashMap imageMimeTypes = new HashMap();
private ImageCache cache = new ContextImageCache(true);
- private ImageFactory() {
+ public ImageFactory() {
/* @todo The mappings set up below of image mime types to implementing
* classes should be made externally configurable
*/
imt.addProvider(emfImage);
}
- /**
- * Get static image factory instance.
- *
- * @return the image factory instance
- */
- public static ImageFactory getInstance() {
- return factory;
- }
-
/**
* Get the url string from a wrapped url.
*
if (!valid || image != null) {
return image;
}
- image = ImageFactory.getInstance().loadImage(url, userAgent);
+ ImageFactory imageFactory = userAgent.getFactory().getImageFactory();
+ image = imageFactory.loadImage(url, userAgent);
if (image == null) {
cache.invalidateImage(url, userAgent);
valid = false;
int y = currentBPPosition;
String url = ImageFactory.getURL(pUrl);
- ImageFactory fact = ImageFactory.getInstance();
+ ImageFactory fact = userAgent.getFactory().getImageFactory();
FopImage fopimage = fact.getImage(url, userAgent);
if (fopimage == null) {
}
url = ImageFactory.getURL(url);
- ImageFactory fact = ImageFactory.getInstance();
+ ImageFactory fact = userAgent.getFactory().getImageFactory();
FopImage fopimage = fact.getImage(url, userAgent);
if (fopimage == null) {
return;
protected void drawImage(String url, Rectangle2D pos) {
endTextObject();
url = ImageFactory.getURL(url);
- ImageFactory fact = ImageFactory.getInstance();
+ ImageFactory fact = userAgent.getFactory().getImageFactory();
FopImage fopimage = fact.getImage(url, userAgent);
if (fopimage == null) {
return;
String url = eg.getURL();
//set image data
- ImageFactory fact = ImageFactory.getInstance();
- FopImage fopimage = fact.getImage(url, eg.getUserAgent());
+ FOUserAgent userAgent = eg.getUserAgent();
+ ImageFactory fact = userAgent.getFactory().getImageFactory();
+ FopImage fopimage = fact.getImage(url, userAgent);
if (fopimage == null) {
log.error("Image could not be found: " + url);
return;
}
private void innerTestFO1(boolean withStream) throws Exception {
+ FOUserAgent ua = new FOUserAgent();
+
//Reset the image caches to force URI resolution!
- ImageFactory.getInstance().clearCaches();
+ ua.getFactory().getImageFactory().clearCaches();
File foFile = new File(getBaseDir(), "test/xml/uri-resolution1.fo");
- FOUserAgent ua = new FOUserAgent();
MyURIResolver resolver = new MyURIResolver(withStream);
ua.setURIResolver(resolver);
ua.setBaseURL(foFile.getParentFile().toURL().toString());