Package org.apache.batik.svggen
Class SVGFont.CharListHelper
java.lang.Object
org.apache.batik.svggen.SVGFont.CharListHelper
- Enclosing class:
SVGFont
this 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 of
implementation: we keep a sorted list of integers. This allows to use binary search for lookup and insert. The use of
int
instead of char
allows us to
handle surrogate characters as well.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int[]
keeps added characters, is kept sorted for efficient search.private StringBuffer
this keeps all added characters in order.private int
the number of slots actually used. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) boolean
add
(int c) test, if the character is contained in the charList.(package private) 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).(package private) void
reset the string of recently added characters - used after glyphs were created for them.(package private) String
get a string of all characters added since last call to clearNewChars().
-
Field Details
-
nUsed
private int nUsedthe number of slots actually used. must always be 0 <= nUsed <= charList.length -
charList
private int[] charListkeeps added characters, is kept sorted for efficient search. -
freshChars
this keeps all added characters in order. It can be cleared from toSVG() when glyphs are created for some characters.
-
-
Constructor Details
-
CharListHelper
CharListHelper()
-
-
Method Details
-
getNewChars
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.
-