1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package de.desy.acop.displayers.table;
24
25 import com.cosylab.gui.components.table.cells.DoubleCell;
26 import com.cosylab.gui.displayers.DataConsumer;
27 import com.cosylab.gui.displayers.DisplayerUtilities;
28 import com.cosylab.gui.displayers.DoubleSeqConsumer;
29 import com.cosylab.util.CommonException;
30
31 import de.desy.acop.displayers.AcopTable;
32
33
34
35
36
37
38
39 public class AcopNumericTableColumn extends AcopTableColumn implements DoubleSeqConsumer {
40
41 @SuppressWarnings("unchecked")
42 public static final Class[] SUPPORTED_CONSUMER_TYPES = {
43 DoubleSeqConsumer.class
44 };
45 public static final String[] SUPPORTED_CHARACTERISTICS = {};
46
47 protected double[] rows;
48
49
50
51
52
53 public AcopNumericTableColumn() {
54 super();
55 }
56
57
58
59
60
61
62
63
64 public AcopNumericTableColumn(AcopTable table, String uniqueName, String shortName) {
65 super(table, uniqueName, shortName);
66 rows = new double[0];
67 cells = new DoubleCell[0];
68 }
69
70
71
72
73
74 @Override
75 public Class<?> getColumnClass() {
76 return DoubleCell.class;
77 }
78
79
80
81
82 public String[] getSupportedCharacteristics() {
83 return DisplayerUtilities.combineCharacteristics(DisplayerUtilities.COMMON_NUMERIC_DISPLAYER_CHARACTERISTICS,
84 SUPPORTED_CHARACTERISTICS);
85 }
86
87
88
89
90 @SuppressWarnings("unchecked")
91 public Class<DataConsumer>[] getSupportedConsumerTypes() {
92 return SUPPORTED_CONSUMER_TYPES;
93 }
94
95
96
97
98
99 public void updateValue(long timestamp, double[] value) throws CommonException {
100 rows = value;
101 if (cells.length != value.length) {
102 cells = new DoubleCell[value.length];
103 }
104 fireColumnChanged();
105 }
106
107
108
109
110
111 public Object getValue(int rowIndex) {
112 if (rows == null || rowIndex >= rows.length || rowIndex < 0) return null;
113 if (cells[rowIndex] == null) {
114 cells[rowIndex] = new DoubleCell(displayerParameters.getName()+"[" + rowIndex+"]", this, rows[rowIndex], null);
115 cells[rowIndex].putAllCharacteristics(characteristics);
116 } else {
117 cells[rowIndex].setValue(rows[rowIndex]);
118 }
119 setCharacteristicsOnCell(cells[rowIndex]);
120 return cells[rowIndex];
121 }
122
123
124 }