git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_URI_Unification@1352101 13f79535-47bb-0310-9956-ffa450edef68pull/26/head
@@ -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; | |||
/** |
@@ -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()); | |||
} | |||
@@ -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"; | |||
} |
@@ -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); | |||
} | |||
} | |||
} |
@@ -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 |
@@ -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(); |
@@ -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 { |
@@ -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)) { |
@@ -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 |
@@ -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; |
@@ -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>(); |
@@ -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) { |
@@ -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 |
@@ -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); | |||
} | |||
@@ -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(); | |||
} | |||
} |
@@ -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(); | |||
} |
@@ -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); | |||
} | |||
} | |||
@@ -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; | |||
} | |||
} |
@@ -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); | |||
} | |||
@@ -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; | |||
} |
@@ -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, |
@@ -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. |
@@ -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; | |||
} |
@@ -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 |
@@ -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; | |||
} |
@@ -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"; | |||
} |
@@ -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()); | |||
} | |||
} | |||
@@ -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 |
@@ -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; | |||
} |
@@ -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 |
@@ -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; | |||
} | |||
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} |
@@ -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; | |||
} | |||
@@ -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); | |||
} | |||
@@ -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 |
@@ -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; |
@@ -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())); | |||
} |
@@ -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; | |||
} |
@@ -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 { | |||
/** |
@@ -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 |
@@ -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 |
@@ -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; | |||
} |
@@ -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; |
@@ -19,33 +19,31 @@ | |||
package org.apache.fop.apps; | |||
import java.net.URI; | |||
import java.util.Map; | |||
import org.w3c.dom.Element; | |||
import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; | |||
import org.apache.fop.render.afp.AFPRendererConfig; | |||
import org.apache.fop.render.afp.AFPRendererConfig.Options; | |||
import org.apache.fop.render.afp.AFPRendererConfigOption; | |||
import org.apache.fop.render.afp.AFPShadingMode; | |||
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.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.RENDERER_RESOLUTION; | |||
import static org.apache.fop.render.afp.AFPRendererConfig.Options.LINE_WIDTH_CORRECTION; | |||
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.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; | |||
/** | |||
* A config builder specific to a particular renderer for specific MIME type. | |||
@@ -58,7 +56,7 @@ public final class AFPRendererConfBuilder extends RendererConfBuilder { | |||
super(MimeConstants.MIME_AFP); | |||
} | |||
private AFPRendererConfBuilder createTextElement(Options option, String value) { | |||
private AFPRendererConfBuilder createTextElement(AFPRendererConfigOption option, String value) { | |||
createTextElement(option.getName(), value); | |||
return this; | |||
} | |||
@@ -155,7 +153,7 @@ public final class AFPRendererConfBuilder extends RendererConfBuilder { | |||
return AFPRendererConfBuilder.this.endImages(); | |||
} | |||
private ImagesBuilder setAttribute(Options options, Object value) { | |||
private ImagesBuilder setAttribute(AFPRendererConfigOption options, Object value) { | |||
return setAttribute(options.getName(), value); | |||
} | |||
@@ -21,11 +21,11 @@ package org.apache.fop.apps; | |||
import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; | |||
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_ELEMENT; | |||
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_ELEMENT; | |||
public class BitmapRendererConfBuilder extends RendererConfBuilder { | |||
@@ -0,0 +1,39 @@ | |||
/* | |||
* 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.apps; | |||
import java.net.URI; | |||
import org.junit.Test; | |||
import org.apache.fop.apps.io.ResourceResolver; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.mockito.Mockito.mock; | |||
public class EnvironmentalProfileFactoryTestCase { | |||
private final URI testURI = URI.create("this.is.purely.for.test.purposes"); | |||
@Test | |||
public void testCreateDefault() { | |||
ResourceResolver mockedResolver = mock(ResourceResolver.class); | |||
EnvironmentProfile sut = EnvironmentalProfileFactory.createDefault(testURI, mockedResolver); | |||
assertEquals(mockedResolver, sut.getResourceResolver()); | |||
} | |||
} |
@@ -42,7 +42,7 @@ import javax.xml.transform.stream.StreamResult; | |||
import org.w3c.dom.Document; | |||
import org.w3c.dom.Element; | |||
import org.apache.fop.render.RendererConfigOptions; | |||
import org.apache.fop.render.RendererConfigOption; | |||
/** | |||
* A builder class for creating fop.xconf XML DOMs for test purposes. You can set all the necessary | |||
@@ -336,7 +336,7 @@ public class FopConfBuilder implements FontConfigurator<FopConfBuilder> { | |||
return createTextElement(name, value, rendererEl); | |||
} | |||
protected final Element createTextElement(RendererConfigOptions option, String value) { | |||
protected final Element createTextElement(RendererConfigOption option, String value) { | |||
return createTextElement(option.getName(), value, rendererEl); | |||
} | |||
@@ -21,7 +21,7 @@ package org.apache.fop.apps; | |||
import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; | |||
import static org.apache.fop.render.java2d.Java2DRendererOptions.JAVA2D_TRANSPARENT_PAGE_BACKGROUND; | |||
import static org.apache.fop.render.java2d.Java2DRendererOption.JAVA2D_TRANSPARENT_PAGE_BACKGROUND; | |||
public class Java2DRendererConfBuilder extends RendererConfBuilder { | |||
@@ -22,19 +22,19 @@ package org.apache.fop.apps; | |||
import org.w3c.dom.Element; | |||
import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; | |||
import org.apache.fop.render.RendererConfigOptions; | |||
import org.apache.fop.render.pdf.PDFRendererConfigOptions; | |||
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.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 org.apache.fop.render.RendererConfigOption; | |||
import org.apache.fop.render.pdf.PDFRendererConfigOption; | |||
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.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; | |||
/** | |||
* A config builder specific to a particular renderer for specific MIME type. | |||
@@ -115,7 +115,7 @@ public final class PDFRendererConfBuilder extends RendererConfBuilder { | |||
return this; | |||
} | |||
public EncryptionParamsBuilder setAllowParam(PDFRendererConfigOptions option) { | |||
public EncryptionParamsBuilder setAllowParam(PDFRendererConfigOption option) { | |||
el.appendChild(createElement(option.getName())); | |||
return this; | |||
} | |||
@@ -124,7 +124,7 @@ public final class PDFRendererConfBuilder extends RendererConfBuilder { | |||
return PDFRendererConfBuilder.this.endEncryptionParams(); | |||
} | |||
private void createTextElement(RendererConfigOptions name, String value) { | |||
private void createTextElement(RendererConfigOption name, String value) { | |||
PDFRendererConfBuilder.this.createTextElement(name.getName(), value, el); | |||
} | |||
@@ -21,11 +21,11 @@ package org.apache.fop.apps; | |||
import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; | |||
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.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.SAFE_SET_PAGE_DEVICE; | |||
/** | |||
* A fop conf builder specific to a particular renderer for Postscript. |
@@ -19,7 +19,7 @@ | |||
package org.apache.fop.apps; | |||
import static org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererConfigOptions.COMPRESSION; | |||
import static org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererConfigOption.COMPRESSION; | |||
public class TIFFRendererConfBuilder extends BitmapRendererConfBuilder { | |||
@@ -21,7 +21,7 @@ package org.apache.fop.apps; | |||
import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; | |||
import static org.apache.fop.render.txt.TxtRendererConfig.TxtRendererConfigOptions.ENCODING; | |||
import static org.apache.fop.render.txt.TxtRendererConfig.TxtRendererConfigOption.ENCODING; | |||
public class TxtRendererConfBuilder extends RendererConfBuilder { | |||
@@ -28,14 +28,14 @@ import org.apache.fop.apps.AbstractRendererConfigParserTester; | |||
import org.apache.fop.apps.BitmapRendererConfBuilder; | |||
import org.apache.fop.render.bitmap.BitmapRendererConfig.BitmapRendererConfigParser; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.COLOR_MODE_BILEVEL; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.COLOR_MODE_BINARY; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.COLOR_MODE_GRAY; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.COLOR_MODE_RGB; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.COLOR_MODE_RGBA; | |||
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_SPEED; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE_BILEVEL; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE_BINARY; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE_GRAY; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE_RGB; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE_RGBA; | |||
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_SPEED; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNull; |
@@ -28,13 +28,13 @@ import org.apache.fop.apps.BitmapRendererConfBuilder; | |||
import org.apache.fop.render.intermediate.IFDocumentHandler; | |||
import org.apache.fop.util.ColorUtil; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.COLOR_MODE_BILEVEL; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.COLOR_MODE_BINARY; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.COLOR_MODE_GRAY; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.COLOR_MODE_RGB; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.COLOR_MODE_RGBA; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.RENDERING_QUALITY; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOptions.RENDERING_SPEED; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE_BILEVEL; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE_BINARY; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE_GRAY; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE_RGB; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.COLOR_MODE_RGBA; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.RENDERING_QUALITY; | |||
import static org.apache.fop.render.bitmap.BitmapRendererConfigOption.RENDERING_SPEED; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; |
@@ -19,11 +19,12 @@ | |||
package org.apache.fop.render.bitmap; | |||
import org.apache.fop.apps.MimeConstants; | |||
import org.apache.fop.render.bitmap.BitmapRendererConfig.BitmapRendererConfigParser; | |||
public class BitmapRendererConfigParserTestCase extends AbstractBitmapRendererConfigParserTester { | |||
public BitmapRendererConfigParserTestCase() { | |||
super(new BitmapRendererConfigParser("bitmap")); | |||
super(new BitmapRendererConfigParser(MimeConstants.MIME_BITMAP)); | |||
} | |||
} |
@@ -22,11 +22,10 @@ package org.apache.fop.render.pcl; | |||
import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; | |||
import org.apache.fop.apps.MimeConstants; | |||
import org.apache.fop.render.pcl.PCLRendererConfig.Options; | |||
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; | |||
/** | |||
* A config builder specific to a particular renderer for specific MIME type. | |||
*/ | |||
@@ -52,7 +51,7 @@ public final class PCLRendererConfBuilder extends RendererConfBuilder { | |||
return createTextElement(DISABLE_PJL, String.valueOf(value)); | |||
} | |||
private PCLRendererConfBuilder createTextElement(Options option, String value) { | |||
private PCLRendererConfBuilder createTextElement(Java2DRendererConfigOption option, String value) { | |||
createTextElement(option.getName(), value); | |||
return this; | |||
} |
@@ -51,7 +51,7 @@ public class PDFRendererConfigParserTestCase | |||
assertEquals(testPassword, conf.getEncryptionParameters().getUserPassword()); | |||
} | |||
private void testRestrictEncryptionParameter(PDFRendererConfigOptions option) | |||
private void testRestrictEncryptionParameter(PDFRendererConfigOption option) | |||
throws Exception { | |||
parseConfig(createRenderer().startEncryptionParams() | |||
.setAllowParam(option) | |||
@@ -62,7 +62,7 @@ public class PDFRendererConfigParserTestCase | |||
assertTrue(testEncryptionParameter(option)); | |||
} | |||
public boolean testEncryptionParameter(PDFRendererConfigOptions option) throws Exception { | |||
public boolean testEncryptionParameter(PDFRendererConfigOption option) throws Exception { | |||
switch (option) { | |||
case NO_PRINT: | |||
return conf.getEncryptionParameters().isAllowPrint(); | |||
@@ -88,14 +88,14 @@ public class PDFRendererConfigParserTestCase | |||
@Test | |||
public void testAllEncryptionRestrictions() throws Exception { | |||
testRestrictEncryptionParameter(PDFRendererConfigOptions.NO_PRINT); | |||
testRestrictEncryptionParameter(PDFRendererConfigOptions.NO_ACCESSCONTENT); | |||
testRestrictEncryptionParameter(PDFRendererConfigOptions.NO_ANNOTATIONS); | |||
testRestrictEncryptionParameter(PDFRendererConfigOptions.NO_ASSEMBLEDOC); | |||
testRestrictEncryptionParameter(PDFRendererConfigOptions.NO_COPY_CONTENT); | |||
testRestrictEncryptionParameter(PDFRendererConfigOptions.NO_EDIT_CONTENT); | |||
testRestrictEncryptionParameter(PDFRendererConfigOptions.NO_FILLINFORMS); | |||
testRestrictEncryptionParameter(PDFRendererConfigOptions.NO_PRINTHQ); | |||
testRestrictEncryptionParameter(PDFRendererConfigOption.NO_PRINT); | |||
testRestrictEncryptionParameter(PDFRendererConfigOption.NO_ACCESSCONTENT); | |||
testRestrictEncryptionParameter(PDFRendererConfigOption.NO_ANNOTATIONS); | |||
testRestrictEncryptionParameter(PDFRendererConfigOption.NO_ASSEMBLEDOC); | |||
testRestrictEncryptionParameter(PDFRendererConfigOption.NO_COPY_CONTENT); | |||
testRestrictEncryptionParameter(PDFRendererConfigOption.NO_EDIT_CONTENT); | |||
testRestrictEncryptionParameter(PDFRendererConfigOption.NO_FILLINFORMS); | |||
testRestrictEncryptionParameter(PDFRendererConfigOption.NO_PRINTHQ); | |||
} | |||
@Test |
@@ -24,7 +24,7 @@ import org.junit.Test; | |||
import org.apache.fop.apps.AbstractRendererConfigParserTester; | |||
import org.apache.fop.apps.TxtRendererConfBuilder; | |||
import org.apache.fop.render.RendererConfig.RendererConfigParser; | |||
import org.apache.fop.render.txt.TxtRendererConfig.TxtRendererConfigOptions; | |||
import org.apache.fop.render.txt.TxtRendererConfig.TxtRendererConfigOption; | |||
import org.apache.fop.render.txt.TxtRendererConfig.TxtRendererConfigParser; | |||
import static org.junit.Assert.assertEquals; | |||
@@ -47,7 +47,7 @@ public class TxtRendererConfigParserTestCase | |||
// Check the default behaviour is expected | |||
parseConfig(createRenderer()); | |||
assertEquals(TxtRendererConfigOptions.ENCODING.getDefaultValue(), conf.getEncoding()); | |||
assertEquals(TxtRendererConfigOption.ENCODING.getDefaultValue(), conf.getEncoding()); | |||
} | |||
} |