/
RuleInterval.java
153 lines (133 loc) · 3.42 KB
/
RuleInterval.java
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package net.seninp.gi.logic;
import java.io.Serializable;
/**
*
* Helper class implementing an interval used when plotting.
*
* @author Manfred Lerner, seninp
*
*/
public class RuleInterval implements Comparable<RuleInterval>, Cloneable, Serializable {
public int id; // the corresponding rule id
public int startPos; // interval start
public int endPos; // interval stop
public double coverage; // coverage or any other sorting criterion
public RuleInterval() {
super();
this.id = -1;
this.startPos = -1;
this.endPos = -1;
}
public RuleInterval(int startPos, int endPos) {
super();
this.id = -1;
this.startPos = startPos;
this.endPos = endPos;
this.coverage = Double.NaN;
}
public RuleInterval(int id, int startPos, int endPos, double coverage) {
this.id = id;
this.startPos = startPos;
this.endPos = endPos;
this.coverage = coverage;
}
public void setId(int ruleIndex) {
this.id = ruleIndex;
}
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param startPos starting position within the original time series
*/
public void setStart(int startPos) {
this.startPos = startPos;
}
/**
* @return starting position within the original time series
*/
public int getStart() {
return startPos;
}
/**
* @param endPos ending position within the original time series
*/
public void setEnd(int endPos) {
this.endPos = endPos;
}
/**
* @return ending position within the original time series
*/
public int getEnd() {
return endPos;
}
/**
* @param coverage the coverage to set
*/
public void setCoverage(double coverage) {
this.coverage = coverage;
}
/**
* @return the coverage
*/
public double getCoverage() {
return this.coverage;
}
public int getLength() {
return this.endPos - this.startPos;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
public String toString() {
return "[" + startPos + "-" + endPos + "]";
}
public int compareTo(RuleInterval arg0) {
return Integer.compare(this.getLength(), Integer.valueOf(arg0.getLength()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(coverage);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + endPos;
result = prime * result + id;
result = prime * result + startPos;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
RuleInterval other = (RuleInterval) obj;
if (Double.doubleToLongBits(coverage) != Double.doubleToLongBits(other.coverage))
return false;
if (endPos != other.endPos)
return false;
if (id != other.id)
return false;
if (startPos != other.startPos)
return false;
return true;
}
@Override
public Object clone() throws CloneNotSupportedException {
RuleInterval clone = (RuleInterval) super.clone();
clone.id = this.id;
clone.startPos = this.startPos;
clone.endPos = this.endPos;
clone.coverage = this.coverage;
return clone;
}
}