Search in sources :

Example 1 with PathTool

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);
}
Also used : Rectangle2D(java.awt.geom.Rectangle2D) Dimension(java.awt.Dimension) PathTool(qupath.lib.gui.viewer.tools.PathTool) Point2D(java.awt.geom.Point2D)

Aggregations

Dimension (java.awt.Dimension)1 Point2D (java.awt.geom.Point2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 PathTool (qupath.lib.gui.viewer.tools.PathTool)1