1 package com.github.celldynamics.quimp.plugin.protanalysis;
2
3 import java.awt.Point;
4 import java.awt.Polygon;
5 import java.awt.geom.Point2D;
6 import java.util.ArrayList;
7 import java.util.Collection;
8 import java.util.Iterator;
9
10 import org.slf4j.Logger;
11 import org.slf4j.LoggerFactory;
12
13
14
15
16
17
18
19
20
21
22 class Track extends ArrayList<Point> {
23 private static final long serialVersionUID = 8928704797702167155L;
24 static final Logger LOGGER = LoggerFactory.getLogger(Track.class.getName());
25
26
27
28
29
30
31
32 public static enum TrackType {
33 BACKWARD, FORWARD, OTHER
34 }
35
36
37
38
39 private int id;
40
41
42
43 private Point parents;
44
45
46
47 TrackType type;
48
49 public Track() {
50 super();
51 id = -1;
52 parents = null;
53 }
54
55 public Track(int id, Point parents) {
56 this();
57 this.id = id;
58 this.parents = parents;
59 }
60
61 public Track(Collection<? extends Point> c) {
62 super(c);
63 id = -1;
64 parents = null;
65 }
66
67 public Track(Collection<? extends Point> c, int id, Point parents) {
68 this(c);
69 this.id = id;
70 this.parents = parents;
71 }
72
73
74
75
76
77
78 @SuppressWarnings("unused")
79 private Track(int initialCapacity) {
80 super(initialCapacity);
81 id = -1;
82 parents = null;
83 }
84
85
86
87
88
89
90 public Polygon asPolygon() {
91 Iterator<Point> it = iterator();
92 Polygon ret = new Polygon();
93 while (it.hasNext()) {
94 Point p = it.next();
95 ret.addPoint(p.x, p.y);
96 }
97 return ret;
98 }
99
100
101
102
103
104
105
106
107
108
109
110 public Point2D.Double getXY(int index, double[][] xmap, double[][] ymap) {
111 Point p = get(index);
112 return new Point2D.Double(xmap[p.x][p.y], ymap[p.x][p.y]);
113 }
114
115
116
117
118
119
120
121
122
123 public int getFrame(int index) {
124 return get(index).x;
125 }
126
127
128
129
130
131
132
133
134
135 public int getOutline(int index) {
136 return get(index).y;
137 }
138
139 }