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.PatternCell;
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 AcopBitTableColumn 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 AcopBitTableColumn() {
54 super();
55 }
56
57
58
59
60
61
62
63
64 public AcopBitTableColumn(AcopTable table, String uniqueName, String shortName) {
65 super(table, uniqueName, shortName);
66 rows = new double[0];
67 cells = new PatternCell[0];
68 }
69
70
71
72
73
74 @Override
75 public Class<?> getColumnClass() {
76 return PatternCell.class;
77 }
78
79
80
81
82
83 public Object getValue(int rowIndex) {
84 if (rows == null || rowIndex >= rows.length || rowIndex < 0) return null;
85 if (cells[rowIndex] == null) {
86 cells[rowIndex] = new PatternCell(displayerParameters.getName()+"[" + rowIndex+"]", this, (long)rows[rowIndex], null);
87 cells[rowIndex].putAllCharacteristics(characteristics);
88 } else {
89 cells[rowIndex].setValue((long)rows[rowIndex]);
90 }
91 setCharacteristicsOnCell(cells[rowIndex]);
92 return cells[rowIndex];
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 PatternCell[value.length];
103 }
104 fireColumnChanged();
105 }
106
107
108
109
110 public String[] getSupportedCharacteristics() {
111 return DisplayerUtilities.combineCharacteristics(DisplayerUtilities.COMMON_NUMERIC_DISPLAYER_CHARACTERISTICS,
112 SUPPORTED_CHARACTERISTICS);
113 }
114
115
116
117
118 @SuppressWarnings("unchecked")
119 public Class<DataConsumer>[] getSupportedConsumerTypes() {
120 return SUPPORTED_CONSUMER_TYPES;
121 }
122
123 }