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