use of qupath.lib.gui.viewer.tools.PathTool in project qupath by qupath.
the class ViewTrackerTools method parseLogString.
private static ViewRecordingFrame parseLogString(String logString, String delimiter, boolean includesCursorTracking, boolean includesActiveToolTracking, boolean includesEyeTracking, boolean includeZAndT) {
String s = logString != null ? logString.trim().toLowerCase() : null;
// Check if we have anything, or if it is just a superfluous new line
if (s == null || s.isEmpty())
return null;
// Should probably be using a Scanner here (?)
String[] columns = s.split(delimiter);
int col = 0;
long timestamp = Long.parseLong(columns[col++]);
double x = Double.parseDouble(columns[col++]);
double y = Double.parseDouble(columns[col++]);
double width = Double.parseDouble(columns[col++]);
double height = Double.parseDouble(columns[col++]);
int canvasWidth = Integer.parseInt(columns[col++]);
int canvasHeight = Integer.parseInt(columns[col++]);
double downFactor = Double.parseDouble(columns[col++]);
double rotation = Double.parseDouble(columns[col++]);
Point2D pCursor = null;
// (currently implementing Alan's MSc required changes)
if (includesCursorTracking && columns.length > col && !columns[col].isEmpty() && !columns[col + 1].isEmpty()) {
double cursorX = Double.parseDouble(columns[col++]);
double cursorY = Double.parseDouble(columns[col++]);
pCursor = new Point2D.Double(cursorX, cursorY);
}
PathTool activeTool = null;
if (includesActiveToolTracking && columns.length > col && !columns[col].isEmpty())
activeTool = PathTools.getTool(columns[col++]);
Point2D pEye = null;
Boolean isFixated = null;
if (includesEyeTracking) {
if (columns.length > col && columns[col].length() > 0 && !columns[col + 1].isEmpty()) {
double eyeX = Double.parseDouble(columns[col++]);
double eyeY = Double.parseDouble(columns[col++]);
pEye = new Point2D.Double(eyeX, eyeY);
}
if (columns.length > col && columns[col].length() > 0)
isFixated = Boolean.parseBoolean(columns[col++]);
}
int z = 0;
int t = 0;
if (includeZAndT) {
if (columns.length > col && columns[col].length() > 0 && !columns[col + 1].isEmpty()) {
z = Integer.parseInt(columns[col++]);
t = Integer.parseInt(columns[col++]);
}
}
return new ViewRecordingFrame(timestamp, new Rectangle2D.Double(x, y, width, height), new Dimension(canvasWidth, canvasHeight), downFactor, rotation, pCursor, activeTool, pEye, isFixated, z, t);
}
Aggregations