aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2010-03-18 15:24:25 +0000
committerJeremias Maerki <jeremias@apache.org>2010-03-18 15:24:25 +0000
commitb2704855bd31c4755205fc8a68fb29ba28faab40 (patch)
tree96ad31213e0ee1ae11cf57923c4fe7931b67bea3 /src/java/org/apache/fop
parent3c7994cf56480e8e716a436801da65e776767cd8 (diff)
downloadxmlgraphics-fop-b2704855bd31c4755205fc8a68fb29ba28faab40.tar.gz
xmlgraphics-fop-b2704855bd31c4755205fc8a68fb29ba28faab40.zip
Bumped xmlgraphics-commons.jar.
Added configuration option to tweak the image loader framework. See also: http://svn.apache.org/viewvc?rev=924666&view=rev git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@924860 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop')
-rw-r--r--src/java/org/apache/fop/apps/FopFactoryConfigurator.java36
-rw-r--r--src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java5
-rw-r--r--src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java5
3 files changed, 36 insertions, 10 deletions
diff --git a/src/java/org/apache/fop/apps/FopFactoryConfigurator.java b/src/java/org/apache/fop/apps/FopFactoryConfigurator.java
index a8b964a5d..736ae05d8 100644
--- a/src/java/org/apache/fop/apps/FopFactoryConfigurator.java
+++ b/src/java/org/apache/fop/apps/FopFactoryConfigurator.java
@@ -31,6 +31,9 @@ import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry;
+import org.apache.xmlgraphics.image.loader.util.Penalty;
+
import org.apache.fop.fonts.FontManager;
import org.apache.fop.fonts.FontManagerConfigurator;
import org.apache.fop.util.LogUtil;
@@ -198,6 +201,39 @@ public class FopFactoryConfigurator {
FontManager fontManager = factory.getFontManager();
FontManagerConfigurator fontManagerConfigurator = new FontManagerConfigurator(cfg);
fontManagerConfigurator.configure(fontManager, strict);
+
+ // configure image loader framework
+ configureImageLoading(cfg.getChild("image-loading", false), strict);
+ }
+
+ private void configureImageLoading(Configuration parent, boolean strict) throws FOPException {
+ if (parent == null) {
+ return;
+ }
+ ImageImplRegistry registry = factory.getImageManager().getRegistry();
+ Configuration[] penalties = parent.getChildren("penalty");
+ try {
+ for (int i = 0, c = penalties.length; i < c; i++) {
+ Configuration penaltyCfg = penalties[i];
+ String className = penaltyCfg.getAttribute("class");
+ String value = penaltyCfg.getAttribute("value");
+ Penalty p = null;
+ if (value.toUpperCase().startsWith("INF")) {
+ p = Penalty.INFINITE_PENALTY;
+ } else {
+ try {
+ p = Penalty.toPenalty(Integer.parseInt(value));
+ } catch (NumberFormatException nfe) {
+ LogUtil.handleException(log, nfe, strict);
+ }
+ }
+ if (p != null) {
+ registry.setAdditionalPenalty(className, p);
+ }
+ }
+ } catch (ConfigurationException e) {
+ LogUtil.handleException(log, e, strict);
+ }
}
/**
diff --git a/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java b/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java
index b37ba925b..3add8be8b 100644
--- a/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java
+++ b/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java
@@ -52,11 +52,6 @@ public class ImageLoaderFactorySVG extends AbstractImageLoaderFactory {
}
/** {@inheritDoc} */
- public int getUsagePenalty(String mime, ImageFlavor flavor) {
- return 0;
- }
-
- /** {@inheritDoc} */
public boolean isAvailable() {
return BatikUtil.isBatikAvailable();
}
diff --git a/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java b/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java
index 6c5384bdb..eaefe9efe 100644
--- a/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java
+++ b/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java
@@ -50,11 +50,6 @@ public class ImageLoaderFactoryWMF extends AbstractImageLoaderFactory {
}
/** {@inheritDoc} */
- public int getUsagePenalty(String mime, ImageFlavor flavor) {
- return 0;
- }
-
- /** {@inheritDoc} */
public boolean isAvailable() {
return BatikUtil.isBatikAvailable();
}