calculate session duration automatically for annotations

This commit is contained in:
Jonathan Shook 2023-09-15 16:48:38 -05:00
parent 255a560957
commit 5e52ff2031
2 changed files with 7 additions and 2 deletions

View File

@ -96,4 +96,8 @@ public interface Annotation extends NBLabeledElement {
String asJson();
default long getDurationMillis() {
return getEndMillis()-getStartMillis();
}
}

View File

@ -88,6 +88,7 @@ public class MutableAnnotation implements Annotation {
public void setEnd(long intervalEnd) {
this.end = intervalEnd;
this.details.put("duration",String.valueOf(getDurationMillis()));
}
public void setLayer(Layer layer) {
@ -136,8 +137,8 @@ public class MutableAnnotation implements Annotation {
public String toString() {
StringBuilder sb = new StringBuilder();
ZonedDateTime startTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(getStart()), zoneid);
ZonedDateTime endTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(getStart()), zoneid);
ZonedDateTime startTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(getStartMillis()), zoneid);
ZonedDateTime endTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(getStartMillis()), zoneid);
sb.append("[");
ZonedDateTime zonedStartTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(getStart()), zoneid);