1
2 package com.github.celldynamics.quimp;
3
4 import java.util.Arrays;
5
6 import com.github.celldynamics.quimp.geom.ExtendedVector2d;
7
8 import ij.IJ;
9
10
11
12
13
14
15
16
17
18 public class Vert extends PointsList<Vert> {
19
20
21
22 public double charge;
23
24
25
26 public double distance;
27
28
29
30 public final FluoMeasurementement.html#FluoMeasurement">FluoMeasurement[] fluores = new FluoMeasurement[3];
31
32
33
34
35 public double curvatureLocal;
36
37
38
39
40
41 @SuppressWarnings("javadoc")
42 public double curvatureSmoothed;
43
44
45
46
47
48 @SuppressWarnings("javadoc")
49 public double curvatureSum;
50
51
52
53 public double coord;
54
55
56
57
58
59
60 @SuppressWarnings("javadoc")
61 public double fCoord;
62
63
64
65
66
67 public double fLandCoord;
68
69
70
71
72
73
74 @SuppressWarnings("javadoc")
75 public double gCoord;
76
77
78
79
80
81 public double gLandCoord;
82
83
84
85 public double tarLandingCoord;
86
87
88
89 public QColor color;
90
91
92
93 private transient boolean intPoint;
94
95
96
97 public transient boolean snapped;
98
99
100
101 public int intsectID;
102
103
104
105
106
107
108
109
110
111
112 public int intState;
113
114
115
116
117 public Vert() {
118 super();
119 vertInitializer();
120 }
121
122
123
124
125
126
127 public Vert(int t) {
128 super(t);
129 vertInitializer();
130 }
131
132
133
134
135
136
137
138
139 public Vert(double xx, double yy, int t) {
140 super(xx, yy, t);
141 vertInitializer();
142 }
143
144
145
146
147
148
149 public Vertmics/quimp/Vert.html#Vert">Vert(final Vert src) {
150 super(src);
151 charge = src.charge;
152 distance = src.distance;
153 for (int i = 0; i < 3; i++) {
154 fluores[i] = new FluoMeasurement(src.fluores[i]);
155 }
156 curvatureLocal = src.curvatureLocal;
157 curvatureSmoothed = src.curvatureSmoothed;
158 curvatureSum = src.curvatureSum;
159 coord = src.coord;
160 fCoord = src.fCoord;
161 fLandCoord = src.fLandCoord;
162 gCoord = src.gCoord;
163 gLandCoord = src.gLandCoord;
164 tarLandingCoord = src.tarLandingCoord;
165 color = new QColor(src.color);
166 intPoint = src.intPoint;
167 snapped = src.snapped;
168 intsectID = src.intsectID;
169 intState = src.intState;
170 }
171
172
173
174
175
176
177 public Vert(final Node src) {
178 super(src);
179 vertInitializer();
180 }
181
182
183
184
185 private void vertInitializer() {
186 intPoint = false;
187 intState = 0;
188 fCoord = -1;
189 gCoord = -1;
190 color = new QColor(1, 0, 0);
191 for (int i = 0; i < 3; i++) {
192 fluores[i] = new FluoMeasurement(-2, -2, -2);
193 }
194 }
195
196
197
198
199
200
201 @Override
202 public int hashCode() {
203 final int prime = 31;
204 int result = super.hashCode();
205 long temp;
206 temp = Double.doubleToLongBits(charge);
207 result = prime * result + (int) (temp ^ (temp >>> 32));
208 result = prime * result + ((color == null) ? 0 : color.hashCode());
209 temp = Double.doubleToLongBits(coord);
210 result = prime * result + (int) (temp ^ (temp >>> 32));
211 temp = Double.doubleToLongBits(curvatureLocal);
212 result = prime * result + (int) (temp ^ (temp >>> 32));
213 temp = Double.doubleToLongBits(curvatureSmoothed);
214 result = prime * result + (int) (temp ^ (temp >>> 32));
215 temp = Double.doubleToLongBits(curvatureSum);
216 result = prime * result + (int) (temp ^ (temp >>> 32));
217 temp = Double.doubleToLongBits(distance);
218 result = prime * result + (int) (temp ^ (temp >>> 32));
219 temp = Double.doubleToLongBits(fCoord);
220 result = prime * result + (int) (temp ^ (temp >>> 32));
221 temp = Double.doubleToLongBits(fLandCoord);
222 result = prime * result + (int) (temp ^ (temp >>> 32));
223 result = prime * result + Arrays.hashCode(fluores);
224 temp = Double.doubleToLongBits(gCoord);
225 result = prime * result + (int) (temp ^ (temp >>> 32));
226 temp = Double.doubleToLongBits(gLandCoord);
227 result = prime * result + (int) (temp ^ (temp >>> 32));
228 result = prime * result + (intPoint ? 1231 : 1237);
229 result = prime * result + intState;
230 result = prime * result + intsectID;
231 result = prime * result + (snapped ? 1231 : 1237);
232 temp = Double.doubleToLongBits(tarLandingCoord);
233 result = prime * result + (int) (temp ^ (temp >>> 32));
234 return result;
235 }
236
237
238
239
240
241
242 @Override
243 public boolean equals(Object obj) {
244 if (this == obj) {
245 return true;
246 }
247 if (!super.equals(obj)) {
248 return false;
249 }
250 if (!(obj instanceof Vert)) {
251 return false;
252 }
253 Vertf="../../../../com/github/celldynamics/quimp/Vert.html#Vert">Vert other = (Vert) obj;
254 if (Double.doubleToLongBits(charge) != Double.doubleToLongBits(other.charge)) {
255 return false;
256 }
257 if (color == null) {
258 if (other.color != null) {
259 return false;
260 }
261 } else if (!color.equals(other.color)) {
262 return false;
263 }
264 if (Double.doubleToLongBits(coord) != Double.doubleToLongBits(other.coord)) {
265 return false;
266 }
267 if (Double.doubleToLongBits(curvatureLocal) != Double.doubleToLongBits(other.curvatureLocal)) {
268 return false;
269 }
270 if (Double.doubleToLongBits(curvatureSmoothed) != Double
271 .doubleToLongBits(other.curvatureSmoothed)) {
272 return false;
273 }
274 if (Double.doubleToLongBits(curvatureSum) != Double.doubleToLongBits(other.curvatureSum)) {
275 return false;
276 }
277 if (Double.doubleToLongBits(distance) != Double.doubleToLongBits(other.distance)) {
278 return false;
279 }
280 if (Double.doubleToLongBits(fCoord) != Double.doubleToLongBits(other.fCoord)) {
281 return false;
282 }
283 if (Double.doubleToLongBits(fLandCoord) != Double.doubleToLongBits(other.fLandCoord)) {
284 return false;
285 }
286 if (!Arrays.equals(fluores, other.fluores)) {
287 return false;
288 }
289 if (Double.doubleToLongBits(gCoord) != Double.doubleToLongBits(other.gCoord)) {
290 return false;
291 }
292 if (Double.doubleToLongBits(gLandCoord) != Double.doubleToLongBits(other.gLandCoord)) {
293 return false;
294 }
295 if (intPoint != other.intPoint) {
296 return false;
297 }
298 if (intState != other.intState) {
299 return false;
300 }
301 if (intsectID != other.intsectID) {
302 return false;
303 }
304 if (snapped != other.snapped) {
305 return false;
306 }
307 if (Double.doubleToLongBits(tarLandingCoord) != Double
308 .doubleToLongBits(other.tarLandingCoord)) {
309 return false;
310 }
311 return true;
312 }
313
314
315
316
317
318
319
320 public void print(String s) {
321 System.out.print(s + "vert: " + tracknumber + ", x:" + getX() + ", y:" + getY() + ", coord: "
322 + coord + ", fCoord: " + fCoord + ", gCoord: " + gCoord);
323 if (intPoint) {
324 System.out.print(", isIntPoint (" + intsectID + ")");
325 }
326 if (head) {
327 System.out.print(", Head");
328 }
329 System.out.println("");
330 }
331
332
333
334
335
336
337 public boolean isIntPoint() {
338 return intPoint;
339 }
340
341
342
343
344
345
346
347 public void setIntPoint(boolean t, int i) {
348 intPoint = t;
349 intsectID = i;
350 tracknumber = -1;
351 }
352
353
354
355
356
357
358
359 public void setLandingCoord(ExtendedVector2d p, Vert edge) {
360 Vert edge2 = edge.getNext();
361
362 while (edge.isIntPoint()) {
363 edge = edge.getPrev();
364 }
365 while (edge2.isIntPoint()) {
366 edge2 = edge2.getNext();
367 }
368
369
370 double d1 = ExtendedVector2d.lengthP2P(edge.point, edge2.point);
371 double d2 = ExtendedVector2d.lengthP2P(edge.point, p);
372 double prop = d2 / d1;
373
374 gLandCoord = calcLanding(edge.gCoord, edge2.gCoord, prop);
375 fLandCoord = calcLanding(edge.coord, edge2.coord, prop);
376
377 if (gLandCoord >= 1 || gLandCoord < 0 || fLandCoord >= 1 || fLandCoord < 0) {
378 System.out.println("Vert253:setLandingCoord-Error in landing coord\n\t" + "gLandCoord= "
379 + gLandCoord + ", fLandCoord = " + fLandCoord);
380
381 }
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399 }
400
401 private double calcLanding(double coordA, double coordB, double prop) {
402 double landing;
403
404 if (coordB < coordA) {
405 coordB += 1;
406 }
407
408 double coordDist = coordB - coordA;
409 landing = coordA + (prop * coordDist);
410
411 if (landing >= 1) {
412 landing -= 1;
413 }
414
415 if (landing < 0 || landing >= 1 || Double.isNaN(landing)) {
416 System.out.println(
417 "Vert295:calcLanding ERROR in landing coord:\n\t" + "landing:" + IJ.d2s(landing)
418 + ", coordA=" + coordA + ", coorB=" + coordB + ", proportion=" + prop);
419 }
420 return landing;
421 }
422
423
424
425
426 public void setCurvatureLocal() {
427 curvatureLocal = getCurvatureLocal();
428 }
429
430
431
432
433
434
435
436 public void setFluoresChannel(FluoMeasurement m, int channel) {
437 fluores[channel].intensity = m.intensity;
438 fluores[channel].x = m.x;
439 fluores[channel].y = m.y;
440 }
441
442
443
444
445
446
447
448
449
450 public void setFluoresChannel(int x, int y, int i, int channel) {
451 fluores[channel].intensity = i;
452 fluores[channel].x = x;
453 fluores[channel].y = y;
454 }
455
456
457
458
459
460
461 public void setFluores(FluoMeasurement[] m) {
462
463 for (int i = 0; i < 3; i++) {
464 fluores[i].intensity = m[i].intensity;
465 fluores[i].x = m[i].x;
466 fluores[i].y = m[i].y;
467 }
468 }
469
470
471
472
473
474
475 @Override
476 public String toString() {
477 return "Vert [charge=" + charge + ", distance=" + distance + ", fluores="
478 + Arrays.toString(fluores) + ", curvatureLocal=" + curvatureLocal
479 + ", curvatureSmoothed=" + curvatureSmoothed + ", curvatureSum=" + curvatureSum
480 + ", coord=" + coord + ", fCoord=" + fCoord + ", fLandCoord=" + fLandCoord + ", gCoord="
481 + gCoord + ", gLandCoord=" + gLandCoord + ", tarLandingCoord=" + tarLandingCoord
482 + ", color=" + color + ", intsectID=" + intsectID + ", intState=" + intState
483 + ", toString()=" + super.toString() + "]";
484 }
485
486
487
488
489
490
491
492
493 static double disCoord2Coord(double a, double b) {
494 if (a < b) {
495 return b - a;
496 }
497 if (b < a) {
498 return (1 - a) + b;
499 } else {
500 return 0;
501 }
502 }
503
504
505
506
507
508
509
510
511 static double addCoords(double a, double b) {
512 double r = a + b;
513 if (r >= 1) {
514 r = r - 1;
515 }
516 return r;
517 }
518
519 }