Class SVGFont.CharListHelper

java.lang.Object
org.apache.batik.svggen.SVGFont.CharListHelper
Enclosing class:
SVGFont

private static class SVGFont.CharListHelper extends Object
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 int instead of char allows us to handle surrogate characters as well.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (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().

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • 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 StringBuffer 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 within
      nUsed - the last used index, can be < list.length
      chr - the character to lookup
      Returns:
      the index when found, or the negative insert position.