AreaOfInterest extends GraphicalContext<BorderPane> { InfoBoxProps calculateInfoBox( final String aoiID, final double ttff, final double timeSpent, final int fixations, final int centerX, final int centerY, final Polygon currentAreaDisplay ) { final GridPane infoBox = makeInfoBox(aoiID, new DecimalFormat("##.###s").format(ttff), new DecimalFormat("##.###s").format(timeSpent), fixations, 0); final Dimension2D screenDimension = getGazePlay().getCurrentScreenDimensionSupplier().get(); final double screenWidthCenter = screenDimension.getWidth() / 2; final double widthOfArea = currentAreaDisplay.getBoundsInLocal().getWidth(); final Line line = new Line(); line.setStartY(centerY); line.setEndY(centerY); line.setStroke(Color.YELLOW); if (centerX > screenWidthCenter) { infoBox.setLayoutX(centerX - widthOfArea - 290); line.setStartX(currentAreaDisplay.getBoundsInLocal().getMinX()); line.setEndX(centerX - widthOfArea - 30); } else { infoBox.setLayoutX(centerX + widthOfArea + 100); line.setEndX(centerX + widthOfArea + 100); line.setStartX(currentAreaDisplay.getBoundsInLocal().getMaxX()); } infoBox.setLayoutY(centerY - 60); infoBox.setStyle("-fx-background-color: rgba(255,255,153, 0.4);"); return new InfoBoxProps(infoBox, line, aoiID, ttff, timeSpent, fixations); } AreaOfInterest(final GazePlay gazePlay, final Stats stats); @Override ObservableList<Node> getChildren();  }
@Test void shouldCalculateInfoBox() { List<CoordinatesTracker> coordinatesTrackers = List.of( new CoordinatesTracker(100, 200, 1234, 3456), new CoordinatesTracker(200, 200, 4321, 4567) ); when(mocksStats.getMovementHistoryWithTime()).thenReturn(coordinatesTrackers); AreaOfInterest areaOfInterest = new AreaOfInterest(mockGazePlay, mocksStats); Polygon currentArea = new Polygon(); currentArea.getPoints().addAll(1d, 1d, 2d, 1d, 2d, 3d, 1d, 3d); InfoBoxProps result1 = areaOfInterest.calculateInfoBox("id", 12.34, 1.23, 3, 300, 400, currentArea); InfoBoxProps result2 = areaOfInterest.calculateInfoBox("id", 12.34, 1.23, 3, 500, 400, currentArea); assertEquals(401, result1.getInfoBox().getLayoutX()); assertEquals(209, result2.getInfoBox().getLayoutX()); }