1
2 package org.freehep.graphicsio.swf;
3
4 import java.io.IOException;
5 import java.util.ArrayList;
6 import java.util.Iterator;
7 import java.util.List;
8
9
10
11
12
13
14
15
16 public class LineStyleArray {
17
18 protected List
19
20 public LineStyleArray() {
21 this.lineStyles = new ArrayList();
22 }
23
24 public LineStyleArray(SWFInputStream swf, boolean isMorphStyle,
25 boolean hasAlpha, boolean hasStyles) throws IOException {
26
27 this();
28
29 int lineStyleCount = swf.readUnsignedByte();
30 if (lineStyleCount == 0xFF) {
31 lineStyleCount = swf.readUnsignedShort();
32 }
33 for (int i = 0; i < lineStyleCount; i++) {
34 lineStyles.add(new LineStyle(swf, isMorphStyle, hasAlpha, hasStyles));
35 }
36 }
37
38 public void add(LineStyle lineStyle) {
39 lineStyles.add(lineStyle);
40 }
41
42 public LineStyle get(int index) {
43 return (LineStyle) lineStyles.get(index);
44 }
45
46 public void write(SWFOutputStream swf, boolean isMorphStyle, boolean hasAlpha, boolean hasStyles) throws IOException {
47
48 if (lineStyles.size() >= 0xFF) {
49 swf.writeUnsignedByte(0xFF);
50 swf.writeUnsignedShort(lineStyles.size());
51 } else {
52 swf.writeUnsignedByte(lineStyles.size());
53 }
54 for (Iterator i = lineStyles.iterator(); i.hasNext();) {
55 ((LineStyle) i.next()).write(swf, isMorphStyle, hasAlpha, hasStyles);
56 }
57 }
58
59 public String toString() {
60 StringBuffer s = new StringBuffer();
61 s.append(" lineStyles: " + lineStyles.size() + "\n");
62 int n = 0;
63 for (Iterator i = lineStyles.iterator(); i.hasNext();) {
64 s.append(" " + (n + 1) + " " + (i.next()) + "\n");
65 n++;
66 }
67 return s.toString();
68 }
69
70 }