1 package org.catacomb.numeric.data;
2
3 import org.catacomb.interlish.content.BasicTouchTime;
4 import org.catacomb.report.E;
5
6
7 public class DDSubSlice implements NumVector {
8
9 DDSlice srcSlice;
10 int index;
11 String label;
12
13 int npcache;
14 double[] data;
15
16
17 BasicTouchTime touchTime;
18
19 public DDSubSlice(DDSlice slice, int i, String lab) {
20 srcSlice = slice;
21 index = i;
22 label = lab;
23 touchTime = new BasicTouchTime();
24 touchTime.never();
25 data = new double[10];
26 }
27
28
29 public String toString() {
30 E.warning("using toString ? ");
31 return label;
32 }
33
34 public String getName() {
35 return label;
36 }
37
38 public int getNPoint() {
39 return srcSlice.getNPoint();
40 }
41
42 public void clear() {
43 npcache = 0;
44 touchTime.never();
45 }
46
47
48 public double[] getData() {
49
50 if (touchTime.isBefore(srcSlice.getTouchTime())) {
51
52 int npn = srcSlice.getNPoint();
53
54 if (npn > data.length) {
55 double[] dn = new double[(3 * npn) / 2 + 10];
56 for (int i = 0; i < npcache; i++) {
57 dn[i] = data[i];
58 }
59 data = dn;
60 }
61
62 double[][] dd = srcSlice.getDData();
63 for (int i = npcache; i < npn; i++) {
64 data[i] = dd[i][index];
65 }
66 npcache = npn;
67
68 touchTime.now();
69 }
70
71 return data;
72 }
73
74
75 public String getLabel() {
76 return label;
77 }
78
79
80 public String getUnit() {
81 return srcSlice.getUnit();
82 }
83
84 }