diff options
Diffstat (limited to 'src')
40 files changed, 725 insertions, 725 deletions
diff --git a/src/java/org/apache/fop/apps/FOURIResolver.java b/src/java/org/apache/fop/apps/FOURIResolver.java index bc0ca25b5..76b0bedd5 100644 --- a/src/java/org/apache/fop/apps/FOURIResolver.java +++ b/src/java/org/apache/fop/apps/FOURIResolver.java @@ -52,7 +52,7 @@ public class FOURIResolver implements javax.xml.transform.URIResolver { /** URIResolver for RFC 2397 data URLs */ private URIResolver dataURIResolver = new DataURIResolver(); - + /** A user settable URI Resolver */ private URIResolver uriResolver = null; @@ -77,7 +77,7 @@ public class FOURIResolver implements javax.xml.transform.URIResolver { } File dir = new File(base); try { - base = (dir.isDirectory() ? dir.toURL() : new URL(base)).toExternalForm(); + base = (dir.isDirectory() ? dir.toURL() : new URL(base)).toExternalForm(); } catch (MalformedURLException mfue) { if (throwExceptions) { throw mfue; @@ -147,11 +147,11 @@ public class FOURIResolver implements javax.xml.transform.URIResolver { */ public Source resolve(String href, String base) throws TransformerException { Source source = null; - + // data URLs can be quite long so evaluate early and don't try to build a File // (can lead to problems) source = dataURIResolver.resolve(href, base); - + // Custom uri resolution if (source == null && uriResolver != null) { source = uriResolver.resolve(href, base); diff --git a/src/java/org/apache/fop/apps/FOUserAgent.java b/src/java/org/apache/fop/apps/FOUserAgent.java index f4c68933e..c7a904f29 100644 --- a/src/java/org/apache/fop/apps/FOUserAgent.java +++ b/src/java/org/apache/fop/apps/FOUserAgent.java @@ -76,7 +76,7 @@ public class FOUserAgent { private static Log log = LogFactory.getLog("FOP"); private FopFactory factory; - + /** * The base URL for all URL resolutions, especially for * external-graphics. @@ -88,7 +88,7 @@ public class FOUserAgent { /** A user settable URI Resolver */ private URIResolver uriResolver = null; - + private float targetResolution = FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION; private Map rendererOptions = new java.util.HashMap(); private File outputFile = null; @@ -96,7 +96,7 @@ public class FOUserAgent { private FOEventHandler foEventHandlerOverride = null; private boolean locatorEnabled = true; // true by default (for error messages). private EventBroadcaster eventBroadcaster = new FOPEventBroadcaster(); - + /** Producer: Metadata element for the system/software that produces * the document. (Some renderers can store this in the document.) */ @@ -107,18 +107,18 @@ public class FOUserAgent { */ protected String creator = null; - /** Creation Date: Override of the date the document was created. + /** Creation Date: Override of the date the document was created. * (Some renderers can store this in the document.) */ protected Date creationDate = null; - + /** Author of the content of the document. */ protected String author = null; /** Title of the document. */ protected String title = null; /** Set of keywords applicable to this document. */ protected String keywords = null; - + private ImageSessionContext imageSessionContext = new AbstractImageSessionContext() { public ImageContext getParentContext() { @@ -132,11 +132,11 @@ public class FOUserAgent { public Source resolveURI(String uri) { return FOUserAgent.this.resolveURI(uri); } - + }; - + /** - * Main constructor. <b>This constructor should not be called directly. Please use the + * Main constructor. <b>This constructor should not be called directly. Please use the * methods from FopFactory to construct FOUserAgent instances!</b> * @param factory the factory that provides environment-level information * @see org.apache.fop.apps.FopFactory @@ -150,17 +150,17 @@ public class FOUserAgent { setFontBaseURL(factory.getFontManager().getFontBaseURL()); setTargetResolution(factory.getTargetResolution()); } - + /** @return the associated FopFactory instance */ public FopFactory getFactory() { return this.factory; } - + // ---------------------------------------------- rendering-run dependent stuff - + /** - * Sets an explicit renderer to use which overrides the one defined by the - * render type setting. + * Sets an explicit renderer to use which overrides the one defined by the + * render type setting. * @param renderer the Renderer instance to use */ public void setRendererOverride(Renderer renderer) { @@ -177,7 +177,7 @@ public class FOUserAgent { /** * Sets an explicit FOEventHandler instance which overrides the one - * defined by the render type setting. + * defined by the render type setting. * @param handler the FOEventHandler instance */ public void setFOEventHandlerOverride(FOEventHandler handler) { @@ -193,7 +193,7 @@ public class FOUserAgent { } /** - * Sets the producer of the document. + * Sets the producer of the document. * @param producer source of document */ public void setProducer(String producer) { @@ -209,7 +209,7 @@ public class FOUserAgent { } /** - * Sets the creator of the document. + * Sets the creator of the document. * @param creator of document */ public void setCreator(String creator) { @@ -225,7 +225,7 @@ public class FOUserAgent { } /** - * Sets the creation date of the document. + * Sets the creation date of the document. * @param creationDate date of document */ public void setCreationDate(Date creationDate) { @@ -241,7 +241,7 @@ public class FOUserAgent { } /** - * Sets the author of the document. + * Sets the author of the document. * @param author of document */ public void setAuthor(String author) { @@ -258,7 +258,7 @@ public class FOUserAgent { /** * Sets the title of the document. This will override any title coming from - * an fo:title element. + * an fo:title element. * @param title of document */ public void setTitle(String title) { @@ -274,7 +274,7 @@ public class FOUserAgent { } /** - * Sets the keywords for the document. + * Sets the keywords for the document. * @param keywords for the document */ public void setKeywords(String keywords) { @@ -296,7 +296,7 @@ public class FOUserAgent { public Map getRendererOptions() { return rendererOptions; } - + /** * Sets the base URL. * @param baseUrl base URL @@ -343,7 +343,7 @@ public class FOUserAgent { * to the default resolver. * @param uri URI to access * @return A {@link javax.xml.transform.Source} object, or null if the URI - * cannot be resolved. + * cannot be resolved. * @see org.apache.fop.apps.FOURIResolver */ public Source resolveURI(String uri) { @@ -357,7 +357,7 @@ public class FOUserAgent { * @param href URI to access * @param base the base URI to resolve against * @return A {@link javax.xml.transform.Source} object, or null if the URI - * cannot be resolved. + * cannot be resolved. * @see org.apache.fop.apps.FOURIResolver */ public Source resolveURI(String href, String base) { @@ -402,9 +402,9 @@ public class FOUserAgent { * @see #getTargetResolution() */ public float getTargetPixelUnitToMillimeter() { - return 25.4f / this.targetResolution; + return 25.4f / this.targetResolution; } - + /** @return the resolution for resolution-dependant output */ public float getTargetResolution() { return this.targetResolution; @@ -419,7 +419,7 @@ public class FOUserAgent { public void setTargetResolution(float dpi) { this.targetResolution = dpi; if (log.isDebugEnabled()) { - log.debug("target-resolution set to: " + targetResolution + log.debug("target-resolution set to: " + targetResolution + "dpi (px2mm=" + getTargetPixelUnitToMillimeter() + ")"); } } @@ -433,7 +433,7 @@ public class FOUserAgent { public void setTargetResolution(int dpi) { setTargetResolution((float)dpi); } - + /** * Returns the image session context for the image package. * @return the ImageSessionContext instance for this rendering run @@ -441,7 +441,7 @@ public class FOUserAgent { public ImageSessionContext getImageSessionContext() { return this.imageSessionContext; } - + // ---------------------------------------------- environment-level stuff // (convenience access to FopFactory methods) @@ -457,9 +457,9 @@ public class FOUserAgent { * @see #getSourceResolution() */ public float getSourcePixelUnitToMillimeter() { - return getFactory().getSourcePixelUnitToMillimeter(); + return getFactory().getSourcePixelUnitToMillimeter(); } - + /** @return the resolution for resolution-dependant input */ public float getSourceResolution() { return getFactory().getSourceResolution(); @@ -475,7 +475,7 @@ public class FOUserAgent { public String getPageHeight() { return getFactory().getPageHeight(); } - + /** * Gets the default page-width to use as fallback, * in case page-width="auto" @@ -486,7 +486,7 @@ public class FOUserAgent { public String getPageWidth() { return getFactory().getPageWidth(); } - + /** * Returns whether FOP is strictly validating input XSL * @return true of strict validation turned on, false otherwise @@ -497,7 +497,7 @@ public class FOUserAgent { } /** - * @return true if the indent inheritance should be broken when crossing reference area + * @return true if the indent inheritance should be broken when crossing reference area * boundaries (for more info, see the javadoc for the relative member variable) * @see FopFactory#isBreakIndentInheritanceOnReferenceAreaBoundary() */ @@ -518,7 +518,7 @@ public class FOUserAgent { public XMLHandlerRegistry getXMLHandlerRegistry() { return getFactory().getXMLHandlerRegistry(); } - + /** * Controls the use of SAXLocators to provide location information in error * messages. @@ -550,7 +550,7 @@ public class FOUserAgent { private class FOPEventBroadcaster extends DefaultEventBroadcaster { private EventListener rootListener; - + public FOPEventBroadcaster() { //Install a temporary event listener that catches the first event to //do some initialization. @@ -569,13 +569,13 @@ public class FOUserAgent { } }; } - + /** {@inheritDoc} */ public void broadcastEvent(Event event) { rootListener.processEvent(event); } } - + } diff --git a/src/java/org/apache/fop/apps/FopFactory.java b/src/java/org/apache/fop/apps/FopFactory.java index c196e1204..ae4d25949 100644 --- a/src/java/org/apache/fop/apps/FopFactory.java +++ b/src/java/org/apache/fop/apps/FopFactory.java @@ -59,37 +59,37 @@ import org.apache.fop.util.ContentHandlerFactoryRegistry; * found and managed in the FOUserAgent. */ public class FopFactory implements ImageContext { - + /** logger instance */ private static Log log = LogFactory.getLog(FopFactory.class); - + /** Factory for Renderers and FOEventHandlers */ private RendererFactory rendererFactory; - + /** Registry for XML handlers */ private XMLHandlerRegistry xmlHandlers; - + /** The registry for ElementMapping instances */ private ElementMappingRegistry elementMappingRegistry; - /** The registry for ContentHandlerFactory instance */ - private ContentHandlerFactoryRegistry contentHandlerFactoryRegistry + /** The registry for ContentHandlerFactory instance */ + private ContentHandlerFactoryRegistry contentHandlerFactoryRegistry = new ContentHandlerFactoryRegistry(); - + /** The resolver for user-supplied hyphenation patterns */ private HyphenationTreeResolver hyphResolver = null; private ColorSpaceCache colorSpaceCache = null; - + /** Image manager for loading and caching image objects */ private ImageManager imageManager; /** Font manager for font substitution, autodetection and caching **/ private FontManager fontManager; - + /** Configuration layer used to configure fop */ private FopFactoryConfigurator config = null; - + /** * The base URL for all URL resolutions, especially for * external-graphics. @@ -101,10 +101,10 @@ public class FopFactory implements ImageContext { /** * FOP has the ability, for some FO's, to continue processing even if the - * input XSL violates that FO's content model. This is the default + * input XSL violates that FO's content model. This is the default * behavior for FOP. However, this flag, if set, provides the user the * ability for FOP to halt on all content model violations if desired. - */ + */ private boolean strictFOValidation = FopFactoryConfigurator.DEFAULT_STRICT_FO_VALIDATION; /** @@ -113,7 +113,7 @@ public class FopFactory implements ImageContext { */ private boolean strictUserConfigValidation = FopFactoryConfigurator.DEFAULT_STRICT_USERCONFIG_VALIDATION; - + /** Source resolution in dpi */ private float sourceResolution = FopFactoryConfigurator.DEFAULT_SOURCE_RESOLUTION; @@ -122,7 +122,7 @@ public class FopFactory implements ImageContext { /** Page height */ private String pageHeight = FopFactoryConfigurator.DEFAULT_PAGE_HEIGHT; - + /** Page width */ private String pageWidth = FopFactoryConfigurator.DEFAULT_PAGE_WIDTH; @@ -136,7 +136,7 @@ public class FopFactory implements ImageContext { private Set ignoredNamespaces; private FOURIResolver foURIResolver; - + /** * Main constructor. */ @@ -150,7 +150,7 @@ public class FopFactory implements ImageContext { this.xmlHandlers = new XMLHandlerRegistry(); this.ignoredNamespaces = new java.util.HashSet(); } - + /** * Returns a new FopFactory instance. * @return the requested FopFactory instance. @@ -158,13 +158,13 @@ public class FopFactory implements ImageContext { public static FopFactory newInstance() { return new FopFactory(); } - + /** * Returns a new FOUserAgent instance. Use the FOUserAgent to configure special values that * are particular to a rendering run. Don't reuse instances over multiple rendering runs but * instead create a new one each time and reuse the FopFactory. * @return the newly created FOUserAgent instance initialized with default values - * @throws FOPException + * @throws FOPException */ public FOUserAgent newFOUserAgent() { FOUserAgent userAgent = new FOUserAgent(this); @@ -172,12 +172,12 @@ public class FopFactory implements ImageContext { } /** - * Returns a new {@link Fop} instance. FOP will be configured with a default user agent + * Returns a new {@link Fop} instance. FOP will be configured with a default user agent * instance. * <p> * MIME types are used to select the output format (ex. "application/pdf" for PDF). You can * use the constants defined in {@link MimeConstants}. - * @param outputFormat the MIME type of the output format to use (ex. "application/pdf"). + * @param outputFormat the MIME type of the output format to use (ex. "application/pdf"). * @return the new Fop instance * @throws FOPException when the constructor fails */ @@ -186,29 +186,29 @@ public class FopFactory implements ImageContext { } /** - * Returns a new {@link Fop} instance. Use this factory method if you want to configure this + * Returns a new {@link Fop} instance. Use this factory method if you want to configure this * very rendering run, i.e. if you want to set some metadata like the title and author of the - * document you want to render. In that case, create a new {@link FOUserAgent} + * document you want to render. In that case, create a new {@link FOUserAgent} * instance using {@link #newFOUserAgent()}. * <p> * MIME types are used to select the output format (ex. "application/pdf" for PDF). You can * use the constants defined in {@link MimeConstants}. * @param outputFormat the MIME type of the output format to use (ex. "application/pdf"). - * @param userAgent the user agent that will be used to control the rendering run + * @param userAgent the user agent that will be used to control the rendering run * @return the new Fop instance * @throws FOPException when the constructor fails */ public Fop newFop(String outputFormat, FOUserAgent userAgent) throws FOPException { return newFop(outputFormat, userAgent, null); } - + /** - * Returns a new {@link Fop} instance. FOP will be configured with a default user agent + * Returns a new {@link Fop} instance. FOP will be configured with a default user agent * instance. Use this factory method if your output type requires an output stream. * <p> * MIME types are used to select the output format (ex. "application/pdf" for PDF). You can * use the constants defined in {@link MimeConstants}. - * @param outputFormat the MIME type of the output format to use (ex. "application/pdf"). + * @param outputFormat the MIME type of the output format to use (ex. "application/pdf"). * @param stream the output stream * @return the new Fop instance * @throws FOPException when the constructor fails @@ -227,30 +227,30 @@ public class FopFactory implements ImageContext { * MIME types are used to select the output format (ex. "application/pdf" for PDF). You can * use the constants defined in {@link MimeConstants}. * @param outputFormat the MIME type of the output format to use (ex. "application/pdf"). - * @param userAgent the user agent that will be used to control the rendering run + * @param userAgent the user agent that will be used to control the rendering run * @param stream the output stream * @return the new Fop instance * @throws FOPException when the constructor fails */ - public Fop newFop(String outputFormat, FOUserAgent userAgent, OutputStream stream) + public Fop newFop(String outputFormat, FOUserAgent userAgent, OutputStream stream) throws FOPException { if (userAgent == null) { throw new NullPointerException("The userAgent parameter must not be null!"); } return new Fop(outputFormat, userAgent, stream); } - + /** * Returns a new {@link Fop} instance. Use this factory method if you want to supply your - * own {@link org.apache.fop.render.Renderer Renderer} or - * {@link org.apache.fop.fo.FOEventHandler FOEventHandler} + * own {@link org.apache.fop.render.Renderer Renderer} or + * {@link org.apache.fop.fo.FOEventHandler FOEventHandler} * instance instead of the default ones created internally by FOP. - * @param userAgent the user agent that will be used to control the rendering run + * @param userAgent the user agent that will be used to control the rendering run * @return the new Fop instance * @throws FOPException when the constructor fails */ public Fop newFop(FOUserAgent userAgent) throws FOPException { - if (userAgent.getRendererOverride() == null + if (userAgent.getRendererOverride() == null && userAgent.getFOEventHandlerOverride() == null) { throw new IllegalStateException("Either the overriding renderer or the overriding" + " FOEventHandler must be set when this factory method is used!"); @@ -267,7 +267,7 @@ public class FopFactory implements ImageContext { public XMLHandlerRegistry getXMLHandlerRegistry() { return this.xmlHandlers; } - + /** @return the element mapping registry */ public ElementMappingRegistry getElementMappingRegistry() { return this.elementMappingRegistry; @@ -310,7 +310,7 @@ public class FopFactory implements ImageContext { public LayoutManagerMaker getLayoutManagerMakerOverride() { return this.lmMakerOverride; } - + /** * Sets the base URL. * @param base the base URL @@ -327,7 +327,7 @@ public class FopFactory implements ImageContext { public String getBaseURL() { return this.base; } - + /** * Sets the font base URL. * @param fontBase font base URL @@ -367,10 +367,10 @@ public class FopFactory implements ImageContext { } this.hyphenBase = foURIResolver.checkBaseURL(hyphenBase); } - + /** * Sets the URI Resolver. It is used for resolving factory-level URIs like hyphenation - * patterns and as backup for URI resolution performed during a rendering run. + * patterns and as backup for URI resolution performed during a rendering run. * @param uriResolver the new URI resolver */ public void setURIResolver(URIResolver uriResolver) { @@ -397,7 +397,7 @@ public class FopFactory implements ImageContext { public HyphenationTreeResolver getHyphenationTreeResolver() { return this.hyphResolver; } - + /** * Sets the HyphenationTreeResolver to be used for resolving user-supplied hyphenation files. * @param hyphResolver the HyphenationTreeResolver instance @@ -424,7 +424,7 @@ public class FopFactory implements ImageContext { } /** - * @return true if the indent inheritance should be broken when crossing reference area + * @return true if the indent inheritance should be broken when crossing reference area * boundaries (for more info, see the javadoc for the relative member variable) */ public boolean isBreakIndentInheritanceOnReferenceAreaBoundary() { @@ -447,7 +447,7 @@ public class FopFactory implements ImageContext { public void setBreakIndentInheritanceOnReferenceAreaBoundary(boolean value) { this.breakIndentInheritanceOnReferenceAreaBoundary = value; } - + /** * @return true if kerning on base 14 fonts is enabled * @deprecated use getFontManager().isBase14KerningEnabled() instead @@ -455,7 +455,7 @@ public class FopFactory implements ImageContext { public boolean isBase14KerningEnabled() { return getFontManager().isBase14KerningEnabled(); } - + /** * Controls whether kerning is activated on base 14 fonts. * @param value true if kerning should be activated @@ -464,7 +464,7 @@ public class FopFactory implements ImageContext { public void setBase14KerningEnabled(boolean value) { getFontManager().setBase14KerningEnabled(value); } - + /** @return the resolution for resolution-dependant input */ public float getSourceResolution() { return this.sourceResolution; @@ -477,7 +477,7 @@ public class FopFactory implements ImageContext { * @see #getSourceResolution() */ public float getSourcePixelUnitToMillimeter() { - return 25.4f / getSourceResolution(); + return 25.4f / getSourceResolution(); } /** @@ -488,7 +488,7 @@ public class FopFactory implements ImageContext { public void setSourceResolution(float dpi) { this.sourceResolution = dpi; if (log.isDebugEnabled()) { - log.debug("source-resolution set to: " + sourceResolution + log.debug("source-resolution set to: " + sourceResolution + "dpi (px2mm=" + getSourcePixelUnitToMillimeter() + ")"); } } @@ -505,7 +505,7 @@ public class FopFactory implements ImageContext { * @see #getTargetResolution() */ public float getTargetPixelUnitToMillimeter() { - return 25.4f / this.targetResolution; + return 25.4f / this.targetResolution; } /** @@ -525,7 +525,7 @@ public class FopFactory implements ImageContext { public void setSourceResolution(int dpi) { setSourceResolution((float)dpi); } - + /** * Gets the default page-height to use as fallback, * in case page-height="auto" @@ -535,7 +535,7 @@ public class FopFactory implements ImageContext { public String getPageHeight() { return this.pageHeight; } - + /** * Sets the page-height to use as fallback, in case * page-height="auto" @@ -548,7 +548,7 @@ public class FopFactory implements ImageContext { log.debug("Default page-height set to: " + pageHeight); } } - + /** * Gets the default page-width to use as fallback, * in case page-width="auto" @@ -558,7 +558,7 @@ public class FopFactory implements ImageContext { public String getPageWidth() { return this.pageWidth; } - + /** * Sets the page-width to use as fallback, in case * page-width="auto" @@ -571,27 +571,27 @@ public class FopFactory implements ImageContext { log.debug("Default page-width set to: " + pageWidth); } } - + /** * Adds a namespace to the set of ignored namespaces. - * If FOP encounters a namespace which it cannot handle, it issues a warning except if this + * If FOP encounters a namespace which it cannot handle, it issues a warning except if this * namespace is in the ignored set. * @param namespaceURI the namespace URI */ public void ignoreNamespace(String namespaceURI) { this.ignoredNamespaces.add(namespaceURI); } - + /** * Adds a collection of namespaces to the set of ignored namespaces. - * If FOP encounters a namespace which it cannot handle, it issues a warning except if this + * If FOP encounters a namespace which it cannot handle, it issues a warning except if this * namespace is in the ignored set. * @param namespaceURIs the namespace URIs */ public void ignoreNamespaces(Collection namespaceURIs) { this.ignoredNamespaces.addAll(namespaceURIs); } - + /** * Indicates whether a namespace URI is on the ignored list. * @param namespaceURI the namespace URI @@ -600,14 +600,14 @@ public class FopFactory implements ImageContext { public boolean isNamespaceIgnored(String namespaceURI) { return this.ignoredNamespaces.contains(namespaceURI); } - + /** @return the set of namespaces that are ignored by FOP */ public Set getIgnoredNamespace() { return Collections.unmodifiableSet(this.ignoredNamespaces); } //------------------------------------------- Configuration stuff - + /** * Set the user configuration. * @param userConfigFile the configuration file @@ -627,11 +627,11 @@ public class FopFactory implements ImageContext { public void setUserConfig(String uri) throws SAXException, IOException { config.setUserConfig(uri); } - + /** * Set the user configuration. * @param userConfig configuration - * @throws FOPException if a configuration problem occurs + * @throws FOPException if a configuration problem occurs */ public void setUserConfig(Configuration userConfig) throws FOPException { config.setUserConfig(userConfig); @@ -690,7 +690,7 @@ public class FopFactory implements ImageContext { public FontCache getFontCache() { return getFontManager().getFontCache(); } - + /** * Returns the font manager. * @return the font manager @@ -698,17 +698,17 @@ public class FopFactory implements ImageContext { public FontManager getFontManager() { if (fontManager == null) { this.fontManager = new FontManager() { - + /** {@inheritDoc} */ public void setFontBaseURL(String fontBase) throws MalformedURLException { super.setFontBaseURL(getFOURIResolver().checkBaseURL(fontBase)); } - + }; } return this.fontManager; } - + /** * Attempts to resolve the given URI. * Will use the configured resolver and if not successful fall back @@ -716,7 +716,7 @@ public class FopFactory implements ImageContext { * @param href URI to access * @param baseUri the base URI to resolve against * @return A {@link javax.xml.transform.Source} object, or null if the URI - * cannot be resolved. + * cannot be resolved. * @see org.apache.fop.apps.FOURIResolver */ public Source resolveURI(String href, String baseUri) { @@ -728,19 +728,19 @@ public class FopFactory implements ImageContext { } return source; } - + /** * Create (if needed) and return an ICC ColorSpace instance. * * The ICC profile source is taken from the src attribute of the color-profile FO element. * If the ICC ColorSpace is not yet in the cache a new one is created and stored in the cache. * - * The FOP URI resolver is used to try and locate the ICC file. + * The FOP URI resolver is used to try and locate the ICC file. * If that fails null is returned. * * @param baseUri a base URI to resolve relative URIs * @param iccProfileSrc ICC Profile source to return a ColorSpace for - * @return ICC ColorSpace object or null if ColorSpace could not be created + * @return ICC ColorSpace object or null if ColorSpace could not be created */ public ColorSpace getColorSpace(String baseUri, String iccProfileSrc) { return colorSpaceCache.get(baseUri, iccProfileSrc); diff --git a/src/java/org/apache/fop/apps/FopFactoryConfigurator.java b/src/java/org/apache/fop/apps/FopFactoryConfigurator.java index cc3ce2d0b..ffcc1332b 100644 --- a/src/java/org/apache/fop/apps/FopFactoryConfigurator.java +++ b/src/java/org/apache/fop/apps/FopFactoryConfigurator.java @@ -42,25 +42,25 @@ public class FopFactoryConfigurator { /** Defines if FOP should use an alternative rule to determine text indents */ public static final boolean DEFAULT_BREAK_INDENT_INHERITANCE = false; - + /** Defines if FOP should validate the user config strictly */ public static final boolean DEFAULT_STRICT_USERCONFIG_VALIDATION = true; - + /** Defines if FOP should use strict validation for FO and user config */ public static final boolean DEFAULT_STRICT_FO_VALIDATION = true; - + /** Defines the default page-width */ public static final String DEFAULT_PAGE_WIDTH = "8.26in"; - + /** Defines the default page-height */ public static final String DEFAULT_PAGE_HEIGHT = "11in"; - + /** Defines the default source resolution (72dpi) for FOP */ public static final float DEFAULT_SOURCE_RESOLUTION = 72.0f; //dpi - + /** Defines the default target resolution (72dpi) for FOP */ public static final float DEFAULT_TARGET_RESOLUTION = 72.0f; //dpi - + /** logger instance */ private final Log log = LogFactory.getLog(FopFactoryConfigurator.class); @@ -78,7 +78,7 @@ public class FopFactoryConfigurator { super(); this.factory = factory; } - + /** * Initializes user agent settings from the user configuration * file, if present: baseURL, resolution, default page size,... @@ -87,7 +87,7 @@ public class FopFactoryConfigurator { */ public void configure(FopFactory factory) throws FOPException { if (log.isDebugEnabled()) { - log.debug("Initializing FopFactory Configuration"); + log.debug("Initializing FopFactory Configuration"); } // strict configuration @@ -98,9 +98,9 @@ public class FopFactoryConfigurator { } catch (ConfigurationException e) { LogUtil.handleException(log, e, false); } - } + } boolean strict = factory.validateUserConfigStrictly(); - + // strict fo validation if (cfg.getChild("strict-validation", false) != null) { try { @@ -128,14 +128,14 @@ public class FopFactoryConfigurator { LogUtil.handleException(log, mfue, strict); } } - + // renderer options if (cfg.getChild("source-resolution", false) != null) { factory.setSourceResolution( cfg.getChild("source-resolution").getValueAsFloat( FopFactoryConfigurator.DEFAULT_SOURCE_RESOLUTION)); if (log.isDebugEnabled()) { - log.debug("source-resolution set to: " + factory.getSourceResolution() + log.debug("source-resolution set to: " + factory.getSourceResolution() + "dpi (px2mm=" + factory.getSourcePixelUnitToMillimeter() + ")"); } } @@ -144,9 +144,9 @@ public class FopFactoryConfigurator { cfg.getChild("target-resolution").getValueAsFloat( FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)); if (log.isDebugEnabled()) { - log.debug("target-resolution set to: " + factory.getTargetResolution() + log.debug("target-resolution set to: " + factory.getTargetResolution() + "dpi (px2mm=" + factory.getTargetPixelUnitToMillimeter() - + ")"); + + ")"); } } if (cfg.getChild("break-indent-inheritance", false) != null) { @@ -156,13 +156,13 @@ public class FopFactoryConfigurator { } catch (ConfigurationException e) { LogUtil.handleException(log, e, strict); } - } + } Configuration pageConfig = cfg.getChild("default-page-settings"); if (pageConfig.getAttribute("height", null) != null) { factory.setPageHeight( pageConfig.getAttribute("height", FopFactoryConfigurator.DEFAULT_PAGE_HEIGHT)); if (log.isInfoEnabled()) { - log.info("Default page-height set to: " + factory.getPageHeight()); + log.info("Default page-height set to: " + factory.getPageHeight()); } } if (pageConfig.getAttribute("width", null) != null) { @@ -178,7 +178,7 @@ public class FopFactoryConfigurator { FontManagerConfigurator fontManagerConfigurator = new FontManagerConfigurator(cfg); fontManagerConfigurator.configure(fontManager, strict); } - + /** * Set the user configuration. * @param userConfigFile the configuration file @@ -193,7 +193,7 @@ public class FopFactoryConfigurator { throw new FOPException(e); } } - + /** * Set the user configuration from an URI. * @param uri the URI to the configuration file @@ -208,22 +208,22 @@ public class FopFactoryConfigurator { throw new FOPException(e); } } - + /** * Set the user configuration. * @param cfg avalon configuration - * @throws FOPException if a configuration problem occurs + * @throws FOPException if a configuration problem occurs */ public void setUserConfig(Configuration cfg) throws FOPException { this.cfg = cfg; configure(this.factory); } - + /** * Get the avalon user configuration. * @return the user configuration */ public Configuration getUserConfig() { return this.cfg; - } + } } diff --git a/src/java/org/apache/fop/fonts/CustomFontCollection.java b/src/java/org/apache/fop/fonts/CustomFontCollection.java index 3c0ffbed4..5e5a61189 100644 --- a/src/java/org/apache/fop/fonts/CustomFontCollection.java +++ b/src/java/org/apache/fop/fonts/CustomFontCollection.java @@ -15,7 +15,8 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ + package org.apache.fop.fonts; import java.util.List; @@ -26,7 +27,7 @@ import org.apache.fop.render.PrintRenderer; * Sets up a set of custom (embedded) fonts */ public class CustomFontCollection implements FontCollection { - + private PrintRenderer renderer = null; /** @@ -51,7 +52,7 @@ public class CustomFontCollection implements FontCollection { //Ensure that we have minimal font resolution capabilities resolver = FontManager.createMinimalFontResolver(); } - + String internalName = null; //FontReader reader = null; @@ -67,7 +68,7 @@ public class CustomFontCollection implements FontCollection { reader.setFontEmbedPath(configFontInfo.getEmbedFile()); fontInfo.addMetrics(internalName, reader.getFont()); */ - + LazyFont font = new LazyFont(embedFontInfo, resolver); fontInfo.addMetrics(internalName, font); @@ -78,5 +79,5 @@ public class CustomFontCollection implements FontCollection { } } return num; - } -}
\ No newline at end of file + } +} diff --git a/src/java/org/apache/fop/fonts/EmbedFontInfo.java b/src/java/org/apache/fop/fonts/EmbedFontInfo.java index 0d0bcafdb..9496b8459 100644 --- a/src/java/org/apache/fop/fonts/EmbedFontInfo.java +++ b/src/java/org/apache/fop/fonts/EmbedFontInfo.java @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.fonts; import java.io.IOException; @@ -27,17 +27,17 @@ import java.util.List; * FontInfo contains meta information on fonts (where is the metrics file etc.) */ public class EmbedFontInfo implements Serializable { - + /** Serialization Version UID */ private static final long serialVersionUID = 8755432068669997367L; - + /** filename of the metrics file */ protected String metricsFile; /** filename of the main font file */ protected String embedFile; /** false, to disable kerning */ protected boolean kerning; - + /** the PostScript name of the font */ protected String postScriptName = null; /** the sub-fontname of the font (used for TrueType Collections, null otherwise) */ @@ -47,7 +47,7 @@ public class EmbedFontInfo implements Serializable { private List/*<FontTriplet>*/ fontTriplets = null; private transient boolean embedded = true; - + /** * Main constructor * @param metricsFile Path to the xml file containing font metrics @@ -64,7 +64,7 @@ public class EmbedFontInfo implements Serializable { this.fontTriplets = fontTriplets; this.subFontName = subFontName; } - + /** * Returns the path to the metrics file * @return the metrics file path @@ -88,16 +88,16 @@ public class EmbedFontInfo implements Serializable { public boolean getKerning() { return kerning; } - + /** - * Returns the sub-font name name of the font. This is primarily used for TrueType Collections - * to select one of the sub-fonts. For all other fonts, this is always null. + * Returns the sub-font name of the font. This is primarily used for TrueType Collections + * to select one of the sub-fonts. For all other fonts, this is always null. * @return the sub-font name (or null) */ public String getSubFontName() { return this.subFontName; } - + /** * Returns the PostScript name of the font. * @return the PostScript name @@ -105,7 +105,7 @@ public class EmbedFontInfo implements Serializable { public String getPostScriptName() { return postScriptName; } - + /** * Sets the PostScript name of the font * @param postScriptName the PostScript name @@ -113,7 +113,7 @@ public class EmbedFontInfo implements Serializable { public void setPostScriptName(String postScriptName) { this.postScriptName = postScriptName; } - + /** * Returns the list of font triplets associated with this font. * @return List of font triplets @@ -121,7 +121,7 @@ public class EmbedFontInfo implements Serializable { public List/*<FontTriplet>*/ getFontTriplets() { return fontTriplets; } - + /** * Indicates whether the font is only referenced rather than embedded. * @return true if the font is embedded, false if it is referenced. @@ -133,7 +133,7 @@ public class EmbedFontInfo implements Serializable { return this.embedded; } } - + /** * Defines whether the font is embedded or not. * @param value true to embed the font, false to reference it @@ -141,19 +141,19 @@ public class EmbedFontInfo implements Serializable { public void setEmbedded(boolean value) { this.embedded = value; } - + private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); this.embedded = true; } - + /** {@inheritDoc} */ public String toString() { return "metrics-url=" + metricsFile + ",embed-url=" + embedFile + ", kerning=" + kerning + ", " + "font-triplet=" + fontTriplets + (getSubFontName() != null ? ", sub-font=" + getSubFontName() : "") - + (isEmbedded() ? "" : ", NOT embedded"); + + (isEmbedded() ? "" : ", NOT embedded"); } } diff --git a/src/java/org/apache/fop/fonts/Font.java b/src/java/org/apache/fop/fonts/Font.java index 4ce3cbfbd..90aced052 100644 --- a/src/java/org/apache/fop/fonts/Font.java +++ b/src/java/org/apache/fop/fonts/Font.java @@ -32,10 +32,10 @@ public class Font { /** Extra Bold font weight */ public static final int WEIGHT_EXTRA_BOLD = 800; - + /** Bold font weight */ public static final int WEIGHT_BOLD = 700; - + /** Normal font weight */ public static final int WEIGHT_NORMAL = 400; @@ -56,7 +56,7 @@ public class Font { /** Default selection priority */ public static final int PRIORITY_DEFAULT = 0; - + /** Default fallback key */ public static final FontTriplet DEFAULT_FONT = new FontTriplet( "any", STYLE_NORMAL, WEIGHT_NORMAL, PRIORITY_DEFAULT); @@ -96,7 +96,7 @@ public class Font { public FontMetrics getFontMetrics() { return this.metric; } - + /** * Returns the font's ascender. * @return the ascender @@ -128,7 +128,7 @@ public class Font { public String getFontName() { return fontName; } - + /** @return the font triplet that selected this font */ public FontTriplet getFontTriplet() { return this.triplet; @@ -154,7 +154,7 @@ public class Font { public boolean hasKerning() { return metric.hasKerningInfo(); } - + /** * Returns the font's kerning table * @return the kerning table @@ -166,7 +166,7 @@ public class Font { return java.util.Collections.EMPTY_MAP; } } - + /** * Returns the amount of kerning between two characters. * @param ch1 first character @@ -217,7 +217,7 @@ public class Font { return c; } - + /** * Determines whether this font contains a particular character/glyph. * @param c character to check diff --git a/src/java/org/apache/fop/fonts/FontCache.java b/src/java/org/apache/fop/fonts/FontCache.java index ba9529c02..f2ca741ff 100644 --- a/src/java/org/apache/fop/fonts/FontCache.java +++ b/src/java/org/apache/fop/fonts/FontCache.java @@ -43,7 +43,7 @@ import org.apache.fop.util.LogUtil; * Fop cache (currently only used for font info caching) */ public final class FontCache implements Serializable { - + /** * Serialization Version UID. Change this value if you want to make sure the user's cache * file is purged after an update. @@ -59,13 +59,13 @@ public final class FontCache implements Serializable { /** font cache file path */ private static final String DEFAULT_CACHE_FILENAME = "fop-fonts.cache"; - + /** has this cache been changed since it was last read? */ private transient boolean changed = false; - + /** change lock */ private transient Object changeLock = new Object(); - + /** master mapping of font url -> font info. This needs to be * a list, since a TTC file may contain more than 1 font. */ private Map/*<String, CachedFontFile>*/ fontfileMap = null; @@ -96,7 +96,7 @@ public final class FontCache implements Serializable { } return null; } - + /** * Returns the default font cache file. * @param forWriting true if the user directory should be created @@ -113,7 +113,7 @@ public final class FontCache implements Serializable { } return new File(FOP_USER_DIR); } - + /** * Reads the default font cache file and returns its contents. * @return the font cache deserialized from the file (or null if no cache file exists or if @@ -122,7 +122,7 @@ public final class FontCache implements Serializable { public static FontCache load() { return loadFrom(getDefaultCacheFile(false)); } - + /** * Reads a font cache file and returns its contents. * @param cacheFile the cache file @@ -145,11 +145,11 @@ public final class FontCache implements Serializable { } } catch (ClassNotFoundException e) { //We don't really care about the exception since it's just a cache file - log.warn("Could not read font cache. Discarding font cache file. Reason: " + log.warn("Could not read font cache. Discarding font cache file. Reason: " + e.getMessage()); } catch (IOException ioe) { //We don't really care about the exception since it's just a cache file - log.warn("I/O exception while reading font cache (" + ioe.getMessage() + log.warn("I/O exception while reading font cache (" + ioe.getMessage() + "). Discarding font cache file."); try { cacheFile.delete(); @@ -160,7 +160,7 @@ public final class FontCache implements Serializable { } return null; } - + /** * Writes the font cache to disk. * @throws FOPException fop exception @@ -168,10 +168,10 @@ public final class FontCache implements Serializable { public void save() throws FOPException { saveTo(getDefaultCacheFile(true)); } - + /** * Writes the font cache to disk. - * @param cacheFile the file to write to + * @param cacheFile the file to write to * @throws FOPException fop exception */ public void saveTo(File cacheFile) throws FOPException { @@ -219,7 +219,7 @@ public final class FontCache implements Serializable { public boolean hasChanged() { return this.changed; } - + /** * is this font in the cache? * @param embedUrl font info @@ -248,11 +248,11 @@ public final class FontCache implements Serializable { * Tries to identify a File instance from an array of URLs. If there's no file URL in the * array, the method returns null. * @param urls array of possible font urls - * @return file font file + * @return file font file */ public static File getFileFromUrls(String[] urls) { for (int i = 0; i < urls.length; i++) { - String urlStr = urls[i]; + String urlStr = urls[i]; if (urlStr != null) { File fontFile = null; if (urlStr.startsWith("file:")) { @@ -270,7 +270,7 @@ public final class FontCache implements Serializable { return fontFile; } } - } + } return null; } @@ -280,7 +280,7 @@ public final class FontCache implements Serializable { } return fontfileMap; } - + /** * Adds a font info to cache * @param fontInfo font info @@ -313,7 +313,7 @@ public final class FontCache implements Serializable { /** * Returns a font from the cache. * @param embedUrl font info - * @return CachedFontFile object + * @return CachedFontFile object */ public CachedFontFile getFontFile(String embedUrl) { if (containsFont(embedUrl)) { @@ -321,7 +321,7 @@ public final class FontCache implements Serializable { } return null; } - + /** * Returns the EmbedFontInfo instances belonging to a font file. If the font file was * modified since it was cached the entry is removed and null is returned. @@ -338,7 +338,7 @@ public final class FontCache implements Serializable { return null; } } - + /** * removes font from cache * @param embedUrl embed url @@ -354,7 +354,7 @@ public final class FontCache implements Serializable { } } } - + /** * has this font previously failed to load? * @param embedUrl embed url @@ -370,7 +370,7 @@ public final class FontCache implements Serializable { // from failed font map for now getFailedFontMap().remove(embedUrl); changed = true; - } + } } return true; } @@ -397,7 +397,7 @@ public final class FontCache implements Serializable { } return failedFontMap; } - + /** * Clears font cache */ @@ -411,7 +411,7 @@ public final class FontCache implements Serializable { changed = true; } } - + /** * Retrieve the last modified date/time of a URL. * @param url the URL @@ -432,7 +432,7 @@ public final class FontCache implements Serializable { return 0; } } - + private static class CachedFontFile implements Serializable { private static final long serialVersionUID = 4524237324330578883L; @@ -440,18 +440,18 @@ public final class FontCache implements Serializable { private long lastModified = -1; private Map/*<String, EmbedFontInfo>*/ filefontsMap = null; - + public CachedFontFile(long lastModified) { setLastModified(lastModified); } private Map/*<String, EmbedFontInfo>*/ getFileFontsMap() { if (filefontsMap == null) { - filefontsMap = new java.util.HashMap/*<String, EmbedFontInfo>*/(); + filefontsMap = new java.util.HashMap/*<String, EmbedFontInfo>*/(); } return filefontsMap; } - + void put(EmbedFontInfo efi) { getFileFontsMap().put(efi.getPostScriptName(), efi); } @@ -467,7 +467,7 @@ public final class FontCache implements Serializable { return (EmbedFontInfo[])getFileFontsMap().values().toArray( new EmbedFontInfo[getFileFontsMap().size()]); } - + /** * Gets the modified timestamp for font file (not always available) * @return modified timestamp @@ -478,15 +478,15 @@ public final class FontCache implements Serializable { /** * Gets the modified timestamp for font file - * (used for the purposes of font info caching) + * (used for the purposes of font info caching) * @param lastModified modified font file timestamp */ public void setLastModified(long lastModified) { this.lastModified = lastModified; } - + /** - * @return string representation of this object + * @return string representation of this object * {@inheritDoc} */ public String toString() { diff --git a/src/java/org/apache/fop/fonts/FontCollection.java b/src/java/org/apache/fop/fonts/FontCollection.java index c83f2523a..331d2639f 100644 --- a/src/java/org/apache/fop/fonts/FontCollection.java +++ b/src/java/org/apache/fop/fonts/FontCollection.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.fonts; diff --git a/src/java/org/apache/fop/fonts/FontDescriptor.java b/src/java/org/apache/fop/fonts/FontDescriptor.java index 73cb235e8..841d99de2 100644 --- a/src/java/org/apache/fop/fonts/FontDescriptor.java +++ b/src/java/org/apache/fop/fonts/FontDescriptor.java @@ -16,12 +16,12 @@ */ /* $Id$ */ - + package org.apache.fop.fonts; /** * This interface enhances the font metrics interface with access methods to - * value needed to register fonts in various target formats like PDF or + * value needed to register fonts in various target formats like PDF or * PostScript. */ public interface FontDescriptor extends FontMetrics { @@ -31,55 +31,55 @@ public interface FontDescriptor extends FontMetrics { * @return the ascender */ int getAscender(); - - + + /** * Returns the capital height of the font. * @return the capital height */ int getCapHeight(); - - + + /** * Returns the descender value of the font. (Descent in pdf spec) * @return the descender value */ int getDescender(); - - + + /** * Returns the flags for the font. (See pdf spec) * @return the flags */ int getFlags(); - - + + /** * Returns the font's bounding box. * @return the bounding box */ int[] getFontBBox(); - - + + /** * Returns the italic angle for the font. * @return the italic angle */ int getItalicAngle(); - - + + /** * Returns the vertical stem width for the font. * @return the vertical stem width */ int getStemV(); - + /** * Indicates if this font may be embedded. * @return True, if embedding is possible/permitted */ boolean isEmbeddable(); - - + + } diff --git a/src/java/org/apache/fop/fonts/FontInfo.java b/src/java/org/apache/fop/fonts/FontInfo.java index 9ac4c1e6a..4e327c782 100644 --- a/src/java/org/apache/fop/fonts/FontInfo.java +++ b/src/java/org/apache/fop/fonts/FontInfo.java @@ -39,34 +39,34 @@ import org.apache.commons.logging.LogFactory; * implemented. */ public class FontInfo { - + private static final FontTriplet[] TRIPLETS_TYPE = new FontTriplet[1]; - + /** logging instance */ protected static Log log = LogFactory.getLog(FontInfo.class); /** Map containing fonts that have been used */ private Map/*<String,FontMetrics>*/ usedFonts = null; //(String = font key) - + /** look up a font-triplet to find a font-name */ private Map/*<FontTriplet,String>*/ triplets = null; //(String = font key) - + /** look up a font-triplet to find its priority * (only used inside addFontProperties()) */ private Map/*<FontTriplet,Integer>*/ tripletPriorities = null; //Map<FontTriplet,Integer> /** look up a font-name to get a font (that implements FontMetrics at least) */ private Map/*<String,FontMetrics>*/ fonts = null; //(String = font key) - + /** - * a collection of missing fonts; used to make sure the user gets + * a collection of missing fonts; used to make sure the user gets * a warning for a missing font only once (not every time the font is used) */ private Set/*<FontTriplet>*/ loggedFontKeys = null; /** Cache for Font instances. */ private Map/*<FontTriplet, Map>*/ fontInstanceCache = null; - + /** Event listener for font events */ private FontEventListener eventListener = null; @@ -79,7 +79,7 @@ public class FontInfo { this.fonts = new java.util.HashMap/*<String, FontMetrics>*/(); this.usedFonts = new java.util.HashMap/*<String,FontMetrics>*/(); } - + /** * Sets the font event listener that can be used to receive events about particular events * in this class. @@ -88,9 +88,9 @@ public class FontInfo { public void setEventListener(FontEventListener listener) { this.eventListener = listener; } - + /** - * Checks if the font setup is valid (At least the ultimate fallback font + * Checks if the font setup is valid (At least the ultimate fallback font * must be registered.) * @return True if valid */ @@ -188,7 +188,7 @@ public class FontInfo { * @param family font family * @param style font style * @param weight font weight - * @param substFont true if the font may be substituted with the + * @param substFont true if the font may be substituted with the * default font if not found * @return internal font triplet key */ @@ -196,8 +196,8 @@ public class FontInfo { int weight, boolean substFont) { if (log.isTraceEnabled()) { log.trace("Font lookup: " + family + " " + style + " " + weight); - } - + } + FontTriplet startKey = createFontKey(family, style, weight); FontTriplet fontTriplet = startKey; // first try given parameters @@ -227,7 +227,7 @@ public class FontInfo { return key; } } - + // adjust weight, favouring normal or bold key = findAdjustWeight(family, style, weight); internalFontKey = getInternalFontKey(key); @@ -235,7 +235,7 @@ public class FontInfo { if (!substFont && internalFontKey == null) { return null; } - + // only if the font may be substituted // fallback 1: try the same font-family and weight with default style if (internalFontKey == null && style != Font.STYLE_NORMAL) { @@ -260,14 +260,14 @@ public class FontInfo { } } } - + // fallback 2: try the same font-family with default style and weight /* obsolete: replaced by the loop above if (f == null) { key = createFontKey(family, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL); f = getInternalFontKey(key); }*/ - + // fallback 3: try any family with orig style/weight if (internalFontKey == null) { return fuzzyFontLookup("any", style, weight, startKey, false); @@ -285,7 +285,7 @@ public class FontInfo { return null; } } - + /** * Tells this class that the font with the given internal name has been used. * @param internalName the internal font name (F1, F2 etc.) @@ -293,7 +293,7 @@ public class FontInfo { public void useFont(String internalName) { usedFonts.put(internalName, fonts.get(internalName)); } - + private Map/*<FontTriplet,Map<Integer,Font>>*/ getFontInstanceCache() { if (fontInstanceCache == null) { fontInstanceCache = new java.util.HashMap/*<FontTriplet, Map<Integer,Font>>*/(); @@ -302,7 +302,7 @@ public class FontInfo { } /** - * Retrieves a (possibly cached) Font instance based on a FontTriplet and a font size. + * Retrieves a (possibly cached) Font instance based on a FontTriplet and a font size. * @param triplet the font triplet designating the requested font * @param fontSize the font size * @return the requested Font instance @@ -325,7 +325,7 @@ public class FontInfo { } return font; } - + /** * Lookup a font. * <br> @@ -342,7 +342,7 @@ public class FontInfo { int weight) { return fontLookup(family, style, weight, true); } - + /** * Looks up a set of fonts. * <br> @@ -383,14 +383,14 @@ public class FontInfo { "fontLookup must return an array with at least one " + "FontTriplet on the last call. Lookup: " + sb.toString()); } - + private Set/*<FontTriplet>*/ getLoggedFontKeys() { if (loggedFontKeys == null) { loggedFontKeys = new java.util.HashSet/*<FontTriplet>*/(); } return loggedFontKeys; } - + private void notifyFontReplacement(FontTriplet replacedKey, FontTriplet newKey) { if (!getLoggedFontKeys().contains(replacedKey)) { getLoggedFontKeys().add(replacedKey); @@ -402,7 +402,7 @@ public class FontInfo { } } } - + /** * Find a font with a given family and style by trying * different font weights according to the spec. @@ -476,7 +476,7 @@ public class FontInfo { public String getInternalFontKey(FontTriplet triplet) { return (String)triplets.get(triplet); } - + /** * Creates a key from the given strings. * @param family font family @@ -504,7 +504,7 @@ public class FontInfo { public Map/*<FontTriplet,String>*/ getFontTriplets() { return this.triplets; } - + /** * This is used by the renderers to retrieve all the * fonts used in the document. @@ -541,7 +541,7 @@ public class FontInfo { } return foundTriplets; } - + /** * Returns the first triplet matching the given font name. * As there may be multiple triplets matching the font name @@ -557,7 +557,7 @@ public class FontInfo { } return null; } - + /** * Returns the font style for a particular font. * There may be multiple font styles matching this font. Only the first @@ -574,7 +574,7 @@ public class FontInfo { return ""; } } - + /** * Returns the font weight for a particular font. * There may be multiple font weights matching this font. Only the first @@ -591,14 +591,14 @@ public class FontInfo { return 0; } } - + /** - * Diagnostic method for logging all registered fonts to System.out. + * Diagnostic method for logging all registered fonts to System.out. */ public void dumpAllTripletsToSystemOut() { System.out.print(toString()); } - + /** * {@inheritDoc} */ @@ -608,7 +608,7 @@ public class FontInfo { while (iter.hasNext()) { FontTriplet triplet = (FontTriplet)iter.next(); String key = getInternalFontKey(triplet); - FontMetrics metrics = getMetricsFor(key); + FontMetrics metrics = getMetricsFor(key); entries.add(triplet.toString() + " -> " + key + " -> " + metrics.getFontName() + "\n"); } StringBuffer stringBuffer = new StringBuffer(); diff --git a/src/java/org/apache/fop/fonts/FontManager.java b/src/java/org/apache/fop/fonts/FontManager.java index d25d2d390..c180fbcc9 100644 --- a/src/java/org/apache/fop/fonts/FontManager.java +++ b/src/java/org/apache/fop/fonts/FontManager.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.fonts; @@ -29,7 +29,7 @@ import org.apache.fop.fonts.FontTriplet.Matcher; import org.apache.fop.fonts.substitute.FontSubstitutions; import org.apache.fop.render.PrintRenderer; -// TODO: Refactor fonts package so major font activities (autodetection etc) +// TODO: Refactor fonts package so major font activities (autodetection etc) // are all centrally managed and delegated from this class, also remove dependency on FopFactory // and start using POJO config/properties type classes @@ -62,7 +62,7 @@ public class FontManager { public FontManager() { setUseCache(DEFAULT_USE_CACHE); } - + /** * Sets the font base URL. * @param fontBase font base URL @@ -90,7 +90,7 @@ public class FontManager { * @param value true if kerning should be activated */ public void setBase14KerningEnabled(boolean value) { - this.enableBase14Kerning = value; + this.enableBase14Kerning = value; } /** @@ -100,7 +100,7 @@ public class FontManager { public void setFontSubstitutions(FontSubstitutions substitutions) { this.fontSubstitutions = substitutions; } - + /** * Returns the font substitution catalog * @return the font substitution catalog @@ -142,7 +142,7 @@ public class FontManager { public FontCache getFontCache() { return this.fontCache; } - + /** * Sets up the fonts on a given PrintRenderer * @param renderer a print renderer @@ -151,7 +151,7 @@ public class FontManager { FontInfo fontInfo = renderer.getFontInfo(); int startNum = 1; - + // Configure base 14 fonts org.apache.fop.fonts.base14.Base14FontCollection base14FontCollection = new org.apache.fop.fonts.base14.Base14FontCollection(this.enableBase14Kerning); @@ -161,7 +161,7 @@ public class FontManager { org.apache.fop.fonts.CustomFontCollection customFontCollection = new org.apache.fop.fonts.CustomFontCollection(renderer); startNum = customFontCollection.setup(startNum, fontInfo); - + // Make any defined substitutions in the font info getFontSubstitutions().adjustFontInfo(fontInfo); } @@ -179,7 +179,7 @@ public class FontManager { // setup base 14 fonts org.apache.fop.render.java2d.Base14FontCollection base14FontCollection = new org.apache.fop.render.java2d.Base14FontCollection(graphics2D); - + // setup any custom font collection startNum = base14FontCollection.setup(startNum, fontInfo); @@ -194,7 +194,7 @@ public class FontManager { startNum = configuredFontCollection.setup(startNum, fontInfo); // Make any defined substitutions in the font info - getFontSubstitutions().adjustFontInfo(fontInfo); + getFontSubstitutions().adjustFontInfo(fontInfo); } /** @return a new FontResolver to be used by the font subsystem */ diff --git a/src/java/org/apache/fop/fonts/FontManagerConfigurator.java b/src/java/org/apache/fop/fonts/FontManagerConfigurator.java index d44470e6b..7f1c267da 100644 --- a/src/java/org/apache/fop/fonts/FontManagerConfigurator.java +++ b/src/java/org/apache/fop/fonts/FontManagerConfigurator.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.fonts; @@ -37,12 +37,12 @@ import org.apache.fop.util.LogUtil; * Configurator of the FontManager */ public class FontManagerConfigurator { - + /** logger instance */ private static Log log = LogFactory.getLog(FontManagerConfigurator.class); private Configuration cfg; - + /** * Main constructor * @param cfg the font manager configuration object @@ -58,7 +58,7 @@ public class FontManagerConfigurator { * @throws FOPException if an exception occurs while processing the configuration */ public void configure(FontManager fontManager, boolean strict) throws FOPException { - + // caching (fonts) if (cfg.getChild("use-cache", false) != null) { try { @@ -84,12 +84,12 @@ public class FontManagerConfigurator { Configuration substitutionsCfg = fontsCfg.getChild("substitutions", false); if (substitutionsCfg != null) { FontSubstitutionsConfigurator fontSubstitutionsConfigurator - = new FontSubstitutionsConfigurator(substitutionsCfg); + = new FontSubstitutionsConfigurator(substitutionsCfg); FontSubstitutions substitutions = new FontSubstitutions(); fontSubstitutionsConfigurator.configure(substitutions); fontManager.setFontSubstitutions(substitutions); } - + // referenced fonts (fonts which are not to be embedded) Configuration referencedFontsCfg = fontsCfg.getChild("referenced-fonts", false); if (referencedFontsCfg != null) { @@ -121,11 +121,11 @@ public class FontManagerConfigurator { private static class OrFontTripletMatcher implements FontTriplet.Matcher { private FontTriplet.Matcher[] matchers; - + public OrFontTripletMatcher(FontTriplet.Matcher[] matchers) { this.matchers = matchers; } - + /** {@inheritDoc} */ public boolean matches(FontTriplet triplet) { for (int i = 0, c = matchers.length; i < c; i++) { @@ -135,22 +135,22 @@ public class FontManagerConfigurator { } return false; } - + } - + private static class FontFamilyRegExFontTripletMatcher implements FontTriplet.Matcher { private Pattern regex; - + public FontFamilyRegExFontTripletMatcher(String regex) { this.regex = Pattern.compile(regex); } - + /** {@inheritDoc} */ public boolean matches(FontTriplet triplet) { return regex.matcher(triplet.getName()).matches(); } - + } - + } diff --git a/src/java/org/apache/fop/fonts/FontSetup.java b/src/java/org/apache/fop/fonts/FontSetup.java index 9aa8440db..7629e67c3 100644 --- a/src/java/org/apache/fop/fonts/FontSetup.java +++ b/src/java/org/apache/fop/fonts/FontSetup.java @@ -182,7 +182,7 @@ public class FontSetup { // All base 14 configured now, so any custom embedded fonts start from 15 final int startNum = 15; - + /* Add configured fonts */ addConfiguredFonts(fontInfo, embedFontInfoList, startNum, resolver); } @@ -204,7 +204,7 @@ public class FontSetup { //Ensure that we have minimal font resolution capabilities resolver = createMinimalFontResolver1(); } - + String internalName = null; for (int i = 0; i < embedFontInfoList.size(); i++) { @@ -212,7 +212,7 @@ public class FontSetup { internalName = "F" + num; num++; - + LazyFont font = new LazyFont(embedFontInfo, resolver); fontInfo.addMetrics(internalName, font); @@ -234,5 +234,5 @@ public class FontSetup { return new StreamSource(href); } }; - } + } } diff --git a/src/java/org/apache/fop/fonts/FontTriplet.java b/src/java/org/apache/fop/fonts/FontTriplet.java index a989cf0f7..906698e53 100644 --- a/src/java/org/apache/fop/fonts/FontTriplet.java +++ b/src/java/org/apache/fop/fonts/FontTriplet.java @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.fonts; import java.io.Serializable; @@ -25,15 +25,15 @@ import java.io.Serializable; * FontTriplet contains information on name, style and weight of one font */ public class FontTriplet implements Comparable, Serializable { - + /** serial version UID */ private static final long serialVersionUID = 1168991106658033508L; - + private String name; private String style; private int weight; private int priority; // priority of this triplet/font mapping - + //This is only a cache private transient String key; @@ -78,7 +78,7 @@ public class FontTriplet implements Comparable, Serializable { public String getStyle() { return style; } - + /** @return the font weight */ public int getWeight() { return weight; @@ -96,7 +96,7 @@ public class FontTriplet implements Comparable, Serializable { } return this.key; } - + /** {@inheritDoc} */ public int compareTo(Object o) { return getKey().compareTo(((FontTriplet)o).getKey()); @@ -117,7 +117,7 @@ public class FontTriplet implements Comparable, Serializable { if (obj instanceof FontTriplet) { FontTriplet other = (FontTriplet)obj; return (getName().equals(other.getName()) - && getStyle().equals(other.getStyle()) + && getStyle().equals(other.getStyle()) && (getWeight() == other.getWeight())); } } @@ -128,13 +128,13 @@ public class FontTriplet implements Comparable, Serializable { public String toString() { return getKey(); } - - + + /** * Matcher interface for {@link FontTriplet}. */ public interface Matcher { - + /** * Indicates whether the given {@link FontTriplet} matches a particular criterium. * @param triplet the font triplet @@ -142,6 +142,6 @@ public class FontTriplet implements Comparable, Serializable { */ boolean matches(FontTriplet triplet); } - + } diff --git a/src/java/org/apache/fop/fonts/FontUtil.java b/src/java/org/apache/fop/fonts/FontUtil.java index d72e283cf..5df5707f0 100644 --- a/src/java/org/apache/fop/fonts/FontUtil.java +++ b/src/java/org/apache/fop/fonts/FontUtil.java @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.fonts; /** @@ -25,7 +25,7 @@ package org.apache.fop.fonts; public class FontUtil { /** - * Parses an CSS2 (SVG and XSL-FO) font weight (normal, bold, 100-900) to + * Parses an CSS2 (SVG and XSL-FO) font weight (normal, bold, 100-900) to * an integer. * See http://www.w3.org/TR/REC-CSS2/fonts.html#propdef-font-weight * TODO: Implement "lighter" and "bolder". @@ -47,7 +47,7 @@ public class FontUtil { weight = 700; } else { throw new IllegalArgumentException( - "Illegal value for font weight: '" + "Illegal value for font weight: '" + text + "'. Use one of: 100, 200, 300, " + "400, 500, 600, 700, 800, 900, " @@ -90,7 +90,7 @@ public class FontUtil { /** font constituent names which identify a font as being of "bold" weight */ private static final String[] BOLD_WORDS = {"bold"}; /** font constituent names which identify a font as being of "extra bold" weight */ - private static final String[] EXTRA_BOLD_WORDS = {"extrabold", "extra bold", "black", + private static final String[] EXTRA_BOLD_WORDS = {"extrabold", "extra bold", "black", "heavy", "ultra", "super"}; /** @@ -102,7 +102,7 @@ public class FontUtil { if (fontName != null) { for (int i = 0; i < ITALIC_WORDS.length; i++) { if (fontName.indexOf(ITALIC_WORDS[i]) != -1) { - return Font.STYLE_ITALIC; + return Font.STYLE_ITALIC; } } } @@ -117,18 +117,18 @@ public class FontUtil { public static int guessWeight(String fontName) { // weight int weight = Font.WEIGHT_NORMAL; - + for (int i = 0; i < BOLD_WORDS.length; i++) { if (fontName.indexOf(BOLD_WORDS[i]) != -1) { weight = Font.WEIGHT_BOLD; break; - } + } } for (int i = 0; i < MEDIUM_WORDS.length; i++) { if (fontName.indexOf(MEDIUM_WORDS[i]) != -1) { weight = Font.WEIGHT_NORMAL + 100; //500 break; - } + } } //Search for "semi/demi" before "light", but after "bold" //(normally semi/demi-bold is meant, but it can also be semi/demi-light) @@ -136,19 +136,19 @@ public class FontUtil { if (fontName.indexOf(DEMI_WORDS[i]) != -1) { weight = Font.WEIGHT_BOLD - 100; //600 break; - } + } } for (int i = 0; i < EXTRA_BOLD_WORDS.length; i++) { if (fontName.indexOf(EXTRA_BOLD_WORDS[i]) != -1) { weight = Font.WEIGHT_EXTRA_BOLD; break; - } + } } for (int i = 0; i < LIGHT_WORDS.length; i++) { if (fontName.indexOf(LIGHT_WORDS[i]) != -1) { weight = Font.WEIGHT_LIGHT; break; - } + } } return weight; } diff --git a/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java b/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java index 11b52f916..c0cc03276 100644 --- a/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java +++ b/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java @@ -44,22 +44,22 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder { /** default depth limit of recursion when searching for font files **/ public static final int DEFAULT_DEPTH_LIMIT = -1; - + /** - * Default constructor + * Default constructor */ public FontFileFinder() { super(getDirectoryFilter(), getFileFilter(), DEFAULT_DEPTH_LIMIT); } /** - * Constructor + * Constructor * @param depthLimit recursion depth limit */ public FontFileFinder(int depthLimit) { super(getDirectoryFilter(), getFileFilter(), depthLimit); } - + /** * Font directory filter. Currently ignores hidden directories. * @return IOFileFilter font directory filter @@ -70,7 +70,7 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder { FileFilterUtils.notFileFilter(FileFilterUtils.prefixFileFilter(".")) ); } - + /** * Font file filter. Currently searches for files with .ttf, .ttc, .otf, and .pfb extensions. * @return IOFileFilter font file filter @@ -83,13 +83,13 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder { IOCase.INSENSITIVE) ); } - + /** * @param directory directory to handle * @param depth recursion depth * @param results collection * @return whether directory should be handled - * {@inheritDoc} + * {@inheritDoc} */ protected boolean handleDirectory(File directory, int depth, Collection results) { return true; @@ -99,7 +99,7 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder { * @param file file to handle * @param depth recursion depth * @param results collection - * {@inheritDoc} + * {@inheritDoc} */ protected void handleFile(File file, int depth, Collection results) { try { @@ -109,7 +109,7 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder { log.debug("MalformedURLException" + e.getMessage()); } } - + /** * @param directory the directory being processed * @param depth the current directory level @@ -119,10 +119,10 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder { protected void handleDirectoryEnd(File directory, int depth, Collection results) { if (log.isDebugEnabled()) { log.debug(directory + ": found " + results.size() + " font" - + ((results.size() == 1) ? "" : "s")); + + ((results.size() == 1) ? "" : "s")); } - } - + } + /** * Automagically finds a list of font files on local system * @@ -162,5 +162,5 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder { List results = new java.util.ArrayList(); super.walk(new File(dir), results); return results; - } + } } diff --git a/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java b/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java index 987b7e918..9ab04282d 100644 --- a/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java +++ b/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java @@ -49,12 +49,12 @@ import org.apache.fop.fonts.truetype.TTFFontLoader; * Attempts to determine correct FontInfo */ public class FontInfoFinder { - + /** logging instance */ private Log log = LogFactory.getLog(FontInfoFinder.class); private FontEventListener eventListener; - + /** * Sets the font event listener that can be used to receive events about particular events * in this class. @@ -63,7 +63,7 @@ public class FontInfoFinder { public void setEventListener(FontEventListener listener) { this.eventListener = listener; } - + /** * Attempts to determine FontTriplets from a given CustomFont. * It seems to be fairly accurate but will probably require some tweaking over time @@ -73,9 +73,9 @@ public class FontInfoFinder { */ private void generateTripletsFromFont(CustomFont customFont, Collection triplets) { if (log.isTraceEnabled()) { - log.trace("Font: " + customFont.getFullName() - + ", family: " + customFont.getFamilyNames() - + ", PS: " + customFont.getFontName() + log.trace("Font: " + customFont.getFullName() + + ", family: " + customFont.getFamilyNames() + + ", PS: " + customFont.getFontName() + ", EmbedName: " + customFont.getEmbedFontName()); } @@ -87,7 +87,7 @@ public class FontInfoFinder { String style = guessStyle(customFont, searchName); int weight; //= customFont.getWeight(); - int guessedWeight = FontUtil.guessWeight(searchName); + int guessedWeight = FontUtil.guessWeight(searchName); //We always take the guessed weight for now since it yield much better results. //OpenType's OS/2 usWeightClass value proves to be unreliable. weight = guessedWeight; @@ -114,9 +114,9 @@ public class FontInfoFinder { } } } - + private final Pattern quotePattern = Pattern.compile("'"); - + private String stripQuotes(String name) { return quotePattern.matcher(name).replaceAll(""); } @@ -125,13 +125,13 @@ public class FontInfoFinder { // style String style = Font.STYLE_NORMAL; if (customFont.getItalicAngle() > 0) { - style = Font.STYLE_ITALIC; + style = Font.STYLE_ITALIC; } else { style = FontUtil.guessStyle(fontName); } return style; } - + /** * Attempts to determine FontInfo from a given custom font * @param fontUrl the font URL @@ -151,13 +151,13 @@ public class FontInfoFinder { } EmbedFontInfo fontInfo = new EmbedFontInfo(null, customFont.isKerningEnabled(), fontTripletList, embedUrl, subFontName); - fontInfo.setPostScriptName(customFont.getFontName()); + fontInfo.setPostScriptName(customFont.getFontName()); if (fontCache != null) { fontCache.addFont(fontInfo); } return fontInfo; } - + /** * Attempts to determine EmbedFontInfo from a given font file. * @@ -170,7 +170,7 @@ public class FontInfoFinder { public EmbedFontInfo[] find(URL fontUrl, FontResolver resolver, FontCache fontCache) { String embedUrl = null; embedUrl = fontUrl.toExternalForm(); - + long fileLastModified = -1; if (fontCache != null) { fileLastModified = FontCache.getLastModified(fontUrl); @@ -188,8 +188,8 @@ public class FontInfoFinder { return null; } } - - + + // try to determine triplet information from font file CustomFont customFont = null; if (fontUrl.toExternalForm().endsWith(".ttc")) { @@ -241,7 +241,7 @@ public class FontInfoFinder { EmbedFontInfo fi = getFontInfoFromCustomFont(fontUrl, customFont, fontCache); if (fi != null) { embedFontInfoList.add(fi); - } + } } return (EmbedFontInfo[])embedFontInfoList.toArray( new EmbedFontInfo[embedFontInfoList.size()]); diff --git a/src/java/org/apache/fop/fonts/base14/Base14FontCollection.java b/src/java/org/apache/fop/fonts/base14/Base14FontCollection.java index 68324f13a..7bebccc88 100644 --- a/src/java/org/apache/fop/fonts/base14/Base14FontCollection.java +++ b/src/java/org/apache/fop/fonts/base14/Base14FontCollection.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.fonts.base14; @@ -27,7 +27,7 @@ import org.apache.fop.fonts.FontInfo; * Sets up Base 14 fonts */ public class Base14FontCollection implements FontCollection { - + private boolean kerning = false; /** @@ -38,7 +38,7 @@ public class Base14FontCollection implements FontCollection { public Base14FontCollection(boolean kerning) { this.kerning = kerning; } - + /** * {@inheritDoc} */ @@ -143,7 +143,7 @@ public class Base14FontCollection implements FontCollection { fontInfo.addFontProperties("F8", "Times Roman", Font.STYLE_ITALIC, Font.WEIGHT_BOLD); fontInfo.addFontProperties("F9", "Computer-Modern-Typewriter", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL); - + return 15; } } diff --git a/src/java/org/apache/fop/fonts/substitute/AttributeValue.java b/src/java/org/apache/fop/fonts/substitute/AttributeValue.java index 1c697dc02..44f2ff571 100644 --- a/src/java/org/apache/fop/fonts/substitute/AttributeValue.java +++ b/src/java/org/apache/fop/fonts/substitute/AttributeValue.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.fonts.substitute; @@ -25,7 +25,7 @@ import java.util.StringTokenizer; * Encapsulates a font attribute value */ public class AttributeValue extends java.util.ArrayList { - + private static final long serialVersionUID = 748610847500940557L; /** @@ -38,15 +38,15 @@ public class AttributeValue extends java.util.ArrayList { */ public static AttributeValue valueOf(String valuesString) { AttributeValue attribute = new AttributeValue(); - StringTokenizer stringTokenzier = new StringTokenizer(valuesString, ","); - if (stringTokenzier.countTokens() > 1) { - while (stringTokenzier.hasMoreTokens()) { - String token = stringTokenzier.nextToken().trim(); + StringTokenizer stringTokenizer = new StringTokenizer(valuesString, ","); + if (stringTokenizer.countTokens() > 1) { + while (stringTokenizer.hasMoreTokens()) { + String token = stringTokenizer.nextToken().trim(); AttributeValue tokenAttribute = AttributeValue.valueOf(token); attribute.addAll(tokenAttribute); } } else { - String token = stringTokenzier.nextToken().trim(); + String token = stringTokenizer.nextToken().trim(); Object value = null; try { value = Integer.valueOf(token); @@ -60,6 +60,6 @@ public class AttributeValue extends java.util.ArrayList { attribute.add(value); } } - return attribute; + return attribute; } } diff --git a/src/java/org/apache/fop/fonts/substitute/FontQualifier.java b/src/java/org/apache/fop/fonts/substitute/FontQualifier.java index a68bb2ccd..63ec13db1 100644 --- a/src/java/org/apache/fop/fonts/substitute/FontQualifier.java +++ b/src/java/org/apache/fop/fonts/substitute/FontQualifier.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.fonts.substitute; @@ -32,7 +32,7 @@ import org.apache.fop.fonts.FontTriplet; import org.apache.fop.fonts.FontUtil; /** - * Encapsulates a font substitution qualifier + * Encapsulates a font substitution qualifier */ public class FontQualifier { @@ -47,15 +47,15 @@ public class FontQualifier { /** font weight attribute value */ private AttributeValue fontWeightAttributeValue = null; - + /** * Default constructor */ public FontQualifier() { } - + /** - * Sets the font family + * Sets the font family * @param fontFamily the font family */ public void setFontFamily(String fontFamily) { @@ -66,20 +66,20 @@ public class FontQualifier { } this.fontFamilyAttributeValue = fontFamilyAttribute; } - + /** - * Sets the font style + * Sets the font style * @param fontStyle the font style */ public void setFontStyle(String fontStyle) { AttributeValue fontStyleAttribute = AttributeValue.valueOf(fontStyle); if (fontStyleAttribute != null) { - this.fontStyleAttributeValue = fontStyleAttribute; + this.fontStyleAttributeValue = fontStyleAttribute; } } /** - * Sets the font weight + * Sets the font weight * @param fontWeight the font weight */ public void setFontWeight(String fontWeight) { @@ -100,7 +100,7 @@ public class FontQualifier { this.fontWeightAttributeValue = fontWeightAttribute; } } - + /** * @return the font family attribute */ @@ -117,7 +117,7 @@ public class FontQualifier { } return this.fontStyleAttributeValue; } - + /** * @return the font weight attribute */ @@ -141,7 +141,7 @@ public class FontQualifier { public boolean hasFontStyle() { return this.fontStyleAttributeValue != null; } - + /** * Returns a list of matching font triplet found in a given font info * @@ -154,7 +154,7 @@ public class FontQualifier { AttributeValue styleValue = getFontStyle(); List/*<FontTriplet>*/ matchingTriplets = new java.util.ArrayList/*<FontTriplet>*/(); - + // try to find matching destination font triplet for (Iterator attrIt = fontFamilyValue.iterator(); attrIt.hasNext();) { String fontFamilyString = (String)attrIt.next(); @@ -165,7 +165,7 @@ public class FontQualifier { tripletIt.hasNext();) { FontTriplet triplet = (FontTriplet)tripletIt.next(); String fontName = triplet.getName(); - + // matched font family name if (fontFamilyString.toLowerCase().equals(fontName.toLowerCase())) { @@ -194,7 +194,7 @@ public class FontQualifier { } } } - + // try and match font style boolean styleMatched = false; String fontStyleString = triplet.getStyle(); @@ -204,17 +204,17 @@ public class FontQualifier { styleMatched = true; } } - + if (weightMatched && styleMatched) { matchingTriplets.add(triplet); } } } - } + } } return matchingTriplets; } - + /** * Returns the highest priority matching font triplet found in a given font info * @param fontInfo the font info @@ -240,25 +240,25 @@ public class FontQualifier { } return bestTriplet; } - + /** * @return a list of font triplets matching this qualifier */ public List/*<FontTriplet>*/ getTriplets() { List/*<FontTriplet>*/ triplets = new java.util.ArrayList/*<FontTriplet>*/(); - + AttributeValue fontFamilyValue = getFontFamily(); for (Iterator fontFamilyIt = fontFamilyValue.iterator(); fontFamilyIt.hasNext();) { String name = (String)fontFamilyIt.next(); - + AttributeValue styleValue = getFontStyle(); for (Iterator styleIt = styleValue.iterator(); styleIt.hasNext();) { String style = (String)styleIt.next(); - + AttributeValue weightValue = getFontWeight(); for (Iterator weightIt = weightValue.iterator(); weightIt.hasNext();) { Object weightObj = weightIt.next(); - + if (weightObj instanceof FontWeightRange) { FontWeightRange fontWeightRange = (FontWeightRange)weightObj; int[] weightRange = fontWeightRange.toArray(); @@ -292,14 +292,14 @@ public class FontQualifier { if (str.length() > 0) { str += ", "; } - str += "font-style=" + fontStyleAttributeValue; + str += "font-style=" + fontStyleAttributeValue; } if (fontWeightAttributeValue != null) { if (str.length() > 0) { str += ", "; } - str += "font-weight=" + fontWeightAttributeValue; + str += "font-weight=" + fontWeightAttributeValue; } return str; } -}
\ No newline at end of file +} diff --git a/src/java/org/apache/fop/fonts/substitute/FontSubstitution.java b/src/java/org/apache/fop/fonts/substitute/FontSubstitution.java index 5f71e7b7c..7e9709a51 100644 --- a/src/java/org/apache/fop/fonts/substitute/FontSubstitution.java +++ b/src/java/org/apache/fop/fonts/substitute/FontSubstitution.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.fonts.substitute; @@ -23,7 +23,7 @@ package org.apache.fop.fonts.substitute; * Encapsulates a pair of substitution qualifiers */ public class FontSubstitution { - + private FontQualifier fromQualifier; private FontQualifier toQualifier; @@ -51,11 +51,11 @@ public class FontSubstitution { public FontQualifier getToQualifier() { return toQualifier; } - + /** * {@inheritDoc} */ public String toString() { return "from=" + fromQualifier + ", to=" + toQualifier; } -}
\ No newline at end of file +} diff --git a/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java b/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java index 346b967e2..cc4e74143 100644 --- a/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java +++ b/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.fonts.substitute; @@ -44,9 +44,9 @@ public class FontSubstitutions extends java.util.ArrayList/*<Substitutions>*/ { public void adjustFontInfo(FontInfo fontInfo) { for (Iterator/*<FontSubstitution>*/ subsIt = super.iterator(); subsIt.hasNext();) { FontSubstitution substitution = (FontSubstitution)subsIt.next(); - + // find the best matching font triplet - FontQualifier toQualifier = substitution.getToQualifier(); + FontQualifier toQualifier = substitution.getToQualifier(); FontTriplet fontTriplet = toQualifier.bestMatch(fontInfo); if (fontTriplet == null) { log.error("Unable to match font substitution for destination qualifier " @@ -54,7 +54,7 @@ public class FontSubstitutions extends java.util.ArrayList/*<Substitutions>*/ { continue; } String internalFontKey = fontInfo.getInternalFontKey(fontTriplet); - + FontQualifier fromQualifier = substitution.getFromQualifier(); List/*<FontTriplet>*/ tripletList = fromQualifier.getTriplets(); for (Iterator tripletit = tripletList.iterator(); tripletit.hasNext();) { @@ -62,5 +62,5 @@ public class FontSubstitutions extends java.util.ArrayList/*<Substitutions>*/ { fontInfo.addFontProperties(internalFontKey, triplet); } } - } + } } diff --git a/src/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.java b/src/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.java index 53045c601..44950221d 100644 --- a/src/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.java +++ b/src/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.fonts.substitute; @@ -37,7 +37,7 @@ public class FontSubstitutionsConfigurator { public FontSubstitutionsConfigurator(Configuration cfg) { this.cfg = cfg; } - + private static FontQualifier getQualfierFromConfiguration(Configuration cfg) throws FOPException { String fontFamily = cfg.getAttribute("font-family", null); @@ -56,7 +56,7 @@ public class FontSubstitutionsConfigurator { } return qualifier; } - + /** * Configures a font substitution catalog * @@ -74,7 +74,7 @@ public class FontSubstitutionsConfigurator { if (fromCfg == null) { throw new FOPException("'substitution' element without child 'to' element"); } - FontQualifier fromQualifier = getQualfierFromConfiguration(fromCfg); + FontQualifier fromQualifier = getQualfierFromConfiguration(fromCfg); FontQualifier toQualifier = getQualfierFromConfiguration(toCfg); FontSubstitution substitution = new FontSubstitution(fromQualifier, toQualifier); substitutions.add(substitution); diff --git a/src/java/org/apache/fop/fonts/substitute/FontWeightRange.java b/src/java/org/apache/fop/fonts/substitute/FontWeightRange.java index 630bc1895..890d6cf7b 100644 --- a/src/java/org/apache/fop/fonts/substitute/FontWeightRange.java +++ b/src/java/org/apache/fop/fonts/substitute/FontWeightRange.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.fonts.substitute; @@ -23,13 +23,12 @@ import java.util.StringTokenizer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.fop.fonts.FontUtil; /** * Encapsulates a range of font weight values */ public class FontWeightRange { - + /** logging instance */ protected static Log log = LogFactory.getLog("org.apache.fop.render.fonts"); @@ -68,7 +67,7 @@ public class FontWeightRange { /** the start range */ private int start; - + /** the end range */ private int end; @@ -81,7 +80,7 @@ public class FontWeightRange { this.start = start; this.end = end; } - + /** * Returns true if the given integer value is within this integer range * @param value the integer value @@ -90,7 +89,7 @@ public class FontWeightRange { public boolean isWithinRange(int value) { return (value >= start && value <= end); } - + /** * {@inheritDoc} */ @@ -111,5 +110,5 @@ public class FontWeightRange { range[i] = start + (i * 100); } return range; - } + } } diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java index f83434f47..1a7b6b710 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java @@ -38,7 +38,7 @@ import org.apache.fop.fo.flow.RetrieveMarker; /** * The base class for most LayoutManagers. */ -public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager +public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager implements Constants { /** @@ -57,13 +57,13 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager /** True if this LayoutManager has handled all of its content. */ private boolean bFinished = false; - + /** child LM during getNextKnuthElement phase */ protected LayoutManager curChildLM = null; - + /** child LM iterator during getNextKnuthElement phase */ protected ListIterator childLMiter = null; - + private int lastGeneratedPosition = -1; private int smallestPosNumberChecked = Integer.MAX_VALUE; @@ -154,7 +154,7 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager } /** - * {@inheritDoc} + * {@inheritDoc} */ public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { @@ -164,7 +164,7 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager } /** - * {@inheritDoc} + * {@inheritDoc} */ public LinkedList getChangedKnuthElements(List oldList, int alignment) { @@ -229,20 +229,20 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager public PageSequenceLayoutManager getPSLM() { return parentLM.getPSLM(); } - + /** * @see PageSequenceLayoutManager#getCurrentPage() * @return the {@link Page} instance corresponding to the current page */ public Page getCurrentPage() { return getPSLM().getCurrentPage(); - } - + } + /** @return the current page viewport */ public PageViewport getCurrentPV() { return getPSLM().getCurrentPage().getPageViewport(); - } - + } + /** * {@inheritDoc} */ @@ -306,7 +306,7 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager pos.setIndex(lastGeneratedPosition); return pos; } - + /** * Indicates whether the given Position is the first area-generating Position of this LM. * @param pos the Position (must be one with a position index) @@ -326,7 +326,7 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager return false; } } - + /** * Indicates whether the given Position is the last area-generating Position of this LM. * @param pos the Position (must be one with a position index) @@ -349,7 +349,7 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager Map atts = fobj.getForeignAttributes(); targetArea.setForeignAttributes(atts); } - + /** * Registers the FO's markers on the current PageViewport * @@ -360,9 +360,9 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager protected void addMarkersToPage(boolean isStarting, boolean isFirst, boolean isLast) { if (this.markers != null) { getCurrentPV().addMarkers( - this.markers, - isStarting, - isFirst, + this.markers, + isStarting, + isFirst, isLast); } } @@ -390,5 +390,5 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager public String toString() { return (super.toString() + (fobj != null ? "[fobj=" + fobj.toString() + "]" : "")); } - + } diff --git a/src/java/org/apache/fop/render/AbstractRendererConfigurator.java b/src/java/org/apache/fop/render/AbstractRendererConfigurator.java index bce5abfbd..982b23f05 100644 --- a/src/java/org/apache/fop/render/AbstractRendererConfigurator.java +++ b/src/java/org/apache/fop/render/AbstractRendererConfigurator.java @@ -36,7 +36,7 @@ public abstract class AbstractRendererConfigurator { /** fop factory configuration */ protected FOUserAgent userAgent = null; - + /** * Default constructor * @param userAgent user agent @@ -45,7 +45,7 @@ public abstract class AbstractRendererConfigurator { super(); this.userAgent = userAgent; } - + /** * Returns the configuration subtree for a specific renderer. * @param renderer the renderer @@ -59,7 +59,7 @@ public abstract class AbstractRendererConfigurator { } return null; } - + return getRendererConfig(mimeType); } @@ -74,11 +74,11 @@ public abstract class AbstractRendererConfigurator { if (log.isDebugEnabled()) { log.debug("userconfig is null"); } - return null; + return null; } - + Configuration userRendererConfig = null; - + Configuration[] cfgs = cfg.getChild("renderers").getChildren("renderer"); for (int i = 0; i < cfgs.length; ++i) { diff --git a/src/java/org/apache/fop/render/PrintRenderer.java b/src/java/org/apache/fop/render/PrintRenderer.java index 23f8a1f62..c37012cb4 100644 --- a/src/java/org/apache/fop/render/PrintRenderer.java +++ b/src/java/org/apache/fop/render/PrintRenderer.java @@ -45,7 +45,7 @@ public abstract class PrintRenderer extends AbstractRenderer { /** list of fonts */ protected List/*<EmbedFontInfo>*/ embedFontInfoList = null; - + /** * Adds a font list to current list of fonts * @param fontList a font info list @@ -57,7 +57,7 @@ public abstract class PrintRenderer extends AbstractRenderer { fontList.addAll(fontList); } } - + /** * @param embedFontInfoList list of available fonts */ @@ -91,7 +91,7 @@ public abstract class PrintRenderer extends AbstractRenderer { FontTriplet triplet = (FontTriplet)area.getTrait(Trait.FONT); return fontInfo.getInternalFontKey(triplet); } - + /** * Returns a Font object constructed based on the font traits in an area * @param area the area from which to retrieve the font triplet information @@ -102,7 +102,7 @@ public abstract class PrintRenderer extends AbstractRenderer { int size = ((Integer)area.getTrait(Trait.FONT_SIZE)).intValue(); return fontInfo.getFontInstance(triplet, size); } - + /** * Lightens up a color for groove, ridge, inset and outset border effects. * @param col the color to lighten up @@ -135,7 +135,7 @@ public abstract class PrintRenderer extends AbstractRenderer { * @param foreignAttributes a Map or foreign attributes, may be null * @return the RendererContext */ - protected RendererContext createRendererContext(int x, int y, int width, int height, + protected RendererContext createRendererContext(int x, int y, int width, int height, Map foreignAttributes) { RendererContext context; context = new RendererContext(this, getMimeType()); @@ -149,7 +149,7 @@ public abstract class PrintRenderer extends AbstractRenderer { new Integer(x)); context.setProperty(RendererContextConstants.YPOS, new Integer(y)); - context.setProperty(RendererContextConstants.PAGE_VIEWPORT, + context.setProperty(RendererContextConstants.PAGE_VIEWPORT, getCurrentPageViewport()); if (foreignAttributes != null) { context.setProperty(RendererContextConstants.FOREIGN_ATTRIBUTES, foreignAttributes); @@ -165,12 +165,12 @@ public abstract class PrintRenderer extends AbstractRenderer { * @param foreignAttributes the foreign attributes containing rendering hints, or null */ public void renderDocument(Document doc, String ns, Rectangle2D pos, Map foreignAttributes) { - int x = currentIPPosition + (int) pos.getX(); + int x = currentIPPosition + (int) pos.getX(); int y = currentBPPosition + (int) pos.getY(); int width = (int)pos.getWidth(); int height = (int)pos.getHeight(); RendererContext context = createRendererContext(x, y, width, height, foreignAttributes); - + renderXML(context, doc, ns); } @@ -185,7 +185,7 @@ public abstract class PrintRenderer extends AbstractRenderer { } return this.fontResolver; } - + /** * @return the font info */ diff --git a/src/java/org/apache/fop/render/PrintRendererConfigurator.java b/src/java/org/apache/fop/render/PrintRendererConfigurator.java index 50d06932d..6849f867f 100644 --- a/src/java/org/apache/fop/render/PrintRendererConfigurator.java +++ b/src/java/org/apache/fop/render/PrintRendererConfigurator.java @@ -55,7 +55,7 @@ import org.apache.fop.util.LogUtil; /** * Base Print renderer configurator (mostly handles font configuration) */ -public class PrintRendererConfigurator extends AbstractRendererConfigurator +public class PrintRendererConfigurator extends AbstractRendererConfigurator implements RendererConfigurator { /** logger instance */ @@ -94,9 +94,9 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator boolean strict = factory.validateUserConfigStrictly(); FontCache fontCache = fontManager.getFontCache(); - List/*<EmbedFontInfo>*/ embedFontInfoList = buildFontListFromConfiguration(cfg, + List/*<EmbedFontInfo>*/ embedFontInfoList = buildFontListFromConfiguration(cfg, fontResolver, strict, fontManager); - + if (fontCache != null && fontCache.hasChanged()) { fontCache.save(); } @@ -113,13 +113,13 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator * @return a List of EmbedFontInfo objects. * @throws FOPException If an error occurs while processing the configuration */ - public static List/*<EmbedFontInfo>*/ buildFontListFromConfiguration(Configuration cfg, - FontResolver fontResolver, + public static List/*<EmbedFontInfo>*/ buildFontListFromConfiguration(Configuration cfg, + FontResolver fontResolver, boolean strict, FontManager fontManager) throws FOPException { FontCache fontCache = fontManager.getFontCache(); String fontBaseURL = fontManager.getFontBaseURL(); List/*<EmbedFontInfo>*/ fontInfoList - = new java.util.ArrayList/*<EmbedFontInfo>*/(); + = new java.util.ArrayList/*<EmbedFontInfo>*/(); Configuration fonts = cfg.getChild("fonts", false); if (fonts != null) { @@ -128,7 +128,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator log.debug("Starting font configuration..."); start = System.currentTimeMillis(); } - + // native o/s search (autodetect) configuration boolean autodetectFonts = (fonts.getChild("auto-detect", false) != null); if (autodetectFonts) { @@ -203,7 +203,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator LogUtil.handleException(log, e, strict); } } - + // font file (singular) configuration Configuration[] font = fonts.getChildren("font"); for (int i = 0; i < font.length; i++) { @@ -216,9 +216,9 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator // Update referenced fonts (fonts which are not to be embedded) updateReferencedFonts(fontInfoList, fontManager.getReferencedFontsMatcher()); - + if (log.isDebugEnabled()) { - log.debug("Finished font configuration in " + log.debug("Finished font configuration in " + (System.currentTimeMillis() - start) + "ms"); } } @@ -243,7 +243,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator } } - + /** * Iterates over font file list adding font info to list * @param fontFileList font file list @@ -258,7 +258,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator // parse font to ascertain font info FontInfoFinder finder = new FontInfoFinder(); //EmbedFontInfo fontInfo = finder.find(fontUrl, resolver, fontCache); - + //List<EmbedFontInfo> embedFontInfoList = finder.find(fontUrl, resolver, fontCache); EmbedFontInfo[] embedFontInfos = finder.find(fontUrl, resolver, fontCache); @@ -299,14 +299,14 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator LogUtil.handleError(log, "font-triplet without name", strict); return null; } - + String weightStr = tripletCfg.getAttribute("weight"); if (weightStr == null) { LogUtil.handleError(log, "font-triplet without weight", strict); return null; } int weight = FontUtil.parseCSS2FontWeight(FontUtil.stripWhiteSpace(weightStr)); - + String style = tripletCfg.getAttribute("style"); if (style == null) { LogUtil.handleError(log, "font-triplet without style", strict); @@ -320,7 +320,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator } return null; } - + /** * Returns a font info from a font node Configuration definition * @@ -337,7 +337,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator String metricsUrl = fontCfg.getAttribute("metrics-url", null); String embedUrl = fontCfg.getAttribute("embed-url", null); String subFont = fontCfg.getAttribute("sub-font", null); - + if (metricsUrl == null && embedUrl == null) { LogUtil.handleError(log, "Font configuration without metric-url or embed-url attribute", @@ -366,13 +366,13 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator } } } - + Configuration[] tripletCfg = fontCfg.getChildren("font-triplet"); - + // no font triplet info if (tripletCfg.length == 0) { LogUtil.handleError(log, "font without font-triplet", strict); - + File fontFile = FontCache.getFileFromUrls(new String[] {embedUrl, metricsUrl}); URL fontUrl; try { @@ -384,28 +384,28 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator } if (fontFile != null) { FontInfoFinder finder = new FontInfoFinder(); - EmbedFontInfo[] infos = finder.find(fontUrl, fontResolver, fontCache); + EmbedFontInfo[] infos = finder.find(fontUrl, fontResolver, fontCache); return infos[0]; //When subFont is set, only one font is returned } else { return null; } } - + List/*<FontTriplet>*/ tripletList = new java.util.ArrayList/*<FontTriplet>*/(); for (int j = 0; j < tripletCfg.length; j++) { FontTriplet fontTriplet = getFontTripletFromConfiguration(tripletCfg[j], strict); tripletList.add(fontTriplet); } - + boolean useKerning = fontCfg.getAttributeAsBoolean("kerning", true); EmbedFontInfo embedFontInfo - = new EmbedFontInfo(metricsUrl, useKerning, tripletList, embedUrl, subFont); + = new EmbedFontInfo(metricsUrl, useKerning, tripletList, embedUrl, subFont); if (fontCache != null) { if (!fontCache.containsFont(embedFontInfo)) { - fontCache.addFont(embedFontInfo); + fontCache.addFont(embedFontInfo); } } - + if (log.isDebugEnabled()) { String embedFile = embedFontInfo.getEmbedFile(); log.debug("Adding font " + (embedFile != null ? embedFile + ", " : "") @@ -417,8 +417,8 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator + triplet.getStyle() + ", " + triplet.getWeight()); } - } + } return embedFontInfo; } - + } diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java index bdbf207d4..045ba9835 100644 --- a/src/java/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java @@ -497,7 +497,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { AffineTransform positionTransform = new AffineTransform(); positionTransform.translate(bv.getXOffset(), bv.getYOffset()); - + //"left/"top" (bv.getX/YOffset()) specify the position of the content rectangle positionTransform.translate(-borderPaddingStart, -borderPaddingBefore); @@ -506,7 +506,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { //saveGraphicsState(); //Viewport position //concatenateTransformationMatrix(mptToPt(positionTransform)); - + //Background and borders float bpwidth = (borderPaddingStart + bv.getBorderAndPaddingWidthEnd()) / 1000f; float bpheight = (borderPaddingBefore + bv.getBorderAndPaddingWidthAfter()) / 1000f; @@ -537,7 +537,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { //concatenateTransformationMatrix(mptToPt(contentTransform)); contentRect = new Rectangle2D.Double(0, 0, 1000 * width, 1000 * height); pushViewPortPos(new ViewPortPos(contentRect, new CTM(contentTransform))); - + currentIPPosition = 0; currentBPPosition = 0; renderBlocks(bv, children); @@ -595,7 +595,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { //Not used here since AFPRenderer defines its own renderBlockViewport() method. throw new UnsupportedOperationException("NYI"); } - + /** * {@inheritDoc} */ @@ -919,7 +919,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {ImageFlavor.RAW_CCITTFAX, ImageFlavor.GRAPHICS2D, - ImageFlavor.BUFFERED_IMAGE, + ImageFlavor.BUFFERED_IMAGE, ImageFlavor.RENDERED_IMAGE, ImageFlavor.XML_DOM}; @@ -947,12 +947,12 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { try { ImageSessionContext sessionContext = getUserAgent().getImageSessionContext(); info = manager.getImageInfo(uri, sessionContext); - + //Only now fully load/prepare the image Map hints = ImageUtil.getDefaultHints(sessionContext); org.apache.xmlgraphics.image.loader.Image img = manager.getImage( info, FLAVORS, hints, sessionContext); - + //...and process the image if (img instanceof ImageGraphics2D) { ImageGraphics2D imageG2D = (ImageGraphics2D)img; @@ -966,7 +966,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { } else if (img instanceof ImageRendered) { ImageRendered imgRend = (ImageRendered)img; RenderedImage ri = imgRend.getRenderedImage(); - + drawBufferedImage(ri, getResolution(), posInt.x + currentIPPosition, posInt.y + currentBPPosition, @@ -1029,7 +1029,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { getUserAgent().getEventBroadcaster()); eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null); } - + /* ImageFactory fact = userAgent.getFactory().getImageFactory(); FopImage fopimage = fact.getImage(url, userAgent); @@ -1102,7 +1102,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { if (!fopimage.load(FopImage.BITMAP)) { return; } - convertToGrayScaleImage(io, fopimage.getBitmaps(), + convertToGrayScaleImage(io, fopimage.getBitmaps(), fopimage.getWidth(), fopimage.getHeight()); } } else { @@ -1413,9 +1413,9 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { */ // UNUSED // public void setOptions(Map options) { -// +// // this.afpOptions = options; -// +// // } /** * Determines the orientation from the string representation, this method @@ -1482,7 +1482,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { /** * Sets the rotation to be used for landsacpe pages, valid values are 0, 90, * 180, 270 (default). - * + * * @param rotation * The rotation in degrees. */ @@ -1649,7 +1649,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { io.setImageIDESize((byte) bitsPerPixel); io.setImageData(bw); } - + private final class ViewPortPos { private int x = 0; @@ -1805,7 +1805,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { } this.resolution = resolution; } - + /** * Returns the output/device resolution. * @return the resolution in dpi diff --git a/src/java/org/apache/fop/render/java2d/Base14FontCollection.java b/src/java/org/apache/fop/render/java2d/Base14FontCollection.java index f97a68191..ca4a4bce3 100644 --- a/src/java/org/apache/fop/render/java2d/Base14FontCollection.java +++ b/src/java/org/apache/fop/render/java2d/Base14FontCollection.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.java2d; @@ -31,7 +31,7 @@ import org.apache.fop.fonts.FontInfo; public class Base14FontCollection implements FontCollection { private Graphics2D graphics2d = null; - + /** * Main constructor * @param graphics2d a graphics 2D @@ -39,7 +39,7 @@ public class Base14FontCollection implements FontCollection { public Base14FontCollection(Graphics2D graphics2d) { this.graphics2d = graphics2d; } - + /** * {@inheritDoc} */ @@ -175,7 +175,7 @@ public class Base14FontCollection implements FontCollection { fontInfo.addFontProperties("F8", "Times Roman", Font.STYLE_ITALIC, Font.WEIGHT_BOLD); fontInfo.addFontProperties("F9", "Computer-Modern-Typewriter", "normal", Font.WEIGHT_NORMAL); - + return 15; } } diff --git a/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java b/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java index 4981905fa..843ab8413 100644 --- a/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java +++ b/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.java2d; @@ -54,7 +54,7 @@ public class ConfiguredFontCollection implements FontCollection { public ConfiguredFontCollection(PrintRenderer renderer) { this.renderer = renderer; } - + /** * {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/java2d/InstalledFontCollection.java b/src/java/org/apache/fop/render/java2d/InstalledFontCollection.java index 4cdd30c41..4eac922e8 100644 --- a/src/java/org/apache/fop/render/java2d/InstalledFontCollection.java +++ b/src/java/org/apache/fop/render/java2d/InstalledFontCollection.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.java2d; @@ -67,7 +67,7 @@ public class InstalledFontCollection implements FontCollection { public InstalledFontCollection(Graphics2D graphics2D) { this.graphics2D = graphics2D; } - + /** * {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java index eea165525..e39ae5831 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java +++ b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java @@ -129,17 +129,17 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem /** false: paints a non-transparent white background, true: for a transparent background */ protected boolean transparentPageBackground = false; - + /** The current state, holds a Graphics2D and its context */ protected Java2DGraphicsState state; - + private Stack stateStack = new Stack(); /** true if the renderer has finished rendering all the pages */ private boolean renderingDone; private GeneralPath currentPath = null; - + /** Default constructor */ public Java2DRenderer() { } @@ -150,7 +150,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem public void setUserAgent(FOUserAgent foUserAgent) { super.setUserAgent(foUserAgent); userAgent.setRendererOverride(this); // for document regeneration - + String s = (String)userAgent.getRendererOptions().get(JAVA2D_TRANSPARENT_PAGE_BACKGROUND); if (s != null) { this.transparentPageBackground = "true".equalsIgnoreCase(s); @@ -173,9 +173,9 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem BufferedImage.TYPE_INT_RGB); Graphics2D graphics2D = fontImage.createGraphics(); //The next line is important to get accurate font metrics! - graphics2D.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, + graphics2D.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); - + userAgent.getFactory().getFontManager().setupRenderer(this, graphics2D); } @@ -218,7 +218,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem public boolean isRenderingDone() { return this.renderingDone; } - + /** * @return The 0-based current page number */ @@ -279,7 +279,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem assert pageViewport.getPageIndex() >= 0; pageViewportList.add(pageViewport); } - + /** * Generates a desired page from the renderer's page viewport list. * @@ -300,18 +300,18 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem + " (pageWidth " + pageWidth + ", pageHeight " + pageHeight + ")"); - double scaleX = scaleFactor - * (25.4 / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION) + double scaleX = scaleFactor + * (25.4 / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION) / userAgent.getTargetPixelUnitToMillimeter(); double scaleY = scaleFactor * (25.4 / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION) / userAgent.getTargetPixelUnitToMillimeter(); int bitmapWidth = (int) ((pageWidth * scaleX) + 0.5); int bitmapHeight = (int) ((pageHeight * scaleY) + 0.5); - - + + BufferedImage currentPageImage = getBufferedImage(bitmapWidth, bitmapHeight); - + Graphics2D graphics = currentPageImage.createGraphics(); graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); @@ -374,7 +374,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem return new BufferedImage( bitmapWidth, bitmapHeight, BufferedImage.TYPE_INT_ARGB); } - + /** * Returns a page viewport. * @param pageIndex the page index (zero-based) @@ -414,21 +414,21 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem state.dispose(); state = (Java2DGraphicsState)stateStack.pop(); } - + /** {@inheritDoc} */ protected void concatenateTransformationMatrix(AffineTransform at) { state.transform(at); } - + /** {@inheritDoc} */ protected void startVParea(CTM ctm, Rectangle2D clippingRect) { saveGraphicsState(); if (clippingRect != null) { - clipRect((float)clippingRect.getX() / 1000f, - (float)clippingRect.getY() / 1000f, - (float)clippingRect.getWidth() / 1000f, + clipRect((float)clippingRect.getX() / 1000f, + (float)clippingRect.getY() / 1000f, + (float)clippingRect.getWidth() / 1000f, (float)clippingRect.getHeight() / 1000f); } @@ -465,7 +465,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem */ protected void restoreStateStackAfterBreakOut(List breakOutList) { log.debug("Block.FIXED --> restoring context after break-out"); - + Iterator i = breakOutList.iterator(); while (i.hasNext()) { Java2DGraphicsState s = (Java2DGraphicsState)i.next(); @@ -475,7 +475,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem } /** - * {@inheritDoc} + * {@inheritDoc} */ protected void updateColor(Color col, boolean fill) { state.updateColor(col); @@ -500,7 +500,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem } /** - * {@inheritDoc} + * {@inheritDoc} */ protected void lineTo(float x, float y) { if (currentPath == null) { @@ -510,7 +510,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem } /** - * {@inheritDoc} + * {@inheritDoc} */ protected void moveTo(float x, float y) { if (currentPath == null) { @@ -520,26 +520,26 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem } /** - * {@inheritDoc} + * {@inheritDoc} */ protected void clipRect(float x, float y, float width, float height) { state.updateClip(new Rectangle2D.Float(x, y, width, height)); } /** - * {@inheritDoc} + * {@inheritDoc} */ protected void fillRect(float x, float y, float width, float height) { state.getGraph().fill(new Rectangle2D.Float(x, y, width, height)); } - + /** - * {@inheritDoc} + * {@inheritDoc} */ - protected void drawBorderLine(float x1, float y1, float x2, float y2, + protected void drawBorderLine(float x1, float y1, float x2, float y2, boolean horz, boolean startOrBefore, int style, Color col) { Graphics2D g2d = state.getGraph(); - drawBorderLine(new Rectangle2D.Float(x1, y1, x2 - x1, y2 - y1), + drawBorderLine(new Rectangle2D.Float(x1, y1, x2 - x1, y2 - y1), horz, startOrBefore, style, col, g2d); } @@ -547,13 +547,13 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem * Draw a border segment of an XSL-FO style border. * @param lineRect the line defined by its bounding rectangle * @param horz true for horizontal border segments, false for vertical border segments - * @param startOrBefore true for border segments on the start or before edge, + * @param startOrBefore true for border segments on the start or before edge, * false for end or after. * @param style the border style (one of Constants.EN_DASHED etc.) * @param col the color for the border segment * @param g2d the Graphics2D instance to paint to */ - public static void drawBorderLine(Rectangle2D.Float lineRect, + public static void drawBorderLine(Rectangle2D.Float lineRect, boolean horz, boolean startOrBefore, int style, Color col, Graphics2D g2d) { float x1 = lineRect.x; float y1 = lineRect.y; @@ -566,7 +566,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem return; } switch (style) { - case Constants.EN_DASHED: + case Constants.EN_DASHED: g2d.setColor(col); if (horz) { float unit = Math.abs(2 * h); @@ -576,7 +576,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem } unit = w / rep; float ym = y1 + (h / 2); - BasicStroke s = new BasicStroke(h, BasicStroke.CAP_BUTT, + BasicStroke s = new BasicStroke(h, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[] {unit}, 0); g2d.setStroke(s); g2d.draw(new Line2D.Float(x1, ym, x2, ym)); @@ -588,7 +588,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem } unit = h / rep; float xm = x1 + (w / 2); - BasicStroke s = new BasicStroke(w, BasicStroke.CAP_BUTT, + BasicStroke s = new BasicStroke(w, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[] {unit}, 0); g2d.setStroke(s); g2d.draw(new Line2D.Float(xm, y1, xm, y2)); @@ -604,7 +604,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem } unit = w / rep; float ym = y1 + (h / 2); - BasicStroke s = new BasicStroke(h, BasicStroke.CAP_ROUND, + BasicStroke s = new BasicStroke(h, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 10.0f, new float[] {0, unit}, 0); g2d.setStroke(s); g2d.draw(new Line2D.Float(x1, ym, x2, ym)); @@ -616,7 +616,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem } unit = h / rep; float xm = x1 + (w / 2); - BasicStroke s = new BasicStroke(w, BasicStroke.CAP_ROUND, + BasicStroke s = new BasicStroke(w, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 10.0f, new float[] {0, unit}, 0); g2d.setStroke(s); g2d.draw(new Line2D.Float(xm, y1, xm, y2)); @@ -722,7 +722,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem state.transform(at); renderText(text, state.getGraph(), font); restoreGraphicsState(); - + currentIPPosition = saveIP + text.getAllocIPD(); //super.renderText(text); @@ -755,8 +755,8 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem int[] letterAdjust = word.getLetterAdjustArray(); GlyphVector gv = g2d.getFont().createGlyphVector(g2d.getFontRenderContext(), s); double additionalWidth = 0.0; - if (letterAdjust == null - && text.getTextLetterSpaceAdjust() == 0 + if (letterAdjust == null + && text.getTextLetterSpaceAdjust() == 0 && text.getTextWordSpaceAdjust() == 0) { //nop } else { @@ -776,8 +776,8 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem SpaceArea space = (SpaceArea)child; String s = space.getSpace(); char sp = s.charAt(0); - int tws = (space.isAdjustable() - ? text.getTextWordSpaceAdjust() + int tws = (space.isAdjustable() + ? text.getTextWordSpaceAdjust() + 2 * text.getTextLetterSpaceAdjust() : 0); @@ -787,8 +787,8 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem } } } - - private static int[] getGlyphOffsets(String s, Font font, TextArea text, + + private static int[] getGlyphOffsets(String s, Font font, TextArea text, int[] letterAdjust) { int textLen = s.length(); int[] offsets = new int[textLen]; @@ -804,11 +804,11 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem } int cw = font.getWidth(mapped); int ladj = (letterAdjust != null && i < textLen - 1 ? letterAdjust[i + 1] : 0); - int tls = (i < textLen - 1 ? text.getTextLetterSpaceAdjust() : 0); + int tls = (i < textLen - 1 ? text.getTextLetterSpaceAdjust() : 0); offsets[i] = cw + ladj + tls + wordSpace; } return offsets; - } + } /** * Render leader area. This renders a leader area which is an area with a @@ -824,7 +824,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem float startx = (currentIPPosition + area.getBorderAndPaddingWidthStart()) / 1000f; float starty = ((currentBPPosition + area.getOffset()) / 1000f); - float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart() + float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart() + area.getIPD()) / 1000f; Color col = (Color) area.getTrait(Trait.COLOR); @@ -839,7 +839,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem case EN_SOLID: case EN_DASHED: case EN_DOUBLE: - drawBorderLine(startx, starty, endx, starty + ruleThickness, + drawBorderLine(startx, starty, endx, starty + ruleThickness, true, true, style, col); break; case EN_DOTTED: @@ -905,7 +905,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem int x = currentIPPosition + (int)Math.round(pos.getX()); int y = currentBPPosition + (int)Math.round(pos.getY()); uri = URISpecification.getURL(uri); - + ImageManager manager = getUserAgent().getFactory().getImageManager(); ImageInfo info = null; try { @@ -913,8 +913,8 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem info = manager.getImageInfo(uri, sessionContext); final ImageFlavor[] flavors = new ImageFlavor[] {ImageFlavor.GRAPHICS2D, - ImageFlavor.BUFFERED_IMAGE, - ImageFlavor.RENDERED_IMAGE, + ImageFlavor.BUFFERED_IMAGE, + ImageFlavor.RENDERED_IMAGE, ImageFlavor.XML_DOM}; Map hints = ImageUtil.getDefaultHints(sessionContext); org.apache.xmlgraphics.image.loader.Image img = manager.getImage( @@ -958,7 +958,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem } /** {@inheritDoc} */ - protected RendererContext createRendererContext(int x, int y, int width, int height, + protected RendererContext createRendererContext(int x, int y, int width, int height, Map foreignAttributes) { RendererContext context = super.createRendererContext( x, y, width, height, foreignAttributes); diff --git a/src/java/org/apache/fop/render/pcl/PCLRenderer.java b/src/java/org/apache/fop/render/pcl/PCLRenderer.java index 5ffef15ba..007ce4828 100644 --- a/src/java/org/apache/fop/render/pcl/PCLRenderer.java +++ b/src/java/org/apache/fop/render/pcl/PCLRenderer.java @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.render.pcl; //Java @@ -111,14 +111,14 @@ public class PCLRenderer extends PrintRenderer { /** The MIME type for PCL */ public static final String MIME_TYPE = MimeConstants.MIME_PCL_ALT; - private static final QName CONV_MODE + private static final QName CONV_MODE = new QName(ExtensionElementMapping.URI, null, "conversion-mode"); - private static final QName SRC_TRANSPARENCY + private static final QName SRC_TRANSPARENCY = new QName(ExtensionElementMapping.URI, null, "source-transparency"); - + /** The OutputStream to write the PCL stream to */ protected OutputStream out; - + /** The PCL generator */ protected PCLGenerator gen; private boolean ioTrouble = false; @@ -130,13 +130,13 @@ public class PCLRenderer extends PrintRenderer { private int currentPrintDirection = 0; private GeneralPath currentPath = null; private java.awt.Color currentFillColor = null; - + /** * Controls whether appearance is more important than speed. False can cause some FO feature - * to be ignored (like the advanced borders). + * to be ignored (like the advanced borders). */ private boolean qualityBeforeSpeed = false; - + /** * Controls whether all text should be painted as text. This is a fallback setting in case * the mixture of native and bitmapped text does not provide the necessary quality. @@ -149,17 +149,17 @@ public class PCLRenderer extends PrintRenderer { * this to true will increase memory consumption. */ private boolean useColorCanvas = false; - + /** - * Controls whether the generation of PJL commands gets disabled. + * Controls whether the generation of PJL commands gets disabled. */ private boolean disabledPJL = false; - + /** contains the pageWith of the last printed page */ private long pageWidth = 0; /** contains the pageHeight of the last printed page */ private long pageHeight = 0; - + /** * Create the PCL renderer */ @@ -182,7 +182,7 @@ public class PCLRenderer extends PrintRenderer { public void setPJLDisabled(boolean disable) { this.disabledPJL = disable; } - + /** * Indicates whether PJL generation is disabled. * @return true if PJL generation is disabled. @@ -190,7 +190,7 @@ public class PCLRenderer extends PrintRenderer { public boolean isPJLDisabled() { return this.disabledPJL; } - + /** * {@inheritDoc} */ @@ -203,9 +203,9 @@ public class PCLRenderer extends PrintRenderer { BufferedImage.TYPE_INT_RGB); Graphics2D graphics2D = fontImage.createGraphics(); //The next line is important to get accurate font metrics! - graphics2D.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, + graphics2D.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); - + userAgent.getFactory().getFontManager().setupRenderer(this, graphics2D); } @@ -231,7 +231,7 @@ public class PCLRenderer extends PrintRenderer { public GraphicContext getGraphicContext() { return this.graphicContext; } - + /** @return the target resolution */ protected int getResolution() { int resolution = (int)Math.round(userAgent.getTargetResolution()); @@ -241,7 +241,7 @@ public class PCLRenderer extends PrintRenderer { return 600; } } - + /** * Sets the current font (NOTE: Hard-coded font mappings ATM!) * @param name the font name (internal F* names for now) @@ -317,25 +317,25 @@ public class PCLRenderer extends PrintRenderer { case 9: // F9 = Courier gen.writeCommand("(0N"); - gen.writeCommand("(s0p" + gen.formatDouble2(120.01f / (size / 1000.00f)) + gen.writeCommand("(s0p" + gen.formatDouble2(120.01f / (size / 1000.00f)) + "h0s0b4099T"); break; case 10: // F10 = Courier Oblique gen.writeCommand("(0N"); - gen.writeCommand("(s0p" + gen.formatDouble2(120.01f / (size / 1000.00f)) + gen.writeCommand("(s0p" + gen.formatDouble2(120.01f / (size / 1000.00f)) + "h1s0b4099T"); break; case 11: // F11 = Courier Bold gen.writeCommand("(0N"); - gen.writeCommand("(s0p" + gen.formatDouble2(120.01f / (size / 1000.00f)) + gen.writeCommand("(s0p" + gen.formatDouble2(120.01f / (size / 1000.00f)) + "h0s3b4099T"); break; case 12: // F12 = Courier Bold Oblique gen.writeCommand("(0N"); - gen.writeCommand("(s0p" + gen.formatDouble2(120.01f / (size / 1000.00f)) + gen.writeCommand("(s0p" + gen.formatDouble2(120.01f / (size / 1000.00f)) + "h1s3b4099T"); break; case 13: // F13 = Symbol @@ -400,52 +400,52 @@ public class PCLRenderer extends PrintRenderer { */ public void renderPage(PageViewport page) throws IOException, FOPException { saveGraphicsState(); - + //Paper source String paperSource = page.getForeignAttributeValue( new QName(PCLElementMapping.NAMESPACE, null, "paper-source")); if (paperSource != null) { gen.selectPaperSource(Integer.parseInt(paperSource)); } - + //Page size final long pagewidth = Math.round(page.getViewArea().getWidth()); final long pageheight = Math.round(page.getViewArea().getHeight()); selectPageFormat(pagewidth, pageheight); - + super.renderPage(page); - + //Eject page gen.formFeed(); restoreGraphicsState(); } private void selectPageFormat(long pagewidth, long pageheight) throws IOException { - //Only set the page format if it changes (otherwise duplex printing won't work) + //Only set the page format if it changes (otherwise duplex printing won't work) if ((pagewidth != this.pageWidth) || (pageheight != this.pageHeight)) { this.pageWidth = pagewidth; this.pageHeight = pageheight; - + this.currentPageDefinition = PCLPageDefinition.getPageDefinition( pagewidth, pageheight, 1000); - + if (this.currentPageDefinition == null) { this.currentPageDefinition = PCLPageDefinition.getDefaultPageDefinition(); - log.warn("Paper type could not be determined. Falling back to: " + log.warn("Paper type could not be determined. Falling back to: " + this.currentPageDefinition.getName()); } if (log.isDebugEnabled()) { log.debug("page size: " + currentPageDefinition.getPhysicalPageSize()); log.debug("logical page: " + currentPageDefinition.getLogicalPageRect()); } - + if (this.currentPageDefinition.isLandscapeFormat()) { gen.writeCommand("&l1O"); //Landscape Orientation } else { gen.writeCommand("&l0O"); //Portrait Orientation } gen.selectPageSize(this.currentPageDefinition.getSelector()); - + gen.clearHorizontalMargins(); gen.setTopMargin(0); } @@ -461,7 +461,7 @@ public class PCLRenderer extends PrintRenderer { protected void restoreGraphicsState() { graphicContext = (GraphicContext)graphicContextStack.pop(); } - + /** * Clip an area. write a clipping operation given coordinates in the current * transform. Coordinates are in points. @@ -478,7 +478,7 @@ public class PCLRenderer extends PrintRenderer { private Point2D transformedPoint(float x, float y) { return transformedPoint(Math.round(x), Math.round(y)); } - + private Point2D transformedPoint(int x, int y) { AffineTransform at = graphicContext.getTransform(); if (log.isTraceEnabled()) { @@ -488,7 +488,7 @@ public class PCLRenderer extends PrintRenderer { Point2D.Float transPoint = new Point2D.Float(); at.transform(orgPoint, transPoint); //At this point we have the absolute position in FOP's coordinate system - + //Now get PCL coordinates taking the current print direction and the logical page //into account. Dimension pageSize = currentPageDefinition.getPhysicalPageSize(); @@ -527,18 +527,18 @@ public class PCLRenderer extends PrintRenderer { } return transPoint; } - + private void changePrintDirection() { AffineTransform at = graphicContext.getTransform(); int newDir; try { - if (at.getScaleX() == 0 && at.getScaleY() == 0 + if (at.getScaleX() == 0 && at.getScaleY() == 0 && at.getShearX() == 1 && at.getShearY() == -1) { newDir = 90; - } else if (at.getScaleX() == -1 && at.getScaleY() == -1 + } else if (at.getScaleX() == -1 && at.getScaleY() == -1 && at.getShearX() == 0 && at.getShearY() == 0) { newDir = 180; - } else if (at.getScaleX() == 0 && at.getScaleY() == 0 + } else if (at.getScaleX() == 0 && at.getScaleY() == 0 && at.getShearX() == -1 && at.getShearY() == 1) { newDir = 270; } else { @@ -588,7 +588,7 @@ public class PCLRenderer extends PrintRenderer { protected void handleBlockTraits(Block block) { int borderPaddingStart = block.getBorderAndPaddingWidthStart(); int borderPaddingBefore = block.getBorderAndPaddingWidthBefore(); - + float startx = currentIPPosition / 1000f; float starty = currentBPPosition / 1000f; float width = block.getIPD() / 1000f; @@ -628,7 +628,7 @@ public class PCLRenderer extends PrintRenderer { */ protected void renderText(final TextArea text) { renderInlineAreaBackAndBorders(text); - + String fontname = getInternalFontNameForArea(text); final int fontsize = text.getTraitAsInteger(Trait.FONT_SIZE); @@ -640,9 +640,9 @@ public class PCLRenderer extends PrintRenderer { try { final Color col = (Color)text.getTrait(Trait.COLOR); - boolean pclFont = allTextAsBitmaps + boolean pclFont = allTextAsBitmaps ? false - : setFont(fontname, fontsize, text.getText()); + : setFont(fontname, fontsize, text.getText()); if (pclFont) { //this.currentFill = col; if (col != null) { @@ -650,7 +650,7 @@ public class PCLRenderer extends PrintRenderer { gen.setTransparencyMode(true, false); gen.selectGrayscale(col); } - + saveGraphicsState(); graphicContext.translate(rx, bl); setCursorPos(0, 0); @@ -667,25 +667,25 @@ public class PCLRenderer extends PrintRenderer { //Use Java2D to paint different fonts via bitmap final Font font = getFontFromArea(text); final int baseline = text.getBaselineOffset(); - + //for cursive fonts, so the text isn't clipped int extraWidth = font.getFontSize() / 3; final FontMetricsMapper mapper = (FontMetricsMapper)fontInfo.getMetricsFor( font.getFontName()); int maxAscent = mapper.getMaxAscent(font.getFontSize()) / 1000; final int additionalBPD = maxAscent - baseline; - + Graphics2DAdapter g2a = getGraphics2DAdapter(); final Rectangle paintRect = new Rectangle( rx, currentBPPosition + text.getOffset() - additionalBPD, text.getIPD() + extraWidth, text.getBPD() + additionalBPD); - RendererContext rc = createRendererContext(paintRect.x, paintRect.y, + RendererContext rc = createRendererContext(paintRect.x, paintRect.y, paintRect.width, paintRect.height, null); Map atts = new java.util.HashMap(); atts.put(CONV_MODE, "bitmap"); atts.put(SRC_TRANSPARENCY, "true"); rc.setProperty(RendererContextConstants.FOREIGN_ATTRIBUTES, atts); - + Graphics2DImagePainter painter = new Graphics2DImagePainter() { public void paint(Graphics2D g2d, Rectangle2D area) { @@ -696,17 +696,17 @@ public class PCLRenderer extends PrintRenderer { Java2DRenderer.renderText(text, g2d, font); renderTextDecoration(g2d, mapper, fontsize, text, 0, 0); } - + public Dimension getImageSize() { return paintRect.getSize(); } - + }; - g2a.paintImage(painter, rc, + g2a.paintImage(painter, rc, paintRect.x, paintRect.y, paintRect.width, paintRect.height); currentIPPosition = saveIP + text.getAllocIPD(); } - + } catch (IOException ioe) { handleIOTrouble(ioe); } @@ -721,11 +721,11 @@ public class PCLRenderer extends PrintRenderer { * @param baseline position of the baseline * @param startx start IPD */ - private static void renderTextDecoration(Graphics2D g2d, - FontMetrics fm, int fontsize, InlineArea inline, + private static void renderTextDecoration(Graphics2D g2d, + FontMetrics fm, int fontsize, InlineArea inline, int baseline, int startx) { - boolean hasTextDeco = inline.hasUnderline() - || inline.hasOverline() + boolean hasTextDeco = inline.hasUnderline() + || inline.hasOverline() || inline.hasLineThrough(); if (hasTextDeco) { float descender = fm.getDescender(fontsize) / 1000f; @@ -737,7 +737,7 @@ public class PCLRenderer extends PrintRenderer { g2d.setColor(ct); float y = baseline - descender / 2f; g2d.setStroke(new BasicStroke(lineWidth)); - g2d.draw(new Line2D.Float(startx / 1000f, y / 1000f, + g2d.draw(new Line2D.Float(startx / 1000f, y / 1000f, endx, y / 1000f)); } if (inline.hasOverline()) { @@ -745,7 +745,7 @@ public class PCLRenderer extends PrintRenderer { g2d.setColor(ct); float y = (float)(baseline - (1.1 * capHeight)); g2d.setStroke(new BasicStroke(lineWidth)); - g2d.draw(new Line2D.Float(startx / 1000f, y / 1000f, + g2d.draw(new Line2D.Float(startx / 1000f, y / 1000f, endx, y / 1000f)); } if (inline.hasLineThrough()) { @@ -753,12 +753,12 @@ public class PCLRenderer extends PrintRenderer { g2d.setColor(ct); float y = (float)(baseline - (0.45 * capHeight)); g2d.setStroke(new BasicStroke(lineWidth)); - g2d.draw(new Line2D.Float(startx / 1000f, y / 1000f, + g2d.draw(new Line2D.Float(startx / 1000f, y / 1000f, endx, y / 1000f)); } } } - + /** * Sets the current cursor position. The coordinates are transformed to the absolute position * on the logical PCL page and then passed on to the PCLGenerator. @@ -784,7 +784,7 @@ public class PCLRenderer extends PrintRenderer { } /** - * Closes the current subpath by appending a straight line segment from + * Closes the current subpath by appending a straight line segment from * the current point to the starting point of the subpath. */ protected void closePath() { @@ -792,8 +792,8 @@ public class PCLRenderer extends PrintRenderer { } /** - * Appends a straight line segment from the current point to (x, y). The - * new current point is (x, y). + * Appends a straight line segment from the current point to (x, y). The + * new current point is (x, y). * @param x x coordinate * @param y y coordinate */ @@ -805,7 +805,7 @@ public class PCLRenderer extends PrintRenderer { } /** - * Moves the current point to (x, y), omitting any connecting line segment. + * Moves the current point to (x, y), omitting any connecting line segment. * @param x x coordinate * @param y y coordinate */ @@ -815,7 +815,7 @@ public class PCLRenderer extends PrintRenderer { } currentPath.moveTo(x, y); } - + /** * Fill a rectangular area. * @param x the x coordinate (in pt) @@ -826,13 +826,13 @@ public class PCLRenderer extends PrintRenderer { protected void fillRect(float x, float y, float width, float height) { try { setCursorPos(x * 1000, y * 1000); - gen.fillRect((int)(width * 1000), (int)(height * 1000), + gen.fillRect((int)(width * 1000), (int)(height * 1000), this.currentFillColor); } catch (IOException ioe) { handleIOTrouble(ioe); } } - + /** * Sets the new current fill color. * @param color the color @@ -866,9 +866,9 @@ public class PCLRenderer extends PrintRenderer { String s = space.getSpace(); char sp = s.charAt(0); Font font = getFontFromArea(textArea); - - int tws = (space.isAdjustable() - ? textArea.getTextWordSpaceAdjust() + + int tws = (space.isAdjustable() + ? textArea.getTextWordSpaceAdjust() + 2 * textArea.getTextLetterSpaceAdjust() : 0); @@ -893,10 +893,10 @@ public class PCLRenderer extends PrintRenderer { float y = (currentBPPosition + viewport.getOffset()) / 1000f; float width = viewport.getIPD() / 1000f; float height = viewport.getBPD() / 1000f; - // TODO: Calculate the border rect correctly. + // TODO: Calculate the border rect correctly. float borderPaddingStart = viewport.getBorderAndPaddingWidthStart() / 1000f; float borderPaddingBefore = viewport.getBorderAndPaddingWidthBefore() / 1000f; - float bpwidth = borderPaddingStart + float bpwidth = borderPaddingStart + (viewport.getBorderAndPaddingWidthEnd() / 1000f); float bpheight = borderPaddingBefore + (viewport.getBorderAndPaddingWidthAfter() / 1000f); @@ -931,7 +931,7 @@ public class PCLRenderer extends PrintRenderer { //This is the content-rect float width = (float)bv.getIPD() / 1000f; float height = (float)bv.getBPD() / 1000f; - + if (bv.getPositioning() == Block.ABSOLUTE || bv.getPositioning() == Block.FIXED) { @@ -943,17 +943,17 @@ public class PCLRenderer extends PrintRenderer { if (bv.getPositioning() == Block.FIXED) { breakOutList = breakOutOfStateStack(); } - + AffineTransform positionTransform = new AffineTransform(); positionTransform.translate(bv.getXOffset(), bv.getYOffset()); - + //"left/"top" (bv.getX/YOffset()) specify the position of the content rectangle positionTransform.translate(-borderPaddingStart, -borderPaddingBefore); saveGraphicsState(); //Viewport position concatenateTransformationMatrix(mptToPt(positionTransform)); - + //Background and borders float bpwidth = (borderPaddingStart + bv.getBorderAndPaddingWidthEnd()) / 1000f; float bpheight = (borderPaddingBefore + bv.getBorderAndPaddingWidthAfter()) / 1000f; @@ -963,7 +963,7 @@ public class PCLRenderer extends PrintRenderer { AffineTransform contentRectTransform = new AffineTransform(); contentRectTransform.translate(borderPaddingStart, borderPaddingBefore); concatenateTransformationMatrix(mptToPt(contentRectTransform)); - + //Clipping if (bv.getClip()) { clipRect(0f, 0f, width, height); @@ -973,7 +973,7 @@ public class PCLRenderer extends PrintRenderer { //Set up coordinate system for content rectangle AffineTransform contentTransform = ctm.toAffineTransform(); concatenateTransformationMatrix(mptToPt(contentTransform)); - + currentIPPosition = 0; currentBPPosition = 0; renderBlocks(bv, children); @@ -984,7 +984,7 @@ public class PCLRenderer extends PrintRenderer { if (breakOutList != null) { restoreStateStackAfterBreakOut(breakOutList); } - + currentIPPosition = saveIP; currentBPPosition = saveBP; } else { @@ -999,16 +999,16 @@ public class PCLRenderer extends PrintRenderer { CTM tempctm = new CTM(containingIPPosition, currentBPPosition); ctm = tempctm.multiply(ctm); - + //Now adjust for border/padding currentBPPosition += borderPaddingBefore; Rectangle2D clippingRect = null; if (bv.getClip()) { - clippingRect = new Rectangle(currentIPPosition, currentBPPosition, + clippingRect = new Rectangle(currentIPPosition, currentBPPosition, bv.getIPD(), bv.getBPD()); } - + startVParea(ctm, clippingRect); currentIPPosition = 0; currentBPPosition = 0; @@ -1017,7 +1017,7 @@ public class PCLRenderer extends PrintRenderer { currentIPPosition = saveIP; currentBPPosition = saveBP; - + currentBPPosition += (int)(bv.getAllocBPD()); } //currentFontName = saveFontName; @@ -1034,7 +1034,7 @@ public class PCLRenderer extends PrintRenderer { changePrintDirection(); } } - + private List breakOutOfStateStack() { log.debug("Block.FIXED --> break out"); List breakOutList = new java.util.ArrayList(); @@ -1054,7 +1054,7 @@ public class PCLRenderer extends PrintRenderer { } /** {@inheritDoc} */ - protected RendererContext createRendererContext(int x, int y, int width, int height, + protected RendererContext createRendererContext(int x, int y, int width, int height, Map foreignAttributes) { RendererContext context = super.createRendererContext( x, y, width, height, foreignAttributes); @@ -1070,7 +1070,7 @@ public class PCLRenderer extends PrintRenderer { private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {ImageFlavor.GRAPHICS2D, - ImageFlavor.BUFFERED_IMAGE, + ImageFlavor.BUFFERED_IMAGE, ImageFlavor.RENDERED_IMAGE, ImageFlavor.XML_DOM}; /** @@ -1089,18 +1089,18 @@ public class PCLRenderer extends PrintRenderer { Point origin = new Point(currentIPPosition, currentBPPosition); int x = origin.x + posInt.x; int y = origin.y + posInt.y; - + ImageManager manager = getUserAgent().getFactory().getImageManager(); ImageInfo info = null; try { ImageSessionContext sessionContext = getUserAgent().getImageSessionContext(); info = manager.getImageInfo(uri, sessionContext); - + //Only now fully load/prepare the image Map hints = ImageUtil.getDefaultHints(sessionContext); org.apache.xmlgraphics.image.loader.Image img = manager.getImage( info, FLAVORS, hints, sessionContext); - + //...and process the image if (img instanceof ImageGraphics2D) { ImageGraphics2D imageG2D = (ImageGraphics2D)img; @@ -1113,8 +1113,8 @@ public class PCLRenderer extends PrintRenderer { ImageRendered imgRend = (ImageRendered)img; RenderedImage ri = imgRend.getRenderedImage(); setCursorPos(x, y); - gen.paintBitmap(ri, - new Dimension(posInt.width, posInt.height), + gen.paintBitmap(ri, + new Dimension(posInt.width, posInt.height), false); } else if (img instanceof ImageXMLDOM) { ImageXMLDOM imgXML = (ImageXMLDOM)img; @@ -1160,18 +1160,18 @@ public class PCLRenderer extends PrintRenderer { float height = area.getBPD() / 1000f; float borderPaddingStart = area.getBorderAndPaddingWidthStart() / 1000f; float borderPaddingBefore = area.getBorderAndPaddingWidthBefore() / 1000f; - float bpwidth = borderPaddingStart + float bpwidth = borderPaddingStart + (area.getBorderAndPaddingWidthEnd() / 1000f); float bpheight = borderPaddingBefore + (area.getBorderAndPaddingWidthAfter() / 1000f); - + if (height != 0.0f || bpheight != 0.0f && bpwidth != 0.0f) { drawBackAndBorders(area, x, y - borderPaddingBefore , width + bpwidth , height + bpheight); } } - + /** * Draw the background and borders. This draws the background and border * traits for an area given the position. @@ -1188,18 +1188,18 @@ public class PCLRenderer extends PrintRenderer { BorderProps bpsAfter = (BorderProps) area.getTrait(Trait.BORDER_AFTER); BorderProps bpsStart = (BorderProps) area.getTrait(Trait.BORDER_START); BorderProps bpsEnd = (BorderProps) area.getTrait(Trait.BORDER_END); - + // draw background Trait.Background back; back = (Trait.Background) area.getTrait(Trait.BACKGROUND); if (back != null) { - + // Calculate padding rectangle float sx = startx; float sy = starty; float paddRectWidth = width; float paddRectHeight = height; - + if (bpsStart != null) { sx += bpsStart.width / 1000f; paddRectWidth -= bpsStart.width / 1000f; @@ -1214,15 +1214,15 @@ public class PCLRenderer extends PrintRenderer { if (bpsAfter != null) { paddRectHeight -= bpsAfter.width / 1000f; } - + if (back.getColor() != null) { updateFillColor(back.getColor()); fillRect(sx, sy, paddRectWidth, paddRectHeight); } - + // background image if (back.getImageInfo() != null) { - ImageSize imageSize = back.getImageInfo().getSize(); + ImageSize imageSize = back.getImageInfo().getSize(); saveGraphicsState(); clipRect(sx, sy, paddRectWidth, paddRectHeight); int horzCount = (int) ((paddRectWidth * 1000 / imageSize.getWidthMpt()) + 1.0f); @@ -1250,7 +1250,7 @@ public class PCLRenderer extends PrintRenderer { Rectangle2D pos; // Image positions are relative to the currentIP/BP pos = new Rectangle2D.Float( - sx - currentIPPosition + sx - currentIPPosition + (x * imageSize.getWidthMpt()), sy - currentBPPosition + (y * imageSize.getHeightMpt()), @@ -1262,7 +1262,7 @@ public class PCLRenderer extends PrintRenderer { restoreGraphicsState(); } } - + Rectangle2D.Float borderRect = new Rectangle2D.Float(startx, starty, width, height); drawBorders(borderRect, bpsBefore, bpsAfter, bpsStart, bpsEnd); } @@ -1275,8 +1275,8 @@ public class PCLRenderer extends PrintRenderer { * @param bpsStart the border specification on the start side * @param bpsEnd the border specification on the end side */ - protected void drawBorders(Rectangle2D.Float borderRect, - final BorderProps bpsBefore, final BorderProps bpsAfter, + protected void drawBorders(Rectangle2D.Float borderRect, + final BorderProps bpsBefore, final BorderProps bpsAfter, final BorderProps bpsStart, final BorderProps bpsEnd) { if (bpsBefore == null && bpsAfter == null && bpsStart == null && bpsEnd == null) { return; //no borders to paint @@ -1287,7 +1287,7 @@ public class PCLRenderer extends PrintRenderer { drawFastBorders(borderRect, bpsBefore, bpsAfter, bpsStart, bpsEnd); } } - + /** * Draws borders. Borders are drawn as shaded rectangles with no clipping. * @param borderRect the border rectangle @@ -1296,8 +1296,8 @@ public class PCLRenderer extends PrintRenderer { * @param bpsStart the border specification on the start side * @param bpsEnd the border specification on the end side */ - protected void drawFastBorders(Rectangle2D.Float borderRect, - final BorderProps bpsBefore, final BorderProps bpsAfter, + protected void drawFastBorders(Rectangle2D.Float borderRect, + final BorderProps bpsBefore, final BorderProps bpsAfter, final BorderProps bpsStart, final BorderProps bpsEnd) { float startx = borderRect.x; float starty = borderRect.y; @@ -1311,7 +1311,7 @@ public class PCLRenderer extends PrintRenderer { if (bpsAfter != null) { float borderWidth = bpsAfter.width / 1000f; updateFillColor(bpsAfter.color); - fillRect(startx, (starty + height - borderWidth), + fillRect(startx, (starty + height - borderWidth), width, borderWidth); } if (bpsStart != null) { @@ -1325,7 +1325,7 @@ public class PCLRenderer extends PrintRenderer { fillRect((startx + width - borderWidth), starty, borderWidth, height); } } - + /** * Draws borders. Borders are drawn in-memory and painted as a bitmap. * @param borderRect the border rectangle @@ -1334,8 +1334,8 @@ public class PCLRenderer extends PrintRenderer { * @param bpsStart the border specification on the start side * @param bpsEnd the border specification on the end side */ - protected void drawQualityBorders(Rectangle2D.Float borderRect, - final BorderProps bpsBefore, final BorderProps bpsAfter, + protected void drawQualityBorders(Rectangle2D.Float borderRect, + final BorderProps bpsBefore, final BorderProps bpsAfter, final BorderProps bpsStart, final BorderProps bpsEnd) { Graphics2DAdapter g2a = getGraphics2DAdapter(); final Rectangle.Float effBorderRect = new Rectangle2D.Float( @@ -1345,7 +1345,7 @@ public class PCLRenderer extends PrintRenderer { borderRect.height); final Rectangle paintRect = new Rectangle( (int)Math.round(borderRect.x * 1000f), - (int)Math.round(borderRect.y * 1000f), + (int)Math.round(borderRect.y * 1000f), (int)Math.floor(borderRect.width * 1000f) + 1, (int)Math.floor(borderRect.height * 1000f) + 1); //Add one pixel wide safety margin around the paint area @@ -1356,14 +1356,14 @@ public class PCLRenderer extends PrintRenderer { paintRect.y += yoffset; paintRect.width += 2 * pixelWidth; paintRect.height += 2 * pixelWidth; - - RendererContext rc = createRendererContext(paintRect.x, paintRect.y, + + RendererContext rc = createRendererContext(paintRect.x, paintRect.y, paintRect.width, paintRect.height, null); Map atts = new java.util.HashMap(); atts.put(CONV_MODE, "bitmap"); atts.put(SRC_TRANSPARENCY, "true"); rc.setProperty(RendererContextConstants.FOREIGN_ATTRIBUTES, atts); - + Graphics2DImagePainter painter = new Graphics2DImagePainter() { public void paint(Graphics2D g2d, Rectangle2D area) { @@ -1374,7 +1374,7 @@ public class PCLRenderer extends PrintRenderer { float width = effBorderRect.width; float height = effBorderRect.height; boolean[] b = new boolean[] { - (bpsBefore != null), (bpsEnd != null), + (bpsBefore != null), (bpsEnd != null), (bpsAfter != null), (bpsStart != null)}; if (!b[0] && !b[1] && !b[2] && !b[3]) { return; @@ -1385,9 +1385,9 @@ public class PCLRenderer extends PrintRenderer { (b[2] ? bpsAfter.width / 1000f : 0.0f), (b[3] ? bpsStart.width / 1000f : 0.0f)}; float[] clipw = new float[] { - BorderProps.getClippedWidth(bpsBefore) / 1000f, - BorderProps.getClippedWidth(bpsEnd) / 1000f, - BorderProps.getClippedWidth(bpsAfter) / 1000f, + BorderProps.getClippedWidth(bpsBefore) / 1000f, + BorderProps.getClippedWidth(bpsEnd) / 1000f, + BorderProps.getClippedWidth(bpsAfter) / 1000f, BorderProps.getClippedWidth(bpsStart) / 1000f}; starty += clipw[0]; height -= clipw[0]; @@ -1395,7 +1395,7 @@ public class PCLRenderer extends PrintRenderer { startx += clipw[3]; width -= clipw[3]; width -= clipw[1]; - + boolean[] slant = new boolean[] { (b[3] && b[0]), (b[0] && b[1]), (b[1] && b[2]), (b[2] && b[3])}; if (bpsBefore != null) { @@ -1433,7 +1433,7 @@ public class PCLRenderer extends PrintRenderer { currentPath = null; Rectangle2D.Float lineRect = new Rectangle2D.Float( sx1a, outery, ex1a - sx1a, innery - outery); - Java2DRenderer.drawBorderLine(lineRect, true, true, + Java2DRenderer.drawBorderLine(lineRect, true, true, bpsBefore.style, bpsBefore.color, g); //restoreGraphicsState(); } @@ -1447,7 +1447,7 @@ public class PCLRenderer extends PrintRenderer { float outerx = startx + width + clipw[1]; float clipx = outerx - clipw[1]; float innerx = outerx - bw[1]; - + //saveGraphicsState(); Graphics2D g = (Graphics2D)g2d.create(); moveTo(clipx, sy1); @@ -1472,7 +1472,7 @@ public class PCLRenderer extends PrintRenderer { currentPath = null; Rectangle2D.Float lineRect = new Rectangle2D.Float( innerx, sy1a, outerx - innerx, ey1a - sy1a); - Java2DRenderer.drawBorderLine(lineRect, false, false, + Java2DRenderer.drawBorderLine(lineRect, false, false, bpsEnd.style, bpsEnd.color, g); //restoreGraphicsState(); } @@ -1511,7 +1511,7 @@ public class PCLRenderer extends PrintRenderer { currentPath = null; Rectangle2D.Float lineRect = new Rectangle2D.Float( sx1a, innery, ex1a - sx1a, outery - innery); - Java2DRenderer.drawBorderLine(lineRect, true, false, + Java2DRenderer.drawBorderLine(lineRect, true, false, bpsAfter.style, bpsAfter.color, g); //restoreGraphicsState(); } @@ -1550,7 +1550,7 @@ public class PCLRenderer extends PrintRenderer { currentPath = null; Rectangle2D.Float lineRect = new Rectangle2D.Float( outerx, sy1a, innerx - outerx, ey1a - sy1a); - Java2DRenderer.drawBorderLine(lineRect, false, false, + Java2DRenderer.drawBorderLine(lineRect, false, false, bpsStart.style, bpsStart.color, g); //restoreGraphicsState(); } @@ -1559,10 +1559,10 @@ public class PCLRenderer extends PrintRenderer { public Dimension getImageSize() { return paintRect.getSize(); } - + }; try { - g2a.paintImage(painter, rc, + g2a.paintImage(painter, rc, paintRect.x - xoffset, paintRect.y, paintRect.width, paintRect.height); } catch (IOException ioe) { handleIOTrouble(ioe); @@ -1577,7 +1577,7 @@ public class PCLRenderer extends PrintRenderer { public void setAllTextAsBitmaps(boolean allTextAsBitmaps) { this.allTextAsBitmaps = allTextAsBitmaps; } - - - + + + } diff --git a/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java b/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java index ea4cc50bb..aa0fc88b9 100644 --- a/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java +++ b/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.render.ps; @@ -91,28 +91,28 @@ public abstract class AbstractPSTranscoder extends AbstractFOPTranscoder { * @exception TranscoderException if an error occured while transcoding */ protected void transcode(Document document, String uri, - TranscoderOutput output) + TranscoderOutput output) throws TranscoderException { graphics = createDocumentGraphics2D(); if (!isTextStroked()) { - FontInfo fontInfo = new FontInfo(); - //TODO Do custom font configuration here somewhere/somehow - FontSetup.setup(fontInfo); + FontInfo fontInfo = new FontInfo(); + //TODO Do custom font configuration here somewhere/somehow + FontSetup.setup(fontInfo); graphics.setCustomTextHandler(new NativeTextHandler(graphics, fontInfo)); } super.transcode(document, uri, output); getLogger().trace("document size: " + width + " x " + height); - + // prepare the image to be painted - UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, + UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, document.getDocumentElement()); - float widthInPt = UnitProcessor.userSpaceToSVG(width, SVGLength.SVG_LENGTHTYPE_PT, + float widthInPt = UnitProcessor.userSpaceToSVG(width, SVGLength.SVG_LENGTHTYPE_PT, UnitProcessor.HORIZONTAL_LENGTH, uctx); int w = (int)(widthInPt + 0.5); - float heightInPt = UnitProcessor.userSpaceToSVG(height, SVGLength.SVG_LENGTHTYPE_PT, + float heightInPt = UnitProcessor.userSpaceToSVG(height, SVGLength.SVG_LENGTHTYPE_PT, UnitProcessor.HORIZONTAL_LENGTH, uctx); int h = (int)(heightInPt + 0.5); getLogger().trace("document size: " + w + "pt x " + h + "pt"); @@ -140,7 +140,7 @@ public abstract class AbstractPSTranscoder extends AbstractFOPTranscoder { throw new TranscoderException(ex); } } - + /** {@inheritDoc} */ protected BridgeContext createBridgeContext() { @@ -148,7 +148,7 @@ public abstract class AbstractPSTranscoder extends AbstractFOPTranscoder { if (!isTextStroked()) { TextHandler handler = graphics.getCustomTextHandler(); if (handler instanceof NativeTextHandler) { - NativeTextHandler nativeTextHandler = (NativeTextHandler)handler; + NativeTextHandler nativeTextHandler = (NativeTextHandler)handler; PSTextPainter textPainter = new PSTextPainter(nativeTextHandler); ctx.setTextPainter(textPainter); ctx.putBridge(new PSTextElementBridge(textPainter)); diff --git a/src/java/org/apache/fop/render/ps/NativeTextHandler.java b/src/java/org/apache/fop/render/ps/NativeTextHandler.java index 174fe8077..9f62097e9 100644 --- a/src/java/org/apache/fop/render/ps/NativeTextHandler.java +++ b/src/java/org/apache/fop/render/ps/NativeTextHandler.java @@ -38,16 +38,16 @@ import org.apache.xmlgraphics.ps.PSGenerator; public class NativeTextHandler implements PSTextHandler { private PSGraphics2D g2d; - + /** FontInfo containing all available fonts */ protected FontInfo fontInfo; /** Currently valid Font */ protected Font font; - + /** Overriding FontState */ protected Font overrideFont = null; - + /** the current (internal) font name */ protected String currentFontName; @@ -67,13 +67,13 @@ public class NativeTextHandler implements PSTextHandler { setupFontInfo(); } } - + private void setupFontInfo() { //Sets up a FontInfo with default fonts fontInfo = new FontInfo(); FontSetup.setup(fontInfo); } - + /** * Return the font information associated with this object * @return the FontInfo object @@ -85,7 +85,7 @@ public class NativeTextHandler implements PSTextHandler { private PSGenerator getPSGenerator() { return this.g2d.getPSGenerator(); } - + /** {@inheritDoc} */ public void writeSetup() throws IOException { if (fontInfo != null) { @@ -99,9 +99,9 @@ public class NativeTextHandler implements PSTextHandler { } /** - * Draw a string to the PostScript document. The text is painted using + * Draw a string to the PostScript document. The text is painted using * text operations. - * {@inheritDoc} + * {@inheritDoc} */ public void drawString(String s, float x, float y) throws IOException { g2d.preparePainting(); @@ -112,7 +112,7 @@ public class NativeTextHandler implements PSTextHandler { this.font = this.overrideFont; this.overrideFont = null; } - + //Color and Font state g2d.establishColor(g2d.getColor()); establishCurrentFont(); @@ -130,14 +130,14 @@ public class NativeTextHandler implements PSTextHandler { gen.writeln(gen.formatDouble(x) + " " + gen.formatDouble(y) + " moveto "); gen.writeln("1 -1 scale"); - + StringBuffer sb = new StringBuffer("("); escapeText(s, sb); sb.append(") t "); gen.writeln(sb.toString()); - - gen.restoreGraphicsState(); + + gen.restoreGraphicsState(); } private void escapeText(final String text, StringBuffer target) { @@ -157,7 +157,7 @@ public class NativeTextHandler implements PSTextHandler { int fontSize = 1000 * f.getSize(); String style = f.isItalic() ? "italic" : "normal"; int weight = f.isBold() ? Font.WEIGHT_BOLD : Font.WEIGHT_NORMAL; - + FontTriplet triplet = fontInfo.findAdjustWeight(fontFamily, style, weight); if (triplet == null) { triplet = fontInfo.findAdjustWeight("sans-serif", style, weight); @@ -166,10 +166,10 @@ public class NativeTextHandler implements PSTextHandler { } private void establishCurrentFont() throws IOException { - if ((currentFontName != this.font.getFontName()) + if ((currentFontName != this.font.getFontName()) || (currentFontSize != this.font.getFontSize())) { PSGenerator gen = getPSGenerator(); - gen.writeln(this.font.getFontName() + " " + gen.writeln(this.font.getFontName() + " " + gen.formatDouble(font.getFontSize() / 1000f) + " F"); currentFontName = this.font.getFontName(); currentFontSize = this.font.getFontSize(); @@ -183,6 +183,6 @@ public class NativeTextHandler implements PSTextHandler { public void setOverrideFont(Font override) { this.overrideFont = override; } - + } diff --git a/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java b/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java index 513ba4587..5bdfe8c8d 100644 --- a/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java @@ -56,7 +56,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { private int width; private int height; - + //for SVG scaling private float svgWidth; private float svgHeight; @@ -65,7 +65,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { public static final int NORMAL_PDF_RESOLUTION = 72; /** Default device resolution (300dpi is a resonable quality for most purposes) */ public static final int DEFAULT_NATIVE_DPI = 300; - + /** * The device resolution may be different from the normal target resolution. See * http://issues.apache.org/bugzilla/show_bug.cgi?id=37305 @@ -96,7 +96,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { public PDFDocumentGraphics2D(boolean textAsShapes) { super(textAsShapes); - this.pdfDoc = new PDFDocument("Apache FOP Version " + Version.getVersion() + this.pdfDoc = new PDFDocument("Apache FOP Version " + Version.getVersion() + ": PDFDocumentGraphics2D"); this.pdfContext = new PDFContext(); } @@ -150,7 +150,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { } /** - * Setup a default FontInfo instance if none has been setup before. + * Setup a default FontInfo instance if none has been setup before. */ public void setupDefaultFontInfo() { if (fontInfo == null) { @@ -160,7 +160,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { setFontInfo(fontInfo); } } - + /** * Set the device resolution for rendering. Will take effect at the * start of the next page. @@ -184,7 +184,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { public void setFontInfo(FontInfo fontInfo) { this.fontInfo = fontInfo; } - + /** * Get the font info for this pdf document. * @return the font information @@ -208,7 +208,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { public PDFContext getPDFContext() { return this.pdfContext; } - + /** * Set the dimensions of the svg document that will be drawn. * This is useful if the dimensions of the svg document are different @@ -248,9 +248,9 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { public void nextPage() { closePage(); } - + /** - * Closes the current page and adds it to the PDF file. + * Closes the current page and adds it to the PDF file. */ protected void closePage() { if (!pdfContext.isPagePending()) { @@ -270,7 +270,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { this.pdfDoc.addObject(pdfContext.getCurrentPage()); pdfContext.clearCurrentPage(); } - + /** {@inheritDoc} */ protected void preparePainting() { if (pdfContext.isPagePending()) { @@ -300,7 +300,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { if (this.initialTransform == null) { //Save initial transformation matrix this.initialTransform = getTransform(); - this.initialClip = getClip(); + this.initialClip = getClip(); } else { //Reset transformation matrix setTransform(this.initialTransform); @@ -313,7 +313,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { if (currentStream == null) { currentStream = new StringWriter(); } - + PDFResources pdfResources = this.pdfDoc.getResources(); PDFPage page = this.pdfDoc.getFactory().makePage(pdfResources, width, height); @@ -321,7 +321,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { pdfContext.setCurrentPage(page); pageRef = page.referencePDF(); - AffineTransform at = new AffineTransform(1.0, 0.0, 0.0, -1.0, + AffineTransform at = new AffineTransform(1.0, 0.0, 0.0, -1.0, 0.0, (double)height); currentStream.write("1 0 0 -1 0 " + height + " cm\n"); if (svgWidth != 0) { @@ -336,7 +336,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { at.scale(s, s); currentStream.write("" + PDFNumber.doubleOut(s) + " 0 0 " + PDFNumber.doubleOut(s) + " 0 0 cm\n"); - + scale(1 / s, 1 / s); } // Remember the transform we installed. @@ -344,8 +344,8 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { pdfContext.increasePageCount(); } - - + + /** * The rendering process has finished. * This should be called after the rendering has completed as there is diff --git a/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java b/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java index 789a7c247..cda1478bb 100644 --- a/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java +++ b/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java @@ -44,23 +44,23 @@ public class PDFDocumentGraphics2DConfigurator { * @param cfg the configuration * @throws ConfigurationException if an error occurs while configuring the object */ - public void configure(PDFDocumentGraphics2D graphics, Configuration cfg) + public void configure(PDFDocumentGraphics2D graphics, Configuration cfg) throws ConfigurationException { PDFDocument pdfDoc = graphics.getPDFDocument(); - + //Filter map pdfDoc.setFilterMap( PDFRendererConfigurator.buildFilterMapFromConfiguration(cfg)); - + //Fonts try { FontResolver fontResolver = FontManager.createMinimalFontResolver(); //TODO The following could be optimized by retaining the FontManager somewhere FontManager fontManager = new FontManager(); - + //TODO Make use of fontBaseURL, font substitution and referencing configuration //Requires a change to the expected configuration layout - + List/*<EmbedFontInfo>*/ embedFontInfoList = PrintRendererConfigurator.buildFontListFromConfiguration( cfg, fontResolver, false, fontManager); @@ -74,5 +74,5 @@ public class PDFDocumentGraphics2DConfigurator { throw new ConfigurationException("Error while setting up fonts", e); } } - + } diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index 5a147f3be..4d1ee6a6d 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -106,13 +106,13 @@ import org.apache.fop.util.ColorExt; public class PDFGraphics2D extends AbstractGraphics2D { private static final AffineTransform IDENTITY_TRANSFORM = new AffineTransform(); - - /** The number of decimal places. */ + + /** The number of decimal places. */ private static final int DEC = 8; /** Convenience constant for full opacity */ static final int OPAQUE = 255; - + /** * the PDF Document being created */ @@ -308,7 +308,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { public String getPageReference() { return this.pageRef; } - + /** * Set the Graphics context. * @param c the graphics context to use @@ -319,10 +319,10 @@ public class PDFGraphics2D extends AbstractGraphics2D { } private void setPrivateHints() { - setRenderingHint(RenderingHintsKeyExt.KEY_AVOID_TILE_PAINTING, + setRenderingHint(RenderingHintsKeyExt.KEY_AVOID_TILE_PAINTING, RenderingHintsKeyExt.VALUE_AVOID_TILE_PAINTING_ON); } - + /** * Set the override font state for drawing text. * This is used by the PDF text painter so that it can temporarily @@ -362,7 +362,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { concatMatrix(matrix); } } - + /** * This is mainly used for shading patterns which use the document-global coordinate system * instead of the local one. @@ -372,7 +372,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { AffineTransform at = new AffineTransform(graphicsState.getTransform()); return at; } - + /** * This is a pdf specific method used to add a link to the * pdf document. @@ -417,7 +417,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { * @param width the width to draw the image * @param height the height to draw the image */ - void addNativeImage(org.apache.xmlgraphics.image.loader.Image image, float x, float y, + void addNativeImage(org.apache.xmlgraphics.image.loader.Image image, float x, float y, float width, float height) { preparePainting(); String key = image.getInfo().getOriginalURI(); @@ -425,10 +425,10 @@ public class PDFGraphics2D extends AbstractGraphics2D { // Need to include hash code as when invoked from FO you // may have several 'independent' PDFGraphics2D so the // count is not enough. - key = "__AddNative_" + hashCode() + "_" + nativeCount; + key = "__AddNative_" + hashCode() + "_" + nativeCount; nativeCount++; } - + PDFImage pdfImage; if (image instanceof ImageRawJPEG) { pdfImage = new ImageRawJPEGAdapter((ImageRawJPEG)image, key); @@ -438,7 +438,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { throw new IllegalArgumentException( "Unsupported Image subclass: " + image.getClass().getName()); } - + PDFXObject xObject = this.pdfDoc.addImage(resourceContext, pdfImage); if (outputStream != null) { try { @@ -649,7 +649,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { graphicsState.pop(); } } - + /* // in theory we could set the clip using these methods // it doesn't seem to improve the file sizes much @@ -784,8 +784,8 @@ public class PDFGraphics2D extends AbstractGraphics2D { (float) gpaint.getPoint1().getX(), (float) gpaint.getPoint1().getY(), (float) gpaint.getPoint2().getX(), - (float) gpaint.getPoint2().getY(), - new float[] {0, 1}, + (float) gpaint.getPoint2().getY(), + new float[] {0, 1}, new Color[] {gpaint.getColor1(), gpaint.getColor2()}, gpaint.isCyclic() ? LinearGradientPaint.REPEAT : LinearGradientPaint.NO_CYCLE); } @@ -927,7 +927,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { return false; // PDF can't do alpha } - someColors.add(new PDFColor(cc.getRed(), cc.getGreen(), + someColors.add(new PDFColor(cc.getRed(), cc.getGreen(), cc.getBlue())); } @@ -947,7 +947,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { currentStream.write(myPat.getColorSpaceOut(fill)); return true; - } + } if (paint instanceof PatternPaint) { PatternPaint pp = (PatternPaint)paint; return createPattern(pp, fill); @@ -990,14 +990,14 @@ public class PDFGraphics2D extends AbstractGraphics2D { // double patMaxX = rect.getX() + rect.getWidth(); // double patMaxY = rect.getY() + rect.getHeight(); // double stepX = rect.getWidth(); - // double stepY = rect.getHeight(); - // + // double stepY = rect.getHeight(); + // // int startX = (int)((rect.getX() - gnMaxX)/stepX); // int startY = (int)((rect.getY() - gnMaxY)/stepY); - // + // // int endX = (int)((patMaxX - gnMinX)/stepX); // int endY = (int)((patMaxY - gnMinY)/stepY); - // + // // pattGraphic.translate(startX*stepX, startY*stepY); // for (int yIdx=startY; yIdx<=endY; yIdx++) { // for (int xIdx=startX; xIdx<=endX; xIdx++) { @@ -1027,14 +1027,14 @@ public class PDFGraphics2D extends AbstractGraphics2D { } /** @todo see if pdfDoc and res can be linked here, - (currently res <> PDFDocument's resources) so addFonts() + (currently res <> PDFDocument's resources) so addFonts() can be moved to PDFDocument class */ res.addFonts(pdfDoc, specialFontInfo); PDFPattern myPat = pdfDoc.getFactory().makePattern( resourceContext, 1, res, 1, 1, bbox, rect.getWidth(), rect.getHeight(), - theMatrix, null, + theMatrix, null, pattGraphic.getBuffer()); currentStream.write(myPat.getColorSpaceOut(fill)); @@ -1094,7 +1094,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { (rgbCS, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000, false, DataBuffer.TYPE_BYTE); - PaintContext pctx = paint.createContext(rgbCM, devBounds, usrBounds, + PaintContext pctx = paint.createContext(rgbCM, devBounds, usrBounds, at, getRenderingHints()); PDFXObject imageInfo = pdfDoc.getXObject ("TempImage:" + pctx.toString()); @@ -1112,7 +1112,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { final int[] line = new int[devW]; final byte[] mask; int x, y, val, rgbIdx = 0; - + if (pcm.hasAlpha()) { mask = new byte[devW * devH]; int maskIdx = 0; @@ -1611,7 +1611,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { return; } } - + AffineTransform trans = getTransform(); double[] tranvals = new double[6]; trans.getMatrix(tranvals); @@ -1709,7 +1709,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { iter.next(); } } - + /** * Do the PDF drawing command. * This does the PDF drawing command according to fill |