You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2010/03/18 16:24:25 UTC
svn commit: r924860 - in /xmlgraphics/fop/trunk: ./ lib/
src/documentation/content/xdocs/trunk/ src/java/org/apache/fop/apps/
src/java/org/apache/fop/image/loader/batik/
Author: jeremias
Date: Thu Mar 18 15:24:25 2010
New Revision: 924860
URL: http://svn.apache.org/viewvc?rev=924860&view=rev
Log:
Bumped xmlgraphics-commons.jar.
Added configuration option to tweak the image loader framework.
See also: http://svn.apache.org/viewvc?rev=924666&view=rev
Modified:
xmlgraphics/fop/trunk/lib/xmlgraphics-commons-1.4svn.jar
xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml
xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FopFactoryConfigurator.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java
xmlgraphics/fop/trunk/status.xml
Modified: xmlgraphics/fop/trunk/lib/xmlgraphics-commons-1.4svn.jar
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/lib/xmlgraphics-commons-1.4svn.jar?rev=924860&r1=924859&r2=924860&view=diff
==============================================================================
Binary files - no diff available.
Modified: xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml?rev=924860&r1=924859&r2=924860&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml (original)
+++ xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml Thu Mar 18 15:24:25 2010
@@ -218,6 +218,42 @@
<!-- etc. etc..... -->
</fop>]]></source>
</section>
+ <section id="image-loading">
+ <title>Image Loading Customization</title>
+ <p>
+ Apache FOP uses the image loading framework from
+ <a href="http://xmlgraphics.apache.org/commons/">Apache XML Graphics Commons</a> to load
+ images using various plug-ins. Every image loader plug-in has a hard-coded usage penalty
+ that influences which solution is chosen if there are multiple possibilities to load an image.
+ Sometimes, though, these penalties need to be tweaked and this can be done in the FOP
+ configuration. An example:
+ </p>
+ <source><![CDATA[<fop version="1.0">
+ [..]
+ <image-loading>
+ <penalty value="10000"
+ class="org.apache.xmlgraphics.image.loader.impl.ImageLoaderRawCCITTFax"/>
+ <penalty value="INFINITE"
+ class="org.apache.xmlgraphics.image.loader.impl.ImageLoaderInternalTIFF"/>
+ </image-loading>
+ <renderers....
+</fop>]]></source>
+ <p>
+ The first penalty element increases the penalty for the raw CCITT loader. This practically
+ forces the decoding of CCITT compressed TIFF images except if there are no TIFF codecs
+ available.
+ </p>
+ <p>
+ The second penalty element sets an "infinite" penalty for the TIFF loader using the internal
+ TIFF codec. This practically disables that plug-in as it will never be chosen as a possible
+ solution.
+ </p>
+ <p>
+ Negative penalties are possible to promote a plug-in but a negative penalty sum will be
+ treated as zero penalty in most cases. For more details on the image loading framework,
+ please consult the documentation there.
+ </p>
+ </section>
<section id="renderers">
<title>Renderer configuration</title>
<p>
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FopFactoryConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FopFactoryConfigurator.java?rev=924860&r1=924859&r2=924860&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FopFactoryConfigurator.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FopFactoryConfigurator.java Thu Mar 18 15:24:25 2010
@@ -31,6 +31,9 @@ import org.apache.avalon.framework.confi
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);
+ }
}
/**
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java?rev=924860&r1=924859&r2=924860&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java Thu Mar 18 15:24:25 2010
@@ -52,11 +52,6 @@ public class ImageLoaderFactorySVG exten
}
/** {@inheritDoc} */
- public int getUsagePenalty(String mime, ImageFlavor flavor) {
- return 0;
- }
-
- /** {@inheritDoc} */
public boolean isAvailable() {
return BatikUtil.isBatikAvailable();
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java?rev=924860&r1=924859&r2=924860&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java Thu Mar 18 15:24:25 2010
@@ -50,11 +50,6 @@ public class ImageLoaderFactoryWMF exten
}
/** {@inheritDoc} */
- public int getUsagePenalty(String mime, ImageFlavor flavor) {
- return 0;
- }
-
- /** {@inheritDoc} */
public boolean isAvailable() {
return BatikUtil.isBatikAvailable();
}
Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=924860&r1=924859&r2=924860&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Thu Mar 18 15:24:25 2010
@@ -58,6 +58,9 @@
documents. Example: the fix of marks layering will be such a case when it's done.
-->
<release version="FOP Trunk" date="TBD">
+ <action context="Images" dev="JM" type="add">
+ Added customization ability for the image loading framework from FOP's configuration file.
+ </action>
<action context="Renderers" dev="JM" type="fix" fixes-bug="48696" due-to="Peter Hancock">
Bugfix for color model in IOCA IDE structure parameter for 4- and 8-bit grayscale images.
</action>
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org