StatDisplayUtils { public static ImageView buildGazeMetrics(Stats stats, final Region root) { ImageView gazeMetrics = new ImageView(); gazeMetrics.setPreserveRatio(true); SavedStatsInfo savedStatsInfo = stats.getSavedStatsInfo(); savedStatsInfo.addObserver((o, arg) -> Platform.runLater( () -> gazeMetrics.setImage(new Image(savedStatsInfo.getGazeMetricsFileMouseAndGaze().toURI().toString())))); gazeMetrics.setImage(new Image(savedStatsInfo.getGazeMetricsFileMouseAndGaze().toURI().toString())); EventHandler<Event> openGazeMetricsEvent = createZoomInGazeMetricsEventHandler(gazeMetrics, root); gazeMetrics.addEventHandler(MouseEvent.MOUSE_CLICKED, openGazeMetricsEvent); return gazeMetrics; }  static HomeButton createHomeButtonInStatsScreen(GazePlay gazePlay, StatsContext statsContext); static LineChart<String, Number> buildLineChart(Stats stats, final Region root); static AreaChart<Number, Number> buildAreaChart(LinkedList<FixationPoint> points, final Region root); static ImageView buildGazeMetrics(Stats stats, final Region root); static String convert(long totalTime);  }
@Test void shouldBuildGazeMetrics() { final File mockFile = new File("bear.jpg"); final SavedStatsInfo mockSavedStatsInfo = new SavedStatsInfo(mockFile, mockFile, mockFile, mockFile, mockFile, mockFile); when(mockStats.getSavedStatsInfo()).thenReturn(mockSavedStatsInfo); final ImageView imageView = StatDisplayUtils.buildGazeMetrics(mockStats, mockRegion); assertTrue(imageView.getImage().getUrl().contains("bear.jpg")); }
@Test void shouldZoomInToGazeMetrics() { final File mockFile = new File("bear.jpg"); final SavedStatsInfo mockSavedStatsInfo = new SavedStatsInfo(mockFile, mockFile, mockFile, mockFile, mockFile, mockFile); when(mockStats.getSavedStatsInfo()).thenReturn(mockSavedStatsInfo); final ImageView imageView = StatDisplayUtils.buildGazeMetrics(mockStats, mockRegion); final VBox parent = new VBox(); parent.getChildren().add(imageView); imageView.fireEvent(mouseClickEvent(imageView)); assertEquals(0, imageView.getTranslateX()); assertEquals(0, imageView.getTranslateY()); }
@Test void shouldZoomOutOfGazeMetrics() { final File mockFile = new File("bear.jpg"); final SavedStatsInfo mockSavedStatsInfo = new SavedStatsInfo(mockFile, mockFile, mockFile, mockFile, mockFile, mockFile); when(mockStats.getSavedStatsInfo()).thenReturn(mockSavedStatsInfo); final ImageView imageView = StatDisplayUtils.buildGazeMetrics(mockStats, mockRegion); final VBox parent = new VBox(); parent.getChildren().add(imageView); imageView.fireEvent(mouseClickEvent(imageView)); imageView.fireEvent(mouseClickEvent(imageView)); assertEquals(1, imageView.getScaleX()); assertEquals(1, imageView.getScaleY()); }