You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by sp...@apache.org on 2010/11/28 19:55:56 UTC
svn commit: r1039922 [1/2] - in
/xmlgraphics/fop/branches/Temp_ComplexScripts: ./
src/java/org/apache/fop/afp/apps/ src/java/org/apache/fop/afp/parser/
src/java/org/apache/fop/fonts/ src/java/org/apache/fop/fonts/autodetect/
src/java/org/apache/fop/fon...
Author: spepping
Date: Sun Nov 28 18:55:54 2010
New Revision: 1039922
URL: http://svn.apache.org/viewvc?rev=1039922&view=rev
Log:
Merged changes from trunk
Added:
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/autodetect/FontDirFinder.java
- copied unchanged from r1039913, xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontDirFinder.java
Modified:
xmlgraphics/fop/branches/Temp_ComplexScripts/ (props changed)
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/afp/apps/ (props changed)
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/afp/parser/ (props changed)
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CIDSubset.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CustomFont.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CustomFontCollection.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/EmbedFontInfo.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/Font.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontAdder.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontCache.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontDetector.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontInfo.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontInfoConfigurator.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontManager.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontManagerConfigurator.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontMetrics.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontReader.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontSetup.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontTriplet.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/LazyFont.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/MultiByteFont.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/MutableFont.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/SingleByteFont.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/Typeface.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/autodetect/FontFinder.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/truetype/TTFFile.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/pdf/PDFResources.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/PrintRenderer.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/PrintRendererConfigurator.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/afp/AFPPainter.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/ps/FontResourceCache.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/ps/PSFontUtils.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/tools/fontlist/FontSpec.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/util/ColorExt.java (props changed)
xmlgraphics/fop/branches/Temp_ComplexScripts/status.xml
xmlgraphics/fop/branches/Temp_ComplexScripts/test/layoutengine/disabled-testcases.xml
xmlgraphics/fop/branches/Temp_ComplexScripts/test/layoutengine/hyphenation-testcases/block_hyphenation_linefeed_preserve.xml
Propchange: xmlgraphics/fop/branches/Temp_ComplexScripts/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 28 18:55:54 2010
@@ -1,4 +1,4 @@
/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign:603620-746655
/xmlgraphics/fop/branches/fop-0_95:684572,688085,688696
/xmlgraphics/fop/branches/fop-1_0:959975-964707
-/xmlgraphics/fop/trunk:981451-1039180
+/xmlgraphics/fop/trunk:981451-1039913
Propchange: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/afp/apps/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 28 18:55:54 2010
@@ -2,4 +2,4 @@
/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/afp/apps:603620-746655
/xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/afp/apps:684572,688085,688696
/xmlgraphics/fop/branches/fop-1_0/src/java/org/apache/fop/afp/apps:959975-964707
-/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/apps:981451-1039180
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/apps:981451-1039913
Propchange: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/afp/parser/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 28 18:55:54 2010
@@ -2,4 +2,4 @@
/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/afp/parser:603620-746655
/xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/afp/parser:684572,688085,688696
/xmlgraphics/fop/branches/fop-1_0/src/java/org/apache/fop/afp/parser:959975-964707
-/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/parser:981451-1039180
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/parser:981451-1039913
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java Sun Nov 28 18:55:54 2010
@@ -20,24 +20,25 @@
package org.apache.fop.fonts;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.Map;
-import org.apache.xmlgraphics.fonts.Glyphs;
-
import org.apache.fop.util.CharUtilities;
+import org.apache.xmlgraphics.fonts.Glyphs;
/**
* Abstract base class for code point mapping classes (1-byte character encodings).
*/
public class AbstractCodePointMapping implements SingleByteEncoding {
- private String name;
+ private final String name;
private char[] latin1Map;
private char[] characters;
private char[] codepoints;
private char[] unicodeMap; //code point to Unicode char
private String[] charNameMap; //all character names in the encoding
- private Map fallbackMap; //Here we accumulate all mappings we have found through substitution
+ //Here we accumulate all mappings we have found through substitution
+ private Map<Character, Character> fallbackMap;
/**
* Main constructor.
@@ -144,7 +145,7 @@ public class AbstractCodePointMapping im
//Fallback: using cache
synchronized (this) {
if (fallbackMap != null) {
- Character fallback = (Character)fallbackMap.get(new Character(c));
+ Character fallback = fallbackMap.get(new Character(c));
if (fallback != null) {
return fallback.charValue();
}
@@ -172,7 +173,7 @@ public class AbstractCodePointMapping im
private void putFallbackCharacter(char c, char mapTo) {
synchronized (this) {
if (this.fallbackMap == null) {
- this.fallbackMap = new java.util.HashMap();
+ this.fallbackMap = new HashMap<Character, Character>();
}
this.fallbackMap.put(new Character(c), new Character(mapTo));
}
@@ -239,6 +240,7 @@ public class AbstractCodePointMapping im
}
/** {@inheritDoc} */
+ @Override
public String toString() {
return getName();
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CIDSubset.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CIDSubset.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CIDSubset.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CIDSubset.java Sun Nov 28 18:55:54 2010
@@ -21,7 +21,7 @@ package org.apache.fop.fonts;
import java.util.BitSet;
import java.util.Collections;
-import java.util.Iterator;
+import java.util.HashMap;
import java.util.Map;
import org.apache.fop.util.CharUtilities;
@@ -42,18 +42,18 @@ public class CIDSubset {
/**
* usedGlyphs contains orginal, new glyph index (glyph index -> char selector)
*/
- private Map/*<Integer, Integer>*/ usedGlyphs = new java.util.HashMap();
+ private Map<Integer, Integer> usedGlyphs = new HashMap<Integer, Integer>();
/**
* usedGlyphsIndex contains new glyph, original index (char selector -> glyph index)
*/
- private Map/*<Integer, Integer>*/ usedGlyphsIndex = new java.util.HashMap();
+ private Map<Integer, Integer> usedGlyphsIndex = new HashMap<Integer, Integer>();
private int usedGlyphsCount = 0;
/**
* usedCharsIndex contains new glyph, original char (char selector -> Unicode)
*/
- private Map/*<Integer, Character>*/ usedCharsIndex = new java.util.HashMap();
+ private Map<Integer, Character> usedCharsIndex = new HashMap<Integer, Character>();
/**
* Default constructor.
@@ -84,7 +84,7 @@ public class CIDSubset {
* @return the original index (or -1 if no glyph index is available for the subset index)
*/
public int getGlyphIndexForSubsetIndex(int subsetIndex) {
- Integer glyphIndex = (Integer)usedGlyphsIndex.get(new Integer(subsetIndex));
+ Integer glyphIndex = usedGlyphsIndex.get(new Integer(subsetIndex));
if (glyphIndex != null) {
return glyphIndex.intValue();
} else {
@@ -99,7 +99,7 @@ public class CIDSubset {
* @return the Unicode value or "NOT A CHARACTER" (0xFFFF)
*/
public char getUnicodeForSubsetIndex(int subsetIndex) {
- Character mapValue = (Character)usedCharsIndex.get(new Integer(subsetIndex));
+ Character mapValue = usedCharsIndex.get(new Integer(subsetIndex));
if (mapValue != null) {
return mapValue.charValue();
} else {
@@ -118,7 +118,7 @@ public class CIDSubset {
public int mapSubsetChar(int glyphIndex, char unicode) {
// Reencode to a new subset font or get the reencoded value
// IOW, accumulate the accessed characters and build a character map for them
- Integer subsetCharSelector = (Integer)usedGlyphs.get(new Integer(glyphIndex));
+ Integer subsetCharSelector = usedGlyphs.get(new Integer(glyphIndex));
if (subsetCharSelector == null) {
int selector = usedGlyphsCount;
usedGlyphs.put(new Integer(glyphIndex),
@@ -139,7 +139,7 @@ public class CIDSubset {
* character selector (i.e. the subset index in this case).
* @return Map Map<Integer, Integer> of the font subset
*/
- public Map/*<Integer, Integer>*/ getSubsetGlyphs() {
+ public Map<Integer, Integer> getSubsetGlyphs() {
return Collections.unmodifiableMap(this.usedGlyphs);
}
@@ -169,9 +169,7 @@ public class CIDSubset {
*/
public BitSet getGlyphIndexBitSet() {
BitSet bitset = new BitSet();
- Iterator iter = usedGlyphsIndex.keySet().iterator();
- while (iter.hasNext()) {
- Integer cid = (Integer)iter.next();
+ for (Integer cid : usedGlyphs.keySet()) {
bitset.set(cid.intValue());
}
return bitset;
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CustomFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CustomFont.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CustomFont.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CustomFont.java Sun Nov 28 18:55:54 2010
@@ -21,6 +21,8 @@ package org.apache.fop.fonts;
import java.io.IOException;
import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -35,7 +37,7 @@ public abstract class CustomFont extends
private String fontName = null;
private String fullName = null;
- private Set familyNames = null; //Set<String>
+ private Set<String> familyNames = null;
private String fontSubName = null;
private String embedFileName = null;
private String embedResourceName = null;
@@ -55,7 +57,7 @@ public abstract class CustomFont extends
private int firstChar = 0;
private int lastChar = 255;
- private Map kerning;
+ private Map<Integer, Map<Integer, Integer>> kerning;
private boolean useKerning = true;
private boolean useAdvanced = true;
@@ -79,7 +81,7 @@ public abstract class CustomFont extends
* Returns the font family names.
* @return the font family names (a Set of Strings)
*/
- public Set getFamilyNames() {
+ public Set<String> getFamilyNames() {
return Collections.unmodifiableSet(this.familyNames);
}
@@ -276,11 +278,11 @@ public abstract class CustomFont extends
/**
* {@inheritDoc}
*/
- public final Map getKerningInfo() {
+ public final Map<Integer, Map<Integer, Integer>> getKerningInfo() {
if (hasKerningInfo()) {
return kerning;
} else {
- return java.util.Collections.EMPTY_MAP;
+ return Collections.emptyMap();
}
}
@@ -306,8 +308,8 @@ public abstract class CustomFont extends
}
/** {@inheritDoc} */
- public void setFamilyNames(Set names) {
- this.familyNames = new java.util.HashSet(names);
+ public void setFamilyNames(Set<String> names) {
+ this.familyNames = new HashSet<String>(names);
}
/**
@@ -451,9 +453,9 @@ public abstract class CustomFont extends
}
/** {@inheritDoc} */
- public void putKerningEntry(Integer key, Map value) {
+ public void putKerningEntry(Integer key, Map<Integer, Integer> value) {
if (kerning == null) {
- kerning = new java.util.HashMap();
+ kerning = new HashMap<Integer, Map<Integer, Integer>>();
}
this.kerning.put(key, value);
}
@@ -463,9 +465,9 @@ public abstract class CustomFont extends
* @param kerningMap the kerning map (Map<Integer, Map<Integer, Integer>, the integers are
* character codes)
*/
- public void replaceKerningMap(Map kerningMap) {
+ public void replaceKerningMap(Map<Integer, Map<Integer, Integer>> kerningMap) {
if (kerningMap == null) {
- this.kerning = Collections.EMPTY_MAP;
+ this.kerning = Collections.emptyMap();
} else {
this.kerning = kerningMap;
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CustomFontCollection.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CustomFontCollection.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CustomFontCollection.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CustomFontCollection.java Sun Nov 28 18:55:54 2010
@@ -27,7 +27,7 @@ import java.util.List;
public class CustomFontCollection implements FontCollection {
private FontResolver fontResolver;
- private List/*<EmbedFontInfo>*/ embedFontInfoList;
+ private final List<EmbedFontInfo> embedFontInfoList;
/**
* Main constructor.
@@ -35,7 +35,7 @@ public class CustomFontCollection implem
* @param customFonts the list of custom fonts
*/
public CustomFontCollection(FontResolver fontResolver,
- List/*<EmbedFontInfo>*/ customFonts) {
+ List<EmbedFontInfo> customFonts) {
this.fontResolver = fontResolver;
if (this.fontResolver == null) {
//Ensure that we have minimal font resolution capabilities
@@ -54,7 +54,7 @@ public class CustomFontCollection implem
//FontReader reader = null;
for (int i = 0; i < embedFontInfoList.size(); i++) {
- EmbedFontInfo embedFontInfo = (EmbedFontInfo)embedFontInfoList.get(i);
+ EmbedFontInfo embedFontInfo = embedFontInfoList.get(i);
//String metricsFile = configFontInfo.getMetricsFile();
internalName = "F" + num;
@@ -69,7 +69,7 @@ public class CustomFontCollection implem
LazyFont font = new LazyFont(embedFontInfo, this.fontResolver);
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);
fontInfo.addFontProperties(internalName, triplet);
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/EmbedFontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/EmbedFontInfo.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/EmbedFontInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/EmbedFontInfo.java Sun Nov 28 18:55:54 2010
@@ -48,7 +48,7 @@ public class EmbedFontInfo implements Se
protected String subFontName = null;
/** the list of associated font triplets */
- private List/*<FontTriplet>*/ fontTriplets = null;
+ private List<FontTriplet> fontTriplets = null;
private transient boolean embedded = true;
@@ -62,7 +62,7 @@ public class EmbedFontInfo implements Se
* @param subFontName the sub-fontname used for TrueType Collections (null otherwise)
*/
public EmbedFontInfo(String metricsFile, boolean kerning, boolean advanced,
- List/*<FontTriplet>*/ fontTriplets, String embedFile, String subFontName) {
+ List<FontTriplet> fontTriplets, String embedFile, String subFontName) {
this.metricsFile = metricsFile;
this.embedFile = embedFile;
this.kerning = kerning;
@@ -132,7 +132,7 @@ public class EmbedFontInfo implements Se
* Returns the list of font triplets associated with this font.
* @return List of font triplets
*/
- public List/*<FontTriplet>*/ getFontTriplets() {
+ public List<FontTriplet> getFontTriplets() {
return fontTriplets;
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/Font.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/Font.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/Font.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/Font.java Sun Nov 28 18:55:54 2010
@@ -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;
// CSOFF: LineLengthCheck
@@ -162,11 +162,11 @@ public class Font implements Substitutab
* 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();
}
}
@@ -180,9 +180,9 @@ public class Font implements Substitutab
* @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(new Integer(ch1));
if (kernPair != null) {
- Integer width = (Integer)kernPair.get(new Integer(ch2));
+ Integer width = kernPair.get(new Integer(ch2));
if (width != null) {
return width.intValue() * getFontSize() / 1000;
}
@@ -241,6 +241,7 @@ public class Font implements Substitutab
/**
* {@inheritDoc}
*/
+ @Override
public String toString() {
StringBuffer sbuf = new StringBuffer(super.toString());
sbuf.append('{');
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontAdder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontAdder.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontAdder.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontAdder.java Sun Nov 28 18:55:54 2010
@@ -20,7 +20,6 @@
package org.apache.fop.fonts;
import java.net.URL;
-import java.util.Iterator;
import java.util.List;
import org.apache.fop.fonts.autodetect.FontInfoFinder;
@@ -29,9 +28,9 @@ import org.apache.fop.fonts.autodetect.F
* 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
@@ -50,14 +49,13 @@ public class FontAdder {
* @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_ComplexScripts/src/java/org/apache/fop/fonts/FontCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontCache.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontCache.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontCache.java Sun Nov 28 18:55:54 2010
@@ -31,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;
@@ -71,13 +72,13 @@ public final class FontCache implements
* 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;
+ 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;
+ private Map<String, Long> failedFontMap = null;
/**
* Default constructor
@@ -304,9 +305,9 @@ 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;
}
@@ -322,8 +323,7 @@ public final class FontCache implements
synchronized (changeLock) {
CachedFontFile cachedFontFile;
if (containsFont(cacheKey)) {
- cachedFontFile = (CachedFontFile) getFontFileMap()
- .get(cacheKey);
+ cachedFontFile = getFontFileMap().get(cacheKey);
if (!cachedFontFile.containsFont(fontInfo)) {
cachedFontFile.put(fontInfo);
}
@@ -352,8 +352,7 @@ public final class FontCache implements
* @return CachedFontFile object
*/
public CachedFontFile getFontFile(String embedUrl) {
- return containsFont(embedUrl) ? (CachedFontFile) getFontFileMap().get(
- embedUrl) : null;
+ return containsFont(embedUrl) ? getFontFileMap().get(embedUrl) : null;
}
/**
@@ -408,8 +407,8 @@ public final class FontCache implements
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
@@ -440,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;
}
@@ -491,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;
}
@@ -514,7 +513,7 @@ public final class FontCache implements
}
public EmbedFontInfo[] getEmbedFontInfos() {
- return (EmbedFontInfo[]) getFileFontsMap().values().toArray(
+ return getFileFontsMap().values().toArray(
new EmbedFontInfo[getFileFontsMap().size()]);
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontDetector.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontDetector.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontDetector.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontDetector.java Sun Nov 28 18:55:54 2010
@@ -42,9 +42,9 @@ public class FontDetector {
"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,8 +72,7 @@ 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
@@ -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_ComplexScripts/src/java/org/apache/fop/fonts/FontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontInfo.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontInfo.java Sun Nov 28 18:55:54 2010
@@ -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;
@@ -44,26 +47,26 @@ public class FontInfo {
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_ComplexScripts/src/java/org/apache/fop/fonts/FontInfoConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontInfoConfigurator.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontInfoConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontInfoConfigurator.java Sun Nov 28 18:55:54 2010
@@ -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;
@@ -46,11 +45,11 @@ public class FontInfoConfigurator {
/** logger instance */
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,7 +73,8 @@ 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 {
+ public void configure(List<EmbedFontInfo> fontInfoList)
+ throws FOPException {
Configuration fontsCfg = cfg.getChild("fonts", false);
if (fontsCfg != null) {
long start = 0;
@@ -120,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++) {
@@ -140,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);
@@ -158,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++) {
@@ -186,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);
@@ -229,25 +228,23 @@ 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);
@@ -276,7 +273,7 @@ public class FontInfoConfigurator {
+ (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_ComplexScripts/src/java/org/apache/fop/fonts/FontManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontManager.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontManager.java Sun Nov 28 18:55:54 2010
@@ -21,7 +21,6 @@ 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;
@@ -260,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);
}
@@ -270,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_ComplexScripts/src/java/org/apache/fop/fonts/FontManagerConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontManagerConfigurator.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontManagerConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontManagerConfigurator.java Sun Nov 28 18:55:54 2010
@@ -28,7 +28,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;
@@ -42,7 +41,7 @@ public class FontManagerConfigurator {
/** logger instance */
private static Log log = LogFactory.getLog(FontManagerConfigurator.class);
- private Configuration cfg;
+ private final Configuration cfg;
/**
* Main constructor
@@ -126,7 +125,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 {
@@ -138,14 +137,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;
@@ -165,7 +163,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_ComplexScripts/src/java/org/apache/fop/fonts/FontMetrics.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontMetrics.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontMetrics.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontMetrics.java Sun Nov 28 18:55:54 2010
@@ -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_ComplexScripts/src/java/org/apache/fop/fonts/FontReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontReader.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontReader.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontReader.java Sun Nov 28 18:55:54 2010
@@ -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;
@@ -57,12 +60,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;
@@ -190,13 +193,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")),
@@ -241,7 +244,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) {
@@ -294,15 +297,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_ComplexScripts/src/java/org/apache/fop/fonts/FontSetup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontSetup.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontSetup.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontSetup.java Sun Nov 28 18:55:54 2010
@@ -72,7 +72,8 @@ public final 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));
@@ -190,7 +191,7 @@ public final 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
}
@@ -202,18 +203,16 @@ public final 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_ComplexScripts/src/java/org/apache/fop/fonts/FontTriplet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontTriplet.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontTriplet.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontTriplet.java Sun Nov 28 18:55:54 2010
@@ -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_ComplexScripts/src/java/org/apache/fop/fonts/LazyFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/LazyFont.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/LazyFont.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/LazyFont.java Sun Nov 28 18:55:54 2010
@@ -230,7 +230,7 @@ public class LazyFont extends Typeface i
}
/** {@inheritDoc} */
- public Set getFamilyNames() {
+ public Set<String> getFamilyNames() {
load(true);
return realFont.getFamilyNames();
}
@@ -302,7 +302,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_ComplexScripts/src/java/org/apache/fop/fonts/MultiByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/MultiByteFont.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/MultiByteFont.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/MultiByteFont.java Sun Nov 28 18:55:54 2010
@@ -275,7 +275,7 @@ 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();
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/MutableFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/MutableFont.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/MutableFont.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/MutableFont.java Sun Nov 28 18:55:54 2010
@@ -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.
@@ -143,6 +143,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_ComplexScripts/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java Sun Nov 28 18:55:54 2010
@@ -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_ComplexScripts/src/java/org/apache/fop/fonts/SingleByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/SingleByteFont.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/SingleByteFont.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/SingleByteFont.java Sun Nov 28 18:55:54 2010
@@ -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_ComplexScripts/src/java/org/apache/fop/fonts/Typeface.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/Typeface.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/Typeface.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/Typeface.java Sun Nov 28 18:55:54 2010
@@ -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);
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java Sun Nov 28 18:55:54 2010
@@ -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;
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/autodetect/FontFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/autodetect/FontFinder.java?rev=1039922&r1=1039921&r2=1039922&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/autodetect/FontFinder.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/autodetect/FontFinder.java Sun Nov 28 18:55:54 2010
@@ -20,6 +20,7 @@
package org.apache.fop.fonts.autodetect;
import java.io.IOException;
+import java.net.URL;
import java.util.List;
/**
@@ -31,12 +32,10 @@ public interface FontFinder {
/**
* Finds a list of font files.
*
- * @return list of font files. List<URL> in the case of the
- * FontFinder, and List<File> in the case of the
- * FonrDirFinders.
+ * @return list of font files.
* @throws IOException
* In case of an I/O problem
*/
- List/*<URL>*/ find() throws IOException;
+ List<URL> find() throws IOException;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org