diff options
author | Mehdi Houshmand <mehdi@apache.org> | 2012-06-20 13:51:14 +0000 |
---|---|---|
committer | Mehdi Houshmand <mehdi@apache.org> | 2012-06-20 13:51:14 +0000 |
commit | c36ffee9dfbf111899bbca5f994e334ca6b95011 (patch) | |
tree | 70107daa49cea97a4456a32087d0703baf84eed8 /src/java/org/apache | |
parent | d32664f71c991d0d9fd4445d3fc1b5e83bb0a963 (diff) | |
download | xmlgraphics-fop-c36ffee9dfbf111899bbca5f994e334ca6b95011.tar.gz xmlgraphics-fop-c36ffee9dfbf111899bbca5f994e334ca6b95011.zip |
Added tests and cleaning up of code
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_URI_Unification@1352101 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
44 files changed, 432 insertions, 341 deletions
diff --git a/src/java/org/apache/fop/afp/util/AFPResourceAccessor.java b/src/java/org/apache/fop/afp/util/AFPResourceAccessor.java index 9993fc81c..ddcfa001b 100644 --- a/src/java/org/apache/fop/afp/util/AFPResourceAccessor.java +++ b/src/java/org/apache/fop/afp/util/AFPResourceAccessor.java @@ -24,6 +24,8 @@ import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.io.InternalResourceResolver; /** diff --git a/src/java/org/apache/fop/apps/FOUserAgent.java b/src/java/org/apache/fop/apps/FOUserAgent.java index 987ba7d1e..fc9287401 100644 --- a/src/java/org/apache/fop/apps/FOUserAgent.java +++ b/src/java/org/apache/fop/apps/FOUserAgent.java @@ -60,7 +60,7 @@ import org.apache.fop.render.ImageHandlerRegistry; import org.apache.fop.render.Renderer; import org.apache.fop.render.RendererConfig; import org.apache.fop.render.RendererConfig.RendererConfigParser; -import org.apache.fop.render.RendererConfigOptions; +import org.apache.fop.render.RendererConfigOption; import org.apache.fop.render.RendererFactory; import org.apache.fop.render.XMLHandlerRegistry; import org.apache.fop.render.intermediate.IFDocumentHandler; @@ -390,7 +390,7 @@ public class FOUserAgent { * @param option the renderer option * @return the value */ - public Object getRendererOption(RendererConfigOptions option) { + public Object getRendererOption(RendererConfigOption option) { return rendererOptions.get(option.getName()); } diff --git a/src/java/org/apache/fop/apps/MimeConstants.java b/src/java/org/apache/fop/apps/MimeConstants.java index 851690db1..75b05c8b7 100644 --- a/src/java/org/apache/fop/apps/MimeConstants.java +++ b/src/java/org/apache/fop/apps/MimeConstants.java @@ -32,4 +32,6 @@ public interface MimeConstants extends org.apache.xmlgraphics.util.MimeConstants String MIME_FOP_AREA_TREE = "application/X-fop-areatree"; /** Apache FOP's intermediate format XML */ String MIME_FOP_IF = "application/X-fop-intermediate-format"; + /** Bitmap images */ + String MIME_BITMAP = "image/x-bitmap"; } diff --git a/src/java/org/apache/fop/apps/io/URIResolverWrapper.java b/src/java/org/apache/fop/apps/io/URIResolverWrapper.java deleted file mode 100644 index 2d2420d49..000000000 --- a/src/java/org/apache/fop/apps/io/URIResolverWrapper.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.apps.io; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; -import java.net.URISyntaxException; - -import javax.xml.transform.Source; -import javax.xml.transform.TransformerException; -import javax.xml.transform.stream.StreamSource; - -import org.apache.xmlgraphics.util.uri.DataURIResolver; - -public class URIResolverWrapper { - private final URI baseUri; - private final ResourceResolver uriResolver; - private final DataURIResolver dataSchemeResolver = new DataURIResolver(); - - public URIResolverWrapper(URI baseUri, ResourceResolver uriResolver) { - this.baseUri = baseUri; - this.uriResolver = uriResolver; - } - - public URI getBaseURI() { - return baseUri; - } - - public InputStream resolveIn(String stringUri) throws IOException, URISyntaxException { - if (stringUri.startsWith("data:")) { - return resolveDataURI(stringUri); - } - return resolveIn(cleanURI(stringUri)); - } - - public InputStream resolveIn(URI uri) throws IOException { - if (uri.getScheme() != null && uri.getScheme().startsWith("data")) { - return resolveDataURI(uri.toASCIIString()); - } - return uriResolver.getResource(resolveFromBase(uri)); - } - - public OutputStream resolveOut(URI uri) throws IOException { - return uriResolver.getOutputStream(resolveFromBase(uri)); - } - - private URI resolveFromBase(URI uri) { - return baseUri.resolve(uri); - } - - public static URI cleanURI(String uriStr) throws URISyntaxException { - // replace back slash with forward slash to ensure windows file:/// URLS are supported - if (uriStr == null) { - return null; - } - String fixedUri = uriStr.replace('\\', '/'); - fixedUri = fixedUri.replace(" ", "%20"); - URI baseURI = new URI(fixedUri); - return baseURI; - } - - public static URI getBaseURI(String base) throws URISyntaxException { - String path = base + (base.endsWith("/") ? "" : "/"); - return cleanURI(path); - } - - private InputStream resolveDataURI(String dataURI) { - try { - Source src = dataSchemeResolver.resolve(dataURI, ""); - return src == null ? null : ((StreamSource) src).getInputStream(); - } catch (TransformerException e) { - throw new RuntimeException(e); - } - } -} diff --git a/src/java/org/apache/fop/cli/CommandLineOptions.java b/src/java/org/apache/fop/cli/CommandLineOptions.java index e0cf0fbb6..780c8758b 100644 --- a/src/java/org/apache/fop/cli/CommandLineOptions.java +++ b/src/java/org/apache/fop/cli/CommandLineOptions.java @@ -57,7 +57,7 @@ import org.apache.fop.render.print.PrintRenderer; import org.apache.fop.render.xml.XMLRenderer; import org.apache.fop.util.CommandLineLogger; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.ENCRYPTION_PARAMS; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.ENCRYPTION_PARAMS; /** * Options parses the commandline arguments diff --git a/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java b/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java index 54b2651d7..717c75d4d 100644 --- a/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java +++ b/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java @@ -153,7 +153,6 @@ public class DefaultFontConfigurator implements FontConfigurator<EmbedFontInfo> // no font triplet info if (tripletList.size() == 0) { - //TODO: could be problematic!! URI fontUri = resourceResolver.resolveFromBase(embedUri); if (fontUri != null) { FontInfoFinder finder = new FontInfoFinder(); diff --git a/src/java/org/apache/fop/fonts/FontManagerConfigurator.java b/src/java/org/apache/fop/fonts/FontManagerConfigurator.java index 31373c8b5..0def335a1 100644 --- a/src/java/org/apache/fop/fonts/FontManagerConfigurator.java +++ b/src/java/org/apache/fop/fonts/FontManagerConfigurator.java @@ -31,8 +31,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.fop.apps.FOPException; -import org.apache.fop.apps.io.ResourceResolver; import org.apache.fop.apps.io.InternalResourceResolver; +import org.apache.fop.apps.io.ResourceResolver; import org.apache.fop.fonts.substitute.FontSubstitutions; import org.apache.fop.fonts.substitute.FontSubstitutionsConfigurator; import org.apache.fop.util.LogUtil; @@ -74,7 +74,6 @@ public class FontManagerConfigurator { // caching (fonts) if (cfg.getChild("use-cache", false) != null) { try { - // TODO: Find some way to deal with this!! if (!cfg.getChild("use-cache").getValueAsBoolean()) { fontManager.disableFontCache(); } else { diff --git a/src/java/org/apache/fop/fonts/FontReader.java b/src/java/org/apache/fop/fonts/FontReader.java index 739532af5..7fed1d400 100644 --- a/src/java/org/apache/fop/fonts/FontReader.java +++ b/src/java/org/apache/fop/fonts/FontReader.java @@ -176,7 +176,7 @@ public class FontReader extends DefaultHandler { try { returnFont.setEmbedURI(InternalResourceResolver.cleanURI(attributes.getValue("file"))); } catch (URISyntaxException e) { - // TODO: dunno what to do here?!?! + throw new SAXException("URI syntax error in metrics file: " + e.getMessage(), e); } returnFont.setEmbedResourceName(attributes.getValue("class")); } else if ("cid-widths".equals(localName)) { diff --git a/src/java/org/apache/fop/fonts/FontSetup.java b/src/java/org/apache/fop/fonts/FontSetup.java index 4c0e910ab..f9bae3332 100644 --- a/src/java/org/apache/fop/fonts/FontSetup.java +++ b/src/java/org/apache/fop/fonts/FontSetup.java @@ -190,7 +190,8 @@ public final class FontSetup { * @param resourceResolver the font resolver */ private static void addConfiguredFonts(FontInfo fontInfo, - List<EmbedFontInfo> embedFontInfoList, int num, InternalResourceResolver resourceResolver, + List<EmbedFontInfo> embedFontInfoList, int num, + InternalResourceResolver resourceResolver, boolean base14Kerning) { if (embedFontInfoList == null) { return; //No fonts to process diff --git a/src/java/org/apache/fop/fonts/LazyFont.java b/src/java/org/apache/fop/fonts/LazyFont.java index eae094b8c..063e54d24 100644 --- a/src/java/org/apache/fop/fonts/LazyFont.java +++ b/src/java/org/apache/fop/fonts/LazyFont.java @@ -108,8 +108,8 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, if (fontEmbedURI == null) { throw new RuntimeException("Cannot load font. No font URIs available."); } - realFont = FontLoader.loadFont(fontEmbedURI, this.subFontName, - this.embedded, this.encodingMode, useKerning, useAdvanced, resourceResolver); + realFont = FontLoader.loadFont(fontEmbedURI, this.subFontName, embedded, + this.encodingMode, useKerning, useAdvanced, resourceResolver); } if (realFont instanceof FontDescriptor) { realFontDescriptor = (FontDescriptor) realFont; diff --git a/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java b/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java index 7f666b0a2..ebde373b8 100644 --- a/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java +++ b/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java @@ -131,6 +131,13 @@ public class FontInfoFinder { return style; } + /** + * Attempts to determine FontInfo from a given custom font + * @param fontUri the font URI + * @param customFont the custom font + * @param fontCache font cache (may be null) + * @return FontInfo from the given custom font + */ private EmbedFontInfo getFontInfoFromCustomFont(URI fontUri, CustomFont customFont, FontCache fontCache, InternalResourceResolver resourceResolver) { List<FontTriplet> fontTripletList = new java.util.ArrayList<FontTriplet>(); diff --git a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java index 6e28ac445..5c6c32e7e 100644 --- a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java +++ b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java @@ -76,9 +76,9 @@ public class Type1FontLoader extends FontLoader { String fontFileStr = fontFileURI.toASCIIString(); String partialAfmUri = fontFileStr.substring(0, fontFileStr.length() - 4); String afmUri = null; - for (int i = 0; i < AFM_EXTENSIONS.length; i++) { + for (String afmExtension : AFM_EXTENSIONS) { try { - afmUri = partialAfmUri + AFM_EXTENSIONS[i]; + afmUri = partialAfmUri + afmExtension; afmIn = resourceResolver.getResource(afmUri); if (afmIn != null) { break; @@ -86,8 +86,7 @@ public class Type1FontLoader extends FontLoader { } catch (IOException ioe) { // Ignore, AFM probably not available under the URI } catch (URISyntaxException e) { - // TODO: Not sure what the best thing to do here is?!? - throw new RuntimeException(e); + // Ignore, AFM probably not available under the URI } } if (afmIn != null) { diff --git a/src/java/org/apache/fop/hyphenation/Hyphenator.java b/src/java/org/apache/fop/hyphenation/Hyphenator.java index f14331b37..31cf8e1c8 100644 --- a/src/java/org/apache/fop/hyphenation/Hyphenator.java +++ b/src/java/org/apache/fop/hyphenation/Hyphenator.java @@ -69,12 +69,12 @@ public final class Hyphenator { * The hyphenation trees are cached. * @param lang the language * @param country the country (may be null or "none") - * @param resourceResolver resolver to find the hyphenation files + * @param resolver resolver to find the hyphenation files * @param hyphPatNames the map with user-configured hyphenation pattern file names * @return the hyphenation tree */ public static HyphenationTree getHyphenationTree(String lang, - String country, InternalResourceResolver resourceResolver, Map hyphPatNames) { + String country, InternalResourceResolver resolver, Map hyphPatNames) { String llccKey = HyphenationTreeCache.constructLlccKey(lang, country); HyphenationTreeCache cache = getHyphenationTreeCache(); @@ -83,13 +83,13 @@ public final class Hyphenator { return null; } - HyphenationTree hTree = getHyphenationTree2(lang, country, resourceResolver, hyphPatNames); + HyphenationTree hTree = getHyphenationTree2(lang, country, resolver, hyphPatNames); // fallback to lang only if (hTree == null && country != null && !country.equals("none")) { String llKey = HyphenationTreeCache.constructLlccKey(lang, null); if (!cache.isMissing(llKey)) { - hTree = getHyphenationTree2(lang, null, resourceResolver, hyphPatNames); + hTree = getHyphenationTree2(lang, null, resolver, hyphPatNames); if (hTree != null && log.isDebugEnabled()) { log.debug("Couldn't find hyphenation pattern " + "for lang=\"" + lang + "\",country=\"" + country + "\"." @@ -125,7 +125,7 @@ public final class Hyphenator { * The hyphenation trees are cached. * @param lang the language * @param country the country (may be null or "none") - * @param resourceResolver resource resolver to find the hyphenation files + * @param resourceResolver resolver to find the hyphenation files * @param hyphPatNames the map with user-configured hyphenation pattern file names * @return the hyphenation tree */ @@ -298,7 +298,7 @@ public final class Hyphenator { * Hyphenates a word. * @param lang the language * @param country the optional country code (may be null or "none") - * @param resourceResolver resource resolver to find the hyphenation files + * @param resourceResolver resolver to find the hyphenation files * @param hyphPatNames the map with user-configured hyphenation pattern file names * @param word the word to hyphenate * @param leftMin the minimum number of characters before the hyphenation point diff --git a/src/java/org/apache/fop/render/adobe/AdobeRendererConfigurator.java b/src/java/org/apache/fop/render/DefaultRendererConfigurator.java index 16a29baf7..061c25709 100644 --- a/src/java/org/apache/fop/render/adobe/AdobeRendererConfigurator.java +++ b/src/java/org/apache/fop/render/DefaultRendererConfigurator.java @@ -17,7 +17,7 @@ /* $Id$ */ -package org.apache.fop.render.adobe; +package org.apache.fop.render; import java.util.ArrayList; import java.util.List; @@ -26,12 +26,15 @@ import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fonts.FontCollection; import org.apache.fop.fonts.FontManager; import org.apache.fop.fonts.base14.Base14FontCollection; -import org.apache.fop.render.PrintRendererConfigurator; import org.apache.fop.render.RendererConfig.RendererConfigParser; -public class AdobeRendererConfigurator extends PrintRendererConfigurator { +/** + * This object represents the default renderer configurator and contains the methods for most the + * RendererConfigurators. + */ +public class DefaultRendererConfigurator extends PrintRendererConfigurator { - public AdobeRendererConfigurator(FOUserAgent userAgent, RendererConfigParser rendererConfigParser) { + public DefaultRendererConfigurator(FOUserAgent userAgent, RendererConfigParser rendererConfigParser) { super(userAgent, rendererConfigParser); } diff --git a/src/java/org/apache/fop/render/RendererConfig.java b/src/java/org/apache/fop/render/RendererConfig.java index 832f5e83f..4b3b63a51 100644 --- a/src/java/org/apache/fop/render/RendererConfig.java +++ b/src/java/org/apache/fop/render/RendererConfig.java @@ -25,14 +25,40 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fonts.FontConfig; +/** + * Implementations of this interface have all the renderer-specific configuration data found in the + * FOP-conf. This object is just a data object that is created by the {@link RendererConfigParser} + * when the FOP conf is parsed. + */ public interface RendererConfig { + /** + * Returns the render-specific font configuration information. + * @return the font config + */ FontConfig getFontInfoConfig(); + /** + * Implementations of this interface parse the relevant renderer-specific configuration data + * within the FOP-conf and create a {@link RendererConfig}. + */ public interface RendererConfigParser { + /** + * Builds the object that contains the renderer configuration data. + * + * @param userAgent the user agent + * @param rendererConfiguration the Avalon config object for parsing the data + * @return the configuration data object + * @throws FOPException if an error occurs while parsing the fop conf + */ RendererConfig build(FOUserAgent userAgent, Configuration rendererConfiguration) throws FOPException; + /** + * The MIME type of the renderer. + * + * @return the mime type + */ String getMimeType(); } } diff --git a/src/java/org/apache/fop/render/RendererConfigOptions.java b/src/java/org/apache/fop/render/RendererConfigOption.java index 9a4e73424..5b670d07a 100644 --- a/src/java/org/apache/fop/render/RendererConfigOptions.java +++ b/src/java/org/apache/fop/render/RendererConfigOption.java @@ -19,6 +19,11 @@ package org.apache.fop.render; -public interface RendererConfigOptions { +/** + * Implementations of this interface enumerate the various renderer configuration options available + * to users in the FOP conf. + */ +public interface RendererConfigOption { + /** The name of the option. */ String getName(); } diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfig.java b/src/java/org/apache/fop/render/afp/AFPRendererConfig.java index f85357238..6b031c9eb 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererConfig.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererConfig.java @@ -20,6 +20,7 @@ package org.apache.fop.render.afp; import java.net.URI; +import java.net.URISyntaxException; import java.util.EnumMap; import org.apache.avalon.framework.configuration.Configuration; @@ -36,6 +37,7 @@ import org.apache.fop.afp.modca.triplets.MappingOptionTriplet; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.MimeConstants; +import org.apache.fop.apps.io.InternalResourceResolver; import org.apache.fop.fonts.FontManager; import org.apache.fop.render.RendererConfig; import org.apache.fop.render.afp.AFPFontConfig.AFPFontInfoConfigParser; @@ -43,26 +45,32 @@ import org.apache.fop.util.LogUtil; import static org.apache.fop.render.afp.AFPRendererConfig.ImagesModeOptions.MODE_COLOR; import static org.apache.fop.render.afp.AFPRendererConfig.ImagesModeOptions.MODE_GRAYSCALE; -import static org.apache.fop.render.afp.AFPRendererConfig.Options.DEFAULT_RESOURCE_LEVELS; -import static org.apache.fop.render.afp.AFPRendererConfig.Options.GOCA; -import static org.apache.fop.render.afp.AFPRendererConfig.Options.GOCA_TEXT; -import static org.apache.fop.render.afp.AFPRendererConfig.Options.IMAGES; -import static org.apache.fop.render.afp.AFPRendererConfig.Options.IMAGES_DITHERING_QUALITY; -import static org.apache.fop.render.afp.AFPRendererConfig.Options.IMAGES_FS45; -import static org.apache.fop.render.afp.AFPRendererConfig.Options.IMAGES_JPEG; -import static org.apache.fop.render.afp.AFPRendererConfig.Options.IMAGES_MAPPING_OPTION; -import static org.apache.fop.render.afp.AFPRendererConfig.Options.IMAGES_MODE; -import static org.apache.fop.render.afp.AFPRendererConfig.Options.IMAGES_NATIVE; -import static org.apache.fop.render.afp.AFPRendererConfig.Options.IMAGES_WRAP_PSEG; -import static org.apache.fop.render.afp.AFPRendererConfig.Options.JPEG_ALLOW_JPEG_EMBEDDING; -import static org.apache.fop.render.afp.AFPRendererConfig.Options.JPEG_BITMAP_ENCODING_QUALITY; -import static org.apache.fop.render.afp.AFPRendererConfig.Options.LINE_WIDTH_CORRECTION; -import static org.apache.fop.render.afp.AFPRendererConfig.Options.RENDERER_RESOLUTION; -import static org.apache.fop.render.afp.AFPRendererConfig.Options.RESOURCE_GROUP_URI; -import static org.apache.fop.render.afp.AFPRendererConfig.Options.SHADING; - +import static org.apache.fop.render.afp.AFPRendererConfigOption.DEFAULT_RESOURCE_LEVELS; +import static org.apache.fop.render.afp.AFPRendererConfigOption.GOCA; +import static org.apache.fop.render.afp.AFPRendererConfigOption.GOCA_TEXT; +import static org.apache.fop.render.afp.AFPRendererConfigOption.IMAGES; +import static org.apache.fop.render.afp.AFPRendererConfigOption.IMAGES_DITHERING_QUALITY; +import static org.apache.fop.render.afp.AFPRendererConfigOption.IMAGES_FS45; +import static org.apache.fop.render.afp.AFPRendererConfigOption.IMAGES_JPEG; +import static org.apache.fop.render.afp.AFPRendererConfigOption.IMAGES_MAPPING_OPTION; +import static org.apache.fop.render.afp.AFPRendererConfigOption.IMAGES_MODE; +import static org.apache.fop.render.afp.AFPRendererConfigOption.IMAGES_NATIVE; +import static org.apache.fop.render.afp.AFPRendererConfigOption.IMAGES_WRAP_PSEG; +import static org.apache.fop.render.afp.AFPRendererConfigOption.JPEG_ALLOW_JPEG_EMBEDDING; +import static org.apache.fop.render.afp.AFPRendererConfigOption.JPEG_BITMAP_ENCODING_QUALITY; +import static org.apache.fop.render.afp.AFPRendererConfigOption.LINE_WIDTH_CORRECTION; +import static org.apache.fop.render.afp.AFPRendererConfigOption.RENDERER_RESOLUTION; +import static org.apache.fop.render.afp.AFPRendererConfigOption.RESOURCE_GROUP_URI; +import static org.apache.fop.render.afp.AFPRendererConfigOption.SHADING; + +/** + * The AFP renderer config object. + */ public final class AFPRendererConfig implements RendererConfig { + /** + * An enumeration for the various images modes available to the AFP renderer. + */ public enum ImagesModeOptions { MODE_GRAYSCALE("b+w", "bits-per-pixel"), @@ -95,41 +103,7 @@ public final class AFPRendererConfig implements RendererConfig { } } - public enum Options { - - DEFAULT_RESOURCE_LEVELS("default-resource-levels", AFPResourceLevelDefaults.class), - IMAGES("images", null), - IMAGES_JPEG("jpeg", null), - IMAGES_DITHERING_QUALITY("dithering-quality", Float.class), - IMAGES_FS45("fs45", Boolean.class), - IMAGES_MAPPING_OPTION("mapping_option", Byte.class), - IMAGES_MODE("mode", Boolean.class), - IMAGES_NATIVE("native", Boolean.class), - IMAGES_WRAP_PSEG("pseg", Boolean.class), - JPEG_ALLOW_JPEG_EMBEDDING("allow-embedding", Boolean.class), - JPEG_BITMAP_ENCODING_QUALITY("bitmap-encoding-quality", Float.class), - RENDERER_RESOLUTION("renderer-resolution", Integer.class), - RESOURCE_GROUP_URI("resource-group-file", URI.class), - SHADING("shading", AFPShadingMode.class), - LINE_WIDTH_CORRECTION("line-width-correction", Float.class), - GOCA("goca", Boolean.class), - GOCA_TEXT("text", Boolean.class); - - private final String name; - - private final Class<?> type; - - private Options(String name, Class<?> type) { - this.name = name; - this.type = type; - } - - public String getName() { - return name; - } - } - - private final EnumMap<Options, Object> params = new EnumMap<Options, Object>(Options.class); + private final EnumMap<AFPRendererConfigOption, Object> params = new EnumMap<AFPRendererConfigOption, Object>(AFPRendererConfigOption.class); private final EnumMap<ImagesModeOptions, Object> imageModeParams = new EnumMap<ImagesModeOptions, Object>(ImagesModeOptions.class); @@ -215,20 +189,24 @@ public final class AFPRendererConfig implements RendererConfig { return getParam(GOCA_TEXT, Boolean.class); } - private <T> T getParam(Options options, Class<T> type) { - assert options.type.equals(type); + private <T> T getParam(AFPRendererConfigOption options, Class<T> type) { + assert options.getType().equals(type); return type.cast(params.get(options)); } - private <T> void setParam(Options option, T value) { - assert option.type.isInstance(value); + private <T> void setParam(AFPRendererConfigOption option, T value) { + assert option.getType().isInstance(value); params.put(option, value); } + /** + * The parser for AFP renderer specific data in the FOP conf. + */ public static final class AFPRendererConfigParser implements RendererConfigParser { private static final Log LOG = LogFactory.getLog(AFPRendererConfigParser.class); + /** {@inheritDoc} */ public AFPRendererConfig build(FOUserAgent userAgent, Configuration cfg) throws FOPException { boolean strict = userAgent != null ? userAgent.validateUserConfigStrictly() : false; AFPRendererConfig config = null; @@ -241,12 +219,12 @@ public final class AFPRendererConfig implements RendererConfig { return config; } + /** {@inheritDoc} */ public String getMimeType() { return MimeConstants.MIME_AFP; } } - private static final class ParserHelper { private static final Log LOG = LogFactory.getLog(ParserHelper.class); @@ -294,7 +272,7 @@ public final class AFPRendererConfig implements RendererConfig { createResourceLevel(); } - private void setParam(Options option, Object value) { + private void setParam(AFPRendererConfigOption option, Object value) { config.setParam(option, value); } @@ -311,7 +289,7 @@ public final class AFPRendererConfig implements RendererConfig { config.imageModeParams.put(MODE_GRAYSCALE, imagesCfg.getAttributeAsInteger(imagesMode.getModeAttribute(), 8)); } - String dithering = imagesCfg.getAttribute(Options.IMAGES_DITHERING_QUALITY.getName(), "medium"); + String dithering = imagesCfg.getAttribute(AFPRendererConfigOption.IMAGES_DITHERING_QUALITY.getName(), "medium"); float dq; if (dithering.startsWith("min")) { dq = 0.0f; @@ -326,7 +304,7 @@ public final class AFPRendererConfig implements RendererConfig { } } setParam(IMAGES_DITHERING_QUALITY, dq); - setParam(IMAGES_NATIVE, imagesCfg.getAttributeAsBoolean(Options.IMAGES_NATIVE.getName(), false)); + setParam(IMAGES_NATIVE, imagesCfg.getAttributeAsBoolean(IMAGES_NATIVE.getName(), false)); setParam(IMAGES_WRAP_PSEG, imagesCfg.getAttributeAsBoolean(IMAGES_WRAP_PSEG.getName(), false)); setParam(IMAGES_FS45, imagesCfg.getAttributeAsBoolean(IMAGES_FS45.getName(), false)); @@ -364,12 +342,13 @@ public final class AFPRendererConfig implements RendererConfig { try { Configuration resourceGroupUriCfg = cfg.getChild(RESOURCE_GROUP_URI.getName(), false); if (resourceGroupUriCfg != null) { - URI resourceGroupUri = URI.create(resourceGroupUriCfg.getValue()); - // TODO validate? + URI resourceGroupUri = InternalResourceResolver.cleanURI(resourceGroupUriCfg.getValue()); setParam(RESOURCE_GROUP_URI, resourceGroupUri); } } catch (ConfigurationException e) { LogUtil.handleException(LOG, e, strict); + } catch (URISyntaxException use) { + LogUtil.handleException(LOG, use, strict); } } diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfigOption.java b/src/java/org/apache/fop/render/afp/AFPRendererConfigOption.java new file mode 100644 index 000000000..5a99ae360 --- /dev/null +++ b/src/java/org/apache/fop/render/afp/AFPRendererConfigOption.java @@ -0,0 +1,64 @@ +/* + * 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. + */ + +package org.apache.fop.render.afp; + +import java.net.URI; + +import org.apache.fop.afp.AFPResourceLevelDefaults; +import org.apache.fop.render.RendererConfigOption; + +/** + * An enumeration of the configuration options available for the AFP renderer. + */ +public enum AFPRendererConfigOption implements RendererConfigOption { + DEFAULT_RESOURCE_LEVELS("default-resource-levels", AFPResourceLevelDefaults.class), + IMAGES("images", null), + IMAGES_JPEG("jpeg", null), + IMAGES_DITHERING_QUALITY("dithering-quality", Float.class), + IMAGES_FS45("fs45", Boolean.class), + IMAGES_MAPPING_OPTION("mapping_option", Byte.class), + IMAGES_MODE("mode", Boolean.class), + IMAGES_NATIVE("native", Boolean.class), + IMAGES_WRAP_PSEG("pseg", Boolean.class), + JPEG_ALLOW_JPEG_EMBEDDING("allow-embedding", Boolean.class), + JPEG_BITMAP_ENCODING_QUALITY("bitmap-encoding-quality", Float.class), + RENDERER_RESOLUTION("renderer-resolution", Integer.class), + RESOURCE_GROUP_URI("resource-group-file", URI.class), + SHADING("shading", AFPShadingMode.class), + LINE_WIDTH_CORRECTION("line-width-correction", Float.class), + GOCA("goca", Boolean.class), + GOCA_TEXT("text", Boolean.class); + + private final String name; + + private final Class<?> type; + + private AFPRendererConfigOption(String name, Class<?> type) { + this.name = name; + this.type = type; + } + + /** {@inheritDoc}}*/ + public String getName() { + return name; + } + + public Class<?> getType() { + return type; + } +} diff --git a/src/java/org/apache/fop/render/bitmap/BitmapRendererConfig.java b/src/java/org/apache/fop/render/bitmap/BitmapRendererConfig.java index 0efb2b930..e76f941d8 100644 --- a/src/java/org/apache/fop/render/bitmap/BitmapRendererConfig.java +++ b/src/java/org/apache/fop/render/bitmap/BitmapRendererConfig.java @@ -34,18 +34,21 @@ import org.apache.fop.render.java2d.Java2DRendererConfig; import org.apache.fop.render.java2d.Java2DRendererConfig.Java2DRendererConfigParser; import org.apache.fop.util.ColorUtil; -import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.ANTI_ALIASING; -import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.BACKGROUND_COLOR; -import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.COLOR_MODE; -import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.JAVA2D_TRANSPARENT_PAGE_BACKGROUND; -import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.RENDERING_QUALITY; -import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.RENDERING_QUALITY_ELEMENT; -import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.RENDERING_SPEED; - +import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.ANTI_ALIASING; +import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.BACKGROUND_COLOR; +import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE; +import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.JAVA2D_TRANSPARENT_PAGE_BACKGROUND; +import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.RENDERING_QUALITY; +import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.RENDERING_QUALITY_ELEMENT; +import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.RENDERING_SPEED; + +/** + * The Bitmap renderer config data object. + */ public class BitmapRendererConfig implements RendererConfig { - private final EnumMap<BitmapRendererConfigOptions, Object> params - = new EnumMap<BitmapRendererConfigOptions, Object>(BitmapRendererConfigOptions.class); + private final EnumMap<BitmapRendererConfigOption, Object> params + = new EnumMap<BitmapRendererConfigOption, Object>(BitmapRendererConfigOption.class); private final DefaultFontConfig fontConfig; @@ -79,10 +82,13 @@ public class BitmapRendererConfig implements RendererConfig { : JAVA2D_TRANSPARENT_PAGE_BACKGROUND.getDefaultValue()); } - private Object get(BitmapRendererConfigOptions option) { + private Object get(BitmapRendererConfigOption option) { return params.get(option); } + /** + * The parser for the Bitmap renderer configuration data. + */ public static class BitmapRendererConfigParser implements RendererConfigParser { private final String mimeType; @@ -91,12 +97,12 @@ public class BitmapRendererConfig implements RendererConfig { this.mimeType = mimeType; } - private void setParam(BitmapRendererConfig config, BitmapRendererConfigOptions option, + private void setParam(BitmapRendererConfig config, BitmapRendererConfigOption option, Object value) { config.params.put(option, value != null ? value : option.getDefaultValue()); } - protected void build(BitmapRendererConfig config, FOUserAgent userAgent, + void build(BitmapRendererConfig config, FOUserAgent userAgent, Configuration cfg) throws FOPException { if (cfg != null) { Java2DRendererConfig j2dConfig = new Java2DRendererConfigParser(null).build( @@ -116,17 +122,17 @@ public class BitmapRendererConfig implements RendererConfig { ColorUtil.parseColorString(userAgent, background)); } - setParam(config, BitmapRendererConfigOptions.ANTI_ALIASING, + setParam(config, BitmapRendererConfigOption.ANTI_ALIASING, getChild(cfg, ANTI_ALIASING).getValueAsBoolean( (Boolean) ANTI_ALIASING.getDefaultValue())); String optimization = getValue(cfg, RENDERING_QUALITY_ELEMENT); setParam(config, RENDERING_QUALITY, - !(BitmapRendererConfigOptions.getValue(optimization) == RENDERING_SPEED)); + !(BitmapRendererConfigOption.getValue(optimization) == RENDERING_SPEED)); String color = getValue(cfg, COLOR_MODE); setParam(config, COLOR_MODE, - getBufferedImageIntegerFromColor(BitmapRendererConfigOptions.getValue(color))); + getBufferedImageIntegerFromColor(BitmapRendererConfigOption.getValue(color))); } } @@ -138,7 +144,7 @@ public class BitmapRendererConfig implements RendererConfig { return config; } - private Integer getBufferedImageIntegerFromColor(BitmapRendererConfigOptions option) { + private Integer getBufferedImageIntegerFromColor(BitmapRendererConfigOption option) { if (option == null) { return null; } @@ -157,11 +163,11 @@ public class BitmapRendererConfig implements RendererConfig { } } - private Configuration getChild(Configuration cfg, BitmapRendererConfigOptions option) { + private Configuration getChild(Configuration cfg, BitmapRendererConfigOption option) { return cfg.getChild(option.getName()); } - private String getValue(Configuration cfg, BitmapRendererConfigOptions option) { + private String getValue(Configuration cfg, BitmapRendererConfigOption option) { return cfg.getChild(option.getName()).getValue(null); } diff --git a/src/java/org/apache/fop/render/bitmap/BitmapRendererConfigOptions.java b/src/java/org/apache/fop/render/bitmap/BitmapRendererConfigOption.java index 2fe0109c6..00b043a4e 100644 --- a/src/java/org/apache/fop/render/bitmap/BitmapRendererConfigOptions.java +++ b/src/java/org/apache/fop/render/bitmap/BitmapRendererConfigOption.java @@ -22,9 +22,13 @@ package org.apache.fop.render.bitmap; import java.awt.Color; import java.awt.image.BufferedImage; -import org.apache.fop.render.RendererConfigOptions; +import org.apache.fop.render.RendererConfigOption; -public enum BitmapRendererConfigOptions implements RendererConfigOptions { +/** + * An enumeration of the Bitmap renderer configuration opetions available to the user via the FOP + * conf. + */ +public enum BitmapRendererConfigOption implements RendererConfigOption { JAVA2D_TRANSPARENT_PAGE_BACKGROUND("transparent-page-background", false), BACKGROUND_COLOR("background-color", Color.WHITE), ANTI_ALIASING("anti-aliasing", true), @@ -41,15 +45,16 @@ public enum BitmapRendererConfigOptions implements RendererConfigOptions { private final String name; private final Object defaultValue; - private BitmapRendererConfigOptions(String name, Object defaultValue) { + private BitmapRendererConfigOption(String name, Object defaultValue) { this.name = name; this.defaultValue = defaultValue; } - private BitmapRendererConfigOptions(String name) { + private BitmapRendererConfigOption(String name) { this(name, null); } + /** {@inheritDoc} */ public String getName() { return name; } @@ -58,8 +63,8 @@ public enum BitmapRendererConfigOptions implements RendererConfigOptions { return defaultValue; } - public static BitmapRendererConfigOptions getValue(String str) { - for (BitmapRendererConfigOptions opt : BitmapRendererConfigOptions.values()) { + public static BitmapRendererConfigOption getValue(String str) { + for (BitmapRendererConfigOption opt : BitmapRendererConfigOption.values()) { if (opt.getName().equalsIgnoreCase(str)) { return opt; } diff --git a/src/java/org/apache/fop/render/bitmap/BitmapRendererConfigurator.java b/src/java/org/apache/fop/render/bitmap/BitmapRendererConfigurator.java index 4f76cbb7d..f0e32a9d7 100644 --- a/src/java/org/apache/fop/render/bitmap/BitmapRendererConfigurator.java +++ b/src/java/org/apache/fop/render/bitmap/BitmapRendererConfigurator.java @@ -24,6 +24,7 @@ import java.util.List; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.MimeConstants; import org.apache.fop.apps.io.InternalResourceResolver; import org.apache.fop.fonts.EmbedFontInfo; import org.apache.fop.fonts.FontCollection; @@ -55,8 +56,8 @@ public class BitmapRendererConfigurator extends Java2DRendererConfigurator { public void configure(IFDocumentHandler documentHandler) throws FOPException { AbstractBitmapDocumentHandler bitmapHandler = (AbstractBitmapDocumentHandler) documentHandler; BitmapRenderingSettings settings = bitmapHandler.getSettings(); - // TODO: magic strings! - configure(documentHandler, settings, new BitmapRendererConfigParser("image/bitmap")); + configure(documentHandler, settings, + new BitmapRendererConfigParser(MimeConstants.MIME_BITMAP)); } void configure(IFDocumentHandler documentHandler, BitmapRenderingSettings settings, diff --git a/src/java/org/apache/fop/render/bitmap/BitmapRenderingSettings.java b/src/java/org/apache/fop/render/bitmap/BitmapRenderingSettings.java index 8c9a68b02..0648b4af0 100644 --- a/src/java/org/apache/fop/render/bitmap/BitmapRenderingSettings.java +++ b/src/java/org/apache/fop/render/bitmap/BitmapRenderingSettings.java @@ -23,9 +23,9 @@ import org.apache.xmlgraphics.image.writer.ImageWriterParams; import org.apache.fop.render.java2d.Java2DRenderingSettings; -import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.ANTI_ALIASING; -import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.COLOR_MODE; -import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.RENDERING_QUALITY; +import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.ANTI_ALIASING; +import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE; +import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.RENDERING_QUALITY; /** * This class holds settings used when rendering to bitmaps. diff --git a/src/java/org/apache/fop/render/bitmap/PNGRendererConfig.java b/src/java/org/apache/fop/render/bitmap/PNGRendererConfig.java index 14984963c..699faea51 100644 --- a/src/java/org/apache/fop/render/bitmap/PNGRendererConfig.java +++ b/src/java/org/apache/fop/render/bitmap/PNGRendererConfig.java @@ -26,12 +26,18 @@ import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fonts.DefaultFontConfig; import org.apache.fop.fonts.DefaultFontConfig.DefaultFontConfigParser; +/** + * The PNG renderer configuration data object. + */ public final class PNGRendererConfig extends BitmapRendererConfig { private PNGRendererConfig(DefaultFontConfig fontConfig) { super(fontConfig); } + /** + * The PNG renderer configuration parser. + */ public static class PNGRendererConfigParser implements RendererConfigParser { public PNGRendererConfig build(FOUserAgent userAgent, Configuration cfg) @@ -40,6 +46,7 @@ public final class PNGRendererConfig extends BitmapRendererConfig { userAgent.validateStrictly())); } + /** {@inheritDoc} */ public String getMimeType() { return MimeConstants.MIME_PNG; } diff --git a/src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java b/src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java index 12bd8aa1e..fb38b61f6 100644 --- a/src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java +++ b/src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java @@ -24,6 +24,7 @@ import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.MimeConstants; import org.apache.fop.render.AbstractRendererMaker; import org.apache.fop.render.Renderer; +import org.apache.fop.render.bitmap.PNGRendererConfig.PNGRendererConfigParser; import org.apache.fop.render.java2d.Java2DRendererConfigurator; /** @@ -40,8 +41,7 @@ public class PNGRendererMaker extends AbstractRendererMaker { @Override public void configureRenderer(FOUserAgent userAgent, Renderer renderer) throws FOPException { - // TODO what constructir params? - new Java2DRendererConfigurator(userAgent, null).configure(renderer); + new Java2DRendererConfigurator(userAgent, new PNGRendererConfigParser()).configure(renderer); } @Override diff --git a/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java b/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java index 68401d9bc..152b669b6 100644 --- a/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java +++ b/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java @@ -29,17 +29,20 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fonts.DefaultFontConfig; import org.apache.fop.fonts.DefaultFontConfig.DefaultFontConfigParser; -import org.apache.fop.render.RendererConfigOptions; +import org.apache.fop.render.RendererConfigOption; +/** + * The renderer configuration object for the TIFF renderer. + */ public final class TIFFRendererConfig extends BitmapRendererConfig { - public enum TIFFRendererConfigOptions implements RendererConfigOptions { + public enum TIFFRendererConfigOption implements RendererConfigOption { COMPRESSION("compression", TIFFCompressionValues.PACKBITS); private final String name; private final Object defaultValue; - private TIFFRendererConfigOptions(String name, Object defaultValue) { + private TIFFRendererConfigOption(String name, Object defaultValue) { this.name = name; this.defaultValue = defaultValue; } @@ -53,17 +56,20 @@ public final class TIFFRendererConfig extends BitmapRendererConfig { } } - private final EnumMap<TIFFRendererConfigOptions, Object> params - = new EnumMap<TIFFRendererConfigOptions, Object>(TIFFRendererConfigOptions.class); + private final EnumMap<TIFFRendererConfigOption, Object> params + = new EnumMap<TIFFRendererConfigOption, Object>(TIFFRendererConfigOption.class); private TIFFRendererConfig(DefaultFontConfig fontConfig) { super(fontConfig); } public TIFFCompressionValues getCompressionType() { - return (TIFFCompressionValues) params.get(TIFFRendererConfigOptions.COMPRESSION); + return (TIFFCompressionValues) params.get(TIFFRendererConfigOption.COMPRESSION); } + /** + * The TIFF renderer configuration parser. + */ public static final class TIFFRendererConfigParser extends BitmapRendererConfigParser { public TIFFRendererConfigParser() { @@ -72,22 +78,23 @@ public final class TIFFRendererConfig extends BitmapRendererConfig { private TIFFRendererConfig config; - private void setParam(TIFFRendererConfigOptions option, Object value) { + private void setParam(TIFFRendererConfigOption option, Object value) { config.params.put(option, value != null ? value : option.getDefaultValue()); } - private String getValue(Configuration cfg, TIFFRendererConfigOptions option) { + private String getValue(Configuration cfg, TIFFRendererConfigOption option) { return cfg.getChild(option.getName()).getValue(null); } + /** {@inheritDoc} */ public TIFFRendererConfig build(FOUserAgent userAgent, Configuration cfg) throws FOPException { config = new TIFFRendererConfig(new DefaultFontConfigParser() .parse(cfg, userAgent.validateStrictly())); super.build(config, userAgent, cfg); if (cfg != null) { - setParam(TIFFRendererConfigOptions.COMPRESSION, + setParam(TIFFRendererConfigOption.COMPRESSION, TIFFCompressionValues.getValue(getValue(cfg, - TIFFRendererConfigOptions.COMPRESSION))); + TIFFRendererConfigOption.COMPRESSION))); } return config; } diff --git a/src/java/org/apache/fop/render/intermediate/IFRendererConfig.java b/src/java/org/apache/fop/render/intermediate/IFRendererConfig.java index 27d9d6eaa..753d9ff30 100644 --- a/src/java/org/apache/fop/render/intermediate/IFRendererConfig.java +++ b/src/java/org/apache/fop/render/intermediate/IFRendererConfig.java @@ -28,6 +28,9 @@ import org.apache.fop.fonts.DefaultFontConfig.DefaultFontConfigParser; import org.apache.fop.fonts.FontConfig; import org.apache.fop.render.RendererConfig; +/** + * The Intermediate Format renderer configuration data object. + */ public final class IFRendererConfig implements RendererConfig { private final DefaultFontConfig fontConfig; @@ -40,14 +43,19 @@ public final class IFRendererConfig implements RendererConfig { return fontConfig; } + /** + * The Intermediate Format configuration data parser. + */ public static final class IFRendererConfigParser implements RendererConfigParser { + /** {@inheritDoc} */ public RendererConfig build(FOUserAgent userAgent, Configuration cfg) throws FOPException { return new IFRendererConfig(new DefaultFontConfigParser().parse(cfg, userAgent.validateStrictly())); } + /** {@inheritDoc} */ public String getMimeType() { return "application/X-fop-intermediate-format"; } diff --git a/src/java/org/apache/fop/render/intermediate/IFSerializer.java b/src/java/org/apache/fop/render/intermediate/IFSerializer.java index 3d20440f5..41d1b01ef 100644 --- a/src/java/org/apache/fop/render/intermediate/IFSerializer.java +++ b/src/java/org/apache/fop/render/intermediate/IFSerializer.java @@ -40,8 +40,8 @@ import org.apache.xmlgraphics.util.XMLizable; import org.apache.fop.accessibility.StructureTreeEventHandler; import org.apache.fop.fo.extensions.InternalElementMapping; import org.apache.fop.fonts.FontInfo; +import org.apache.fop.render.DefaultRendererConfigurator; import org.apache.fop.render.RenderingContext; -import org.apache.fop.render.adobe.AdobeRendererConfigurator; import org.apache.fop.render.intermediate.IFRendererConfig.IFRendererConfigParser; import org.apache.fop.render.intermediate.IFStructureTreeBuilder.IFStructureTreeElement; import org.apache.fop.render.intermediate.extensions.AbstractAction; @@ -111,7 +111,7 @@ implements IFConstants, IFPainter, IFDocumentNavigationHandler { if (this.mimicHandler != null) { return getMimickedDocumentHandler().getConfigurator(); } else { - return new AdobeRendererConfigurator(getUserAgent(), new IFRendererConfigParser()); + return new DefaultRendererConfigurator(getUserAgent(), new IFRendererConfigParser()); } } diff --git a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java index be5405cbb..91d38675d 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java +++ b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java @@ -84,7 +84,7 @@ import org.apache.fop.render.pdf.CTMHelper; import org.apache.fop.util.CharUtilities; import org.apache.fop.util.ColorUtil; -import static org.apache.fop.render.java2d.Java2DRendererOptions.JAVA2D_TRANSPARENT_PAGE_BACKGROUND; +import static org.apache.fop.render.java2d.Java2DRendererOption.JAVA2D_TRANSPARENT_PAGE_BACKGROUND; /** * The <code>Java2DRenderer</code> class provides the abstract technical diff --git a/src/java/org/apache/fop/render/java2d/Java2DRendererConfig.java b/src/java/org/apache/fop/render/java2d/Java2DRendererConfig.java index 139d05916..1ed0aec96 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DRendererConfig.java +++ b/src/java/org/apache/fop/render/java2d/Java2DRendererConfig.java @@ -29,12 +29,15 @@ import org.apache.fop.fonts.DefaultFontConfig; import org.apache.fop.fonts.DefaultFontConfig.DefaultFontConfigParser; import org.apache.fop.render.RendererConfig; -import static org.apache.fop.render.java2d.Java2DRendererOptions.JAVA2D_TRANSPARENT_PAGE_BACKGROUND; +import static org.apache.fop.render.java2d.Java2DRendererOption.JAVA2D_TRANSPARENT_PAGE_BACKGROUND; +/** + * The Java2D renderer configuration data object. + */ public final class Java2DRendererConfig implements RendererConfig { - private final EnumMap<Java2DRendererOptions, Object> params - = new EnumMap<Java2DRendererOptions, Object>(Java2DRendererOptions.class); + private final EnumMap<Java2DRendererOption, Object> params + = new EnumMap<Java2DRendererOption, Object>(Java2DRendererOption.class); private final DefaultFontConfig fontConfig; @@ -50,6 +53,9 @@ public final class Java2DRendererConfig implements RendererConfig { return Boolean.class.cast(params.get(JAVA2D_TRANSPARENT_PAGE_BACKGROUND)); } + /** + * The Java2D renderer configuration data parser. + */ public static class Java2DRendererConfigParser implements RendererConfigParser { private final String mimeType; @@ -58,6 +64,7 @@ public final class Java2DRendererConfig implements RendererConfig { this.mimeType = mimeType; } + /** {@inheritDoc} */ public Java2DRendererConfig build(FOUserAgent userAgent, Configuration cfg) throws FOPException { Java2DRendererConfig config = new Java2DRendererConfig(new DefaultFontConfigParser() @@ -68,6 +75,7 @@ public final class Java2DRendererConfig implements RendererConfig { return config; } + /** {@inheritDoc} */ public String getMimeType() { return mimeType; } diff --git a/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java b/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java index 6b09ff740..9ff2ccdbd 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java +++ b/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java @@ -21,14 +21,14 @@ package org.apache.fop.render.java2d; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.render.DefaultRendererConfigurator; import org.apache.fop.render.Renderer; import org.apache.fop.render.RendererConfig.RendererConfigParser; -import org.apache.fop.render.adobe.AdobeRendererConfigurator; /** * Configurerer for Java 2D renderer */ -public class Java2DRendererConfigurator extends AdobeRendererConfigurator { +public class Java2DRendererConfigurator extends DefaultRendererConfigurator { /** * Default constructor diff --git a/src/java/org/apache/fop/render/java2d/Java2DRendererOptions.java b/src/java/org/apache/fop/render/java2d/Java2DRendererOption.java index c531aa771..b25f05889 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DRendererOptions.java +++ b/src/java/org/apache/fop/render/java2d/Java2DRendererOption.java @@ -19,15 +19,15 @@ package org.apache.fop.render.java2d; -import org.apache.fop.render.RendererConfigOptions; +import org.apache.fop.render.RendererConfigOption; -public enum Java2DRendererOptions implements RendererConfigOptions { +public enum Java2DRendererOption implements RendererConfigOption { /** Rendering Options key for the controlling the transparent page background option. */ JAVA2D_TRANSPARENT_PAGE_BACKGROUND("transparent-page-background"); private final String name; - private Java2DRendererOptions(String name) { + private Java2DRendererOption(String name) { this.name = name; } diff --git a/src/java/org/apache/fop/render/pcl/Java2DRendererConfigOption.java b/src/java/org/apache/fop/render/pcl/Java2DRendererConfigOption.java new file mode 100644 index 000000000..a3ce884ab --- /dev/null +++ b/src/java/org/apache/fop/render/pcl/Java2DRendererConfigOption.java @@ -0,0 +1,49 @@ +/* + * 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. + */ + +package org.apache.fop.render.pcl; + +import org.apache.fop.render.RendererConfigOption; + +/** + * An enumeration of the renderer configuration options available to the Java2D renderer via the + * FOP conf. + */ +public enum Java2DRendererConfigOption implements RendererConfigOption { + + RENDERING_MODE("rendering", PCLRenderingMode.class), + TEXT_RENDERING("text-rendering", Boolean.class), + DISABLE_PJL("disable-pjl", Boolean.class); + + private final String name; + + private final Class<?> type; + + private Java2DRendererConfigOption(String name, Class<?> type) { + this.name = name; + this.type = type; + } + + /** {@inheritDoc} */ + public String getName() { + return name; + } + + Class<?> getType() { + return type; + } +} diff --git a/src/java/org/apache/fop/render/pcl/PCLRendererConfig.java b/src/java/org/apache/fop/render/pcl/PCLRendererConfig.java index c46bd9e0b..d48c00cd3 100644 --- a/src/java/org/apache/fop/render/pcl/PCLRendererConfig.java +++ b/src/java/org/apache/fop/render/pcl/PCLRendererConfig.java @@ -31,33 +31,17 @@ import org.apache.fop.fonts.DefaultFontConfig; import org.apache.fop.fonts.DefaultFontConfig.DefaultFontConfigParser; import org.apache.fop.render.RendererConfig; -import static org.apache.fop.render.pcl.PCLRendererConfig.Options.DISABLE_PJL; -import static org.apache.fop.render.pcl.PCLRendererConfig.Options.RENDERING_MODE; -import static org.apache.fop.render.pcl.PCLRendererConfig.Options.TEXT_RENDERING; +import static org.apache.fop.render.pcl.Java2DRendererConfigOption.DISABLE_PJL; +import static org.apache.fop.render.pcl.Java2DRendererConfigOption.RENDERING_MODE; +import static org.apache.fop.render.pcl.Java2DRendererConfigOption.TEXT_RENDERING; +/** + * The PCL renderer configuration data object. + */ public final class PCLRendererConfig implements RendererConfig { - public enum Options { - - RENDERING_MODE("rendering", PCLRenderingMode.class), - TEXT_RENDERING("text-rendering", Boolean.class), - DISABLE_PJL("disable-pjl", Boolean.class); - - private final String name; - - private final Class<?> type; - - private Options(String name, Class<?> type) { - this.name = name; - this.type = type; - } - - public String getName() { - return name; - } - } - - private final Map<Options, Object> params = new EnumMap<Options, Object>(Options.class); + private final Map<Java2DRendererConfigOption, Object> params + = new EnumMap<Java2DRendererConfigOption, Object>(Java2DRendererConfigOption.class); private final DefaultFontConfig fontConfig; @@ -81,18 +65,22 @@ public final class PCLRendererConfig implements RendererConfig { return getParam(DISABLE_PJL, Boolean.class); } - private <T> T getParam(Options option, Class<T> type) { - assert option.type.equals(type); + private <T> T getParam(Java2DRendererConfigOption option, Class<T> type) { + assert option.getType().equals(type); return type.cast(params.get(option)); } - private <T> void setParam(Options option, T value) { - assert option.type.isInstance(value); + private <T> void setParam(Java2DRendererConfigOption option, T value) { + assert option.getType().isInstance(value); params.put(option, value); } + /** + * The PCL renderer configuration data parser. + */ public static final class PCLRendererConfigParser implements RendererConfigParser { + /** {@inheritDoc} */ public PCLRendererConfig build(FOUserAgent userAgent, Configuration cfg) throws FOPException { PCLRendererConfig config = new PCLRendererConfig(new DefaultFontConfigParser() .parse(cfg, userAgent.validateStrictly())); @@ -126,6 +114,7 @@ public final class PCLRendererConfig implements RendererConfig { } } + /** {@inheritDoc} */ public String getMimeType() { return MimeConstants.MIME_PCL; } diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererConfig.java b/src/java/org/apache/fop/render/pdf/PDFRendererConfig.java index 1fb61a380..0337ef5a7 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRendererConfig.java +++ b/src/java/org/apache/fop/render/pdf/PDFRendererConfig.java @@ -43,32 +43,34 @@ import org.apache.fop.pdf.Version; import org.apache.fop.render.RendererConfig; import org.apache.fop.util.LogUtil; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.DISABLE_SRGB_COLORSPACE; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.ENCRYPTION_LENGTH; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.ENCRYPTION_PARAMS; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.FILTER_LIST; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.NO_ACCESSCONTENT; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.NO_ANNOTATIONS; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.NO_ASSEMBLEDOC; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.NO_COPY_CONTENT; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.NO_EDIT_CONTENT; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.NO_FILLINFORMS; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.NO_PRINT; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.NO_PRINTHQ; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.OUTPUT_PROFILE; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.OWNER_PASSWORD; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.PDF_A_MODE; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.PDF_X_MODE; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.USER_PASSWORD; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.VERSION; - - +import static org.apache.fop.render.pdf.PDFRendererConfigOption.DISABLE_SRGB_COLORSPACE; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.ENCRYPTION_LENGTH; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.ENCRYPTION_PARAMS; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.FILTER_LIST; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_ACCESSCONTENT; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_ANNOTATIONS; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_ASSEMBLEDOC; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_COPY_CONTENT; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_EDIT_CONTENT; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_FILLINFORMS; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_PRINT; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_PRINTHQ; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.OUTPUT_PROFILE; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.OWNER_PASSWORD; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.PDF_A_MODE; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.PDF_X_MODE; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.USER_PASSWORD; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.VERSION; + +/** + * The PDF renderer configuration data object. + */ public final class PDFRendererConfig implements RendererConfig { private static final Log LOG = LogFactory.getLog(PDFRendererConfig.class); - private final Map<PDFRendererConfigOptions, Object> configOptions - = new EnumMap<PDFRendererConfigOptions, Object>(PDFRendererConfigOptions.class); + private final Map<PDFRendererConfigOption, Object> configOptions + = new EnumMap<PDFRendererConfigOption, Object>(PDFRendererConfigOption.class); private final DefaultFontConfig fontConfig; @@ -109,6 +111,9 @@ public final class PDFRendererConfig implements RendererConfig { return pdfVersion == null ? null : Version.getValueOf(pdfVersion); } + /** + * The PDF renderer configuration data parser. + */ public static final class PDFRendererConfigParser implements RendererConfigParser { public PDFRendererConfig build(FOUserAgent userAgent, Configuration cfg) throws FOPException { @@ -132,7 +137,7 @@ public final class PDFRendererConfig implements RendererConfig { } } - private void put(PDFRendererConfigOptions option, Object value) { + private void put(PDFRendererConfigOption option, Object value) { if (value != null && !value.equals(option.getDefaultValue())) { pdfConfig.configOptions.put(option, value); } @@ -209,12 +214,12 @@ public final class PDFRendererConfig implements RendererConfig { put(FILTER_LIST, filterMap); } - private String parseConfig(Configuration cfg, PDFRendererConfigOptions option) { + private String parseConfig(Configuration cfg, PDFRendererConfigOption option) { Configuration child = cfg.getChild(option.getName()); return child.getValue(null); } - private boolean doesValueExist(Configuration cfg, PDFRendererConfigOptions option) { + private boolean doesValueExist(Configuration cfg, PDFRendererConfigOption option) { return cfg.getChild(option.getName(), false) != null; } diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererConfigOptions.java b/src/java/org/apache/fop/render/pdf/PDFRendererConfigOption.java index 81a410c3d..faa3302c3 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRendererConfigOptions.java +++ b/src/java/org/apache/fop/render/pdf/PDFRendererConfigOption.java @@ -21,9 +21,9 @@ package org.apache.fop.render.pdf; import org.apache.fop.pdf.PDFAMode; import org.apache.fop.pdf.PDFXMode; -import org.apache.fop.render.RendererConfigOptions; +import org.apache.fop.render.RendererConfigOption; -public enum PDFRendererConfigOptions implements RendererConfigOptions { +public enum PDFRendererConfigOption implements RendererConfigOption { FILTER_LIST("filterList"), /** Rendering Options key for the PDF/A mode, default: {@link PDFAMode#DISABLED} */ PDF_A_MODE("pdf-a-mode", PDFAMode.DISABLED), @@ -93,12 +93,12 @@ public enum PDFRendererConfigOptions implements RendererConfigOptions { private final String name; private final Object defaultValue; - private PDFRendererConfigOptions(String name, Object defaultValue) { + private PDFRendererConfigOption(String name, Object defaultValue) { this.name = name; this.defaultValue = defaultValue; } - private PDFRendererConfigOptions(String name) { + private PDFRendererConfigOption(String name) { this(name, null); } diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java b/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java index a4892dd70..9cd89fa01 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java +++ b/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java @@ -22,14 +22,14 @@ package org.apache.fop.render.pdf; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.pdf.PDFEncryptionParams; +import org.apache.fop.render.DefaultRendererConfigurator; import org.apache.fop.render.RendererConfig.RendererConfigParser; -import org.apache.fop.render.adobe.AdobeRendererConfigurator; import org.apache.fop.render.intermediate.IFDocumentHandler; /** * PDF renderer configurator. */ -public class PDFRendererConfigurator extends AdobeRendererConfigurator { +public class PDFRendererConfigurator extends DefaultRendererConfigurator { /** * Default constructor diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java b/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java index c7252baf1..daffe2d3f 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java @@ -68,21 +68,21 @@ import org.apache.fop.pdf.Version; import org.apache.fop.pdf.VersionController; import org.apache.fop.render.pdf.extensions.PDFEmbeddedFileExtensionAttachment; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.DISABLE_SRGB_COLORSPACE; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.ENCRYPTION_PARAMS; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.NO_ACCESSCONTENT; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.NO_ANNOTATIONS; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.NO_ASSEMBLEDOC; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.NO_COPY_CONTENT; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.NO_EDIT_CONTENT; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.NO_FILLINFORMS; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.NO_PRINT; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.NO_PRINTHQ; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.OUTPUT_PROFILE; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.OWNER_PASSWORD; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.PDF_A_MODE; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.PDF_X_MODE; -import static org.apache.fop.render.pdf.PDFRendererConfigOptions.USER_PASSWORD; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.DISABLE_SRGB_COLORSPACE; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.ENCRYPTION_PARAMS; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_ACCESSCONTENT; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_ANNOTATIONS; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_ASSEMBLEDOC; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_COPY_CONTENT; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_EDIT_CONTENT; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_FILLINFORMS; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_PRINT; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.NO_PRINTHQ; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.OUTPUT_PROFILE; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.OWNER_PASSWORD; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.PDF_A_MODE; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.PDF_X_MODE; +import static org.apache.fop.render.pdf.PDFRendererConfigOption.USER_PASSWORD; /** * Utility class which enables all sorts of features that are not directly connected to the @@ -99,10 +99,10 @@ class PDFRenderingUtil { private PDFDocument pdfDoc; /** the PDF/A mode (Default: disabled) */ - private PDFAMode pdfAMode = (PDFAMode) PDFRendererConfigOptions.PDF_A_MODE.getDefaultValue(); + private PDFAMode pdfAMode = (PDFAMode) PDFRendererConfigOption.PDF_A_MODE.getDefaultValue(); /** the PDF/X mode (Default: disabled) */ - private PDFXMode pdfXMode = (PDFXMode) PDFRendererConfigOptions.PDF_X_MODE.getDefaultValue(); + private PDFXMode pdfXMode = (PDFXMode) PDFRendererConfigOption.PDF_X_MODE.getDefaultValue(); /** the (optional) encryption parameters */ private PDFEncryptionParams encryptionParams; diff --git a/src/java/org/apache/fop/render/ps/PSRendererConfig.java b/src/java/org/apache/fop/render/ps/PSRendererConfig.java index f023b4647..0d043c10d 100644 --- a/src/java/org/apache/fop/render/ps/PSRendererConfig.java +++ b/src/java/org/apache/fop/render/ps/PSRendererConfig.java @@ -35,17 +35,20 @@ import org.apache.fop.fonts.DefaultFontConfig.DefaultFontConfigParser; import org.apache.fop.render.RendererConfig; import org.apache.fop.util.LogUtil; -import static org.apache.fop.render.ps.PSRendererConfigurationOptions.AUTO_ROTATE_LANDSCAPE; -import static org.apache.fop.render.ps.PSRendererConfigurationOptions.DSC_COMPLIANT; -import static org.apache.fop.render.ps.PSRendererConfigurationOptions.LANGUAGE_LEVEL; -import static org.apache.fop.render.ps.PSRendererConfigurationOptions.OPTIMIZE_RESOURCES; -import static org.apache.fop.render.ps.PSRendererConfigurationOptions.RENDERING_MODE; -import static org.apache.fop.render.ps.PSRendererConfigurationOptions.SAFE_SET_PAGE_DEVICE; - +import static org.apache.fop.render.ps.PSRendererConfigurationOption.AUTO_ROTATE_LANDSCAPE; +import static org.apache.fop.render.ps.PSRendererConfigurationOption.DSC_COMPLIANT; +import static org.apache.fop.render.ps.PSRendererConfigurationOption.LANGUAGE_LEVEL; +import static org.apache.fop.render.ps.PSRendererConfigurationOption.OPTIMIZE_RESOURCES; +import static org.apache.fop.render.ps.PSRendererConfigurationOption.RENDERING_MODE; +import static org.apache.fop.render.ps.PSRendererConfigurationOption.SAFE_SET_PAGE_DEVICE; + +/** + * The PostScript renderer configuration data object. + */ public final class PSRendererConfig implements RendererConfig { - private final EnumMap<PSRendererConfigurationOptions, Object> params - = new EnumMap<PSRendererConfigurationOptions, Object>(PSRendererConfigurationOptions.class); + private final EnumMap<PSRendererConfigurationOption, Object> params + = new EnumMap<PSRendererConfigurationOption, Object>(PSRendererConfigurationOption.class); private final DefaultFontConfig fontConfig; @@ -81,6 +84,9 @@ public final class PSRendererConfig implements RendererConfig { return (PSRenderingMode) params.get(RENDERING_MODE); } + /** + * The PostScript renderer configuration data parser. + */ public static final class PSRendererConfigParser implements RendererConfigParser { private static final Log LOG = LogFactory.getLog(PSRendererConfigParser.class); @@ -126,12 +132,12 @@ public final class PSRendererConfig implements RendererConfig { } } - private void setConfigParameter(PSRendererConfigurationOptions option, + private void setConfigParameter(PSRendererConfigurationOption option, Object value) { config.params.put(option, value != null ? value : option.getDefaultValue()); } - private void setBoolConfigParam(Configuration cfg, PSRendererConfigurationOptions option) { + private void setBoolConfigParam(Configuration cfg, PSRendererConfigurationOption option) { setConfigParameter(option, cfg.getChild( option.getName()).getValueAsBoolean((Boolean) option.getDefaultValue())); } diff --git a/src/java/org/apache/fop/render/ps/PSRendererConfigurationOptions.java b/src/java/org/apache/fop/render/ps/PSRendererConfigurationOption.java index ffecbf6b4..7358517af 100644 --- a/src/java/org/apache/fop/render/ps/PSRendererConfigurationOptions.java +++ b/src/java/org/apache/fop/render/ps/PSRendererConfigurationOption.java @@ -21,12 +21,12 @@ package org.apache.fop.render.ps; import org.apache.xmlgraphics.ps.PSGenerator; -import org.apache.fop.render.RendererConfigOptions; +import org.apache.fop.render.RendererConfigOption; /** * An enumeration of the PostScript renderer configuration options along with their default values. */ -public enum PSRendererConfigurationOptions implements RendererConfigOptions { +public enum PSRendererConfigurationOption implements RendererConfigOption { /** Indicates whether landscape pages should be rotated, default: false */ AUTO_ROTATE_LANDSCAPE("auto-rotate-landscape", false), /** Sets the PostScript language leven, default: {@see PSGenerator#DEFAULT_LANGUAGE_LEVEL}*/ @@ -42,7 +42,7 @@ public enum PSRendererConfigurationOptions implements RendererConfigOptions { private final String name; private final Object defaultValue; - private PSRendererConfigurationOptions(String name, Object defaultValue) { + private PSRendererConfigurationOption(String name, Object defaultValue) { this.name = name; this.defaultValue = defaultValue; } diff --git a/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java b/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java index cec3a6547..b453de413 100644 --- a/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java +++ b/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java @@ -21,8 +21,8 @@ package org.apache.fop.render.ps; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.render.DefaultRendererConfigurator; import org.apache.fop.render.RendererConfig.RendererConfigParser; -import org.apache.fop.render.adobe.AdobeRendererConfigurator; import org.apache.fop.render.intermediate.IFDocumentHandler; import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator; @@ -30,7 +30,7 @@ import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator; /** * Postscript renderer config */ -public class PSRendererConfigurator extends AdobeRendererConfigurator +public class PSRendererConfigurator extends DefaultRendererConfigurator implements IFDocumentHandlerConfigurator { /** diff --git a/src/java/org/apache/fop/render/ps/PSRenderingUtil.java b/src/java/org/apache/fop/render/ps/PSRenderingUtil.java index 9d40c378c..1322d5e4b 100644 --- a/src/java/org/apache/fop/render/ps/PSRenderingUtil.java +++ b/src/java/org/apache/fop/render/ps/PSRenderingUtil.java @@ -33,9 +33,9 @@ import org.apache.fop.render.ps.extensions.PSCommentBefore; import org.apache.fop.render.ps.extensions.PSExtensionAttachment; import org.apache.fop.render.ps.extensions.PSSetupCode; -import static org.apache.fop.render.ps.PSRendererConfigurationOptions.AUTO_ROTATE_LANDSCAPE; -import static org.apache.fop.render.ps.PSRendererConfigurationOptions.LANGUAGE_LEVEL; -import static org.apache.fop.render.ps.PSRendererConfigurationOptions.OPTIMIZE_RESOURCES; +import static org.apache.fop.render.ps.PSRendererConfigurationOption.AUTO_ROTATE_LANDSCAPE; +import static org.apache.fop.render.ps.PSRendererConfigurationOption.LANGUAGE_LEVEL; +import static org.apache.fop.render.ps.PSRendererConfigurationOption.OPTIMIZE_RESOURCES; /** * Utility class which enables all sorts of features that are not directly connected to the diff --git a/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java b/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java index 8532873dd..a600047ae 100644 --- a/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java +++ b/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java @@ -21,14 +21,14 @@ package org.apache.fop.render.txt; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.render.DefaultRendererConfigurator; import org.apache.fop.render.Renderer; import org.apache.fop.render.RendererConfig.RendererConfigParser; -import org.apache.fop.render.adobe.AdobeRendererConfigurator; /** * TXT Renderer configurator */ -public class TXTRendererConfigurator extends AdobeRendererConfigurator { +public class TXTRendererConfigurator extends DefaultRendererConfigurator { /** * Default constructor diff --git a/src/java/org/apache/fop/render/txt/TxtRendererConfig.java b/src/java/org/apache/fop/render/txt/TxtRendererConfig.java index c0c819206..7b0045664 100644 --- a/src/java/org/apache/fop/render/txt/TxtRendererConfig.java +++ b/src/java/org/apache/fop/render/txt/TxtRendererConfig.java @@ -29,17 +29,20 @@ import org.apache.fop.apps.MimeConstants; import org.apache.fop.fonts.DefaultFontConfig; import org.apache.fop.fonts.DefaultFontConfig.DefaultFontConfigParser; import org.apache.fop.render.RendererConfig; -import org.apache.fop.render.RendererConfigOptions; +import org.apache.fop.render.RendererConfigOption; -public class TxtRendererConfig implements RendererConfig { +/** + * The Text renderer configuration data object. + */ +public final class TxtRendererConfig implements RendererConfig { - public enum TxtRendererConfigOptions implements RendererConfigOptions { + public enum TxtRendererConfigOption implements RendererConfigOption { ENCODING("encoding", "UTF-8"); private final String name; private final Object defaultValue; - private TxtRendererConfigOptions(String name, Object defaultValue) { + private TxtRendererConfigOption(String name, Object defaultValue) { this.name = name; this.defaultValue = defaultValue; } @@ -53,8 +56,8 @@ public class TxtRendererConfig implements RendererConfig { } } - private final EnumMap<TxtRendererConfigOptions, Object> params - = new EnumMap<TxtRendererConfigOptions, Object>(TxtRendererConfigOptions.class); + private final EnumMap<TxtRendererConfigOption, Object> params + = new EnumMap<TxtRendererConfigOption, Object>(TxtRendererConfigOption.class); private final DefaultFontConfig fontConfig; @@ -67,22 +70,27 @@ public class TxtRendererConfig implements RendererConfig { } public String getEncoding() { - return (String) params.get(TxtRendererConfigOptions.ENCODING); + return (String) params.get(TxtRendererConfigOption.ENCODING); } + /** + * The Text renderer configuration data parser. + */ public static final class TxtRendererConfigParser implements RendererConfigParser { + /** {@inheritDoc} */ public TxtRendererConfig build(FOUserAgent userAgent, Configuration cfg) throws FOPException { TxtRendererConfig config = new TxtRendererConfig(new DefaultFontConfigParser().parse(cfg, userAgent.validateStrictly())); if (cfg != null) { - TxtRendererConfigOptions option = TxtRendererConfigOptions.ENCODING; + TxtRendererConfigOption option = TxtRendererConfigOption.ENCODING; String value = cfg.getChild(option.getName(), true).getValue(null); config.params.put(option, value != null ? value : option.getDefaultValue()); } return config; } + /** {@inheritDoc} */ public String getMimeType() { return MimeConstants.MIME_PLAIN_TEXT; } diff --git a/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java b/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java index d02694cda..2199df4f9 100644 --- a/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java +++ b/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java @@ -25,8 +25,8 @@ 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.io.ResourceResolverFactory; import org.apache.fop.apps.io.InternalResourceResolver; +import org.apache.fop.apps.io.ResourceResolverFactory; import org.apache.fop.fonts.DefaultFontConfig; import org.apache.fop.fonts.DefaultFontConfigurator; import org.apache.fop.fonts.EmbedFontInfo; |