Added some generics. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1142192 13f79535-47bb-0310-9956-ffa450edef68tags/fop-1_1rc1old
@@ -25,9 +25,10 @@ import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import org.apache.fop.util.CharUtilities; | |||
import org.apache.xmlgraphics.fonts.Glyphs; | |||
import org.apache.fop.util.CharUtilities; | |||
/** | |||
* A simple implementation of the OneByteEncoding mostly used for encodings that are constructed | |||
* on-the-fly. | |||
@@ -53,7 +54,7 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding { | |||
/** {@inheritDoc} */ | |||
public char mapChar(char c) { | |||
Character nc = charMap.get(new Character(c)); | |||
Character nc = charMap.get(Character.valueOf(c)); | |||
if (nc != null) { | |||
return nc.charValue(); | |||
} | |||
@@ -118,7 +119,7 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding { | |||
} | |||
char newSlot = (char)(getLastChar() + 1); | |||
this.mapping.add(ch); | |||
this.charMap.put(new Character(ch.getSingleUnicodeValue()), new Character(newSlot)); | |||
this.charMap.put(Character.valueOf(ch.getSingleUnicodeValue()), Character.valueOf(newSlot)); | |||
return newSlot; | |||
} | |||
@@ -81,7 +81,7 @@ public class SingleByteFont extends CustomFont { | |||
if (i < 256) { | |||
int idx = i - getFirstChar(); | |||
if (idx >= 0 && idx < width.length) { | |||
return size * width[i - getFirstChar()]; | |||
return size * width[idx]; | |||
} | |||
} else if (this.additionalEncodings != null) { | |||
int encodingIndex = (i / 256) - 1; | |||
@@ -89,7 +89,7 @@ public class SingleByteFont extends CustomFont { | |||
int codePoint = i % 256; | |||
NamedCharacter nc = encoding.getCharacterForIndex(codePoint); | |||
UnencodedCharacter uc | |||
= this.unencodedCharacters.get(new Character(nc.getSingleUnicodeValue())); | |||
= this.unencodedCharacters.get(Character.valueOf(nc.getSingleUnicodeValue())); | |||
return size * uc.getWidth(); | |||
} | |||
return 0; | |||
@@ -172,7 +172,7 @@ public class SingleByteFont extends CustomFont { | |||
private char mapUnencodedChar(char ch) { | |||
if (this.unencodedCharacters != null) { | |||
UnencodedCharacter unencoded = this.unencodedCharacters.get(new Character(ch)); | |||
UnencodedCharacter unencoded = this.unencodedCharacters.get(Character.valueOf(ch)); | |||
if (unencoded != null) { | |||
if (this.additionalEncodings == null) { | |||
this.additionalEncodings = new ArrayList<SimpleSingleByteEncoding>(); | |||
@@ -294,7 +294,7 @@ public class SingleByteFont extends CustomFont { | |||
} | |||
if (ch.hasSingleUnicodeValue()) { | |||
UnencodedCharacter uc = new UnencodedCharacter(ch, width); | |||
this.unencodedCharacters.put(new Character(ch.getSingleUnicodeValue()), uc); | |||
this.unencodedCharacters.put(Character.valueOf(ch.getSingleUnicodeValue()), uc); | |||
} else { | |||
//Cannot deal with unicode sequences, so ignore this character | |||
} | |||
@@ -362,7 +362,7 @@ public class SingleByteFont extends CustomFont { | |||
for (int i = 0, c = arr.length; i < c; i++) { | |||
NamedCharacter nc = enc.getCharacterForIndex(enc.getFirstChar() + i); | |||
UnencodedCharacter uc = this.unencodedCharacters.get( | |||
new Character(nc.getSingleUnicodeValue())); | |||
Character.valueOf(nc.getSingleUnicodeValue())); | |||
arr[i] = uc.getWidth(); | |||
} | |||
return arr; |
@@ -65,6 +65,7 @@ public class Type1FontLoader extends FontLoader { | |||
private static final String[] AFM_EXTENSIONS = new String[] {".AFM", ".afm", ".Afm"}; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void read() throws IOException { | |||
AFMFile afm = null; | |||
PFMFile pfm = null; | |||
@@ -173,10 +174,10 @@ public class Type1FontLoader extends FontLoader { | |||
} | |||
} | |||
private Set toGlyphSet(String[] glyphNames) { | |||
Set glyphSet = new java.util.HashSet(); | |||
for (int i = 0, c = glyphNames.length; i < c; i++) { | |||
glyphSet.add(glyphNames[i]); | |||
private Set<String> toGlyphSet(String[] glyphNames) { | |||
Set<String> glyphSet = new java.util.HashSet<String>(); | |||
for (String name : glyphNames) { | |||
glyphSet.add(name); | |||
} | |||
return glyphSet; | |||
} | |||
@@ -188,10 +189,9 @@ public class Type1FontLoader extends FontLoader { | |||
*/ | |||
private void addUnencodedBasedOnEncoding(AFMFile afm) { | |||
SingleByteEncoding encoding = singleFont.getEncoding(); | |||
Set glyphNames = toGlyphSet(encoding.getCharNameMap()); | |||
List charMetrics = afm.getCharMetrics(); | |||
for (int i = 0, c = afm.getCharCount(); i < c; i++) { | |||
AFMCharMetrics metrics = (AFMCharMetrics)charMetrics.get(i); | |||
Set<String> glyphNames = toGlyphSet(encoding.getCharNameMap()); | |||
List<AFMCharMetrics> charMetrics = afm.getCharMetrics(); | |||
for (AFMCharMetrics metrics : charMetrics) { | |||
String charName = metrics.getCharName(); | |||
if (charName != null && !glyphNames.contains(charName)) { | |||
singleFont.addUnencodedCharacter(metrics.getCharacter(), | |||
@@ -357,9 +357,7 @@ public class Type1FontLoader extends FontLoader { | |||
returnFont.setFirstChar(afm.getFirstChar()); | |||
returnFont.setLastChar(afm.getLastChar()); | |||
Iterator iter = afm.getCharMetrics().iterator(); | |||
while (iter.hasNext()) { | |||
AFMCharMetrics chm = (AFMCharMetrics)iter.next(); | |||
for (AFMCharMetrics chm : afm.getCharMetrics()) { | |||
if (chm.hasCharCode()) { | |||
singleFont.setWidth(chm.getCharCode(), (int)Math.round(chm.getWidthX())); | |||
} |