xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r1060241 [9/21] - in /xmlgraphics/fop/branches/Temp_Color: ./ examples/plan/src/org/apache/fop/plan/ lib/ lib/build/ src/codegen/java/org/apache/fop/tools/ src/codegen/unicode/data/ src/codegen/unicode/java/org/apache/fop/hyphenation/ src/c...
Date Tue, 18 Jan 2011 08:54:26 GMT
Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/Font.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/Font.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/Font.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/Font.java Tue Jan 18 08:54:08 2011
@@ -19,11 +19,11 @@
 
 package org.apache.fop.fonts;
 
+import java.util.Collections;
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.fop.fonts.CodePointMapping;
 
 /**
  * This class holds font state information and provides access to the font
@@ -160,11 +160,11 @@ public class Font {
      * Returns the font's kerning table
      * @return the kerning table
      */
-    public Map getKerning() {
+    public Map<Integer, Map<Integer, Integer>> getKerning() {
         if (metric.hasKerningInfo()) {
             return metric.getKerningInfo();
         } else {
-            return java.util.Collections.EMPTY_MAP;
+            return Collections.emptyMap();
         }
     }
 
@@ -178,9 +178,9 @@ public class Font {
      * @return the distance to adjust for kerning, 0 if there's no kerning
      */
     public int getKernValue(char ch1, char ch2) {
-        Map kernPair = (Map)getKerning().get(new Integer(ch1));
+        Map<Integer, Integer> kernPair = getKerning().get((int) ch1);
         if (kernPair != null) {
-            Integer width = (Integer)kernPair.get(new Integer(ch2));
+            Integer width = kernPair.get((int) ch2);
             if (width != null) {
                 return width.intValue() * getFontSize() / 1000;
             }
@@ -239,6 +239,7 @@ public class Font {
     /**
      * {@inheritDoc}
      */
+    @Override
     public String toString() {
         StringBuffer sbuf = new StringBuffer();
         sbuf.append('(');

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontAdder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontAdder.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontAdder.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontAdder.java Tue Jan 18 08:54:08 2011
@@ -20,18 +20,17 @@
 package org.apache.fop.fonts;
 
 import java.net.URL;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.fop.fonts.autodetect.FontInfoFinder;
 
 /**
- * Adds a list of fonts to a given font info list 
+ * Adds a list of fonts to a given font info list
  */
 public class FontAdder {
-    private FontEventListener listener;
-    private FontResolver resolver;
-    private FontManager manager;
+    private final FontEventListener listener;
+    private final FontResolver resolver;
+    private final FontManager manager;
 
     /**
      * Main constructor
@@ -44,20 +43,19 @@ public class FontAdder {
         this.resolver = resolver;
         this.listener = listener;
     }
-    
+
     /**
      * Iterates over font url list adding to font info list
      * @param fontURLList font file list
      * @param fontInfoList a configured font info list
      */
-    public void add(List/*<URL>*/ fontURLList, List/*<EmbedFontInfo>*/ fontInfoList) {
+    public void add(List<URL> fontURLList, List<EmbedFontInfo> fontInfoList) {
         FontCache cache = manager.getFontCache();
         FontInfoFinder finder = new FontInfoFinder();
         finder.setEventListener(listener);
 
-        for (Iterator iter = fontURLList.iterator(); iter.hasNext();) {
-            URL fontUrl = (URL)iter.next();
-            EmbedFontInfo[] embedFontInfos = finder.find(fontUrl, resolver, cache);
+        for (URL fontURL : fontURLList) {
+            EmbedFontInfo[] embedFontInfos = finder.find(fontURL, resolver, cache);
             if (embedFontInfos == null) {
                 continue;
             }

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontCache.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontCache.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontCache.java Tue Jan 18 08:54:08 2011
@@ -19,7 +19,9 @@
 
 package org.apache.fop.fonts;
 
+import java.io.BufferedInputStream;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.ObjectInputStream;
@@ -29,6 +31,7 @@ import java.io.Serializable;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
+import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.commons.io.FileUtils;
@@ -45,8 +48,8 @@ import org.apache.fop.util.LogUtil;
 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.
+     * Serialization Version UID. Change this value if you want to make sure the
+     * user's cache file is purged after an update.
      */
     private static final long serialVersionUID = 605232520271754719L;
 
@@ -59,19 +62,23 @@ public final class FontCache implements 
     /** 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 final boolean[] changeLock = new boolean[1];
 
-    /** 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;
+    /**
+     * 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;
 
-    /** mapping of font url -> file modified date (for all fonts that have failed to load) */
-    private Map failedFontMap/*<String, Long>*/ = null;
+    /**
+     * mapping of font url -> file modified date (for all fonts that have failed
+     * to load)
+     */
+    private Map<String, Long> failedFontMap = null;
 
     /**
      * Default constructor
@@ -100,7 +107,9 @@ public final class FontCache implements 
 
     /**
      * Returns the default font cache file.
-     * @param forWriting true if the user directory should be created
+     *
+     * @param forWriting
+     *            true if the user directory should be created
      * @return the default font cache file
      */
     public static File getDefaultCacheFile(boolean forWriting) {
@@ -125,8 +134,9 @@ public final class FontCache implements 
 
     /**
      * 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
-     *         it could not be read)
+     *
+     * @return the font cache deserialized from the file (or null if no cache
+     *         file exists or if it could not be read)
      */
     public static FontCache load() {
         return loadFrom(getDefaultCacheFile(false));
@@ -134,36 +144,41 @@ public final class FontCache implements 
 
     /**
      * Reads a font cache file and returns its contents.
-     * @param cacheFile the cache file
-     * @return the font cache deserialized from the file (or null if no cache file exists or if
-     *         it could not be read)
+     *
+     * @param cacheFile
+     *            the cache file
+     * @return the font cache deserialized from the file (or null if no cache
+     *         file exists or if it could not be read)
      */
     public static FontCache loadFrom(File cacheFile) {
         if (cacheFile.exists()) {
             try {
                 if (log.isTraceEnabled()) {
-                    log.trace("Loading font cache from " + cacheFile.getCanonicalPath());
+                    log.trace("Loading font cache from "
+                            + cacheFile.getCanonicalPath());
                 }
-                InputStream in = new java.io.FileInputStream(cacheFile);
-                in = new java.io.BufferedInputStream(in);
+                InputStream in = new BufferedInputStream(new FileInputStream(cacheFile));
                 ObjectInputStream oin = new ObjectInputStream(in);
                 try {
-                    return (FontCache)oin.readObject();
+                    return (FontCache) oin.readObject();
                 } finally {
                     IOUtils.closeQuietly(oin);
                 }
             } catch (ClassNotFoundException e) {
-                //We don't really care about the exception since it's just a cache file
+                // 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: "
                         + 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()
-                        + "). Discarding font cache file.");
+                // 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() + "). Discarding font cache file.");
                 try {
                     cacheFile.delete();
                 } catch (SecurityException ex) {
-                    log.warn("Failed to delete font cache file: " + cacheFile.getAbsolutePath());
+                    log.warn("Failed to delete font cache file: "
+                            + cacheFile.getAbsolutePath());
                 }
             }
         }
@@ -172,7 +187,9 @@ public final class FontCache implements 
 
     /**
      * Writes the font cache to disk.
-     * @throws FOPException fop exception
+     *
+     * @throws FOPException
+     *             fop exception
      */
     public void save() throws FOPException {
         saveTo(getDefaultCacheFile(true));
@@ -180,16 +197,17 @@ public final class FontCache implements 
 
     /**
      * Writes the font cache to disk.
-     * @param cacheFile the file to write to
-     * @throws FOPException fop exception
+     *
+     * @param cacheFile
+     *            the file to write to
+     * @throws FOPException
+     *             fop exception
      */
     public void saveTo(File cacheFile) throws FOPException {
         synchronized (changeLock) {
             if (changed) {
                 try {
-                    if (log.isTraceEnabled()) {
-                        log.trace("Writing font cache to " + cacheFile.getCanonicalPath());
-                    }
+                    log.trace("Writing font cache to " + cacheFile.getCanonicalPath());
                     OutputStream out = new java.io.FileOutputStream(cacheFile);
                     out = new java.io.BufferedOutputStream(out);
                     ObjectOutputStream oout = new ObjectOutputStream(out);
@@ -209,7 +227,9 @@ public final class FontCache implements 
 
     /**
      * creates a key given a font info for the font mapping
-     * @param fontInfo font info
+     *
+     * @param fontInfo
+     *            font info
      * @return font cache key
      */
     protected static String getCacheKey(EmbedFontInfo fontInfo) {
@@ -223,6 +243,7 @@ public final class FontCache implements 
 
     /**
      * cache has been updated since it was read
+     *
      * @return if this cache has changed
      */
     public boolean hasChanged() {
@@ -231,28 +252,33 @@ public final class FontCache implements 
 
     /**
      * is this font in the cache?
-     * @param embedUrl font info
+     *
+     * @param embedUrl
+     *            font info
      * @return boolean
      */
     public boolean containsFont(String embedUrl) {
-        return (embedUrl != null
-                && getFontFileMap().containsKey(embedUrl));
+        return (embedUrl != null && getFontFileMap().containsKey(embedUrl));
     }
 
     /**
      * is this font info in the cache?
-     * @param fontInfo font info
+     *
+     * @param fontInfo
+     *            font info
      * @return font
      */
     public boolean containsFont(EmbedFontInfo fontInfo) {
-        return (fontInfo != null
-                && getFontFileMap().containsKey(getCacheKey(fontInfo)));
+        return (fontInfo != null && getFontFileMap().containsKey(
+                getCacheKey(fontInfo)));
     }
 
     /**
-     * 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
+     * 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
      */
     public static File getFileFromUrls(String[] urls) {
@@ -279,31 +305,34 @@ public final class FontCache implements 
         return null;
     }
 
-    private Map/*<String, CachedFontFile>*/ getFontFileMap() {
+    private Map<String, CachedFontFile> getFontFileMap() {
         if (fontfileMap == null) {
-            fontfileMap = new java.util.HashMap/*<String, CachedFontFile>*/();
+            fontfileMap = new HashMap<String, CachedFontFile>();
         }
         return fontfileMap;
     }
 
     /**
      * Adds a font info to cache
-     * @param fontInfo font info
+     *
+     * @param fontInfo
+     *            font info
      */
     public void addFont(EmbedFontInfo fontInfo) {
         String cacheKey = getCacheKey(fontInfo);
         synchronized (changeLock) {
             CachedFontFile cachedFontFile;
             if (containsFont(cacheKey)) {
-                cachedFontFile = (CachedFontFile)getFontFileMap().get(cacheKey);
+                cachedFontFile = getFontFileMap().get(cacheKey);
                 if (!cachedFontFile.containsFont(fontInfo)) {
                     cachedFontFile.put(fontInfo);
                 }
             } else {
                 // try and determine modified date
-                File fontFile = getFileFromUrls(new String[]
-                                     {fontInfo.getEmbedFile(), fontInfo.getMetricsFile()});
-                long lastModified = (fontFile != null ? fontFile.lastModified() : -1);
+                File fontFile = getFileFromUrls(new String[] {
+                        fontInfo.getEmbedFile(), fontInfo.getMetricsFile() });
+                long lastModified = (fontFile != null ? fontFile.lastModified()
+                        : -1);
                 cachedFontFile = new CachedFontFile(lastModified);
                 if (log.isTraceEnabled()) {
                     log.trace("Font added to cache: " + cacheKey);
@@ -317,19 +346,26 @@ public final class FontCache implements 
 
     /**
      * Returns a font from the cache.
-     * @param embedUrl font info
+     *
+     * @param embedUrl
+     *            font info
      * @return CachedFontFile object
      */
     public CachedFontFile getFontFile(String embedUrl) {
-        return containsFont(embedUrl) ? (CachedFontFile) getFontFileMap().get(embedUrl) : null;
+        return containsFont(embedUrl) ? getFontFileMap().get(embedUrl) : 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.
-     * @param embedUrl the font URL
-     * @param lastModified the last modified date/time of the font file
-     * @return the EmbedFontInfo instances or null if there's no cached entry or if it is outdated
+     * 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.
+     *
+     * @param embedUrl
+     *            the font URL
+     * @param lastModified
+     *            the last modified date/time of the font file
+     * @return the EmbedFontInfo instances or null if there's no cached entry or
+     *         if it is outdated
      */
     public EmbedFontInfo[] getFontInfos(String embedUrl, long lastModified) {
         CachedFontFile cff = getFontFile(embedUrl);
@@ -343,7 +379,9 @@ public final class FontCache implements 
 
     /**
      * removes font from cache
-     * @param embedUrl embed url
+     *
+     * @param embedUrl
+     *            embed url
      */
     public void removeFont(String embedUrl) {
         synchronized (changeLock) {
@@ -359,14 +397,18 @@ public final class FontCache implements 
 
     /**
      * has this font previously failed to load?
-     * @param embedUrl embed url
-     * @param lastModified last modified
+     *
+     * @param embedUrl
+     *            embed url
+     * @param lastModified
+     *            last modified
      * @return whether this is a failed font
      */
     public boolean isFailedFont(String embedUrl, long lastModified) {
         synchronized (changeLock) {
             if (getFailedFontMap().containsKey(embedUrl)) {
-                long failedLastModified = ((Long)getFailedFontMap().get(embedUrl)).longValue();
+                long failedLastModified = getFailedFontMap().get(
+                        embedUrl).longValue();
                 if (lastModified != failedLastModified) {
                     // this font has been changed so lets remove it
                     // from failed font map for now
@@ -382,8 +424,11 @@ public final class FontCache implements 
 
     /**
      * Registers a failed font with the cache
-     * @param embedUrl embed url
-     * @param lastModified time last modified
+     *
+     * @param embedUrl
+     *            embed url
+     * @param lastModified
+     *            time last modified
      */
     public void registerFailedFont(String embedUrl, long lastModified) {
         synchronized (changeLock) {
@@ -394,9 +439,9 @@ public final class FontCache implements 
         }
     }
 
-    private Map/*<String, Long>*/ getFailedFontMap() {
+    private Map<String, Long> getFailedFontMap() {
         if (failedFontMap == null) {
-            failedFontMap = new java.util.HashMap/*<String, Long>*/();
+            failedFontMap = new HashMap<String, Long>();
         }
         return failedFontMap;
     }
@@ -417,7 +462,9 @@ public final class FontCache implements 
 
     /**
      * Retrieve the last modified date/time of a URL.
-     * @param url the URL
+     *
+     * @param url
+     *            the URL
      * @return the last modified date/time
      */
     public static long getLastModified(URL url) {
@@ -426,7 +473,8 @@ public final class FontCache implements 
             try {
                 return conn.getLastModified();
             } finally {
-                //An InputStream is created even if it's not accessed, but we need to close it.
+                // An InputStream is created even if it's not accessed, but we
+                // need to close it.
                 IOUtils.closeQuietly(conn.getInputStream());
             }
         } catch (IOException e) {
@@ -442,15 +490,15 @@ public final class FontCache implements 
         /** file modify date (if available) */
         private long lastModified = -1;
 
-        private Map/*<String, EmbedFontInfo>*/ filefontsMap = null;
+        private Map<String, EmbedFontInfo> filefontsMap = null;
 
         public CachedFontFile(long lastModified) {
             setLastModified(lastModified);
         }
 
-        private Map/*<String, EmbedFontInfo>*/ getFileFontsMap() {
+        private Map<String, EmbedFontInfo> getFileFontsMap() {
             if (filefontsMap == null) {
-                filefontsMap = new java.util.HashMap/*<String, EmbedFontInfo>*/();
+                filefontsMap = new HashMap<String, EmbedFontInfo>();
             }
             return filefontsMap;
         }
@@ -465,12 +513,13 @@ public final class FontCache implements 
         }
 
         public EmbedFontInfo[] getEmbedFontInfos() {
-            return (EmbedFontInfo[])getFileFontsMap().values().toArray(
+            return getFileFontsMap().values().toArray(
                     new EmbedFontInfo[getFileFontsMap().size()]);
         }
 
         /**
          * Gets the modified timestamp for font file (not always available)
+         *
          * @return modified timestamp
          */
         public long lastModified() {
@@ -478,17 +527,18 @@ public final class FontCache implements 
         }
 
         /**
-         * Gets the modified timestamp for font file
-         * (used for the purposes of font info caching)
-         * @param lastModified modified font file timestamp
+         * Gets the modified timestamp for font file (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
-         * {@inheritDoc}
+         * @return string representation of this object {@inheritDoc}
          */
         public String toString() {
             return super.toString() + ", lastModified=" + lastModified;

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontDetector.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontDetector.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontDetector.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontDetector.java Tue Jan 18 08:54:08 2011
@@ -41,10 +41,10 @@ public class FontDetector {
     private static final String[] FONT_MIMETYPES = {
         "application/x-font", "application/x-font-truetype"
     };
-    
-    private FontManager fontManager;
-    private FontAdder fontAdder;
-    private boolean strict;
+
+    private final FontManager fontManager;
+    private final FontAdder fontAdder;
+    private final boolean strict;
 
     /**
      * Main constructor
@@ -63,7 +63,7 @@ public class FontDetector {
      * @param fontInfoList a list of fontinfo to populate
      * @throws FOPException thrown if a problem occurred during detection
      */
-    public void detect(List/*<EmbedFontInfo>*/ fontInfoList) throws FOPException {
+    public void detect(List<EmbedFontInfo> fontInfoList) throws FOPException {
         // search in font base if it is defined and
         // is a directory but don't recurse
         FontFileFinder fontFileFinder = new FontFileFinder();
@@ -72,10 +72,9 @@ public class FontDetector {
             try {
                 File fontBase = FileUtils.toFile(new URL(fontBaseURL));
                 if (fontBase != null) {
-                    List/*<URL>*/ fontURLList = fontFileFinder.find(
-                            fontBase.getAbsolutePath());
+                    List<URL> fontURLList = fontFileFinder.find(fontBase.getAbsolutePath());
                     fontAdder.add(fontURLList, fontInfoList);
-                    
+
                     //Can only use the font base URL if it's a file URL
                 }
             } catch (IOException e) {
@@ -84,7 +83,7 @@ public class FontDetector {
         }
 
         // native o/s font directory finding
-        List/*<URL>*/ systemFontList;
+        List<URL> systemFontList;
         try {
             systemFontList = fontFileFinder.find();
             fontAdder.add(systemFontList, fontInfoList);

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontInfo.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontInfo.java Tue Jan 18 08:54:08 2011
@@ -19,12 +19,15 @@
 
 package org.apache.fop.fonts;
 
-import java.util.Collection;
+import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Iterator;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -41,29 +44,29 @@ import org.apache.commons.logging.LogFac
 public class FontInfo {
 
     /** logging instance */
-    protected static Log log = LogFactory.getLog(FontInfo.class);
+    protected static final Log log = LogFactory.getLog(FontInfo.class);
 
     /** Map containing fonts that have been used */
-    private Map/*<String,FontMetrics>*/ usedFonts = null; //(String = font key)
+    private Map<String, Typeface> usedFonts = null; //(String = font key)
 
     /** look up a font-triplet to find a font-name */
-    private Map/*<FontTriplet,String>*/ triplets = null; //(String = font key)
+    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>
+    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)
+    private Map<String, Typeface> fonts = null; //(String = font key)
 
     /**
      *  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;
+    private Set<FontTriplet> loggedFontKeys = null;
 
     /** Cache for Font instances. */
-    private Map/*<FontTriplet, Map>*/ fontInstanceCache = null;
+    private Map<FontTriplet, Map<Integer, Font>> fontInstanceCache = null;
 
     /** Event listener for font events */
     private FontEventListener eventListener = null;
@@ -72,10 +75,10 @@ public class FontInfo {
      * Main constructor
      */
     public FontInfo() {
-        this.triplets = new java.util.HashMap/*<FontTriplet, String>*/();
-        this.tripletPriorities = new java.util.HashMap/*<FontTriplet, Integer>*/();
-        this.fonts = new java.util.HashMap/*<String, FontMetrics>*/();
-        this.usedFonts = new java.util.HashMap/*<String,FontMetrics>*/();
+        this.triplets = new HashMap<FontTriplet, String>();
+        this.tripletPriorities = new HashMap<FontTriplet, Integer>();
+        this.fonts = new HashMap<String, Typeface>();
+        this.usedFonts = new HashMap<String, Typeface>();
     }
 
     /**
@@ -135,10 +138,10 @@ public class FontInfo {
         if (log.isDebugEnabled()) {
             log.debug("Registering: " + triplet + " under " + internalFontKey);
         }
-        String oldName = (String)triplets.get(triplet);
+        String oldName = triplets.get(triplet);
         int newPriority = triplet.getPriority();
         if (oldName != null) {
-            int oldPriority = ((Integer)tripletPriorities.get(triplet)).intValue();
+            int oldPriority = tripletPriorities.get(triplet).intValue();
             if (oldPriority < newPriority) {
                 logDuplicateFont(triplet, false, oldName, oldPriority,
                             internalFontKey, newPriority);
@@ -168,9 +171,9 @@ public class FontInfo {
         if (log.isDebugEnabled()) {
             log.debug(triplet
                     + (replacing ? ": Replacing " : ": Not replacing ")
-                    + ((FontMetrics)fonts.get(triplets.get(triplet))).getFullName()
+                    + fonts.get(triplets.get(triplet)).getFullName()
                     + " (priority=" + oldPriority + ") by "
-                    + ((FontMetrics)fonts.get(newKey)).getFullName()
+                    + fonts.get(newKey).getFullName()
                     + " (priority=" + newPriority + ")");
         }
     }
@@ -186,7 +189,7 @@ public class FontInfo {
         if (metrics instanceof Typeface) {
             ((Typeface)metrics).setEventListener(this.eventListener);
         }
-        this.fonts.put(internalFontKey, metrics);
+        this.fonts.put(internalFontKey, (Typeface)metrics);
     }
 
     /**
@@ -292,9 +295,9 @@ public class FontInfo {
         usedFonts.put(internalName, fonts.get(internalName));
     }
 
-    private Map/*<FontTriplet,Map<Integer,Font>>*/ getFontInstanceCache() {
+    private Map<FontTriplet, Map<Integer, Font>> getFontInstanceCache() {
         if (fontInstanceCache == null) {
-            fontInstanceCache = new java.util.HashMap/*<FontTriplet, Map<Integer,Font>>*/();
+            fontInstanceCache = new HashMap<FontTriplet, Map<Integer, Font>>();
         }
         return fontInstanceCache;
     }
@@ -307,14 +310,14 @@ public class FontInfo {
      * @return the requested Font instance
      */
     public Font getFontInstance(FontTriplet triplet, int fontSize) {
-        Map/*<Integer,Font>*/ sizes
-            = (Map/*<Integer,Font>*/)getFontInstanceCache().get(triplet);
+        Map<Integer, Font> sizes
+            = getFontInstanceCache().get(triplet);
         if (sizes == null) {
-            sizes = new java.util.HashMap/*<Integer,Font>*/();
+            sizes = new HashMap<Integer, Font>();
             getFontInstanceCache().put(triplet, sizes);
         }
         Integer size = new Integer(fontSize);
-        Font font = (Font)sizes.get(size);
+        Font font = sizes.get(size);
         if (font == null) {
             String fontKey = getInternalFontKey(triplet);
             useFont(fontKey);
@@ -325,11 +328,9 @@ public class FontInfo {
         return font;
     }
 
-    private List/*<FontTriplet>*/ getTripletsForName(String fontName) {
-        List/*<FontTriplet>*/ matchedTriplets = new java.util.ArrayList/*<FontTriplet>*/();
-        Iterator it = triplets.keySet().iterator();
-        while (it.hasNext()) {
-            FontTriplet triplet = (FontTriplet)it.next();
+    private List<FontTriplet> getTripletsForName(String fontName) {
+        List<FontTriplet> matchedTriplets = new ArrayList<FontTriplet>();
+        for (FontTriplet triplet : triplets.keySet()) {
             String tripletName = triplet.getName();
             if (tripletName.toLowerCase().equals(fontName.toLowerCase())) {
                 matchedTriplets.add(triplet);
@@ -351,11 +352,9 @@ public class FontInfo {
         int awtFontWeight = awtFont.isBold() ? Font.WEIGHT_BOLD : Font.WEIGHT_NORMAL;
 
         FontTriplet matchedTriplet = null;
-        List/*<FontTriplet>*/ triplets = getTripletsForName(awtFontName);
+        List<FontTriplet> triplets = getTripletsForName(awtFontName);
         if (!triplets.isEmpty()) {
-            Iterator it = triplets.iterator();
-            while (it.hasNext()) {
-                FontTriplet triplet = (FontTriplet)it.next();
+            for (FontTriplet triplet : triplets) {
                 boolean styleMatched = triplet.getStyle().equals(awtFontStyle);
                 boolean weightMatched = triplet.getWeight() == awtFontWeight;
                 if (styleMatched && weightMatched) {
@@ -393,9 +392,9 @@ public class FontInfo {
         return fontLookup(family, style, weight, true);
     }
 
-    private List/*<FontTriplet>*/ fontLookup(String[] families, String style,
+    private List<FontTriplet> fontLookup(String[] families, String style,
             int weight, boolean substitutable) {
-        List/*<FontTriplet>*/ matchingTriplets = new java.util.ArrayList/*<FontTriplet>*/();
+        List<FontTriplet> matchingTriplets = new ArrayList<FontTriplet>();
         FontTriplet triplet = null;
         for (int i = 0; i < families.length; i++) {
             triplet = fontLookup(families[i], style, weight, substitutable);
@@ -426,7 +425,7 @@ public class FontInfo {
         }
 
         // try matching without substitutions
-        List/*<FontTriplet>*/ matchedTriplets = fontLookup(families, style, weight, false);
+        List<FontTriplet> matchedTriplets = fontLookup(families, style, weight, false);
 
         // if there are no matching font triplets found try with substitutions
         if (matchedTriplets.size() == 0) {
@@ -454,9 +453,9 @@ public class FontInfo {
         return fontTriplets;
     }
 
-    private Set/*<FontTriplet>*/ getLoggedFontKeys() {
+    private Set<FontTriplet> getLoggedFontKeys() {
         if (loggedFontKeys == null) {
-            loggedFontKeys = new java.util.HashSet/*<FontTriplet>*/();
+            loggedFontKeys = new HashSet<FontTriplet>();
         }
         return loggedFontKeys;
     }
@@ -544,7 +543,7 @@ public class FontInfo {
      * @return the associated internal key or null, if not found
      */
     public String getInternalFontKey(FontTriplet triplet) {
-        return (String)triplets.get(triplet);
+        return triplets.get(triplet);
     }
 
     /**
@@ -563,15 +562,15 @@ public class FontInfo {
      * Gets a Map of all registered fonts.
      * @return a read-only Map with font key/FontMetrics pairs
      */
-    public Map/*<String,FontMetrics>*/ getFonts() {
-        return java.util.Collections.unmodifiableMap(this.fonts);
+    public Map<String, Typeface> getFonts() {
+        return Collections.unmodifiableMap(this.fonts);
     }
 
     /**
      * Gets a Map of all registered font triplets.
      * @return a Map with FontTriplet/font key pairs
      */
-    public Map/*<FontTriplet,String>*/ getFontTriplets() {
+    public Map<FontTriplet, String> getFontTriplets() {
         return this.triplets;
     }
 
@@ -581,7 +580,7 @@ public class FontInfo {
      * This is for embedded font or creating a list of used fonts.
      * @return a read-only Map with font key/FontMetrics pairs
      */
-    public Map/*<String,FontMetrics>*/ getUsedFonts() {
+    public Map<String, Typeface> getUsedFonts() {
         return this.usedFonts;
     }
 
@@ -591,7 +590,7 @@ public class FontInfo {
      * @return font metrics
      */
     public FontMetrics getMetricsFor(String fontName) {
-        FontMetrics metrics = (FontMetrics)fonts.get(fontName);
+        Typeface metrics = fonts.get(fontName);
         usedFonts.put(fontName, metrics);
         return metrics;
     }
@@ -601,10 +600,9 @@ public class FontInfo {
      * @param fontName The font name we are looking for
      * @return A list of matching font triplets
      */
-    public List/*<FontTriplet>*/ getTripletsFor(String fontName) {
-        List/*<FontTriplet>*/ foundTriplets = new java.util.ArrayList();
-        for (Iterator iter = triplets.entrySet().iterator(); iter.hasNext();) {
-            Map.Entry tripletEntry = (Map.Entry) iter.next();
+    public List<FontTriplet> getTripletsFor(String fontName) {
+        List<FontTriplet> foundTriplets = new ArrayList<FontTriplet> ();
+        for (Map.Entry<FontTriplet, String> tripletEntry : triplets.entrySet()) {
             if (fontName.equals((tripletEntry.getValue()))) {
                 foundTriplets.add(tripletEntry.getKey());
             }
@@ -620,10 +618,10 @@ public class FontInfo {
      * @return The first triplet for the given font name
      */
     public FontTriplet getTripletFor(String fontName) {
-        List/*<FontTriplet>*/ foundTriplets = getTripletsFor(fontName);
+        List<FontTriplet> foundTriplets = getTripletsFor(fontName);
         if (foundTriplets.size() > 0) {
             Collections.sort(foundTriplets);
-            return (FontTriplet)foundTriplets.get(0);
+            return foundTriplets.get(0);
         }
         return null;
     }
@@ -672,18 +670,17 @@ public class FontInfo {
     /**
      * {@inheritDoc}
      */
+    @Override
     public String toString() {
-        Collection entries = new java.util.TreeSet();
-        Iterator iter = this.triplets.keySet().iterator();
-        while (iter.hasNext()) {
-            FontTriplet triplet = (FontTriplet)iter.next();
+        SortedSet<String> entries = new TreeSet<String>();
+        for (FontTriplet triplet : this.triplets.keySet()) {
             String key = getInternalFontKey(triplet);
             FontMetrics metrics = getMetricsFor(key);
             entries.add(triplet.toString() + " -> " + key + " -> " + metrics.getFontName() + "\n");
         }
         StringBuffer stringBuffer = new StringBuffer();
-        for (iter = entries.iterator(); iter.hasNext();) {
-            stringBuffer.append(iter.next());
+        for (String str : entries) {
+            stringBuffer.append(str);
         }
         return stringBuffer.toString();
     }

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontInfoConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontInfoConfigurator.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontInfoConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontInfoConfigurator.java Tue Jan 18 08:54:08 2011
@@ -33,7 +33,6 @@ import org.apache.avalon.framework.confi
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fonts.autodetect.FontFileFinder;
 import org.apache.fop.fonts.autodetect.FontInfoFinder;
@@ -44,13 +43,13 @@ import org.apache.fop.util.LogUtil;
  */
 public class FontInfoConfigurator {
     /** logger instance */
-    protected static Log log = LogFactory.getLog(FontInfoConfigurator.class);
+    protected static final Log log = LogFactory.getLog(FontInfoConfigurator.class);
 
-    private Configuration cfg;
-    private FontManager fontManager;
-    private FontResolver fontResolver;
-    private FontEventListener listener;
-    private boolean strict;
+    private final Configuration cfg;
+    private final FontManager fontManager;
+    private final FontResolver fontResolver;
+    private final FontEventListener listener;
+    private final boolean strict;
 
     /**
      * Main constructor
@@ -74,9 +73,10 @@ public class FontInfoConfigurator {
      * @param fontInfoList a font info list
      * @throws FOPException if an exception occurs while processing the configuration
      */
-    public void configure(List/*<EmbedFontInfo>*/ fontInfoList) throws FOPException {
-        Configuration fonts = cfg.getChild("fonts", false);
-        if (fonts != null) {
+    public void configure(List<EmbedFontInfo> fontInfoList)
+            throws FOPException {
+        Configuration fontsCfg = cfg.getChild("fonts", false);
+        if (fontsCfg != null) {
             long start = 0;
             if (log.isDebugEnabled()) {
                 log.debug("Starting font configuration...");
@@ -86,24 +86,23 @@ public class FontInfoConfigurator {
             FontAdder fontAdder = new FontAdder(fontManager, fontResolver, listener);
 
             // native o/s search (autodetect) configuration
-            boolean autodetectFonts = (fonts.getChild("auto-detect", false) != null);
+            boolean autodetectFonts = (fontsCfg.getChild("auto-detect", false) != null);
             if (autodetectFonts) {
                 FontDetector fontDetector = new FontDetector(fontManager, fontAdder, strict);
                 fontDetector.detect(fontInfoList);
             }
 
-            // Add configured directories to FontInfo
-            addDirectories(fonts, fontAdder, fontInfoList);
+            // Add configured directories to FontInfo list
+            addDirectories(fontsCfg, fontAdder, fontInfoList);
 
-            // Add configured fonts to FontInfo
-            FontCache fontCache = fontManager.getFontCache();
-            addFonts(fonts, fontCache, fontInfoList);
+            // Add fonts from configuration to FontInfo list
+            addFonts(fontsCfg, fontManager.getFontCache(), fontInfoList);
 
             // Update referenced fonts (fonts which are not to be embedded)
             fontManager.updateReferencedFonts(fontInfoList);
 
             // Renderer-specific referenced fonts
-            Configuration referencedFontsCfg = fonts.getChild("referenced-fonts", false);
+            Configuration referencedFontsCfg = fontsCfg.getChild("referenced-fonts", false);
             if (referencedFontsCfg != null) {
                 FontTriplet.Matcher matcher = FontManagerConfigurator.createFontsMatcher(
                         referencedFontsCfg, strict);
@@ -111,9 +110,7 @@ public class FontInfoConfigurator {
             }
 
             // Update font cache if it has changed
-            if (fontCache != null && fontCache.hasChanged()) {
-                fontCache.save();
-            }
+            fontManager.saveCache();
 
             if (log.isDebugEnabled()) {
                 log.debug("Finished font configuration in "
@@ -123,7 +120,7 @@ public class FontInfoConfigurator {
     }
 
     private void addDirectories(Configuration fontsCfg,
-            FontAdder fontAdder, List/*<URL>*/ fontInfoList) throws FOPException {
+            FontAdder fontAdder, List<EmbedFontInfo> fontInfoList) throws FOPException {
         // directory (multiple font) configuration
         Configuration[] directories = fontsCfg.getChildren("directory");
         for (int i = 0; i < directories.length; i++) {
@@ -143,7 +140,7 @@ public class FontInfoConfigurator {
 
             // add fonts found in directory
             FontFileFinder fontFileFinder = new FontFileFinder(recursive ? -1 : 1);
-            List/*<URL>*/ fontURLList;
+            List<URL> fontURLList;
             try {
                 fontURLList = fontFileFinder.find(directory);
                 fontAdder.add(fontURLList, fontInfoList);
@@ -161,7 +158,7 @@ public class FontInfoConfigurator {
      * @throws FOPException if an exception occurs while processing the configuration
      */
     protected void addFonts(Configuration fontsCfg, FontCache fontCache,
-            List/*<EmbedFontInfo>*/ fontInfoList) throws FOPException {
+            List<EmbedFontInfo> fontInfoList) throws FOPException {
         // font file (singular) configuration
         Configuration[] font = fontsCfg.getChildren("font");
         for (int i = 0; i < font.length; i++) {
@@ -189,9 +186,8 @@ public class FontInfoConfigurator {
      * @return the embedded font info
      * @throws FOPException if something's wrong with the config data
      */
-    protected EmbedFontInfo getFontInfo(
-            Configuration fontCfg, FontCache fontCache)
-                    throws FOPException {
+    protected EmbedFontInfo getFontInfo(Configuration fontCfg, FontCache fontCache)
+            throws FOPException {
         String metricsUrl = fontCfg.getAttribute("metrics-url", null);
         String embedUrl = fontCfg.getAttribute("embed-url", null);
         String subFont = fontCfg.getAttribute("sub-font", null);
@@ -232,32 +228,30 @@ public class FontInfoConfigurator {
             LogUtil.handleError(log, "font without font-triplet", strict);
 
             File fontFile = FontCache.getFileFromUrls(new String[] {embedUrl, metricsUrl});
-            URL fontUrl;
+            URL fontURL = null;
             try {
-                fontUrl = fontFile.toURI().toURL();
+                fontURL = fontFile.toURI().toURL();
             } catch (MalformedURLException e) {
-                // Should never happen
-                log.debug("Malformed Url: " + e.getMessage());
-                return null;
+                LogUtil.handleException(log, e, strict);
             }
             if (fontFile != null) {
                 FontInfoFinder finder = new FontInfoFinder();
                 finder.setEventListener(listener);
-                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>*/();
+        List<FontTriplet> tripletList = new java.util.ArrayList<FontTriplet>();
         for (int j = 0; j < tripletCfg.length; j++) {
             FontTriplet fontTriplet = getFontTriplet(tripletCfg[j]);
             tripletList.add(fontTriplet);
         }
 
         boolean useKerning = fontCfg.getAttributeAsBoolean("kerning", true);
-        EncodingMode encodingMode = EncodingMode.valueOf(
+        EncodingMode encodingMode = EncodingMode.getEncodingMode(
                 fontCfg.getAttribute("encoding-mode", EncodingMode.AUTO.getName()));
         EmbedFontInfo embedFontInfo
                 = new EmbedFontInfo(metricsUrl, useKerning, tripletList, embedUrl, subFont);
@@ -273,7 +267,7 @@ public class FontInfoConfigurator {
             log.debug("Adding font " + (embedFile != null ? embedFile + ", " : "")
                     + "metric file " + embedFontInfo.getMetricsFile());
             for (int j = 0; j < tripletList.size(); ++j) {
-                FontTriplet triplet = (FontTriplet) tripletList.get(j);
+                FontTriplet triplet = tripletList.get(j);
                 log.debug("  Font triplet "
                         + triplet.getName() + ", "
                         + triplet.getStyle() + ", "

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontLoader.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontLoader.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontLoader.java Tue Jan 18 08:54:08 2011
@@ -40,7 +40,7 @@ import org.apache.fop.fonts.type1.Type1F
 public abstract class FontLoader {
 
     /** logging instance */
-    protected static Log log = LogFactory.getLog(FontLoader.class);
+    protected static final Log log = LogFactory.getLog(FontLoader.class);
 
     /** URI representing the font file */
     protected String fontFileURI = null;

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontManager.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontManager.java Tue Jan 18 08:54:08 2011
@@ -19,19 +19,19 @@
 
 package org.apache.fop.fonts;
 
+import java.io.File;
 import java.net.MalformedURLException;
-import java.util.Iterator;
 import java.util.List;
 
 import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
 
+import org.apache.fop.apps.FOPException;
 import org.apache.fop.fonts.FontTriplet.Matcher;
 import org.apache.fop.fonts.substitute.FontSubstitutions;
 
 // 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
+// are all centrally managed and delegated from this class
 
 /**
  * The manager of fonts. The class holds a reference to the font cache and information about
@@ -56,11 +56,16 @@ public class FontManager {
     /** FontTriplet matcher for fonts that shall be referenced rather than embedded. */
     private FontTriplet.Matcher referencedFontsMatcher;
 
+    /** Enables/disables the use of font caching */
+    private boolean useCache = DEFAULT_USE_CACHE;
+
+    /** Provides a font cache file path **/
+    private File cacheFile;
+
     /**
      * Main constructor
      */
     public FontManager() {
-        setUseCache(DEFAULT_USE_CACHE);
     }
 
     /**
@@ -113,16 +118,31 @@ public class FontManager {
     }
 
     /**
+     * Sets the font cache file
+     * @param cacheFile the font cache file
+     */
+    public void setCacheFile(File cacheFile) {
+        this.cacheFile = cacheFile;
+    }
+
+    /**
+     * Returns the font cache file
+     * @return the font cache file
+     */
+    public File getCacheFile() {
+        if (cacheFile != null) {
+            return this.cacheFile;
+        }
+        return FontCache.getDefaultCacheFile(false);
+    }
+
+    /**
      * Whether or not to cache results of font triplet detection/auto-config
      * @param useCache use cache or not
      */
     public void setUseCache(boolean useCache) {
-        if (useCache) {
-            this.fontCache = FontCache.load();
-            if (this.fontCache == null) {
-                this.fontCache = new FontCache();
-            }
-        } else {
+        this.useCache = useCache;
+        if (!useCache) {
             this.fontCache = null;
         }
     }
@@ -132,7 +152,7 @@ public class FontManager {
      * @return true if this font manager uses the cache
      */
     public boolean useCache() {
-        return (this.fontCache != null);
+        return useCache;
     }
 
     /**
@@ -140,7 +160,52 @@ public class FontManager {
      * @return the font cache
      */
     public FontCache getFontCache() {
-        return this.fontCache;
+        if (fontCache == null) {
+            if (useCache) {
+                if (cacheFile != null) {
+                    fontCache = FontCache.loadFrom(cacheFile);
+                } else {
+                    fontCache = FontCache.load();
+                }
+                if (fontCache == null) {
+                    fontCache = new FontCache();
+                }
+            }
+        }
+        return fontCache;
+    }
+
+    /**
+     * Saves the FontCache as necessary
+     *
+     * @throws FOPException fop exception
+     */
+    public void saveCache() throws FOPException {
+        if (useCache) {
+            if (fontCache != null && fontCache.hasChanged()) {
+                if (cacheFile != null) {
+                    fontCache.saveTo(cacheFile);
+                } else {
+                    fontCache.save();
+                }
+            }
+        }
+    }
+
+    /**
+     * Deletes the current FontCache file
+     * @return Returns true if the font cache file was successfully deleted.
+     */
+    public boolean deleteCache() {
+        boolean deleted = false;
+        if (useCache) {
+            if (cacheFile != null) {
+                deleted = cacheFile.delete();
+            } else {
+                deleted = FontCache.getDefaultCacheFile(true).delete();
+            }
+        }
+        return deleted;
     }
 
     /**
@@ -194,7 +259,7 @@ public class FontManager {
      * ({@link #getReferencedFontsMatcher()}).
      * @param fontInfoList a font info list
      */
-    public void updateReferencedFonts(List fontInfoList) {
+    public void updateReferencedFonts(List<EmbedFontInfo> fontInfoList) {
         Matcher matcher = getReferencedFontsMatcher();
         updateReferencedFonts(fontInfoList, matcher);
     }
@@ -204,16 +269,12 @@ public class FontManager {
      * @param fontInfoList a font info list
      * @param matcher the font triplet matcher to use
      */
-    public void updateReferencedFonts(List fontInfoList, Matcher matcher) {
+    public void updateReferencedFonts(List<EmbedFontInfo> fontInfoList, Matcher matcher) {
         if (matcher == null) {
             return; //No referenced fonts
         }
-        Iterator iter = fontInfoList.iterator();
-        while (iter.hasNext()) {
-            EmbedFontInfo fontInfo = (EmbedFontInfo)iter.next();
-            Iterator triplets = fontInfo.getFontTriplets().iterator();
-            while (triplets.hasNext()) {
-                FontTriplet triplet = (FontTriplet)triplets.next();
+        for (EmbedFontInfo fontInfo : fontInfoList) {
+            for (FontTriplet triplet : fontInfo.getFontTriplets()) {
                 if (matcher.matches(triplet)) {
                     fontInfo.setEmbedded(false);
                     break;

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontManagerConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontManagerConfigurator.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontManagerConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontManagerConfigurator.java Tue Jan 18 08:54:08 2011
@@ -19,7 +19,9 @@
 
 package org.apache.fop.fonts;
 
+import java.io.File;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.util.List;
 import java.util.regex.Pattern;
 
@@ -27,7 +29,6 @@ import org.apache.avalon.framework.confi
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fonts.substitute.FontSubstitutions;
 import org.apache.fop.fonts.substitute.FontSubstitutionsConfigurator;
@@ -41,7 +42,9 @@ public class FontManagerConfigurator {
     /** logger instance */
     private static Log log = LogFactory.getLog(FontManagerConfigurator.class);
 
-    private Configuration cfg;
+    private final Configuration cfg;
+
+    private URI baseURI = null;
 
     /**
      * Main constructor
@@ -52,26 +55,44 @@ public class FontManagerConfigurator {
     }
 
     /**
+     * Main constructor
+     * @param cfg the font manager configuration object
+     * @param baseURI the base URI of the configuration
+     */
+    public FontManagerConfigurator(Configuration cfg, URI baseURI) {
+        this.cfg = cfg;
+        this.baseURI = baseURI;
+    }
+
+    /**
      * Initializes font settings from the user configuration
      * @param fontManager a font manager
      * @param strict true if strict checking of the configuration is enabled
      * @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 {
-                fontManager.setUseCache(
-                        cfg.getChild("use-cache").getValueAsBoolean());
-            } catch (ConfigurationException mfue) {
-                LogUtil.handleException(log, mfue, true);
+                fontManager.setUseCache(cfg.getChild("use-cache").getValueAsBoolean());
+            } catch (ConfigurationException e) {
+                LogUtil.handleException(log, e, true);
+            }
+        }
+        if (cfg.getChild("cache-file", false) != null) {
+            try {
+                fontManager.setCacheFile(new File(cfg.getChild("cache-file").getValue()));
+            } catch (ConfigurationException e) {
+                LogUtil.handleException(log, e, true);
             }
         }
         if (cfg.getChild("font-base", false) != null) {
+            String path = cfg.getChild("font-base").getValue(null);
+            if (baseURI != null) {
+                path = baseURI.resolve(path).normalize().toString();
+            }
             try {
-                fontManager.setFontBaseURL(
-                        cfg.getChild("font-base").getValue(null));
+                fontManager.setFontBaseURL(path);
             } catch (MalformedURLException mfue) {
                 LogUtil.handleException(log, mfue, true);
             }
@@ -80,13 +101,12 @@ public class FontManagerConfigurator {
         // global font configuration
         Configuration fontsCfg = cfg.getChild("fonts", false);
         if (fontsCfg != null) {
+
             // font substitution
             Configuration substitutionsCfg = fontsCfg.getChild("substitutions", false);
             if (substitutionsCfg != null) {
-                FontSubstitutionsConfigurator fontSubstitutionsConfigurator
-                        = new FontSubstitutionsConfigurator(substitutionsCfg);
                 FontSubstitutions substitutions = new FontSubstitutions();
-                fontSubstitutionsConfigurator.configure(substitutions);
+                new FontSubstitutionsConfigurator(substitutionsCfg).configure(substitutions);
                 fontManager.setFontSubstitutions(substitutions);
             }
 
@@ -110,7 +130,7 @@ public class FontManagerConfigurator {
      */
     public static FontTriplet.Matcher createFontsMatcher(
             Configuration cfg, boolean strict) throws FOPException {
-        List matcherList = new java.util.ArrayList();
+        List<FontTriplet.Matcher> matcherList = new java.util.ArrayList<FontTriplet.Matcher>();
         Configuration[] matches = cfg.getChildren("match");
         for (int i = 0; i < matches.length; i++) {
             try {
@@ -122,14 +142,13 @@ public class FontManagerConfigurator {
             }
         }
         FontTriplet.Matcher orMatcher = new OrFontTripletMatcher(
-                (FontTriplet.Matcher[])matcherList.toArray(
-                        new FontTriplet.Matcher[matcherList.size()]));
+                matcherList.toArray(new FontTriplet.Matcher[matcherList.size()]));
         return orMatcher;
     }
 
     private static class OrFontTripletMatcher implements FontTriplet.Matcher {
 
-        private FontTriplet.Matcher[] matchers;
+        private final FontTriplet.Matcher[] matchers;
 
         public OrFontTripletMatcher(FontTriplet.Matcher[] matchers) {
             this.matchers = matchers;
@@ -149,7 +168,7 @@ public class FontManagerConfigurator {
 
     private static class FontFamilyRegExFontTripletMatcher implements FontTriplet.Matcher {
 
-        private Pattern regex;
+        private final Pattern regex;
 
         public FontFamilyRegExFontTripletMatcher(String regex) {
             this.regex = Pattern.compile(regex);

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontMetrics.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontMetrics.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontMetrics.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontMetrics.java Tue Jan 18 08:54:08 2011
@@ -45,7 +45,7 @@ public interface FontMetrics {
      * Returns the font's family names as a Set of Strings (Example: "Helvetica").
      * @return the font's family names (a Set of Strings)
      */
-    Set getFamilyNames();
+    Set<String> getFamilyNames();
 
     /**
      * Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT").
@@ -129,6 +129,6 @@ public interface FontMetrics {
      * Returns the kerning map for the font.
      * @return the kerning map
      */
-    Map getKerningInfo();
+    Map<Integer, Map<Integer, Integer>> getKerningInfo();
 
 }

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontReader.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontReader.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontReader.java Tue Jan 18 08:54:08 2011
@@ -21,6 +21,9 @@ package org.apache.fop.fonts;
 
 //Java
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -56,12 +59,12 @@ public class FontReader extends DefaultH
     private SingleByteFont singleFont = null;
     private StringBuffer text = new StringBuffer();
 
-    private List cidWidths = null;
+    private List<Integer> cidWidths = null;
     private int cidWidthIndex = 0;
 
-    private Map currentKerning = null;
+    private Map<Integer, Integer> currentKerning = null;
 
-    private List bfranges = null;
+    private List<BFEntry> bfranges = null;
 
     private void createFont(InputSource source) throws FOPException {
         XMLReader parser = null;
@@ -181,13 +184,13 @@ public class FontReader extends DefaultH
             returnFont.setEmbedResourceName(attributes.getValue("class"));
         } else if ("cid-widths".equals(localName)) {
             cidWidthIndex = getInt(attributes.getValue("start-index"));
-            cidWidths = new java.util.ArrayList();
+            cidWidths = new ArrayList<Integer>();
         } else if ("kerning".equals(localName)) {
-            currentKerning = new java.util.HashMap();
+            currentKerning = new HashMap<Integer, Integer>();
             returnFont.putKerningEntry(new Integer(attributes.getValue("kpx1")),
                                         currentKerning);
         } else if ("bfranges".equals(localName)) {
-            bfranges = new java.util.ArrayList();
+            bfranges = new ArrayList<BFEntry>();
         } else if ("bf".equals(localName)) {
             BFEntry entry = new BFEntry(getInt(attributes.getValue("us")),
                                         getInt(attributes.getValue("ue")),
@@ -231,7 +234,7 @@ public class FontReader extends DefaultH
         } else if ("full-name".equals(localName)) {
             returnFont.setFullName(content);
         } else if ("family-name".equals(localName)) {
-            Set s = new java.util.HashSet();
+            Set<String> s = new HashSet<String>();
             s.add(content);
             returnFont.setFamilyNames(s);
         } else if ("ttc-name".equals(localName) && isCID) {
@@ -284,15 +287,14 @@ public class FontReader extends DefaultH
             int[] wds = new int[cidWidths.size()];
             int j = 0;
             for (int count = 0; count < cidWidths.size(); count++) {
-                Integer i = (Integer)cidWidths.get(count);
-                wds[j++] = i.intValue();
+                wds[j++] = cidWidths.get(count).intValue();
             }
 
             //multiFont.addCIDWidthEntry(cidWidthIndex, wds);
             multiFont.setWidthArray(wds);
 
         } else if ("bfranges".equals(localName)) {
-            multiFont.setBFEntries((BFEntry[])bfranges.toArray(new BFEntry[0]));
+            multiFont.setBFEntries(bfranges.toArray(new BFEntry[0]));
         }
         text.setLength(0); //Reset text buffer (see characters())
     }

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontSetup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontSetup.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontSetup.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontSetup.java Tue Jan 18 08:54:08 2011
@@ -25,8 +25,6 @@ import java.util.List;
 import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.fop.fonts.base14.Courier;
 import org.apache.fop.fonts.base14.CourierBold;
 import org.apache.fop.fonts.base14.CourierBoldOblique;
@@ -51,12 +49,10 @@ import org.apache.fop.fonts.base14.ZapfD
  * Assigns the font (with metrics) to internal names like "F1" and
  * assigns family-style-weight triplets to the fonts
  */
-public class FontSetup {
+public final class FontSetup {
 
-    /**
-     * logging instance
-     */
-    protected static Log log = LogFactory.getLog(FontSetup.class);
+    private FontSetup() {
+    }
 
     /**
      * Sets up a font info
@@ -76,7 +72,8 @@ public class FontSetup {
      * @param embedFontInfoList a list of EmbedFontInfo objects
      * @param resolver the font resolver
      */
-    public static void setup(FontInfo fontInfo, List embedFontInfoList, FontResolver resolver) {
+    public static void setup(FontInfo fontInfo, List<EmbedFontInfo> embedFontInfoList,
+            FontResolver resolver) {
         final boolean base14Kerning = false;
         fontInfo.addMetrics("F1", new Helvetica(base14Kerning));
         fontInfo.addMetrics("F2", new HelveticaOblique(base14Kerning));
@@ -194,7 +191,7 @@ public class FontSetup {
      * @param resolver the font resolver
      */
     private static void addConfiguredFonts(FontInfo fontInfo,
-            List/*<EmbedFontInfo>*/ embedFontInfoList, int num, FontResolver resolver) {
+            List<EmbedFontInfo> embedFontInfoList, int num, FontResolver resolver) {
         if (embedFontInfoList == null) {
             return; //No fonts to process
         }
@@ -206,18 +203,16 @@ public class FontSetup {
 
         String internalName = null;
 
-        for (int i = 0; i < embedFontInfoList.size(); i++) {
-            EmbedFontInfo embedFontInfo = (EmbedFontInfo)embedFontInfoList.get(i);
-
+        for (EmbedFontInfo embedFontInfo : embedFontInfoList) {
             internalName = "F" + num;
             num++;
 
             LazyFont font = new LazyFont(embedFontInfo, resolver);
             fontInfo.addMetrics(internalName, font);
 
-            List triplets = embedFontInfo.getFontTriplets();
+            List<FontTriplet> triplets = embedFontInfo.getFontTriplets();
             for (int tripletIndex = 0; tripletIndex < triplets.size(); tripletIndex++) {
-                FontTriplet triplet = (FontTriplet) triplets.get(tripletIndex);
+                FontTriplet triplet = triplets.get(tripletIndex);
                 fontInfo.addFontProperties(internalName, triplet);
             }
         }

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontTriplet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontTriplet.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontTriplet.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontTriplet.java Tue Jan 18 08:54:08 2011
@@ -25,7 +25,7 @@ import java.io.Serializable;
 /**
  * FontTriplet contains information on name, style and weight of one font
  */
-public class FontTriplet implements Comparable, Serializable {
+public class FontTriplet implements Comparable<FontTriplet>, Serializable {
 
     /** serial version UID */
     private static final long serialVersionUID = 1168991106658033508L;
@@ -99,8 +99,8 @@ public class FontTriplet implements Comp
     }
 
     /** {@inheritDoc} */
-    public int compareTo(Object o) {
-        return getKey().compareTo(((FontTriplet)o).getKey());
+    public int compareTo(FontTriplet o) {
+        return getKey().compareTo(o.getKey());
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontType.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontType.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontType.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontType.java Tue Jan 18 08:54:08 2011
@@ -54,6 +54,9 @@ public class FontType {
 
 
     /**
+     * Construct a font type.
+     * @param name a font type name
+     * @param value a font type value
      * @see org.apache.avalon.framework.Enum#Enum(String)
      */
     protected FontType(String name, int value) {

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontUtil.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontUtil.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/FontUtil.java Tue Jan 18 08:54:08 2011
@@ -23,7 +23,10 @@ package org.apache.fop.fonts;
 /**
  * Font utilities.
  */
-public class FontUtil {
+public final class FontUtil {
+
+    private FontUtil() {
+    }
 
     /**
      * Parses an CSS2 (SVG and XSL-FO) font weight (normal, bold, 100-900) to

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/Glyphs.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/Glyphs.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/Glyphs.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/Glyphs.java Tue Jan 18 08:54:08 2011
@@ -23,7 +23,10 @@ package org.apache.fop.fonts;
  * This class provides a number of constants for glyph management.
  * @deprecated Use the Glyphs class from XML Graphics Commons instead!
  */
-public class Glyphs {
+public final class Glyphs {
+
+    private Glyphs() {
+    }
 
     /**
      * Glyph name for the "notdef" glyph
@@ -33,7 +36,7 @@ public class Glyphs {
     /**
      * Glyph names for Mac encoding
      */
-    public static final String MAC_GLYPH_NAMES[] = {
+    public static final String[] MAC_GLYPH_NAMES = {
         /* 0x00 */
         NOTDEF, ".null", "CR", "space", "exclam", "quotedbl", "numbersign",
                 "dollar", "percent", "ampersand", "quotesingle", "parenleft",
@@ -1273,7 +1276,7 @@ public class Glyphs {
      * @param ch glyph to evaluate
      * @return the name of the glyph
      */
-    public static final String charToGlyphName(char ch) {
+    public static String charToGlyphName(char ch) {
         return stringToGlyph(new Character(ch).toString());
     }
 
@@ -1286,7 +1289,7 @@ public class Glyphs {
      * TODO: javadocs for glyphToString and stringToGlyph are confused
      * TODO: Improve method names
      */
-    public static final String glyphToString(String name) {
+    public static String glyphToString(String name) {
         for (int i = 0; i < UNICODE_GLYPHS.length; i += 2) {
             if (UNICODE_GLYPHS[i + 1].equals(name)) {
                 return UNICODE_GLYPHS[i];

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/LazyFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/LazyFont.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/LazyFont.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/LazyFont.java Tue Jan 18 08:54:08 2011
@@ -221,7 +221,7 @@ public class LazyFont extends Typeface i
     }
 
     /** {@inheritDoc} */
-    public Set getFamilyNames() {
+    public Set<String> getFamilyNames() {
         load(true);
         return realFont.getFamilyNames();
     }
@@ -293,7 +293,7 @@ public class LazyFont extends Typeface i
     /**
      * {@inheritDoc}
      */
-    public Map getKerningInfo() {
+    public Map<Integer, Map<Integer, Integer>> getKerningInfo() {
         load(true);
         return realFont.getKerningInfo();
     }

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/MultiByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/MultiByteFont.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/MultiByteFont.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/MultiByteFont.java Tue Jan 18 08:54:08 2011
@@ -237,11 +237,11 @@ public class MultiByteFont extends CIDFo
      * Returns a Map of used Glyphs.
      * @return Map Map of used Glyphs
      */
-    public Map getUsedGlyphs() {
+    public Map<Integer, Integer> getUsedGlyphs() {
         return subset.getSubsetGlyphs();
     }
 
-    /** {@inheritDoc} */
+    /** @return an array of the chars used */
     public char[] getCharsUsed() {
         if (!isEmbeddable()) {
             return null;

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/MutableFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/MutableFont.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/MutableFont.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/MutableFont.java Tue Jan 18 08:54:08 2011
@@ -46,7 +46,7 @@ public interface MutableFont {
      * Sets the font's family names (Example: "Helvetica").
      * @param names the font's family names (a Set of Strings)
      */
-    void setFamilyNames(Set names);
+    void setFamilyNames(Set<String> names);
 
     /**
      * Sets the path to the embeddable font file.
@@ -137,6 +137,6 @@ public interface MutableFont {
      * @param key Kerning key
      * @param value Kerning value
      */
-    void putKerningEntry(Integer key, Map value);
+    void putKerningEntry(Integer key, Map<Integer, Integer> value);
 
 }

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java Tue Jan 18 08:54:08 2011
@@ -19,13 +19,14 @@
 
 package org.apache.fop.fonts;
 
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.xmlgraphics.fonts.Glyphs;
-
 import org.apache.fop.util.CharUtilities;
+import org.apache.xmlgraphics.fonts.Glyphs;
 
 /**
  * A simple implementation of the OneByteEncoding mostly used for encodings that are constructed
@@ -33,11 +34,9 @@ import org.apache.fop.util.CharUtilities
  */
 public class SimpleSingleByteEncoding implements SingleByteEncoding {
 
-    private String name;
-    private List mapping = new java.util.ArrayList();
-    //List<NamedCharacter>
-    private Map charMap = new java.util.HashMap();
-    //Map<Character(Unicode), Character(code point)>
+    private final String name;
+    private final List<NamedCharacter> mapping = new ArrayList<NamedCharacter>();
+    private final Map<Character, Character> charMap = new HashMap<Character, Character>();
 
     /**
      * Main constructor.
@@ -54,7 +53,7 @@ public class SimpleSingleByteEncoding im
 
     /** {@inheritDoc} */
     public char mapChar(char c) {
-        Character nc = (Character)charMap.get(new Character(c));
+        Character nc = charMap.get(new Character(c));
         if (nc != null) {
             return nc.charValue();
         }
@@ -66,7 +65,7 @@ public class SimpleSingleByteEncoding im
         String[] map = new String[getSize()];
         Arrays.fill(map, Glyphs.NOTDEF);
         for (int i = getFirstChar(); i <= getLastChar(); i++) {
-            NamedCharacter ch = (NamedCharacter)this.mapping.get(i - 1);
+            NamedCharacter ch = this.mapping.get(i - 1);
             map[i] = ch.getName();
         }
         return map;
@@ -133,7 +132,7 @@ public class SimpleSingleByteEncoding im
             throw new IllegalArgumentException("codePoint must be between 0 and 255");
         }
         if (codePoint <= getLastChar()) {
-            return (NamedCharacter)this.mapping.get(codePoint - 1);
+            return this.mapping.get(codePoint - 1);
         } else {
             return null;
         }
@@ -152,6 +151,7 @@ public class SimpleSingleByteEncoding im
     }
 
     /** {@inheritDoc} */
+    @Override
     public String toString() {
         return getName() + " (" + getSize() + " chars)";
     }

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/SingleByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/SingleByteFont.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/SingleByteFont.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/SingleByteFont.java Tue Jan 18 08:54:08 2011
@@ -19,10 +19,12 @@
 
 package org.apache.fop.fonts;
 
-import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.TreeSet;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -40,9 +42,8 @@ public class SingleByteFont extends Cust
 
     private int[] width = null;
 
-    private Map unencodedCharacters;
-    //Map<Character, UnencodedCharacter>
-    private List additionalEncodings;
+    private Map<Character, UnencodedCharacter> unencodedCharacters;
+    private List<SimpleSingleByteEncoding> additionalEncodings;
 
 
     /**
@@ -59,6 +60,7 @@ public class SingleByteFont extends Cust
     }
 
     /** {@inheritDoc} */
+    @Override
     public String getEncodingName() {
         return this.mapping.getName();
     }
@@ -84,8 +86,7 @@ public class SingleByteFont extends Cust
             int codePoint = i % 256;
             NamedCharacter nc = encoding.getCharacterForIndex(codePoint);
             UnencodedCharacter uc
-                = (UnencodedCharacter)this.unencodedCharacters.get(
-                        new Character(nc.getSingleUnicodeValue()));
+                = this.unencodedCharacters.get(new Character(nc.getSingleUnicodeValue()));
             return size * uc.getWidth();
         }
         return 0;
@@ -99,6 +100,7 @@ public class SingleByteFont extends Cust
     }
 
     /** {@inheritDoc} */
+    @Override
     public char mapChar(char c) {
         notifyMapOperation();
         char d = mapping.mapChar(c);
@@ -117,11 +119,10 @@ public class SingleByteFont extends Cust
 
     private char mapUnencodedChar(char ch) {
         if (this.unencodedCharacters != null) {
-            UnencodedCharacter unencoded
-                = (UnencodedCharacter)this.unencodedCharacters.get(new Character(ch));
+            UnencodedCharacter unencoded = this.unencodedCharacters.get(new Character(ch));
             if (unencoded != null) {
                 if (this.additionalEncodings == null) {
-                    this.additionalEncodings = new java.util.ArrayList();
+                    this.additionalEncodings = new ArrayList<SimpleSingleByteEncoding>();
                 }
                 SimpleSingleByteEncoding encoding = null;
                 char mappedStart = 0;
@@ -150,6 +151,7 @@ public class SingleByteFont extends Cust
     }
 
     /** {@inheritDoc} */
+    @Override
     public boolean hasChar(char c) {
         char d = mapping.mapChar(c);
         if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) {
@@ -230,7 +232,7 @@ public class SingleByteFont extends Cust
      */
     public void addUnencodedCharacter(NamedCharacter ch, int width) {
         if (this.unencodedCharacters == null) {
-            this.unencodedCharacters = new java.util.HashMap();
+            this.unencodedCharacters = new HashMap<Character, UnencodedCharacter>();
         }
         if (ch.hasSingleUnicodeValue()) {
             UnencodedCharacter uc = new UnencodedCharacter(ch, width);
@@ -248,10 +250,8 @@ public class SingleByteFont extends Cust
      */
     public void encodeAllUnencodedCharacters() {
         if (this.unencodedCharacters != null) {
-            Set sortedKeys = new java.util.TreeSet(this.unencodedCharacters.keySet());
-            Iterator iter = sortedKeys.iterator();
-            while (iter.hasNext()) {
-                Character ch = (Character)iter.next();
+            Set<Character> sortedKeys = new TreeSet<Character>(this.unencodedCharacters.keySet());
+            for (Character ch : sortedKeys) {
                 char mapped = mapChar(ch.charValue());
                 assert mapped != Typeface.NOT_FOUND;
             }
@@ -287,7 +287,7 @@ public class SingleByteFont extends Cust
     public SimpleSingleByteEncoding getAdditionalEncoding(int index)
             throws IndexOutOfBoundsException {
         if (hasAdditionalEncodings()) {
-            return (SimpleSingleByteEncoding)this.additionalEncodings.get(index);
+            return this.additionalEncodings.get(index);
         } else {
             throw new IndexOutOfBoundsException("No additional encodings available");
         }
@@ -303,7 +303,7 @@ public class SingleByteFont extends Cust
         int[] arr = new int[enc.getLastChar() - enc.getFirstChar() + 1];
         for (int i = 0, c = arr.length; i < c; i++) {
             NamedCharacter nc = enc.getCharacterForIndex(enc.getFirstChar() + i);
-            UnencodedCharacter uc = (UnencodedCharacter)this.unencodedCharacters.get(
+            UnencodedCharacter uc = this.unencodedCharacters.get(
                     new Character(nc.getSingleUnicodeValue()));
             arr[i] = uc.getWidth();
         }
@@ -312,8 +312,8 @@ public class SingleByteFont extends Cust
 
     private static final class UnencodedCharacter {
 
-        private NamedCharacter character;
-        private int width;
+        private final NamedCharacter character;
+        private final int width;
 
         public UnencodedCharacter(NamedCharacter character, int width) {
             this.character = character;
@@ -329,6 +329,7 @@ public class SingleByteFont extends Cust
         }
 
         /** {@inheritDoc} */
+        @Override
         public String toString() {
             return getCharacter().toString();
         }

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/Typeface.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/Typeface.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/Typeface.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/Typeface.java Tue Jan 18 08:54:08 2011
@@ -19,6 +19,7 @@
 
 package org.apache.fop.fonts;
 
+import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.commons.logging.Log;
@@ -49,7 +50,7 @@ public abstract class Typeface implement
     /** An optional event listener that receives events such as missing glyphs etc. */
     protected FontEventListener eventListener;
 
-    private Set warnedChars;
+    private Set<Character> warnedChars;
 
     /**
      * Get the encoding of the font.
@@ -120,7 +121,7 @@ public abstract class Typeface implement
         // Give up, character is not available
         Character ch = new Character(c);
         if (warnedChars == null) {
-            warnedChars = new java.util.HashSet();
+            warnedChars = new HashSet<Character>();
         }
         if (warnedChars.size() < 8 && !warnedChars.contains(ch)) {
             warnedChars.add(ch);
@@ -139,9 +140,9 @@ public abstract class Typeface implement
             }
         }
     }
-    
+
     /** {@inheritDoc} */
     public String toString() {
         return getFullName();
-    }   
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java?rev=1060241&r1=1060240&r2=1060241&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java (original)
+++ xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java Tue Jan 18 08:54:08 2011
@@ -22,8 +22,8 @@ package org.apache.fop.fonts.autodetect;
 import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.io.DirectoryWalker;
@@ -91,6 +91,7 @@ public class FontFileFinder extends Dire
      * @return whether directory should be handled
      * {@inheritDoc}
      */
+    @Override
     protected boolean handleDirectory(File directory, int depth, Collection results) {
         return true;
     }
@@ -101,6 +102,7 @@ public class FontFileFinder extends Dire
      * @param results collection
      * {@inheritDoc}
      */
+    @Override
     protected void handleFile(File file, int depth, Collection results) {
         try {
             // Looks Strange, but is actually recommended over just .URL()
@@ -116,6 +118,7 @@ public class FontFileFinder extends Dire
      * @param results the collection of results objects
      * {@inheritDoc}
      */
+    @Override
     protected void handleDirectoryEnd(File directory, int depth, Collection results) {
         if (log.isDebugEnabled()) {
             log.debug(directory + ": found " + results.size() + " font"
@@ -130,8 +133,8 @@ public class FontFileFinder extends Dire
      * @throws IOException io exception
      * {@inheritDoc}
      */
-    public List/*<URL>*/ find() throws IOException {
-        final FontFinder fontDirFinder;
+    public List<URL> find() throws IOException {
+        final FontDirFinder fontDirFinder;
         final String osName = System.getProperty("os.name");
         if (osName.startsWith("Windows")) {
             fontDirFinder = new WindowsFontDirFinder();
@@ -142,10 +145,9 @@ public class FontFileFinder extends Dire
                 fontDirFinder = new UnixFontDirFinder();
             }
         }
-        List/*<URL>*/ fontDirs = fontDirFinder.find();
-        List/*<URL>*/ results = new java.util.ArrayList/*<URL>*/();
-        for (Iterator iter = fontDirs.iterator(); iter.hasNext();) {
-            final File dir = (File)iter.next();
+        List<File> fontDirs = fontDirFinder.find();
+        List<URL> results = new java.util.ArrayList<URL>();
+        for (File dir : fontDirs) {
             super.walk(dir, results);
         }
         return results;
@@ -158,8 +160,8 @@ public class FontFileFinder extends Dire
      * @return list of font files
      * @throws IOException thrown if an I/O exception of some sort has occurred
      */
-    public List find(String dir) throws IOException {
-        List results = new java.util.ArrayList();
+    public List<URL> find(String dir) throws IOException {
+        List<URL> results = new java.util.ArrayList<URL>();
         super.walk(new File(dir), results);
         return results;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message