1
2
3 package org.catacomb.dataview.build;
4
5
6 import org.catacomb.datalish.Box;
7 import org.catacomb.graph.gui.Labellee;
8 import org.catacomb.graph.gui.Painter;
9 import org.catacomb.numeric.data.DataExtractor;
10 import org.catacomb.report.E;
11
12
13
14
15 public class Line extends Displayable {
16
17 public double width;
18
19
20 private int npts;
21 private double[] xpts;
22 private double[] ypts;
23
24 int ilabel = -1;
25
26 Labellee labellee;
27
28
29
30
31
32 public void markNeeded(DataExtractor dex) {
33 String sif = "-1";
34 String xf = x.replaceAll("frame", sif);
35 String yf = y.replaceAll("frame", sif);
36
37 dex.mark(xf);
38 dex.mark(yf);
39 }
40
41
42
43 public void getData(DataExtractor dex, int iframe) {
44 String sif = "" + iframe;
45 String xf = x.replaceAll("frame", sif);
46 String yf = y.replaceAll("frame", sif);
47
48 xpts = dex.getVector(xf);
49 ypts = dex.getVector(yf);
50
51 if (xpts == null || ypts == null) {
52 xpts = null;
53 E.error("null data in line - wanted " + x + " and " + y);
54 } else {
55
56 npts = xpts.length;
57 if (npts == ypts.length) {
58
59 } else {
60 int n = ypts.length;
61 if (npts > n) {
62 npts = n;
63 }
64
65 E.warning("Line: idfferent array lengths " + xpts.length + " and " + ypts.length);
66 }
67 }
68 if (width < 0.5) {
69 width =1.;
70 }
71
72 if (label != null) {
73 if (labellee == null) {
74 labellee = new Labellee(xpts, ypts, label, getColor());
75 } else {
76 labellee.update(xpts, ypts, label, getColor());
77 }
78 }
79 }
80
81
82 public Labellee getLabellee() {
83 return labellee;
84 }
85
86
87 public void pushBox(Box b) {
88 for (int i = 0; i < npts; i++) {
89 b.extendTo(xpts[i], ypts[i]);
90 }
91 }
92
93
94
95 public void instruct(Painter p, int wf) {
96 if (xpts != null) {
97 p.setColor(getColor());
98 p.drawPolyline(xpts, ypts, npts, getColor(), width * wf, true);
99
100 }
101
102 }
103
104 }
105