-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrawNode.java
More file actions
74 lines (66 loc) · 1.88 KB
/
DrawNode.java
File metadata and controls
74 lines (66 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package datastructure;
import javafx.scene.shape.Rectangle;
import screens.GraphInfo;
/**
* Created by 101010.
*/
public class DrawNode extends Rectangle {
/**
* The id of the node corresponding to the node in the GFA file.
*/
private int id;
/**
* Constructor for the draw node.
* @param index the id of the node.
*/
public DrawNode(int index) {
this.id = index;
}
/**
* Getter for the id of the draw node.
* @return the id of the draw node.
*/
public int getIndex() {
return this.id;
}
/**
* Checks if given object is the same as current DrawNode.
* @param other The objectto be checked.
* @return true iff object is the same.
*/
public boolean equals(Object other) {
if (other instanceof DrawNode) {
DrawNode that = (DrawNode) other;
return this.id == that.id;
}
return false;
}
/**
* Givens the hashcode of the DrawNode.
* @return the hashcode.
*/
public int hashCode() {
return id;
}
/**
* Getter for the genome paths going through a DrawNode.
* @return all genomes that cross this DrawNode.
*/
public String[] getGenomes() {
int[][] allGenomes = GraphInfo.getInstance().getGenomes();
int index = -1;
for (int i = 0; i < allGenomes.length; i++) {
if (allGenomes[i][0] == this.getIndex()) {
index = i;
break;
}
}
int[] genomes = GraphInfo.getInstance().getGenomes()[index];
String[] strGenomes = new String[genomes.length - 1];
for (int i = 1; i < genomes.length; i++) {
String name = GraphInfo.getInstance().getGenomeNames()[genomes[i]];
strGenomes[i - 1] = name.substring(0, name.length() - 6);
}
return strGenomes;
}
}