1 | package org.expeditee.io;
|
---|
2 |
|
---|
3 | import java.io.IOException;
|
---|
4 | import java.util.List;
|
---|
5 |
|
---|
6 | import org.expeditee.items.Circle;
|
---|
7 | import org.expeditee.items.Dot;
|
---|
8 | import org.expeditee.items.Item;
|
---|
9 | import org.expeditee.items.Line;
|
---|
10 | import org.expeditee.items.Picture;
|
---|
11 | import org.expeditee.items.Text;
|
---|
12 | import org.expeditee.items.widgets.InteractiveWidget;
|
---|
13 | import org.expeditee.items.widgets.WidgetEdge;
|
---|
14 |
|
---|
15 | public abstract class ItemWriter {
|
---|
16 |
|
---|
17 | public static final String NEW_LINE = System.getProperty("line.separator");
|
---|
18 |
|
---|
19 | protected void writeTitle(Text toWrite, List<Item> items)
|
---|
20 | throws IOException {
|
---|
21 | }
|
---|
22 |
|
---|
23 | protected void writeAnnotationTitle(Item toWrite) throws IOException {
|
---|
24 | }
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Called for each item on each frame to write out the contents of the
|
---|
28 | * items.
|
---|
29 | *
|
---|
30 | * @param toWrite
|
---|
31 | * the item to be written out.
|
---|
32 | * @throws IOException
|
---|
33 | */
|
---|
34 | protected void writeItem(Item toWrite) throws IOException {
|
---|
35 | if (toWrite.isAnnotation()) {
|
---|
36 | writeAnnotationItem(toWrite);
|
---|
37 | return;
|
---|
38 | }
|
---|
39 |
|
---|
40 | if (toWrite instanceof Text)
|
---|
41 | writeText((Text) toWrite);
|
---|
42 |
|
---|
43 | if (toWrite instanceof Picture)
|
---|
44 | writePicture((Picture) toWrite);
|
---|
45 |
|
---|
46 | if (toWrite instanceof Line) {
|
---|
47 | if (toWrite instanceof WidgetEdge) {
|
---|
48 | writeWidget(((WidgetEdge) toWrite).getWidgetSource());
|
---|
49 | }
|
---|
50 | writeLine((Line) toWrite);
|
---|
51 | }
|
---|
52 |
|
---|
53 | if (toWrite instanceof Dot)
|
---|
54 | writeDot((Item) toWrite);
|
---|
55 |
|
---|
56 | if (toWrite instanceof Circle)
|
---|
57 | writeCircle((Circle) toWrite);
|
---|
58 | }
|
---|
59 |
|
---|
60 | protected void writeAnnotationItem(Item toWrite) throws IOException {
|
---|
61 | if (toWrite instanceof Text)
|
---|
62 | writeAnnotationText((Text) toWrite);
|
---|
63 |
|
---|
64 | if (toWrite instanceof Picture)
|
---|
65 | writeAnnotationPicture((Picture) toWrite);
|
---|
66 |
|
---|
67 | if (toWrite instanceof Line) {
|
---|
68 | writeAnnotationLine((Line) toWrite);
|
---|
69 | }
|
---|
70 |
|
---|
71 | if (toWrite instanceof Dot)
|
---|
72 | writeAnnotationDot((Item) toWrite);
|
---|
73 | }
|
---|
74 |
|
---|
75 | protected void writeAnnotationText(Text toWrite) throws IOException {
|
---|
76 | }
|
---|
77 |
|
---|
78 | protected void writeAnnotationPicture(Picture toWrite) throws IOException {
|
---|
79 | }
|
---|
80 |
|
---|
81 | protected void writeAnnotationLine(Line toWrite) throws IOException {
|
---|
82 | }
|
---|
83 |
|
---|
84 | protected void writeAnnotationDot(Item toWrite) throws IOException {
|
---|
85 | }
|
---|
86 |
|
---|
87 | protected void writeText(Text toWrite) throws IOException {
|
---|
88 | }
|
---|
89 |
|
---|
90 | protected void writePicture(Picture toWrite) throws IOException {
|
---|
91 | }
|
---|
92 |
|
---|
93 | protected void writeLine(Line toWrite) throws IOException {
|
---|
94 | }
|
---|
95 |
|
---|
96 | protected void writeCircle(Circle toWrite) throws IOException {
|
---|
97 | }
|
---|
98 |
|
---|
99 | protected void writeWidget(InteractiveWidget toWrite) throws IOException {
|
---|
100 | }
|
---|
101 |
|
---|
102 | protected void writeDot(Item toWrite) throws IOException {
|
---|
103 | }
|
---|
104 | }
|
---|