1 package com.github.celldynamics.quimp.plugin.qanalysis;
2
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5
6 import com.github.celldynamics.quimp.QColor;
7 import com.github.celldynamics.quimp.utils.QuimPArrayUtils;
8
9
10
11
12
13
14
15 public class FluoMap {
16
17
18
19
20 static final Logger LOGGER = LoggerFactory.getLogger(FluoMap.class.getName());
21
22
23
24 private int T;
25
26
27
28 private int res;
29
30
31
32 private int channel;
33
34
35
36 private double[][] map;
37
38
39
40
41
42
43 byte[] fluColor;
44
45
46
47 boolean enabled;
48
49
50
51
52
53
54 public FluoMapynamics/quimp/plugin/qanalysis/FluoMap.html#FluoMap">FluoMap(final FluoMap src) {
55 this.T = src.T;
56 this.res = src.res;
57 this.channel = src.channel;
58 this.map = QuimPArrayUtils.copy2darray(src.map, null);
59 this.fluColor = new byte[src.fluColor.length];
60 System.arraycopy(src.fluColor, 0, this.fluColor, 0, src.fluColor.length);
61 this.enabled = src.enabled;
62 }
63
64
65
66
67
68
69
70
71 public FluoMap(int t, int r, int i) {
72 T = t;
73 res = r;
74 channel = i;
75 enabled = true;
76 map = new double[T][res];
77 fluColor = new byte[T * res];
78 }
79
80
81
82
83
84
85 public void setEnabled(boolean b) {
86 enabled = b;
87 }
88
89
90
91
92
93
94 public boolean isEnabled() {
95 return enabled;
96 }
97
98
99
100
101
102
103
104
105
106
107
108 public void fill(int t, int p, int pn, double intensity, double max) {
109 map[t][p] = intensity;
110 fluColor[pn] = (byte) QColor.bwScale(intensity, 256, max, 0);
111 }
112
113
114
115
116
117
118
119 public void recalculateColorScale(double max) {
120 LOGGER.debug("Recalculate fluColor, max=" + max + " enabled state:" + isEnabled());
121 if (!isEnabled()) {
122 return;
123 }
124 int pn;
125 double intensity;
126 for (int r = 0; r < res; r++) {
127 for (int t = 0; t < T; t++) {
128 pn = t * res + r;
129 intensity = map[t][r];
130 fluColor[pn] = (byte) QColor.bwScale(intensity, 256, max, 0);
131 }
132 }
133
134 }
135
136
137
138
139
140
141 public byte[] getColours() {
142 return fluColor;
143 }
144
145
146
147
148
149
150 public double[][] getMap() {
151 return map;
152 }
153
154
155
156
157
158
159 public int getChannel() {
160 return channel;
161 }
162
163
164
165
166
167
168 public void setMap(double[][] map) {
169 this.map = map;
170 recalculateColorScale(QuimPArrayUtils.array2dMax(map));
171 setEnabled(true);
172 T = map.length;
173 res = map[0].length;
174 }
175 }