Debian Codegraph @

freehep-graphicsio-swf/src/main/java/org/freehep/graphicsio/swf/DefineButton.java

raw symbols SCIP
1 // Copyright 2001, FreeHEP.
2 package org.freehep.graphicsio.swf;
3
4 import java.io.IOException;
5 import java.util.Vector;
6
7 import org.freehep.util.io.Action;
8
9 /**
10 * DefineButton TAG.
11 *
12 * @author Mark Donszelmann
13 * @author Charles Loomis
14 * @version $Id: freehep-graphicsio-swf/src/main/java/org/freehep/graphicsio/swf/DefineButton.java db861da05344 2005/12/05 00:59:43 duns $
15 */
16 public class DefineButton extends DefinitionTag {
17
18 private int character;
19
20 private Vector<ButtonRecord> buttons;
21
22 private Vector<Action> actions;
23
24 public DefineButton(int id, Vector<ButtonRecord> buttons, Vector<Action> actions) {
25 this();
26 character = id;
27 this.buttons = buttons;
28 this.actions = actions;
29 }
30
31 public DefineButton() {
32 super(7, 1);
33 }
34
35 public SWFTag read(int tagID, SWFInputStream swf, int len)
36 throws IOException {
37
38 DefineButton tag = new DefineButton();
39 tag.character = swf.readUnsignedShort();
40 swf.getDictionary().put(tag.character, tag);
41
42 tag.buttons = new Vector<ButtonRecord>();
43 ButtonRecord record = new ButtonRecord(swf, false);
44 while (!record.isEndRecord()) {
45 tag.buttons.add(record);
46 record = new ButtonRecord(swf, false);
47 }
48
49 tag.actions = new Vector<Action>();
50 Action action = swf.readAction();
51 while (action != null) {
52 tag.actions.add(action);
53 action = swf.readAction();
54 }
55 return tag;
56 }
57
58 public void write(int tagID, SWFOutputStream swf) throws IOException {
59
60 swf.writeUnsignedShort(character);
61 for (int i = 0; i < buttons.size(); i++) {
62 ButtonRecord b = buttons.get(i);
63 b.write(swf);
64 }
65 swf.writeUnsignedByte(0);
66
67 for (int i = 0; i < actions.size(); i++) {
68 Action a = actions.get(i);
69 swf.writeAction(a);
70 }
71 swf.writeAction(null);
72 }
73
74 public String toString() {
75 StringBuffer s = new StringBuffer();
76 s.append(super.toString() + "\n");
77 s.append(" character: " + character + "\n");
78 for (int i = 0; i < buttons.size(); i++) {
79 s.append(" ");
80 s.append(buttons.get(i));
81 s.append("\n");
82 }
83 for (int i = 0; i < actions.size(); i++) {
84 s.append(" ");
85 s.append(actions.get(i));
86 s.append("\n");
87 }
88 return s.toString();
89 }
90 }