1 50 51 package org.openlaszlo.iv.flash.util; 52 53 import java.io.*; 54 import java.util.*; 55 import org.openlaszlo.iv.flash.api.*; 56 import org.openlaszlo.iv.flash.api.text.*; 57 58 68 public class FlashOutput extends FlashBuffer { 69 70 private FlashItem jpegTables; 72 private Hashtable hashTable = new Hashtable(); 73 private FlashOutput main; 74 private int currentID = 1; 75 private Object userData; 76 private FlashFile file; 77 78 public FlashOutput( int size ) { 79 super(size); 80 } 81 82 public FlashOutput( FlashFile file, int size ) { 83 super(size); 84 this.file = file; 85 } 86 87 public FlashOutput( FlashOutput main, int size ) { 88 super(size); 89 this.main = main; 90 } 91 92 public FlashFile getFlashFile() { 93 if( main != null ) return main.getFlashFile(); 94 return file; 95 } 96 97 103 public int getDefID( FlashDef def ) { 104 return getObjID( def ); 105 } 106 107 private synchronized int getObjID( Object key ) { 108 if( main != null ) return main.getObjID( key ); 109 Integer id = (Integer ) hashTable.get( key ); 110 if( id != null ) return id.intValue(); 111 hashTable.put( key, new Integer (currentID) ); 112 116 return currentID++; 117 } 118 119 public synchronized boolean defined( Object key ) { 120 if (main != null) return main.defined(key); 121 return (hashTable.get( key ) != null ); 122 } 123 124 129 public void writeDefID( FlashDef def ) { 130 writeWord( getObjID( def ) ); 131 } 132 133 138 public void writeFontID( Font font ) { 139 writeWord( getObjID( font ) ); 140 } 141 142 public void writeJPegTables( FlashItem jt ) { 143 if( main != null ) { 144 main.writeJPegTables( jt ); 145 } else { 146 if( jpegTables != null ) return; 147 jpegTables = jt; 148 jt.write( this ); 149 } 150 } 151 152 public void setUserData( Object data ) { 153 userData = data; 154 } 155 156 public Object getUserData() { 157 return userData; 158 } 159 } 160 | Popular Tags |