View Javadoc

1   package org.catacomb.dataview.formats;
2   
3   import java.io.File;
4   
5   import org.catacomb.datalish.Box;
6   import org.catacomb.dataview.display.ViewConfig;
7   import org.catacomb.graph.gui.Painter;
8   import org.catacomb.report.E;
9   
10  
11  public class TableDataHandler implements DataHandler {
12  
13      double max = Double.NaN;
14      double min = Double.NaN;
15  
16      double[][] data;
17  
18      String[] columnNames;
19  
20  
21      public DataHandler getCoHandler() {
22          return null;
23      }
24  
25  
26      public int getContentStyle() {
27          return DataHandler.STATIC;
28      }
29  
30  
31      public double[] getFrameValues() {
32          // TODO Auto-generated method stub
33          return null;
34      }
35  
36  
37      public String getMagic() {
38          return "cctbl";
39      }
40  
41  
42      public double getMaxValue() {
43          if (Double.isNaN(max)) {
44              evalLims();
45          }
46          return max;
47      }
48  
49  
50      public double getMinValue() {
51          if (Double.isNaN(min)) {
52              evalLims();
53          }
54          return max;
55      }
56  
57  
58      private void evalLims() {
59          if (data.length > 1 && data[0].length > 0) {
60              max = data[1][0];
61              min = max;
62              for (int i = 1; i < data.length; i++) {
63                  for (int j = 0; j < data[i].length; j++) {
64                      double d = data[i][j];
65                      if (max < d) {
66                          max = d;
67                      }
68                      if (min > d) {
69                          min = d;
70                      }
71                  }
72              }
73  
74          } else {
75              max = 0.;
76              min = 0.;
77          }
78  
79      }
80  
81  
82  
83  
84  
85      public String[] getPlotNames() {
86          return columnNames;
87      }
88  
89  
90      public String[] getViewOptions() {
91          String[] sa = {"lines"};
92          return sa;
93      }
94  
95  
96      public boolean hasData() {
97          return (data != null && data.length > 0);
98      }
99  
100 
101     public void read(File f) {
102         E.missing();
103     }
104 
105 
106     public void setFrame(int ifr) {
107 
108     }
109 
110 
111     public void setPlot(String s) {
112         E.info("time to set plot " + s);
113     }
114 
115 
116     public void setViewStyle(String s) {
117 
118 
119     }
120 
121 
122     public boolean antialias() {
123 
124         return false;
125     }
126 
127 
128     public Box getLimitBox() {
129         Box b = new Box();
130         b.extendTo(data[0][0], getMinValue());
131         b.extendTo(data[0][data[0].length - 1], getMaxValue());
132         return b;
133     }
134 
135 
136     public void instruct(Painter p) {
137         p.setColorWhite();
138         for (int i = 1; i < data.length; i++) {
139             p.drawPolyline(data[0], data[i], data[0].length);
140         }
141     }
142 
143 
144     public void setColumnNames(String[] cn) {
145         columnNames = cn;
146     }
147 
148 
149     public void setData(double[][] db) {
150         data = db;
151     }
152 
153 
154     public String getXAxisLabel() {
155         // TODO Auto-generated method stub
156         return null;
157     }
158 
159 
160     public String getYAxisLabel() {
161         // TODO Auto-generated method stub
162         return null;
163     }
164 
165 
166     public ViewConfig getViewConfig(String s) {
167         // TODO Auto-generated method stub
168         return null;
169     }
170 
171 
172     public void setZValue(double d) {
173         // TODO Auto-generated method stub
174 
175     }
176 
177 }