Ejemplo n.º 1
0
 /**
  * Show the cached object.
  *
  * @param info the font info
  * @param character the encoded character
  */
 public CharWidth showCachedCharacter(
     FontInfo info, AffineTransform ctm, Point2D curpt, String character) {
   this.character = character;
   CacheEntry key = new CacheEntry(info, character);
   CacheEntry val = (CacheEntry) cache.get(key);
   if (val == null) return null;
   ctm.translate(curpt.getX(), curpt.getY());
   AffineTransform ftm = info.getFontMatrix();
   ctm.concatenate(ftm);
   show(val.getObject(), ctm);
   return val.getCharWidth().transform(ftm);
 }
Ejemplo n.º 2
0
 /**
  * Flush the cache device.
  *
  * @param info the font info
  * @param ctm the current transformation matrix
  */
 public void flush(FontInfo info, AffineTransform ctm) {
   try {
     if (character != null) {
       displayList.trimToSize();
       CharacterShape charShape = (CharacterShape) displayList;
       charShape.setCharCode(character);
       charShape.setCharWidth(charWidth);
       charShape.normalize(ctm);
       CacheEntry key = new CacheEntry(info, character, charWidth, charShape);
       cache.put(key, key); // TODO: redundant, we should use set instead of map
       show(charShape, ctm);
     }
   } catch (NoninvertibleTransformException ex) {
     System.err.println("warning: " + ex);
   } finally {
     character = null;
     charWidth = null;
     bounds = null;
   }
 }
Ejemplo n.º 3
0
 /** @return the current cache size */
 public int getMaxCacheSize() {
   return cache.getMaximumSize();
 }
Ejemplo n.º 4
0
 /** @return the current cache size */
 public int getCacheSize() {
   return cache.getSize();
 }
Ejemplo n.º 5
0
 /** Clear the cache. */
 public void clearCache() {
   cache.clear();
 }
Ejemplo n.º 6
0
 /** @return the current cache size */
 public void setMaxCacheSize(int size) {
   cache.setMaximumSize(size);
 }