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 2007/05/28 16:31:33 UTC
svn commit: r542237 [3/5] - in /xmlgraphics/fop/trunk: ./ lib/
src/documentation/content/xdocs/trunk/ src/java/org/apache/fop/apps/
src/java/org/apache/fop/area/ src/java/org/apache/fop/cli/
src/java/org/apache/fop/fonts/ src/java/org/apache/fop/fonts/...
Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRendererConfigurator.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRendererConfigurator.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRendererConfigurator.java Mon May 28 07:31:24 2007
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.render;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.apps.FOUserAgent;
+
+/**
+ * Abstract base classes for renderer-related configurator classes. This class basically just
+ * provides an accessor to the specific renderer configuration object.
+ */
+public abstract class AbstractRendererConfigurator {
+
+ /** logger instance */
+ protected static Log log = LogFactory.getLog(AbstractRendererConfigurator.class);
+
+ /** fop factory configuration */
+ protected FOUserAgent userAgent = null;
+
+ /**
+ * Default constructor
+ * @param userAgent user agent
+ */
+ public AbstractRendererConfigurator(FOUserAgent userAgent) {
+ super();
+ this.userAgent = userAgent;
+ }
+
+
+ /**
+ * Returns the configuration subtree for a specific renderer.
+ * @param renderer the renderer
+ * @return the requested configuration subtree, null if there's no configuration
+ */
+ protected Configuration getRendererConfig(Renderer renderer) {
+ Configuration cfg = userAgent.getFactory().getUserConfig();
+ if (cfg == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("userconfig is null");
+ }
+ return null;
+ }
+
+ String mimeType = renderer.getMimeType();
+ if (mimeType == null) {
+ if (log.isInfoEnabled()) {
+ log.info("renderer mimeType is null");
+ }
+ return null;
+ }
+
+ Configuration userRendererConfig = null;
+
+ Configuration[] cfgs
+ = cfg.getChild("renderers").getChildren("renderer");
+ for (int i = 0; i < cfgs.length; ++i) {
+ Configuration child = cfgs[i];
+ try {
+ if (child.getAttribute("mime").equals(mimeType)) {
+ userRendererConfig = child;
+ break;
+ }
+ } catch (ConfigurationException e) {
+ // silently pass over configurations without mime type
+ }
+ }
+ log.debug((userRendererConfig == null ? "No u" : "U")
+ + "ser configuration found for MIME type " + mimeType);
+ return userRendererConfig;
+ }
+}
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRendererConfigurator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRendererMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRendererMaker.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRendererMaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRendererMaker.java Mon May 28 07:31:24 2007
@@ -29,10 +29,10 @@
/**
* Instantiates a new renderer.
- * @param ua the user agent
+ * @param userAgent the user agent
* @return the newly instantiated renderer
*/
- public abstract Renderer makeRenderer(FOUserAgent ua);
+ public abstract Renderer makeRenderer(FOUserAgent userAgent);
/**
* @return Indicates whether this renderer requires an OutputStream to work with.
@@ -45,6 +45,16 @@
public abstract String[] getSupportedMimeTypes();
/**
+ * Returns a renderer config object that can be used to
+ * configure the renderer.
+ * @param userAgent user agent
+ * @return a config object that can be used to configure the renderer
+ */
+ public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
+ return null;
+ }
+
+ /**
* Indicates whether a specific MIME type is supported by this renderer.
* @param mimeType the MIME type (ex. "application/pdf")
* @return true if the MIME type is supported
@@ -58,5 +68,4 @@
}
return false;
}
-
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRenderer.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRenderer.java Mon May 28 07:31:24 2007
@@ -46,7 +46,26 @@
/** list of fonts */
protected List fontList = null;
+
+ /**
+ * adds a font list to current list of fonts
+ * @param fontInfoList font list
+ */
+ public void addFontList(List fontInfoList) {
+ if (this.fontList == null) {
+ setFontList(fontInfoList);
+ } else {
+ this.fontList.addAll(fontInfoList);
+ }
+ }
+ /**
+ * @param fontList list of available fonts
+ */
+ public void setFontList(List fontList) {
+ this.fontList = fontList;
+ }
+
/**
* Set up the font info
*
Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRendererConfigurator.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRendererConfigurator.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRendererConfigurator.java Mon May 28 07:31:24 2007
@@ -0,0 +1,332 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.render;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.FopFactory;
+import org.apache.fop.fonts.CachedFontInfo;
+import org.apache.fop.fonts.EmbedFontInfo;
+import org.apache.fop.fonts.FontCache;
+import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.fonts.FontResolver;
+import org.apache.fop.fonts.FontSetup;
+import org.apache.fop.fonts.FontTriplet;
+import org.apache.fop.fonts.FontUtil;
+import org.apache.fop.fonts.autodetect.FontFileFinder;
+import org.apache.fop.fonts.autodetect.FontInfoFinder;
+import org.apache.fop.util.LogUtil;
+
+/**
+ * Base Print renderer configurator (mostly handles font configuration)
+ */
+public class PrintRendererConfigurator extends AbstractRendererConfigurator
+ implements RendererConfigurator {
+
+ /** have we already autodetected system fonts? */
+ private static boolean autodetectedFonts = false;
+
+ /** logger instance */
+ protected static Log log = LogFactory.getLog(PrintRendererConfigurator.class);
+
+ /**
+ * Default constructor
+ * @param userAgent user agent
+ */
+ public PrintRendererConfigurator(FOUserAgent userAgent) {
+ super(userAgent);
+ }
+
+ /**
+ * Builds a list of EmbedFontInfo objects for use with the setup() method.
+ *
+ * @param renderer print renderer
+ * @throws FOPException if something's wrong with the config data
+ */
+ public void configure(Renderer renderer) throws FOPException {
+ Configuration cfg = getRendererConfig(renderer);
+ if (cfg == null) {
+ return;
+ }
+
+ PrintRenderer printRenderer = (PrintRenderer)renderer;
+ FontResolver fontResolver = printRenderer.getFontResolver();
+ if (fontResolver == null) {
+ //Ensure that we have minimal font resolution capabilities
+ fontResolver = FontSetup.createMinimalFontResolver();
+ }
+
+ FopFactory factory = userAgent.getFactory();
+ boolean strict = factory.validateUserConfigStrictly();
+ FontCache fontCache = factory.getFontCache();
+
+ List fontInfoList = buildFontListFromConfiguration(cfg,
+ userAgent.getFontBaseURL(), fontResolver, strict,
+ fontCache);
+
+ if (fontCache != null && fontCache.hasChanged()) {
+ fontCache.save();
+ }
+ printRenderer.addFontList(fontInfoList);
+ }
+
+ /**
+ * Builds a list of EmbedFontInfo objects for use with the setup() method.
+ *
+ * @param cfg Configuration object
+ * @param fontBaseURL the base URL to resolve relative font URLs with
+ * @param fontResolver the FontResolver to use
+ * @param strict true if an Exception should be thrown if an error is found.
+ * @param fontCache the font cache (or null if it is disabled)
+ * @return a List of EmbedFontInfo objects.
+ * @throws FOPException If an error occurs while processing the configuration
+ */
+ public static List buildFontListFromConfiguration(Configuration cfg,
+ String fontBaseURL, FontResolver fontResolver,
+ boolean strict, FontCache fontCache) throws FOPException {
+ List fontInfoList = new java.util.ArrayList();
+
+ Configuration fonts = cfg.getChild("fonts");
+ if (fonts != null) {
+ long start = 0;
+ if (log.isDebugEnabled()) {
+ log.debug("Starting font configuration...");
+ start = System.currentTimeMillis();
+ }
+
+ // native o/s search (autodetect) configuration
+ boolean autodetectFonts = (fonts.getChild("auto-detect", false) != null);
+ if (!autodetectedFonts && autodetectFonts) {
+ // search in font base if it is defined and
+ // is a directory but don't recurse
+ FontFileFinder fontFileFinder = new FontFileFinder();
+ if (fontBaseURL != null) {
+ try {
+ File fontBase = FileUtils.toFile(new URL(fontBaseURL));
+ if (fontBase != null) {
+ //Can only use the font base URL if it's a file URL
+ addFontInfoListFromFileList(
+ fontFileFinder.find(fontBase.getAbsolutePath()),
+ fontInfoList,
+ fontResolver,
+ fontCache
+ );
+ }
+ } catch (IOException e) {
+ LogUtil.handleException(log, e, strict);
+ }
+ }
+
+ // native o/s font directory finder
+ try {
+ addFontInfoListFromFileList(
+ fontFileFinder.find(),
+ fontInfoList,
+ fontResolver,
+ fontCache
+ );
+ } catch (IOException e) {
+ LogUtil.handleException(log, e, strict);
+ }
+ autodetectedFonts = true;
+ }
+
+ // directory (multiple font) configuration
+ Configuration[] directories = fonts.getChildren("directory");
+ for (int i = 0; i < directories.length; i++) {
+ boolean recursive = directories[i].getAttributeAsBoolean("recursive", false);
+ String directory = null;
+ try {
+ directory = directories[i].getValue();
+ } catch (ConfigurationException e) {
+ LogUtil.handleException(log, e, strict);
+ continue;
+ }
+ if (directory == null) {
+ LogUtil.handleException(log,
+ new FOPException("directory defined without value"), strict);
+ continue;
+ }
+ FontFileFinder fontFileFinder = new FontFileFinder(recursive ? -1 : 1);
+ try {
+ addFontInfoListFromFileList(
+ fontFileFinder.find(directory),
+ fontInfoList,
+ fontResolver,
+ fontCache
+ );
+ } catch (IOException e) {
+ LogUtil.handleException(log, e, strict);
+ }
+ }
+
+ // font file (singular) configuration
+ Configuration[] font = fonts.getChildren("font");
+ for (int i = 0; i < font.length; i++) {
+ EmbedFontInfo fontInfo = getFontInfoFromConfiguration(
+ font[i], fontResolver, strict, fontCache);
+ if (fontInfo != null) {
+ fontInfoList.add(fontInfo);
+ }
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Finished font configuration in "
+ + (System.currentTimeMillis() - start) + "ms");
+ }
+ }
+ return fontInfoList;
+ }
+
+ /**
+ * Iterates over font file list adding font info to list
+ * @param fontFileList font file list
+ * @param fontInfoList font info list
+ * @param resolver font resolver
+ */
+ private static void addFontInfoListFromFileList(
+ List fontFileList, List fontInfoList, FontResolver resolver, FontCache fontCache) {
+ for (Iterator iter = fontFileList.iterator(); iter.hasNext();) {
+ File fontFile = (File)iter.next();
+ // parse font to ascertain font info
+ FontInfoFinder finder = new FontInfoFinder();
+ EmbedFontInfo fontInfo = finder.find(fontFile, resolver, fontCache);
+ if (fontInfo != null) {
+ fontInfoList.add(fontInfo);
+ }
+ }
+ }
+
+ /**
+ * Returns a font info from a font node Configuration definition
+ *
+ * @param fontCfg Configuration object (font node)
+ * @param fontResolver font resolver used to resolve font
+ * @param strict validate configuration strictly
+ * @param fontCache the font cache (or null if it is disabled)
+ * @return font info
+ * @throws FOPException if something's wrong with the config data
+ */
+ public static EmbedFontInfo getFontInfoFromConfiguration(
+ Configuration fontCfg, FontResolver fontResolver, boolean strict, FontCache fontCache)
+ throws FOPException {
+ String metricsUrl = fontCfg.getAttribute("metrics-url", null);
+ String embedUrl = fontCfg.getAttribute("embed-url", null);
+
+ if (metricsUrl == null && embedUrl == null) {
+ LogUtil.handleError(log, "Font configuration without metric-url or embed-url", strict);
+ return null;
+ }
+ if (embedUrl != null) {
+ StreamSource source = (StreamSource)fontResolver.resolve(embedUrl);
+ if (source == null) {
+ LogUtil.handleError(log,
+ "Failed to resolve font with embed-url '" + embedUrl + "'", strict);
+ return null;
+ }
+ embedUrl = source.getSystemId(); // absolute path/url
+ }
+ if (metricsUrl != null) {
+ StreamSource source = (StreamSource)fontResolver.resolve(metricsUrl);
+ if (source == null) {
+ LogUtil.handleError(log,
+ "Failed to resolve font with metric-url '" + metricsUrl + "'", strict);
+ return null;
+ }
+ metricsUrl = source.getSystemId(); // absolute path/url
+ }
+ boolean useKerning = fontCfg.getAttributeAsBoolean("kerning", true);
+
+ EmbedFontInfo fontInfo = null;
+ Configuration[] tripletCfg = fontCfg.getChildren("font-triplet");
+ // no font triplet info
+ if (tripletCfg.length == 0) {
+ LogUtil.handleError(log, "font without font-triplet", strict);
+
+ // if not strict try to determine font info from the embed/metrics url
+ File fontFile = CachedFontInfo.getFileFromUrls(new String[] {embedUrl, metricsUrl});
+ if (fontFile != null) {
+ FontInfoFinder finder = new FontInfoFinder();
+ return finder.find(fontFile, fontResolver, fontCache);
+ } else {
+ return null;
+ }
+ } else {
+ List tripleList = new java.util.ArrayList();
+ for (int j = 0; j < tripletCfg.length; j++) {
+ try {
+ String name = tripletCfg[j].getAttribute("name");
+ if (name == null) {
+ LogUtil.handleError(log, "font-triplet without name", strict);
+ continue;
+ }
+ String weightStr = tripletCfg[j].getAttribute("weight");
+ if (weightStr == null) {
+ LogUtil.handleError(log, "font-triplet without weight", strict);
+ continue;
+ }
+ int weight = FontUtil.parseCSS2FontWeight(weightStr);
+ String style = tripletCfg[j].getAttribute("style");
+ if (style == null) {
+ LogUtil.handleError(log, "font-triplet without style", strict);
+ continue;
+ }
+ tripleList.add(FontInfo.createFontKey(name, style, weight));
+ } catch (ConfigurationException e) {
+ LogUtil.handleException(log, e, strict);
+ }
+ }
+
+ fontInfo = new EmbedFontInfo(metricsUrl, useKerning, tripleList, embedUrl);
+
+ if (fontCache != null) {
+ if (!fontCache.containsFont(fontInfo)) {
+ fontCache.addFont(fontInfo);
+ }
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Adding font " + fontInfo.getEmbedFile()
+ + ", metric file " + fontInfo.getMetricsFile());
+ for (int j = 0; j < tripleList.size(); ++j) {
+ FontTriplet triplet = (FontTriplet) tripleList.get(j);
+ log.debug(" Font triplet "
+ + triplet.getName() + ", "
+ + triplet.getStyle() + ", "
+ + triplet.getWeight());
+ }
+ }
+ }
+ return fontInfo;
+ }
+
+}
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRendererConfigurator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererConfigurator.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererConfigurator.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererConfigurator.java Mon May 28 07:31:24 2007
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.render;
+
+import org.apache.fop.apps.FOPException;
+
+/**
+ * Renderer configurator interface
+ */
+public interface RendererConfigurator {
+ /**
+ * Configures a renderer
+ * @param renderer renderer
+ * @throws FOPException fop exception
+ */
+ void configure(Renderer renderer) throws FOPException;
+}
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererConfigurator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererContext.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererContext.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererContext.java Mon May 28 07:31:24 2007
@@ -23,7 +23,6 @@
import java.util.Map;
//FOP
-import org.apache.avalon.framework.configuration.Configuration;
import org.apache.fop.apps.FOUserAgent;
/**
@@ -156,17 +155,10 @@
return ((Integer)context.getProperty(RendererContextConstants.HEIGHT)).intValue();
}
- /** @return the handler configuration */
- public Configuration getHandlerConfiguration() {
- return (Configuration)context.getProperty(
- RendererContextConstants.HANDLER_CONFIGURATION);
- }
-
/** @return the foreign attributes */
public Map getForeignAttributes() {
return (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES);
- }
-
+ }
}
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererFactory.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererFactory.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererFactory.java Mon May 28 07:31:24 2007
@@ -25,9 +25,6 @@
import java.util.List;
import java.util.Map;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -185,18 +182,9 @@
}
Renderer rend = maker.makeRenderer(userAgent);
rend.setUserAgent(userAgent);
- String mimeType = rend.getMimeType(); //Always use main MIME type for this
- Configuration userRendererConfig = null;
- if (mimeType != null) {
- userRendererConfig
- = userAgent.getFactory().getUserRendererConfig(mimeType);
- }
- if (userRendererConfig != null) {
- try {
- ContainerUtil.configure(rend, userRendererConfig);
- } catch (ConfigurationException e) {
- throw new FOPException(e);
- }
+ RendererConfigurator configurator = maker.getConfigurator(userAgent);
+ if (configurator != null) {
+ configurator.configure(rend);
}
return rend;
}
Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/XMLHandlerConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/XMLHandlerConfigurator.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/XMLHandlerConfigurator.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/XMLHandlerConfigurator.java Mon May 28 07:31:24 2007
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.render;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+
+/**
+ * Configurator for XMLHandler objects.
+ */
+public class XMLHandlerConfigurator extends AbstractRendererConfigurator {
+
+ /** logger instance */
+ protected static Log log = LogFactory.getLog(XMLHandlerConfigurator.class);
+
+ /**
+ * Default constructor
+ * @param userAgent the user agent
+ */
+ public XMLHandlerConfigurator(FOUserAgent userAgent) {
+ super(userAgent);
+ }
+
+ /**
+ * Returns the configuration subtree for a specific renderer.
+ * @param cfg the renderer configuration
+ * @param namespace the namespace (i.e. the XMLHandler) for which the configuration should
+ * be returned
+ * @return the requested configuration subtree, null if there's no configuration
+ */
+ private Configuration getHandlerConfig(Configuration cfg, String namespace) {
+ if (cfg == null || namespace == null) {
+ return null;
+ }
+ Configuration handlerConfig = null;
+
+ Configuration[] children = cfg.getChildren("xml-handler");
+ for (int i = 0; i < children.length; ++i) {
+ try {
+ if (children[i].getAttribute("namespace").equals(namespace)) {
+ handlerConfig = children[i];
+ break;
+ }
+ } catch (ConfigurationException e) {
+ // silently pass over configurations without namespace
+ }
+ }
+ if (log.isDebugEnabled()) {
+ log.debug((handlerConfig == null ? "No" : "")
+ + "XML handler configuration found for namespace " + namespace);
+ }
+ return handlerConfig;
+ }
+
+ /**
+ * Configures renderer context by setting the handler configuration on it.
+ * @param context the RendererContext (contains the user agent)
+ * @param ns the Namespace of the foreign object
+ * @throws FOPException if configuring the target objects fails
+ */
+ public void configure(RendererContext context, String ns) throws FOPException {
+ //Optional XML handler configuration
+ Configuration cfg = getRendererConfig(context.getRenderer());
+ if (cfg != null) {
+ cfg = getHandlerConfig(cfg, ns);
+ if (cfg != null) {
+ context.setProperty(RendererContextConstants.HANDLER_CONFIGURATION, cfg);
+ }
+ }
+ }
+}
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/XMLHandlerConfigurator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java Mon May 28 07:31:24 2007
@@ -33,8 +33,6 @@
import java.util.List;
import java.util.Map;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
@@ -57,8 +55,6 @@
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontMetrics;
import org.apache.fop.fonts.FontTriplet;
-import org.apache.fop.fonts.FontUtil;
-import org.apache.fop.fonts.Typeface;
import org.apache.fop.fonts.base14.Courier;
import org.apache.fop.fonts.base14.Helvetica;
import org.apache.fop.fonts.base14.TimesRoman;
@@ -76,7 +72,6 @@
import org.apache.fop.render.afp.fonts.CharacterSet;
import org.apache.fop.render.afp.fonts.FopCharacterSet;
import org.apache.fop.render.afp.fonts.OutlineFont;
-import org.apache.fop.render.afp.fonts.RasterFont;
import org.apache.fop.render.afp.modca.AFPConstants;
import org.apache.fop.render.afp.modca.AFPDataStream;
import org.apache.fop.render.afp.modca.ImageObject;
@@ -303,195 +298,6 @@
}
/**
- */
- private AFPFontInfo buildFont(Configuration fontCfg, String _path)
- throws ConfigurationException {
-
- Configuration[] triple = fontCfg.getChildren("font-triplet");
- List tripleList = new java.util.ArrayList();
- if (triple.length == 0) {
- log.error("Mandatory font configuration element '<font-triplet...' is missing");
- return null;
- }
- for (int j = 0; j < triple.length; j++) {
- int weight = FontUtil.parseCSS2FontWeight(triple[j].getAttribute("weight"));
- tripleList.add(new FontTriplet(triple[j].getAttribute("name"),
- triple[j].getAttribute("style"),
- weight));
- }
-
- //build the fonts
- Configuration afpFontCfg = fontCfg.getChild("afp-font");
- if (afpFontCfg == null) {
- log.error("Mandatory font configuration element '<afp-font...' is missing");
- return null;
- }
- String path = afpFontCfg.getAttribute("path", _path);
- String type = afpFontCfg.getAttribute("type");
- if (type == null) {
- log.error("Mandatory afp-font configuration attribute 'type=' is missing");
- return null;
- }
- String codepage = afpFontCfg.getAttribute("codepage");
- if (codepage == null) {
- log.error("Mandatory afp-font configuration attribute 'code=' is missing");
- return null;
- }
- String encoding = afpFontCfg.getAttribute("encoding");
- if (encoding == null) {
- log.error("Mandatory afp-font configuration attribute 'encoding=' is missing");
- return null;
- }
-
- if ("raster".equalsIgnoreCase(type)) {
-
- String name = afpFontCfg.getAttribute("name", "Unknown");
-
- // Create a new font object
- RasterFont font = new RasterFont(name);
-
- Configuration[] rasters = afpFontCfg.getChildren("afp-raster-font");
- if (rasters.length == 0) {
- log.error("Mandatory font configuration elements '<afp-raster-font...' are missing");
- return null;
- }
- for (int j = 0; j < rasters.length; j++) {
- Configuration rasterCfg = rasters[j];
-
- String characterset = rasterCfg.getAttribute("characterset");
- if (characterset == null) {
- log.error("Mandatory afp-raster-font configuration attribute 'characterset=' is missing");
- return null;
- }
- int size = rasterCfg.getAttributeAsInteger("size");
- String base14 = rasterCfg.getAttribute("base14-font", null);
-
- if (base14 != null) {
- try {
- Class clazz = Class.forName("org.apache.fop.fonts.base14."
- + base14);
- try {
- Typeface tf = (Typeface)clazz.newInstance();
- font.addCharacterSet(size, new FopCharacterSet(
- codepage, encoding, characterset, size, tf));
- } catch (Exception ie) {
- String msg = "The base 14 font class " + clazz.getName()
- + " could not be instantiated";
- log.error(msg);
- }
- } catch (ClassNotFoundException cnfe) {
- String msg = "The base 14 font class for " + characterset
- + " could not be found";
- log.error(msg);
- }
- } else {
- font.addCharacterSet(size, new CharacterSet(
- codepage, encoding, characterset, path));
- }
- }
- return new AFPFontInfo(font, tripleList);
-
- } else if ("outline".equalsIgnoreCase(type)) {
-
- String characterset = afpFontCfg.getAttribute("characterset");
- if (characterset == null) {
- log.error("Mandatory afp-font configuration attribute 'characterset=' is missing");
- return null;
- }
- String name = afpFontCfg.getAttribute("name", characterset);
-
- CharacterSet characterSet = null;
-
- String base14 = afpFontCfg.getAttribute("base14-font", null);
-
- if (base14 != null) {
- try {
- Class clazz = Class.forName("org.apache.fop.fonts.base14."
- + base14);
- try {
- Typeface tf = (Typeface)clazz.newInstance();
- characterSet = new FopCharacterSet(
- codepage, encoding, characterset, 1, tf);
- } catch (Exception ie) {
- String msg = "The base 14 font class " + clazz.getName()
- + " could not be instantiated";
- log.error(msg);
- }
- } catch (ClassNotFoundException cnfe) {
- String msg = "The base 14 font class for " + characterset
- + " could not be found";
- log.error(msg);
- }
- } else {
- characterSet = new CharacterSet(codepage, encoding, characterset, path);
- }
- // Create a new font object
- OutlineFont font = new OutlineFont(name, characterSet);
- return new AFPFontInfo(font, tripleList);
- } else {
- log.error("No or incorrect type attribute");
- }
- return null;
- }
-
- /**
- * Builds a list of AFPFontInfo objects for use with the setup() method.
- * @param cfg Configuration object
- * @return List the newly created list of fonts
- * @throws ConfigurationException if something's wrong with the config data
- */
- public List buildFontListFromConfiguration(Configuration cfg)
- throws ConfigurationException {
- List fontList = new java.util.ArrayList();
- Configuration[] font = cfg.getChild("fonts").getChildren("font");
- for (int i = 0; i < font.length; i++) {
- AFPFontInfo afi = buildFont(font[i], null);
- if (afi != null) {
- if (log.isDebugEnabled()) {
- log.debug("Adding font " + afi.getAFPFont().getFontName());
- for (int j = 0; j < afi.getFontTriplets().size(); ++j) {
- FontTriplet triplet = (FontTriplet) afi.getFontTriplets().get(j);
- log.debug("Font triplet "
- + triplet.getName() + ", "
- + triplet.getStyle() + ", "
- + triplet.getWeight());
- }
- }
-
- fontList.add(afi);
- }
- }
- return fontList;
- }
-
- /**
- * Configure the AFP renderer.
- * Get the configuration to be used for fonts etc.
- * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
- */
- public void configure(Configuration cfg) throws ConfigurationException {
- //Font configuration
- this.fontList = buildFontListFromConfiguration(cfg);
- Configuration images = cfg.getChild("images");
- if (!"color".equalsIgnoreCase(images.getAttribute("mode", "b+w"))) {
- bitsPerPixel = images.getAttributeAsInteger("bits-per-pixel", 8);
- switch (bitsPerPixel) {
- case 1:
- case 4:
- case 8:
- break;
- default:
- log.warn("Invalid bits_per_pixel value, must be 1, 4 or 8.");
- bitsPerPixel = 8;
- break;
- }
- } else {
- colorImages = true;
- }
-
- }
-
- /**
* @see org.apache.fop.render.Renderer#setUserAgent(FOUserAgent)
*/
public void setUserAgent(FOUserAgent agent) {
@@ -1765,5 +1571,22 @@
}
}
+ public void setBitsPerPixel(int bitsPerPixel) {
+ this.bitsPerPixel = bitsPerPixel;
+ switch (bitsPerPixel) {
+ case 1:
+ case 4:
+ case 8:
+ break;
+ default:
+ log.warn("Invalid bits_per_pixel value, must be 1, 4 or 8.");
+ bitsPerPixel = 8;
+ break;
+ }
+ }
+
+ public void setColorImages(boolean colorImages) {
+ this.colorImages = colorImages;
+ }
}
Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java Mon May 28 07:31:24 2007
@@ -0,0 +1,241 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.render.afp;
+
+import java.util.List;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fonts.FontTriplet;
+import org.apache.fop.fonts.FontUtil;
+import org.apache.fop.fonts.Typeface;
+import org.apache.fop.render.PrintRendererConfigurator;
+import org.apache.fop.render.Renderer;
+import org.apache.fop.render.afp.fonts.AFPFontInfo;
+import org.apache.fop.render.afp.fonts.CharacterSet;
+import org.apache.fop.render.afp.fonts.FopCharacterSet;
+import org.apache.fop.render.afp.fonts.OutlineFont;
+import org.apache.fop.render.afp.fonts.RasterFont;
+import org.apache.fop.util.LogUtil;
+
+/**
+ * AFP Renderer configurator
+ */
+public class AFPRendererConfigurator extends PrintRendererConfigurator {
+
+ /**
+ * Default constructor
+ * @param userAgent user agent
+ */
+ public AFPRendererConfigurator(FOUserAgent userAgent) {
+ super(userAgent);
+ }
+
+ private AFPFontInfo buildFont(Configuration fontCfg, String fontPath)
+ throws ConfigurationException {
+
+ Configuration[] triple = fontCfg.getChildren("font-triplet");
+ List tripleList = new java.util.ArrayList();
+ if (triple.length == 0) {
+ log.error("Mandatory font configuration element '<font-triplet...' is missing");
+ return null;
+ }
+ for (int j = 0; j < triple.length; j++) {
+ int weight = FontUtil.parseCSS2FontWeight(triple[j].getAttribute("weight"));
+ tripleList.add(new FontTriplet(triple[j].getAttribute("name"),
+ triple[j].getAttribute("style"),
+ weight));
+ }
+
+ //build the fonts
+ Configuration afpFontCfg = fontCfg.getChild("afp-font");
+ if (afpFontCfg == null) {
+ log.error("Mandatory font configuration element '<afp-font...' is missing");
+ return null;
+ }
+ String path = afpFontCfg.getAttribute("path", fontPath);
+ String type = afpFontCfg.getAttribute("type");
+ if (type == null) {
+ log.error("Mandatory afp-font configuration attribute 'type=' is missing");
+ return null;
+ }
+ String codepage = afpFontCfg.getAttribute("codepage");
+ if (codepage == null) {
+ log.error("Mandatory afp-font configuration attribute 'code=' is missing");
+ return null;
+ }
+ String encoding = afpFontCfg.getAttribute("encoding");
+ if (encoding == null) {
+ log.error("Mandatory afp-font configuration attribute 'encoding=' is missing");
+ return null;
+ }
+
+ if ("raster".equalsIgnoreCase(type)) {
+
+ String name = afpFontCfg.getAttribute("name", "Unknown");
+
+ // Create a new font object
+ RasterFont font = new RasterFont(name);
+
+ Configuration[] rasters = afpFontCfg.getChildren("afp-raster-font");
+ if (rasters.length == 0) {
+ log.error(
+ "Mandatory font configuration elements '<afp-raster-font...' are missing");
+ return null;
+ }
+ for (int j = 0; j < rasters.length; j++) {
+ Configuration rasterCfg = rasters[j];
+
+ String characterset = rasterCfg.getAttribute("characterset");
+ if (characterset == null) {
+ log.error(
+ "Mandatory afp-raster-font configuration attribute 'characterset=' is missing");
+ return null;
+ }
+ int size = rasterCfg.getAttributeAsInteger("size");
+ String base14 = rasterCfg.getAttribute("base14-font", null);
+
+ if (base14 != null) {
+ try {
+ Class clazz = Class.forName("org.apache.fop.fonts.base14."
+ + base14);
+ try {
+ Typeface tf = (Typeface)clazz.newInstance();
+ font.addCharacterSet(size, new FopCharacterSet(
+ codepage, encoding, characterset, size, tf));
+ } catch (Exception ie) {
+ String msg = "The base 14 font class " + clazz.getName()
+ + " could not be instantiated";
+ log.error(msg);
+ }
+ } catch (ClassNotFoundException cnfe) {
+ String msg = "The base 14 font class for " + characterset
+ + " could not be found";
+ log.error(msg);
+ }
+ } else {
+ font.addCharacterSet(size, new CharacterSet(
+ codepage, encoding, characterset, path));
+ }
+ }
+ return new AFPFontInfo(font, tripleList);
+
+ } else if ("outline".equalsIgnoreCase(type)) {
+
+ String characterset = afpFontCfg.getAttribute("characterset");
+ if (characterset == null) {
+ log.error("Mandatory afp-font configuration attribute 'characterset=' is missing");
+ return null;
+ }
+ String name = afpFontCfg.getAttribute("name", characterset);
+
+ CharacterSet characterSet = null;
+
+ String base14 = afpFontCfg.getAttribute("base14-font", null);
+
+ if (base14 != null) {
+ try {
+ Class clazz = Class.forName("org.apache.fop.fonts.base14."
+ + base14);
+ try {
+ Typeface tf = (Typeface)clazz.newInstance();
+ characterSet = new FopCharacterSet(
+ codepage, encoding, characterset, 1, tf);
+ } catch (Exception ie) {
+ String msg = "The base 14 font class " + clazz.getName()
+ + " could not be instantiated";
+ log.error(msg);
+ }
+ } catch (ClassNotFoundException cnfe) {
+ String msg = "The base 14 font class for " + characterset
+ + " could not be found";
+ log.error(msg);
+ }
+ } else {
+ characterSet = new CharacterSet(codepage, encoding, characterset, path);
+ }
+ // Create a new font object
+ OutlineFont font = new OutlineFont(name, characterSet);
+ return new AFPFontInfo(font, tripleList);
+ } else {
+ log.error("No or incorrect type attribute");
+ }
+ return null;
+ }
+
+ /**
+ * Builds a list of AFPFontInfo objects for use with the setup() method.
+ * @param cfg Configuration object
+ * @return List the newly created list of fonts
+ * @throws ConfigurationException if something's wrong with the config data
+ */
+ private List buildFontListFromConfiguration(Configuration cfg)
+ throws ConfigurationException {
+ List fontList = new java.util.ArrayList();
+ Configuration[] font = cfg.getChild("fonts").getChildren("font");
+ for (int i = 0; i < font.length; i++) {
+ AFPFontInfo afi = buildFont(font[i], null);
+ if (afi != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Adding font " + afi.getAFPFont().getFontName());
+ for (int j = 0; j < afi.getFontTriplets().size(); ++j) {
+ FontTriplet triplet = (FontTriplet) afi.getFontTriplets().get(j);
+ log.debug(" Font triplet "
+ + triplet.getName() + ", "
+ + triplet.getStyle() + ", "
+ + triplet.getWeight());
+ }
+ }
+
+ fontList.add(afi);
+ }
+ }
+ return fontList;
+ }
+
+ /**
+ * Configure the AFP renderer.
+ * @param renderer AFP renderer
+ * @throws FOPException fop exception
+ * @see org.apache.fop.render.PrintRendererConfigurator#configure(Renderer)
+ */
+ public void configure(Renderer renderer) throws FOPException {
+ Configuration cfg = super.getRendererConfig(renderer);
+ if (cfg != null) {
+ AFPRenderer afpRenderer = (AFPRenderer)renderer;
+ try {
+ List fontList = buildFontListFromConfiguration(cfg);
+ afpRenderer.setFontList(fontList);
+ } catch (ConfigurationException e) {
+ LogUtil.handleException(log, e,
+ userAgent.getFactory().validateUserConfigStrictly());
+ }
+
+ Configuration images = cfg.getChild("images");
+ if (!"color".equalsIgnoreCase(images.getAttribute("mode", "b+w"))) {
+ afpRenderer.setBitsPerPixel(images.getAttributeAsInteger("bits-per-pixel", 8));
+ } else {
+ afpRenderer.setColorImages(true);
+ }
+ }
+ }
+}
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererMaker.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererMaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererMaker.java Mon May 28 07:31:24 2007
@@ -23,6 +23,7 @@
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.render.AbstractRendererMaker;
import org.apache.fop.render.Renderer;
+import org.apache.fop.render.RendererConfigurator;
/**
* RendererMaker for the AFP Renderer.
@@ -35,8 +36,13 @@
/**@see org.apache.fop.render.AbstractRendererMaker */
- public Renderer makeRenderer(FOUserAgent ua) {
+ public Renderer makeRenderer(FOUserAgent userAgent) {
return new AFPRenderer();
+ }
+
+ /** @see org.apache.fop.render.AbstractRendererMaker#getConfigurator(FOUserAgent) */
+ public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
+ return new AFPRendererConfigurator(userAgent);
}
/** @see org.apache.fop.render.AbstractRendererMaker#needsOutputStream() */
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/AWTRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/AWTRenderer.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/AWTRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/AWTRenderer.java Mon May 28 07:31:24 2007
@@ -38,6 +38,7 @@
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.FopFactoryConfigurator;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.area.Area;
import org.apache.fop.area.PageViewport;
@@ -149,10 +150,10 @@
pageWidth = (int) Math.round(bounds.getWidth() / 1000f);
pageHeight = (int) Math.round(bounds.getHeight() / 1000f);
double scaleX = scaleFactor
- * (25.4 / FOUserAgent.DEFAULT_TARGET_RESOLUTION)
+ * (25.4 / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
/ userAgent.getTargetPixelUnitToMillimeter();
double scaleY = scaleFactor
- * (25.4 / FOUserAgent.DEFAULT_TARGET_RESOLUTION)
+ * (25.4 / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
/ userAgent.getTargetPixelUnitToMillimeter();
int bitmapWidth = (int) ((pageWidth * scaleX) + 0.5);
int bitmapHeight = (int) ((pageHeight * scaleY) + 0.5);
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java Mon May 28 07:31:24 2007
@@ -32,9 +32,6 @@
import java.io.OutputStream;
import java.util.Iterator;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-
import org.apache.commons.logging.Log;
import org.apache.xmlgraphics.image.GraphicsUtil;
@@ -77,12 +74,12 @@
//private static final String COMPRESSION_NONE = "NONE";
//private static final String COMPRESSION_JPEG = "JPEG";
- private static final String COMPRESSION_PACKBITS = "PackBits";
+ public static final String COMPRESSION_PACKBITS = "PackBits";
//private static final String COMPRESSION_DEFLATE = "Deflate";
//private static final String COMPRESSION_LZW = "LZW";
//private static final String COMPRESSION_ZLIB = "ZLib";
- private static final String COMPRESSION_CCITT_T6 = "CCITT T.6"; //CCITT Group 4
- private static final String COMPRESSION_CCITT_T4 = "CCITT T.4"; //CCITT Group 3
+ public static final String COMPRESSION_CCITT_T6 = "CCITT T.6"; //CCITT Group 4
+ public static final String COMPRESSION_CCITT_T4 = "CCITT T.4"; //CCITT Group 3
/** ImageWriter parameters */
private ImageWriterParams writerParams;
@@ -115,30 +112,6 @@
writerParams.setResolution(dpi);
}
- /**
- * Configure the TIFF renderer. Get the configuration to be used for
- * compression
- * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
- */
- public void configure(Configuration cfg) throws ConfigurationException {
- super.configure(cfg);
-
- //set compression
- String name = cfg.getChild("compression").getValue(COMPRESSION_PACKBITS);
- //Some compression formats need a special image format:
- if (name.equalsIgnoreCase(COMPRESSION_CCITT_T6)) {
- bufferedImageType = BufferedImage.TYPE_BYTE_BINARY;
- } else if (name.equalsIgnoreCase(COMPRESSION_CCITT_T4)) {
- bufferedImageType = BufferedImage.TYPE_BYTE_BINARY;
- } else {
- bufferedImageType = BufferedImage.TYPE_INT_ARGB;
- }
- if (!"NONE".equalsIgnoreCase(name)) {
- writerParams.setCompressionMethod(name);
- }
- log.info("TIFF compression set to " + name);
- }
-
/** @see org.apache.fop.render.Renderer#startRenderer(java.io.OutputStream) */
public void startRenderer(OutputStream outputStream) throws IOException {
this.outputStream = outputStream;
@@ -252,5 +225,13 @@
throw new UnsupportedOperationException(
"Method 'remove' is not supported.");
}
+ }
+
+ public void setBufferedImageType(int bufferedImageType) {
+ this.bufferedImageType = bufferedImageType;
+ }
+
+ public ImageWriterParams getWriterParams() {
+ return writerParams;
}
}
Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java Mon May 28 07:31:24 2007
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.render.bitmap;
+
+import java.awt.image.BufferedImage;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.render.PrintRendererConfigurator;
+import org.apache.fop.render.Renderer;
+
+/**
+ * TIFF Renderer configurator
+ */
+public class TIFFRendererConfigurator extends PrintRendererConfigurator {
+
+ /**
+ * Default constructor
+ * @param userAgent user agent
+ */
+ public TIFFRendererConfigurator(FOUserAgent userAgent) {
+ super(userAgent);
+ }
+
+ /**
+ * Configure the TIFF renderer. Get the configuration to be used for
+ * compression
+ * @param renderer tiff renderer
+ * @throws FOPException fop exception
+ * @see org.apache.fop.render.PrintRendererConfigurator#configure(Renderer)
+ */
+ public void configure(Renderer renderer) throws FOPException {
+ Configuration cfg = super.getRendererConfig(renderer);
+ if (cfg != null) {
+ TIFFRenderer tiffRenderer = (TIFFRenderer)renderer;
+ //set compression
+ String name = cfg.getChild("compression").getValue(TIFFRenderer.COMPRESSION_PACKBITS);
+ //Some compression formats need a special image format:
+ if (name.equalsIgnoreCase(TIFFRenderer.COMPRESSION_CCITT_T6)) {
+ tiffRenderer.setBufferedImageType(BufferedImage.TYPE_BYTE_BINARY);
+ } else if (name.equalsIgnoreCase(TIFFRenderer.COMPRESSION_CCITT_T4)) {
+ tiffRenderer.setBufferedImageType(BufferedImage.TYPE_BYTE_BINARY);
+ } else {
+ tiffRenderer.setBufferedImageType(BufferedImage.TYPE_INT_ARGB);
+ }
+ if (!"NONE".equalsIgnoreCase(name)) {
+ tiffRenderer.getWriterParams().setCompressionMethod(name);
+ }
+ if (log.isInfoEnabled()) {
+ log.info("TIFF compression set to " + name);
+ }
+ }
+ }
+}
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java Mon May 28 07:31:24 2007
@@ -23,6 +23,7 @@
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.render.AbstractRendererMaker;
import org.apache.fop.render.Renderer;
+import org.apache.fop.render.RendererConfigurator;
/**
* RendererMaker for the TIFF Renderer.
@@ -31,10 +32,14 @@
private static final String[] MIMES = new String[] {MimeConstants.MIME_TIFF};
-
- /** @see org.apache.fop.render.AbstractRendererMaker */
- public Renderer makeRenderer(FOUserAgent ua) {
+ /** @see org.apache.fop.render.AbstractRendererMaker#makeRenderer(FOUserAgent) */
+ public Renderer makeRenderer(FOUserAgent userAgent) {
return new TIFFRenderer();
+ }
+
+ /** @see org.apache.fop.render.AbstractRendererMaker#getConfigurator(FOUserAgent) */
+ public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
+ return new TIFFRendererConfigurator(userAgent);
}
/** @see org.apache.fop.render.AbstractRendererMaker#needsOutputStream() */
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontSetup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontSetup.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontSetup.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontSetup.java Mon May 28 07:31:24 2007
@@ -139,52 +139,52 @@
// fontInfo.addMetrics("F17", new BauerBodoniBoldItalic());
/* any is treated as serif */
- fontInfo.addFontProperties("F5", "any", "normal", Font.NORMAL);
- fontInfo.addFontProperties("F6", "any", "italic", Font.NORMAL);
- fontInfo.addFontProperties("F6", "any", "oblique", Font.NORMAL);
- fontInfo.addFontProperties("F7", "any", "normal", Font.BOLD);
- fontInfo.addFontProperties("F8", "any", "italic", Font.BOLD);
- fontInfo.addFontProperties("F8", "any", "oblique", Font.BOLD);
-
- fontInfo.addFontProperties("F1", "sans-serif", "normal", Font.NORMAL);
- fontInfo.addFontProperties("F2", "sans-serif", "oblique", Font.NORMAL);
- fontInfo.addFontProperties("F2", "sans-serif", "italic", Font.NORMAL);
- fontInfo.addFontProperties("F3", "sans-serif", "normal", Font.BOLD);
- fontInfo.addFontProperties("F4", "sans-serif", "oblique", Font.BOLD);
- fontInfo.addFontProperties("F4", "sans-serif", "italic", Font.BOLD);
- fontInfo.addFontProperties("F5", "serif", "normal", Font.NORMAL);
- fontInfo.addFontProperties("F6", "serif", "oblique", Font.NORMAL);
- fontInfo.addFontProperties("F6", "serif", "italic", Font.NORMAL);
- fontInfo.addFontProperties("F7", "serif", "normal", Font.BOLD);
- fontInfo.addFontProperties("F8", "serif", "oblique", Font.BOLD);
- fontInfo.addFontProperties("F8", "serif", "italic", Font.BOLD);
- fontInfo.addFontProperties("F9", "monospace", "normal", Font.NORMAL);
- fontInfo.addFontProperties("F10", "monospace", "oblique", Font.NORMAL);
- fontInfo.addFontProperties("F10", "monospace", "italic", Font.NORMAL);
- fontInfo.addFontProperties("F11", "monospace", "normal", Font.BOLD);
- fontInfo.addFontProperties("F12", "monospace", "oblique", Font.BOLD);
- fontInfo.addFontProperties("F12", "monospace", "italic", Font.BOLD);
-
- fontInfo.addFontProperties("F1", "Helvetica", "normal", Font.NORMAL);
- fontInfo.addFontProperties("F2", "Helvetica", "oblique", Font.NORMAL);
- fontInfo.addFontProperties("F2", "Helvetica", "italic", Font.NORMAL);
- fontInfo.addFontProperties("F3", "Helvetica", "normal", Font.BOLD);
- fontInfo.addFontProperties("F4", "Helvetica", "oblique", Font.BOLD);
- fontInfo.addFontProperties("F4", "Helvetica", "italic", Font.BOLD);
- fontInfo.addFontProperties("F5", "Times", "normal", Font.NORMAL);
- fontInfo.addFontProperties("F6", "Times", "oblique", Font.NORMAL);
- fontInfo.addFontProperties("F6", "Times", "italic", Font.NORMAL);
- fontInfo.addFontProperties("F7", "Times", "normal", Font.BOLD);
- fontInfo.addFontProperties("F8", "Times", "oblique", Font.BOLD);
- fontInfo.addFontProperties("F8", "Times", "italic", Font.BOLD);
- fontInfo.addFontProperties("F9", "Courier", "normal", Font.NORMAL);
- fontInfo.addFontProperties("F10", "Courier", "oblique", Font.NORMAL);
- fontInfo.addFontProperties("F10", "Courier", "italic", Font.NORMAL);
- fontInfo.addFontProperties("F11", "Courier", "normal", Font.BOLD);
- fontInfo.addFontProperties("F12", "Courier", "oblique", Font.BOLD);
- fontInfo.addFontProperties("F12", "Courier", "italic", Font.BOLD);
- fontInfo.addFontProperties("F13", "Symbol", "normal", Font.NORMAL);
- fontInfo.addFontProperties("F14", "ZapfDingbats", "normal", Font.NORMAL);
+ fontInfo.addFontProperties("F5", "any", "normal", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "any", "italic", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "any", "oblique", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F7", "any", "normal", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "any", "italic", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "any", "oblique", Font.WEIGHT_BOLD);
+
+ fontInfo.addFontProperties("F1", "sans-serif", "normal", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F2", "sans-serif", "oblique", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F2", "sans-serif", "italic", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F3", "sans-serif", "normal", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F4", "sans-serif", "oblique", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F4", "sans-serif", "italic", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F5", "serif", "normal", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "serif", "oblique", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "serif", "italic", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F7", "serif", "normal", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "serif", "oblique", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "serif", "italic", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F9", "monospace", "normal", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F10", "monospace", "oblique", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F10", "monospace", "italic", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F11", "monospace", "normal", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F12", "monospace", "oblique", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F12", "monospace", "italic", Font.WEIGHT_BOLD);
+
+ fontInfo.addFontProperties("F1", "Helvetica", "normal", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F2", "Helvetica", "oblique", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F2", "Helvetica", "italic", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F3", "Helvetica", "normal", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F4", "Helvetica", "oblique", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F4", "Helvetica", "italic", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F5", "Times", "normal", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "Times", "oblique", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "Times", "italic", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F7", "Times", "normal", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "Times", "oblique", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "Times", "italic", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F9", "Courier", "normal", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F10", "Courier", "oblique", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F10", "Courier", "italic", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F11", "Courier", "normal", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F12", "Courier", "oblique", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F12", "Courier", "italic", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F13", "Symbol", "normal", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F14", "ZapfDingbats", "normal", Font.WEIGHT_NORMAL);
// Custom type 1 fonts step 2/2
// fontInfo.addFontProperties("F15", "OMEP", "normal", FontInfo.NORMAL);
@@ -192,20 +192,20 @@
// fontInfo.addFontProperties("F17", "BauerBodoni", "italic", FontInfo.BOLD);
/* for compatibility with PassiveTex */
- fontInfo.addFontProperties("F5", "Times-Roman", "normal", Font.NORMAL);
- fontInfo.addFontProperties("F6", "Times-Roman", "oblique", Font.NORMAL);
- fontInfo.addFontProperties("F6", "Times-Roman", "italic", Font.NORMAL);
- fontInfo.addFontProperties("F7", "Times-Roman", "normal", Font.BOLD);
- fontInfo.addFontProperties("F8", "Times-Roman", "oblique", Font.BOLD);
- fontInfo.addFontProperties("F8", "Times-Roman", "italic", Font.BOLD);
- fontInfo.addFontProperties("F5", "Times Roman", "normal", Font.NORMAL);
- fontInfo.addFontProperties("F6", "Times Roman", "oblique", Font.NORMAL);
- fontInfo.addFontProperties("F6", "Times Roman", "italic", Font.NORMAL);
- fontInfo.addFontProperties("F7", "Times Roman", "normal", Font.BOLD);
- fontInfo.addFontProperties("F8", "Times Roman", "oblique", Font.BOLD);
- fontInfo.addFontProperties("F8", "Times Roman", "italic", Font.BOLD);
+ fontInfo.addFontProperties("F5", "Times-Roman", "normal", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "Times-Roman", "oblique", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "Times-Roman", "italic", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F7", "Times-Roman", "normal", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "Times-Roman", "oblique", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "Times-Roman", "italic", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F5", "Times Roman", "normal", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "Times Roman", "oblique", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "Times Roman", "italic", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F7", "Times Roman", "normal", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "Times Roman", "oblique", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "Times Roman", "italic", Font.WEIGHT_BOLD);
fontInfo.addFontProperties("F9", "Computer-Modern-Typewriter",
- "normal", Font.NORMAL);
+ "normal", Font.WEIGHT_NORMAL);
configureInstalledAWTFonts(fontInfo, graphics, LAST_PREDEFINED_FONT_NUMBER + 1);
}
@@ -252,9 +252,9 @@
FontMetricsMapper metric = new FontMetricsMapper(family, fontStyle, graphics);
fontInfo.addMetrics(fontKey, metric);
- int weight = Font.NORMAL;
+ int weight = Font.WEIGHT_NORMAL;
if ((fontStyle & java.awt.Font.BOLD) != 0) {
- weight = Font.BOLD;
+ weight = Font.WEIGHT_BOLD;
}
String style = "normal";
if ((fontStyle & java.awt.Font.ITALIC) != 0) {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java Mon May 28 07:31:24 2007
@@ -53,10 +53,9 @@
import org.w3c.dom.Document;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.FopFactoryConfigurator;
import org.apache.fop.area.CTM;
import org.apache.fop.area.PageViewport;
import org.apache.fop.area.Trait;
@@ -73,7 +72,6 @@
import org.apache.fop.image.FopImage;
import org.apache.fop.image.ImageFactory;
import org.apache.fop.image.XMLImage;
-import org.apache.fop.pdf.PDFAMode;
import org.apache.fop.render.AbstractPathOrientedRenderer;
import org.apache.fop.render.Graphics2DAdapter;
import org.apache.fop.render.RendererContext;
@@ -151,19 +149,6 @@
}
/**
- * @see org.apache.fop.render.AbstractRenderer#configure(
- * org.apache.avalon.framework.configuration.Configuration)
- */
- public void configure(Configuration cfg) throws ConfigurationException {
- super.configure(cfg);
-
- String s = cfg.getChild(JAVA2D_TRANSPARENT_PAGE_BACKGROUND, true).getValue(null);
- if (s != null) {
- this.transparentPageBackground = "true".equalsIgnoreCase(s);
- }
- }
-
- /**
* @see org.apache.fop.render.Renderer#setUserAgent(org.apache.fop.apps.FOUserAgent)
*/
public void setUserAgent(FOUserAgent foUserAgent) {
@@ -305,10 +290,10 @@
+ pageHeight + ")");
double scaleX = scaleFactor
- * (25.4 / FOUserAgent.DEFAULT_TARGET_RESOLUTION)
+ * (25.4 / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
/ userAgent.getTargetPixelUnitToMillimeter();
double scaleY = scaleFactor
- * (25.4 / FOUserAgent.DEFAULT_TARGET_RESOLUTION)
+ * (25.4 / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
/ userAgent.getTargetPixelUnitToMillimeter();
int bitmapWidth = (int) ((pageWidth * scaleX) + 0.5);
int bitmapHeight = (int) ((pageHeight * scaleY) + 0.5);
@@ -1021,6 +1006,10 @@
/** @see org.apache.fop.render.AbstractPathOrientedRenderer#endTextObject() */
protected void endTextObject() {
//not necessary in Java2D
+ }
+
+ public void setTransparentPageBackground(boolean transparentPageBackground) {
+ this.transparentPageBackground = transparentPageBackground;
}
}
Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java Mon May 28 07:31:24 2007
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.render.java2d;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.render.PrintRendererConfigurator;
+import org.apache.fop.render.Renderer;
+
+/**
+ * Configurerer for Java 2D renderer
+ */
+public class Java2DRendererConfigurator extends PrintRendererConfigurator {
+
+ /**
+ * Default constructor
+ * @param userAgent user agent
+ */
+ public Java2DRendererConfigurator(FOUserAgent userAgent) {
+ super(userAgent);
+ }
+
+ /**
+ * Configure the Java 2D renderer.
+ * @param renderer java 2d renderer
+ * @throws FOPException fop exception
+ */
+ public void configure(Renderer renderer) throws FOPException {
+ Configuration cfg = super.getRendererConfig(renderer);
+ if (cfg != null) {
+ Java2DRenderer java2dRenderer = (Java2DRenderer)renderer;
+ String value = cfg.getChild(
+ Java2DRenderer.JAVA2D_TRANSPARENT_PAGE_BACKGROUND, true).getValue(null);
+ if (value != null) {
+ java2dRenderer.setTransparentPageBackground("true".equalsIgnoreCase(value));
+ }
+ }
+ }
+}
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java Mon May 28 07:31:24 2007
@@ -53,8 +53,6 @@
import org.apache.xmlgraphics.java2d.GraphicContext;
// FOP
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.fop.apps.FOPException;
@@ -143,31 +141,8 @@
public PCLRenderer() {
}
- /**
- * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
- */
- public void configure(Configuration cfg) throws ConfigurationException {
- super.configure(cfg);
- String rendering = cfg.getChild("rendering").getValue(null);
- if ("quality".equalsIgnoreCase(rendering)) {
- this.qualityBeforeSpeed = true;
- } else if ("speed".equalsIgnoreCase(rendering)) {
- this.qualityBeforeSpeed = false;
- } else if (rendering != null) {
- throw new ConfigurationException(
- "Valid values for 'rendering' are 'quality' and 'speed'. Value found: "
- + rendering);
- }
- String textRendering = cfg.getChild("text-rendering").getValue(null);
- if ("bitmap".equalsIgnoreCase(textRendering)) {
- this.allTextAsBitmaps = true;
- } else if ("auto".equalsIgnoreCase(textRendering)) {
- this.allTextAsBitmaps = false;
- } else if (textRendering != null) {
- throw new ConfigurationException(
- "Valid values for 'text-rendering' are 'auto' and 'bitmap'. Value found: "
- + textRendering);
- }
+ public void setQualityBeforeSpeed(boolean qualityBeforeSpeed) {
+ this.qualityBeforeSpeed = qualityBeforeSpeed;
}
/**
@@ -1498,6 +1473,10 @@
} catch (IOException ioe) {
handleIOTrouble(ioe);
}
+ }
+
+ public void setAllTextAsBitmaps(boolean allTextAsBitmaps) {
+ this.allTextAsBitmaps = allTextAsBitmaps;
}
Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java Mon May 28 07:31:24 2007
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.render.pcl;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.render.PrintRendererConfigurator;
+import org.apache.fop.render.Renderer;
+
+/**
+ * PCL Renderer configurator
+ */
+public class PCLRendererConfigurator extends PrintRendererConfigurator {
+
+ /**
+ * Default constructor
+ * @param userAgent user agent
+ */
+ public PCLRendererConfigurator(FOUserAgent userAgent) {
+ super(userAgent);
+ }
+
+ /**
+ * Configure the TIFF renderer. Get the configuration to be used for
+ * compression
+ * @param renderer PCL renderer
+ * @throws FOPException fop exception
+ * @see org.apache.fop.render.PrintRendererConfigurator#configure(Renderer)
+ */
+ public void configure(Renderer renderer) throws FOPException {
+ Configuration cfg = super.getRendererConfig(renderer);
+ if (cfg != null) {
+ PCLRenderer pclRenderer = (PCLRenderer)renderer;
+ String rendering = cfg.getChild("rendering").getValue(null);
+ if ("quality".equalsIgnoreCase(rendering)) {
+ pclRenderer.setQualityBeforeSpeed(true);
+ } else if ("speed".equalsIgnoreCase(rendering)) {
+ pclRenderer.setQualityBeforeSpeed(false);
+ } else if (rendering != null) {
+ throw new FOPException(
+ "Valid values for 'rendering' are 'quality' and 'speed'. Value found: "
+ + rendering);
+ }
+ String textRendering = cfg.getChild("text-rendering").getValue(null);
+ if ("bitmap".equalsIgnoreCase(textRendering)) {
+ pclRenderer.setAllTextAsBitmaps(true);
+ } else if ("auto".equalsIgnoreCase(textRendering)) {
+ pclRenderer.setAllTextAsBitmaps(false);
+ } else if (textRendering != null) {
+ throw new FOPException(
+ "Valid values for 'text-rendering' are 'auto' and 'bitmap'. Value found: "
+ + textRendering);
+ }
+ }
+ }
+}
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRendererMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRendererMaker.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRendererMaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRendererMaker.java Mon May 28 07:31:24 2007
@@ -23,6 +23,7 @@
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.render.AbstractRendererMaker;
import org.apache.fop.render.Renderer;
+import org.apache.fop.render.RendererConfigurator;
/**
* RendererMaker for the PCL Renderer.
@@ -31,14 +32,19 @@
private static final String[] MIMES = new String[] {
MimeConstants.MIME_PCL,
- MimeConstants.MIME_PCL_ALT};
+ MimeConstants.MIME_PCL_ALT
+ };
-
- /**@see org.apache.fop.render.AbstractRendererMaker */
- public Renderer makeRenderer(FOUserAgent ua) {
+ /**@see org.apache.fop.render.AbstractRendererMaker#makeRenderer(FOUserAgent) */
+ public Renderer makeRenderer(FOUserAgent userAgent) {
return new PCLRenderer();
}
+ /** @see org.apache.fop.render.AbstractRendererMaker#getConfigurator(FOUserAgent) */
+ public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
+ return new PCLRendererConfigurator(userAgent);
+ }
+
/** @see org.apache.fop.render.AbstractRendererMaker#needsOutputStream() */
public boolean needsOutputStream() {
return true;
@@ -48,5 +54,4 @@
public String[] getSupportedMimeTypes() {
return MIMES;
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org