1
2 package org.freehep.graphicsio.swf;
3
4 import java.awt.geom.Rectangle2D;
5 import java.io.IOException;
6
7
8
9
10
11
12
13
14 public class DefineMorphShape extends DefinitionTag {
15
16 private int character;
17
18 private Rectangle2D startBounds, endBounds;
19
20 protected FillStyleArray fillStyles;
21
22 protected LineStyleArray lineStyles;
23
24 protected SWFShape startEdges, endEdges;
25
26 public DefineMorphShape(int id, Rectangle2D startBounds,
27 Rectangle2D endBounds, FillStyleArray fillStyles,
28 LineStyleArray lineStyles, SWFShape startEdges, SWFShape endEdges) {
29 this();
30 character = id;
31 this.startBounds = startBounds;
32 this.endBounds = endBounds;
33 this.fillStyles = fillStyles;
34 this.lineStyles = lineStyles;
35 this.startEdges = startEdges;
36 this.endEdges = endEdges;
37 }
38
39 public DefineMorphShape() {
40 super(46, 3);
41 }
42
43 public SWFTag read(int tagID, SWFInputStream swf, int len)
44 throws IOException {
45
46 DefineMorphShape tag = new DefineMorphShape();
47 tag.character = swf.readUnsignedShort();
48 swf.getDictionary().put(tag.character, tag);
49
50 tag.startBounds = swf.readRect();
51 tag.endBounds = swf.readRect();
52
53
54
55
56 fillStyles = new FillStyleArray(swf, true, true);
57 lineStyles = new LineStyleArray(swf, true, true, false);
58
59 startEdges = new SWFShape(swf, fillStyles, lineStyles, true, true, false);
60 endEdges = new SWFShape(swf, fillStyles, lineStyles, true, true, false);
61
62 return tag;
63 }
64
65 public void write(int tagID, SWFOutputStream swf) throws IOException {
66 swf.writeUnsignedShort(character);
67 swf.writeRect(startBounds);
68 swf.writeRect(endBounds);
69
70 swf.pushBuffer();
71
72 fillStyles.write(swf, true, true);
73 lineStyles.write(swf, true, true, false);
74
75 startEdges.write(swf, true, true, false);
76 int offset = swf.popBuffer();
77 swf.writeUnsignedInt(offset);
78 swf.append();
79
80 endEdges.write(swf, true, true, false);
81 }
82
83 public String toString() {
84 StringBuffer s = new StringBuffer();
85 s.append(super.toString() + "\n");
86 s.append(" character: " + character + "\n");
87 s.append(" startBounds: " + startBounds + "\n");
88 s.append(" endBounds: " + endBounds + "\n");
89 s.append(fillStyles.toString());
90 s.append(lineStyles.toString());
91 s.append(" startEdges: " + startEdges + "\n");
92 s.append(" endEdges: " + endEdges + "\n");
93 return s.toString();
94 }
95 }