1 50 51 package org.openlaszlo.iv.flash.util; 52 53 import java.util.*; 54 import org.openlaszlo.iv.flash.api.*; 55 import org.openlaszlo.iv.flash.api.text.*; 56 57 68 public final class DepsCollector { 69 70 protected Hashtable allGenerated = new Hashtable(); 71 protected IVVector collected = new IVVector(20); 72 protected int current = -1; 74 protected IVVector fonts; 75 76 81 public DepsCollector( FontsCollector fc ) { 82 fonts = fc.getFonts(); 83 } 85 86 91 public void addDep( FlashItem item ) { 92 getLevel(current).addElement(item); 93 } 94 95 101 public boolean isGenerated( FlashItem item ) { 102 return allGenerated.containsKey(item); 103 } 104 105 110 public void addGenerated( FlashItem item ) { 111 allGenerated.put(item,item); 112 } 113 114 121 public void addDep( Font font ) { 122 for( int i=0; i<fonts.size(); i++ ) { 123 FontDef fdef = (FontDef) fonts.elementAt(i); 124 if( fdef.getFont() == font ) { 125 addDep( fdef ); 126 return; 127 } 128 } 129 } 130 131 134 public void startCollect() { 135 getLevel(++current).reset(); 136 } 139 140 143 public void endCollect() { 144 --current; 146 } 148 149 154 public IVVector getCollected() { 155 return getLevel(current); 156 } 157 158 private IVVector getLevel( int num ) { 159 IVVector level; 160 if( num >= collected.size() ) { 161 level = new IVVector(); 162 collected.setElementAt(level, num); 163 } else { 164 level = (IVVector) collected.elementAt(num); 165 if( level == null ) { 166 level = new IVVector(); 167 collected.setElementAt(level, num); 168 } 169 } 170 return level; 171 } 172 173 } 174 | Popular Tags |