1 package org.catacomb.dataview.formats;
2
3 import java.io.File;
4 import java.util.ArrayList;
5
6 import org.catacomb.datalish.Box;
7 import org.catacomb.dataview.display.Displayable;
8 import org.catacomb.dataview.display.ViewConfig;
9 import org.catacomb.dataview.model.XAxis;
10 import org.catacomb.dataview.model.YAxis;
11 import org.catacomb.graph.gui.Painter;
12
13 import java.util.HashMap;
14
15 public class PolyLineHandler implements DataHandler {
16
17
18 ArrayList<ViewConfig> views = new ArrayList<ViewConfig>();
19 HashMap<String, ViewConfig> viewHM = new HashMap<String, ViewConfig>();
20
21 String[] plotNames = null;
22 String[] viewOptions = {"lines"};
23
24
25 XAxis xaxis;
26 YAxis yaxis;
27
28
29 ArrayList<Displayable> displayables;
30
31
32
33 public DataHandler getCoHandler() {
34 return null;
35 }
36
37 public int getContentStyle() {
38 return DataHandler.STATIC;
39 }
40
41 public double[] getFrameValues() {
42 return null;
43 }
44
45 public String getMagic() {
46 return "cctable";
47 }
48
49
50
51 public double getMaxValue() {
52
53 return 0;
54 }
55
56 public double getMinValue() {
57
58 return 0;
59 }
60
61
62 public String[] getPlotNames() {
63 if (plotNames == null || plotNames.length != views.size()) {
64 int npn = views.size();
65 plotNames = new String[npn];
66 for (int i = 0; i < npn; i++) {
67 plotNames[i] = views.get(i).getID();
68 }
69 }
70 return plotNames;
71 }
72
73
74 public String[] getViewOptions() {
75 return viewOptions;
76 }
77
78 public boolean hasData() {
79 return (displayables != null && displayables.size() > 0);
80 }
81
82 public void read(File f) {
83
84 }
85
86 public void setFrame(int ifr) {
87
88 }
89
90 public void setPlot(String s) {
91
92 }
93
94 public void setViewStyle(String s) {
95
96 }
97
98 public boolean antialias() {
99
100 return false;
101 }
102
103
104
105
106
107
108 public Box getLimitBox() {
109 Box b = new Box();
110 if (displayables != null) {
111 for (Displayable dbl : displayables) {
112 dbl.pushBox(b);
113 }
114 }
115 return b;
116 }
117
118
119 public Box getDefaultBox() {
120 Box b = new Box();
121 if (xaxis != null) {
122 b.setXMin(xaxis.getMin());
123 b.setXMax(xaxis.getMax());
124 }
125 if (yaxis != null) {
126 b.setYMin(yaxis.getMin());
127 b.setYMax(yaxis.getMax());
128 }
129 return b;
130 }
131
132 public void instruct(Painter p) {
133 if (displayables != null) {
134 for (Displayable dbl : displayables) {
135 dbl.instruct(p);
136 }
137 }
138 }
139
140 public void setXAxis(XAxis ax) {
141 xaxis = ax;
142
143 }
144
145 public void setYAxis(YAxis ax) {
146 yaxis = ax;
147
148 }
149
150
151 public String getXAxisLabel() {
152 String ret = "";
153 if (xaxis != null) {
154 ret = xaxis.getLabel();
155 }
156 return ret;
157 }
158
159 public String getYAxisLabel() {
160 String ret = "";
161 if (yaxis != null) {
162 ret = yaxis.getLabel();
163 }
164 return ret;
165 }
166
167
168
169
170 public void addItems(ArrayList<Displayable> items) {
171 if (displayables == null) {
172 displayables = new ArrayList<Displayable>();
173 }
174 displayables.addAll(items);
175
176 }
177
178 public void addView(ViewConfig vc) {
179 views.add(vc);
180 viewHM.put(vc.getID(), vc);
181 }
182
183 public ViewConfig getViewConfig(String s) {
184 ViewConfig ret = null;
185 if (viewHM.containsKey(s)) {
186 ret = viewHM.get(s);
187 }
188 return ret;
189 }
190
191 public void setZValue(double d) {
192
193
194 }
195
196 }