Exemplo 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);
 }
Exemplo 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;
   }
 }
Exemplo n.º 3
0
 /** @return the current cache size */
 public int getMaxCacheSize() {
   return cache.getMaximumSize();
 }
Exemplo n.º 4
0
 /** @return the current cache size */
 public int getCacheSize() {
   return cache.getSize();
 }
Exemplo n.º 5
0
 /** Clear the cache. */
 public void clearCache() {
   cache.clear();
 }
Exemplo n.º 6
0
 /** @return the current cache size */
 public void setMaxCacheSize(int size) {
   cache.setMaximumSize(size);
 }