1 50 51 package org.openlaszlo.iv.flash.api.shape; 52 53 import org.openlaszlo.iv.flash.util.*; 54 import org.openlaszlo.iv.flash.api.*; 55 import java.io.PrintStream ; 56 57 75 public final class StyleChangeRecord extends FlashItem { 76 77 public static final int NEW_STYLES = 0x10; 78 public static final int LINESTYLE = 0x08; 79 public static final int FILLSTYLE1 = 0x04; 80 public static final int FILLSTYLE0 = 0x02; 81 public static final int MOVETO = 0x01; 82 83 private int flags; 84 private int deltaX; 85 private int deltaY; 86 private int fillStyle0; 87 private int fillStyle1; 88 private int lineStyle; 89 90 public StyleChangeRecord() {} 91 92 public int getFlags() { 93 return flags; 94 } 95 96 public void setFlags( int flags ) { 97 this.flags = flags; 98 } 99 100 public void addFlags( int flags ) { 101 this.flags |= flags; 102 } 103 104 public int getDeltaX() { 105 return deltaX; 106 } 107 108 public void setDeltaX( int deltaX ) { 109 this.deltaX = deltaX; 110 } 111 112 public int getDeltaY() { 113 return deltaY; 114 } 115 116 public void setDeltaY( int deltaY ) { 117 this.deltaY = deltaY; 118 } 119 120 public int getFillStyle0() { 121 return fillStyle0; 122 } 123 124 public void setFillStyle0( int fillStyle0 ) { 125 this.fillStyle0 = fillStyle0; 126 } 127 128 public int getFillStyle1() { 129 return fillStyle1; 130 } 131 132 public void setFillStyle1( int fillStyle1 ) { 133 this.fillStyle1 = fillStyle1; 134 } 135 136 public int getLineStyle() { 137 return lineStyle; 138 } 139 140 public void setLineStyle( int lineStyle ) { 141 this.lineStyle = lineStyle; 142 } 143 144 public void write( FlashOutput fob ) { 145 write(fob, 0, 0); 146 } 147 148 public void write( FlashOutput fob, int nFillBits, int nLineBits ) { 149 fob.writeBits(flags, 6); 150 if( (flags&MOVETO) != 0 ) { 151 int nBits = Util.getMinBitsS( Util.getMax(deltaX, deltaY) ); 152 fob.writeBits(nBits, 5); 153 fob.writeBits(deltaX, nBits); 154 fob.writeBits(deltaY, nBits); 155 } 156 if( (flags&FILLSTYLE0) != 0 ) { 157 fob.writeBits(fillStyle0, nFillBits); 158 } 159 if( (flags&FILLSTYLE1) != 0 ) { 160 fob.writeBits(fillStyle1, nFillBits); 161 } 162 if( (flags&LINESTYLE) != 0 ) { 163 fob.writeBits(lineStyle, nLineBits); 164 } 165 } 166 167 public void printContent( PrintStream out, String indent ) { 168 if( (flags&MOVETO) != 0 ) { 169 out.println( indent+" moveto ("+deltaX+","+deltaY+")" ); 170 } 171 if( (flags&FILLSTYLE0) != 0 ) { 172 out.println( indent+" fillStyle0 "+fillStyle0 ); 173 } 174 if( (flags&FILLSTYLE1) != 0 ) { 175 out.println( indent+" fillStyle1 "+fillStyle1 ); 176 } 177 if( (flags&LINESTYLE) != 0 ) { 178 out.println( indent+" lineStyle "+lineStyle ); 179 } 180 if( (flags&NEW_STYLES) != 0 ) { 181 out.println( indent+" newstyles" ); 182 } 183 } 184 185 protected FlashItem copyInto( FlashItem item, ScriptCopier copier ) { 186 ((StyleChangeRecord)item).deltaX = deltaX; 187 ((StyleChangeRecord)item).deltaY = deltaY; 188 ((StyleChangeRecord)item).fillStyle0 = fillStyle0; 189 ((StyleChangeRecord)item).fillStyle1 = fillStyle1; 190 ((StyleChangeRecord)item).lineStyle = lineStyle; 191 ((StyleChangeRecord)item).flags = flags; 192 return item; 193 } 194 195 public FlashItem getCopy( ScriptCopier copier ) { 196 return copyInto( new StyleChangeRecord(), copier ); 197 } 198 } 199 | Popular Tags |