1 50 51 package org.openlaszlo.iv.flash.cache; 52 53 import org.openlaszlo.iv.flash.api.text.*; 54 import org.openlaszlo.iv.flash.util.*; 55 import java.util.*; 56 57 public class FontCache extends GenericCache { 58 59 private static FontCache instance = new FontCache(); 60 61 private FontCache() { 62 } 63 64 public static FontCache getInstance() { 65 return instance; 66 } 67 68 public static CacheSettings getSettings() { 69 return instance.getMySettings(); 70 } 71 72 78 public static Font getFont( String fontName ) { 79 CacheItem item = instance.getItem( fontName ); 80 if( item == null ) return null; 81 return (Font) item.getObject(); 82 } 83 84 90 public static void addFont( String fontName, Font font ) { 91 long now = System.currentTimeMillis(); 92 long expire = now + Integer.MAX_VALUE*1000L; 93 int size = font.getFontSize(); 94 CacheItem item = new CacheItem( fontName, font, size, now, expire ); 95 font.cached = instance.addItem( item ); 96 } 97 98 103 public static void removeFont( String fontName ) { 104 CacheItem item = instance.getItem( fontName ); 105 if( item == null ) return; 106 Font font = (Font) item.getObject(); 107 font.cached = false; 108 instance.removeItem( item ); 109 } 110 111 } 112 | Popular Tags |