public ShotEntry( Shot shot, Optional<Shot> lastShot, Optional<Color> rowColor, boolean hadMalfunction, boolean hadReload) { this.shot = shot; if (shot.getColor().equals(Color.RED)) { color = "red"; } else if (shot.getColor().equals(Color.GREEN)) { color = "green"; } else { color = "infrared"; } this.rowColor = rowColor; float timestampS = ((float) shot.getTimestamp()) / (float) 1000; timestamp = String.format("%.2f", timestampS); String split; if (lastShot.isPresent()) { split = String.format( "%.2f", timestampS - ((float) lastShot.get().getTimestamp() / (float) 1000)); } else { split = "-"; } this.split = new SplitData(split, rowColor, hadMalfunction, hadReload); }
@Override public void visitShot( long timestamp, Shot shot, boolean isMalfunction, boolean isReload, Optional<Integer> targetIndex, Optional<Integer> hitRegionIndex, Optional<String> videoString) { int targIndex; if (targetIndex.isPresent()) { targIndex = targetIndex.get(); } else { targIndex = -1; } int hitRegIndex; if (hitRegionIndex.isPresent()) { hitRegIndex = hitRegionIndex.get(); } else { hitRegIndex = -1; } if (videoString.isPresent()) { xmlBody.append( String.format( Locale.US, "\t\t<shot timestamp=\"%d\" color=\"%s\"" + " x=\"%f\" y=\"%f\" shotTimestamp=\"%d\" markerRadius=\"%d\" isMalfunction=\"%b\"" + " isReload=\"%b\" targetIndex=\"%d\" hitRegionIndex=\"%d\" videos=\"%s\" />%n", timestamp, shot.getColor().toString(), shot.getX(), shot.getY(), shot.getTimestamp(), (int) shot.getMarker().getRadiusX(), isMalfunction, isReload, targIndex, hitRegIndex, videoString.get())); } else { xmlBody.append( String.format( Locale.US, "\t\t<shot timestamp=\"%d\" color=\"%s\"" + " x=\"%f\" y=\"%f\" shotTimestamp=\"%d\" markerRadius=\"%d\" isMalfunction=\"%b\"" + " isReload=\"%b\" targetIndex=\"%d\" hitRegionIndex=\"%d\" />%n", timestamp, shot.getColor().toString(), shot.getX(), shot.getY(), shot.getTimestamp(), (int) shot.getMarker().getRadiusX(), isMalfunction, isReload, targIndex, hitRegIndex)); } }