1 50 51 package org.openlaszlo.iv.flash.commands; 52 53 import java.awt.geom.*; 54 55 import org.openlaszlo.iv.flash.parser.*; 56 import org.openlaszlo.iv.flash.api.*; 57 import org.openlaszlo.iv.flash.util.*; 58 import org.openlaszlo.iv.flash.context.Context; 59 60 public class SetScaleCommand extends GenericCommand { 61 62 public SetScaleCommand() {} 63 64 private double parseNumber( String num, double def ) { 65 if( num == null ) return def; 66 try { 67 return Double.valueOf(num).doubleValue(); 68 } catch( NumberFormatException e ) { 69 return def; 70 } 71 } 72 73 public void doCommand( FlashFile file, Context context, Script parent, int frameNum ) throws IVException { 74 Instance inst = getCommandInstance(file, context, parent, frameNum); 75 76 processFlashDef(inst, file, context); 78 79 double xscale = parseNumber( getParameter( context, "xscale" ), 1.0 ); 80 double yscale = parseNumber( getParameter( context, "yscale" ), 1.0 ); 81 double rotate = parseNumber( getParameter( context, "rotate" ), 0.0 ); 82 double xoffset = parseNumber( getParameter( context, "xoffset" ), 0.0 ) * 20.0; 83 double yoffset = parseNumber( getParameter( context, "yoffset" ), 0.0 ) * 20.0; 84 85 88 inst.matrix.preConcatenate( AffineTransform.getTranslateInstance( xoffset, yoffset ) ); 89 90 inst.matrix.scale( xscale, yscale ); 91 92 if( rotate != 0.0 ) { 93 double theta = (rotate/180)*Math.PI; 94 inst.matrix.rotate( theta ); 95 } 96 97 } 98 99 } 100 | Popular Tags |