Package org.apache.batik.svggen
Class SVGFont.CharListHelper
- java.lang.Object
-
- org.apache.batik.svggen.SVGFont.CharListHelper
-
- Enclosing class:
- SVGFont
private static class SVGFont.CharListHelper extends java.lang.Objectthis helper-class implements a set of characters. it stores all used characters in a font.
implementation: we keep a sorted list of integers. This allows to use binary search for lookup and insert. The use ofintinstead ofcharallows us to handle surrogate characters as well.
-
-
Field Summary
Fields Modifier and Type Field Description private int[]charListkeeps added characters, is kept sorted for efficient search.private java.lang.StringBufferfreshCharsthis keeps all added characters in order.private intnUsedthe number of slots actually used.
-
Constructor Summary
Constructors Constructor Description CharListHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) booleanadd(int c)test, if the character is contained in the charList.(package private) static intbinSearch(int[] list, int nUsed, int chr)unfortunatly, Arrays.binarySearch() does not support search in a part of the array (not in jdk1.3 and jdk1.4).(package private) voidclearNewChars()reset the string of recently added characters - used after glyphs were created for them.(package private) java.lang.StringgetNewChars()get a string of all characters added since last call to clearNewChars().
-
-
-
Field Detail
-
nUsed
private int nUsed
the number of slots actually used. must always be 0 <= nUsed <= charList.length
-
charList
private int[] charList
keeps added characters, is kept sorted for efficient search.
-
freshChars
private java.lang.StringBuffer freshChars
this keeps all added characters in order. It can be cleared from toSVG() when glyphs are created for some characters.
-
-
Method Detail
-
getNewChars
java.lang.String getNewChars()
get a string of all characters added since last call to clearNewChars().- Returns:
- a string of all recently added characters
-
clearNewChars
void clearNewChars()
reset the string of recently added characters - used after glyphs were created for them.
-
add
boolean add(int c)
test, if the character is contained in the charList. If not, insert c into charList. charList is kept sorted for efficient search.- Parameters:
c-- Returns:
- true, when fresh inserted
-
binSearch
static int binSearch(int[] list, int nUsed, int chr)unfortunatly, Arrays.binarySearch() does not support search in a part of the array (not in jdk1.3 and jdk1.4). - so we have do provide our own implementation.- Parameters:
list- to search withinnUsed- the last used index, can be < list.lengthchr- the character to lookup- Returns:
- the index when found, or the negative insert position.
-
-