AreaOfInterest extends GraphicalContext<BorderPane> { static void calculateTargetAOI(final ArrayList<TargetAOI> targetAOIArrayList) { for (final TargetAOI targetAOI : targetAOIArrayList) { log.debug("The target is at (" + targetAOI.getXValue() + ", " + targetAOI.getYValue() + ")"); final int radius = targetAOI.getAreaRadius(); final Point2D[] point2D = { new Point2D(targetAOI.getXValue() - 100, targetAOI.getYValue()), new Point2D(targetAOI.getXValue() + radius, targetAOI.getYValue() + 100), new Point2D(targetAOI.getXValue(), targetAOI.getYValue() - radius), new Point2D(targetAOI.getXValue() + radius, targetAOI.getYValue() - radius) }; final Double[] polygonPoints; polygonPoints = calculateRectangle(point2D); final Polygon targetArea; targetArea = new Polygon(); targetArea.getPoints().addAll(polygonPoints); targetArea.setFill(Color.rgb(255, 255, 255, 0.4)); targetAOI.setPolygon(targetArea); } } AreaOfInterest(final GazePlay gazePlay, final Stats stats); @Override ObservableList<Node> getChildren();  }
@Test void shouldCalculateTargetAOI() { TargetAOI t1 = new TargetAOI(500, 500, 300, 1234); TargetAOI t2 = new TargetAOI(650, 700, 200, 1234); Double[] e1 = new Double[]{ 385d, 615d, 815d, 615d, 815d, 185d, 385d, 185d }; Double[] e2 = new Double[]{ 535d, 815d, 865d, 815d, 865d, 485d, 535d, 485d }; ArrayList<TargetAOI> input = new ArrayList<>(List.of(t1, t2)); AreaOfInterest.calculateTargetAOI(input); Double[] r1 = new Double[8], r2 = new Double[8]; input.get(0).getPolygon().getPoints().toArray(r1); input.get(1).getPolygon().getPoints().toArray(r2); assertArrayEquals(r1, e1); assertArrayEquals(r2, e2); }