1 50 51 package org.openlaszlo.iv.flash.api; 52 53 import org.openlaszlo.iv.flash.util.*; 54 import org.openlaszlo.iv.flash.context.Context; 55 import java.io.*; 56 import java.util.*; 57 import java.awt.geom.*; 58 59 68 public final class Timeline extends IVVector { 69 70 73 public Timeline() {} 74 75 78 public Timeline( int capacity ) { 79 super( capacity ); 80 } 81 82 89 public Timeline( IVVector data ) { 90 super( data ); 91 } 92 93 98 public Frame newFrame() { 99 Frame f = new Frame(); 100 addFrame(f); 101 return f; 102 } 103 104 109 public void addFrame( Frame o ) { 110 addElement( o ); 111 } 112 113 119 public int getFrameIndex( Frame frame ) { 120 return find(frame); 121 } 122 123 129 public Frame removeFrameAt( int index ) { 130 return (Frame) removeElementAt( index ); 131 } 132 133 138 public void removeFrame( Frame o ) { 139 removeElement( o ); 140 } 141 142 148 public Frame getFrameAt( int index ) { 149 return (Frame) elementAt( index ); 150 } 151 152 158 public void setFrameAt( Frame o, int index ) { 159 setElementAt( o , index ); 160 } 161 162 170 public void insertFrames( int from, int num ) { 171 insertObjects( from, num ); 172 for( int i=from; i<from+num; i++ ) { 173 setFrameAt( new Frame(), i ); 174 } 175 } 176 177 183 public Frame insertFrame( int index ) { 184 insertFrames( index, 1 ); 185 return getFrameAt(index); 186 } 187 188 193 public int getFrameCount() { 194 return size(); 195 } 196 197 204 public void write( FlashOutput fob ) { 205 for( int i=0; i<top; i++ ) { 206 Frame fo = (Frame) objects[i]; 207 fo.write(fob); 208 } 209 } 210 211 212 220 public void generate( FlashOutput fob, DepsCollector dc ) { 221 generate(fob, dc, 0); 222 } 223 224 233 public void generate( FlashOutput fob, DepsCollector dc, int off ) { 234 for( int i=off; i<top; i++ ) { 235 Frame fo = (Frame) objects[i]; 236 fo.generate( fob, dc ); 237 } 238 } 239 240 241 public void collectDeps( DepsCollector dc ) { 242 for( int i=0; i<top; i++ ) { 243 Frame fo = (Frame) objects[i]; 244 fo.collectDeps(dc); 245 } 246 } 247 248 public void apply( Context context ) { 249 for( int i=0; i<top; i++ ) { 250 Frame fo = (Frame) objects[i]; 251 fo.apply(context); 252 } 253 } 254 255 public void process( FlashFile file, Context context ) throws IVException { 256 for( int i=0; i<top; i++ ) { 257 Frame fo = (Frame) objects[i]; 258 fo.process(file, context); 259 } 260 } 261 262 public void doCommand( FlashFile file, Context context, Script parent ) throws IVException { 263 for( int i=0; i<top; i++ ) { 264 Frame fo = (Frame) objects[i]; 265 fo.doCommand(file, context, parent, i); 266 } 267 } 268 269 public void addBounds( Rectangle2D rect ) { 270 for( int i=0; i<top; i++ ) { 271 Frame fo = (Frame) objects[i]; 272 fo.addBounds( rect ); 273 } 274 } 275 276 public boolean isConstant() { 277 for( int i=0; i<top; i++ ) { 278 Frame fo = (Frame) objects[i]; 279 if( !fo.isConstant() ) return false; 280 } 281 return true; 282 } 283 284 public void printContent( PrintStream out, String indent ) { 285 for( int i=0; i<top; i++ ) { 286 Frame fo = (Frame) objects[i]; 287 out.print( indent+"Frame #"+i ); 288 if( fo.getName() != null ) { 289 out.println( " name='"+fo.getName()+"' "+(fo.isAnchor()?"anchor":"") ); 290 } else { 291 out.println(); 292 } 293 fo.printContent( out, indent ); 294 } 295 } 296 297 public IVVector getCopy( ScriptCopier copier ) { 298 Timeline t = new Timeline( size() ); 299 for( int i=0; i<top; i++ ) { 300 Frame fo = (Frame) objects[i]; 301 t.setElementAt( fo.getCopy(copier), i ); 302 } 303 return t; 304 } 305 } 306 307 | Popular Tags |