1 | /**
|
---|
2 | * ItemWriter.java
|
---|
3 | * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
|
---|
4 | *
|
---|
5 | * This program is free software: you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
8 | * (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
17 | */
|
---|
18 |
|
---|
19 | package org.expeditee.io;
|
---|
20 |
|
---|
21 | import java.io.IOException;
|
---|
22 | import java.util.List;
|
---|
23 |
|
---|
24 | import org.expeditee.items.Circle;
|
---|
25 | import org.expeditee.items.Dot;
|
---|
26 | import org.expeditee.items.Item;
|
---|
27 | import org.expeditee.items.Line;
|
---|
28 | import org.expeditee.items.Picture;
|
---|
29 | import org.expeditee.items.Text;
|
---|
30 | import org.expeditee.items.widgets.Widget;
|
---|
31 | import org.expeditee.items.widgets.WidgetEdge;
|
---|
32 |
|
---|
33 | public abstract class ItemWriter {
|
---|
34 |
|
---|
35 | public static final String NEW_LINE = System.getProperty("line.separator");
|
---|
36 |
|
---|
37 | protected void writeTitle(Text toWrite, List<Item> items)
|
---|
38 | throws IOException {
|
---|
39 | }
|
---|
40 |
|
---|
41 | protected void writeAnnotationTitle(Item toWrite) throws IOException {
|
---|
42 | }
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * Called for each item on each frame to write out the contents of the
|
---|
46 | * items.
|
---|
47 | *
|
---|
48 | * @param toWrite
|
---|
49 | * the item to be written out.
|
---|
50 | * @throws IOException
|
---|
51 | */
|
---|
52 | protected void writeItem(Item toWrite) throws IOException {
|
---|
53 | if (toWrite.isAnnotation()) {
|
---|
54 | writeAnnotationItem(toWrite);
|
---|
55 | return;
|
---|
56 | }
|
---|
57 |
|
---|
58 | if (toWrite instanceof Text)
|
---|
59 | writeText((Text) toWrite);
|
---|
60 |
|
---|
61 | if (toWrite instanceof Picture)
|
---|
62 | writePicture((Picture) toWrite);
|
---|
63 |
|
---|
64 | if (toWrite instanceof Line) {
|
---|
65 | if (toWrite instanceof WidgetEdge) {
|
---|
66 | writeWidget(((WidgetEdge) toWrite).getWidgetSource());
|
---|
67 | }
|
---|
68 | writeLine((Line) toWrite);
|
---|
69 | }
|
---|
70 |
|
---|
71 | if (toWrite instanceof Dot)
|
---|
72 | writeDot((Item) toWrite);
|
---|
73 |
|
---|
74 | if (toWrite instanceof Circle)
|
---|
75 | writeCircle((Circle) toWrite);
|
---|
76 | }
|
---|
77 |
|
---|
78 | protected void writeAnnotationItem(Item toWrite) throws IOException {
|
---|
79 | if (toWrite instanceof Text)
|
---|
80 | writeAnnotationText((Text) toWrite);
|
---|
81 |
|
---|
82 | if (toWrite instanceof Picture)
|
---|
83 | writeAnnotationPicture((Picture) toWrite);
|
---|
84 |
|
---|
85 | if (toWrite instanceof Line) {
|
---|
86 | writeAnnotationLine((Line) toWrite);
|
---|
87 | }
|
---|
88 |
|
---|
89 | if (toWrite instanceof Dot)
|
---|
90 | writeAnnotationDot((Item) toWrite);
|
---|
91 | }
|
---|
92 |
|
---|
93 | protected void writeAnnotationText(Text toWrite) throws IOException {
|
---|
94 | }
|
---|
95 |
|
---|
96 | protected void writeAnnotationPicture(Picture toWrite) throws IOException {
|
---|
97 | }
|
---|
98 |
|
---|
99 | protected void writeAnnotationLine(Line toWrite) throws IOException {
|
---|
100 | }
|
---|
101 |
|
---|
102 | protected void writeAnnotationDot(Item toWrite) throws IOException {
|
---|
103 | }
|
---|
104 |
|
---|
105 | protected void writeText(Text toWrite) throws IOException {
|
---|
106 | }
|
---|
107 |
|
---|
108 | protected void writePicture(Picture toWrite) throws IOException {
|
---|
109 | }
|
---|
110 |
|
---|
111 | protected void writeLine(Line toWrite) throws IOException {
|
---|
112 | }
|
---|
113 |
|
---|
114 | protected void writeCircle(Circle toWrite) throws IOException {
|
---|
115 | }
|
---|
116 |
|
---|
117 | protected void writeWidget(Widget toWrite) throws IOException {
|
---|
118 | }
|
---|
119 |
|
---|
120 | protected void writeDot(Item toWrite) throws IOException {
|
---|
121 | }
|
---|
122 | }
|
---|