View Javadoc

1   // Copyright 2006, FreeHEP.
2   package org.freehep.graphicsio.swf;
3   
4   import java.awt.geom.Rectangle2D;
5   import java.io.IOException;
6   
7   /**
8    * DefineShape4 TAG.
9    * 
10   * @author Mark Donszelmann
11   * @author Charles Loomis
12   * @version $Id: DefineShape3.java 4973 2005-12-05 00:59:43Z duns $
13   */
14  public class DefineShape4 extends DefineShape {
15  
16  	protected Rectangle2D edgeBounds;
17  	protected boolean usesNonScalingStrokes;
18  	protected boolean usesScalingStrokes = true;
19  	
20      public DefineShape4(int id, Rectangle2D bounds, FillStyleArray fillStyles, LineStyleArray lineStyles, SWFShape shape) {
21          this(id, bounds, bounds, false, true, fillStyles, lineStyles, shape);
22      }
23      
24      public DefineShape4(int id, Rectangle2D bounds, Rectangle2D edgeBounds, 
25      		boolean usesNonScalingStrokes, boolean usesScalingStrokes,
26      		FillStyleArray fillStyles,
27              LineStyleArray lineStyles, SWFShape shape) {
28          this();
29          character = id;
30          this.bounds = bounds;
31          this.edgeBounds = edgeBounds;
32          this.usesNonScalingStrokes = usesNonScalingStrokes;
33          this.usesScalingStrokes = usesScalingStrokes;
34          this.fillStyles = fillStyles;
35          this.lineStyles = lineStyles;
36          this.shape = shape;
37      }
38  
39      public DefineShape4() {
40          super(83, 8);
41      }
42  
43      public SWFTag read(int tagID, SWFInputStream swf, int len)
44              throws IOException {
45          DefineShape4 tag = new DefineShape4();
46          
47          tag.character = swf.readUnsignedShort();
48          swf.getDictionary().put(tag.character, tag);
49          bounds = swf.readRect();
50  
51          tag.edgeBounds = swf.readRect();
52          swf.readUBits(6);
53          tag.usesNonScalingStrokes = swf.readBitFlag();
54          tag.usesScalingStrokes = swf.readBitFlag();
55          
56          tag.fillStyles = new FillStyleArray(swf, false, true);
57          tag.lineStyles = new LineStyleArray(swf, false, true, true);
58  
59          tag.shape = new SWFShape(swf, tag.fillStyles, tag.lineStyles, false, true, false);
60  
61          return tag;
62      }
63  
64      public void write(int tagID, SWFOutputStream swf) throws IOException {
65          swf.writeUnsignedShort(character);
66          swf.writeRect(bounds);
67  
68      	swf.writeRect(edgeBounds);
69      	swf.writeUBits(0, 6);
70      	swf.writeBitFlag(usesNonScalingStrokes);
71      	swf.writeBitFlag(usesScalingStrokes);
72          
73          fillStyles.write(swf, false, true);
74          lineStyles.write(swf, false, true, true);
75  
76          shape.write(swf, false, true, true);
77      }
78  }