Package com.esprit.controllers.cinemas
Class CinemaStatisticsController
java.lang.Object
com.esprit.controllers.cinemas.CinemaStatisticsController
Is responsible for generating and displaying sentiment statistics for various
cinemas based on user comments. It retrieves movie commentary data from a
service, generates sentiment statistics for each cinema using the comments,
and creates PieCharts to visualize the statistics. The controller also
displays the generated PieCharts in an AnchorPane.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CinemaCommentService
private final CinemaService
private javafx.scene.layout.AnchorPane
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate javafx.scene.chart.PieChart
createPieChart
(String cinemaName, Map<String, Integer> sentimentStatistics) Creates a PieChart object and sets its title based on a cinema name and sentiment statistics map.generateSentimentStatistics
(List<CinemaComment> comments) Generates a map of sentiment statistics for each cinema based on a list of comments, where each comment is associated with a cinema and a sentiment label.(package private) void
showStatistics
(javafx.event.ActionEvent event) Clears an existing children container, retrieves comments from a database, generates sentiment statistics for each cinema, and displays the statistics as PieCharts within a new container added to the parent AnchorPane.
-
Field Details
-
cinemaCommentService
-
cinemaService
-
statisticsAnchor
private javafx.scene.layout.AnchorPane statisticsAnchor
-
-
Constructor Details
-
CinemaStatisticsController
public CinemaStatisticsController()
-
-
Method Details
-
showStatistics
void showStatistics(javafx.event.ActionEvent event) Clears an existing children container, retrieves comments from a database, generates sentiment statistics for each cinema, and displays the statistics as PieCharts within a new container added to the parent AnchorPane.- Parameters:
event
- ActionEvent triggered by the button click that initiates the code execution and calls the `showStatistics()` method.- `event`: an instance of `ActionEvent`, representing a user-generated event
-
generateSentimentStatistics
Generates a map of sentiment statistics for each cinema based on a list of comments, where each comment is associated with a cinema and a sentiment label. The function counts the number of comments with each sentiment and stores it in the map for that cinema.- Parameters:
comments
- list of comments that will be processed to generate sentiment statistics for each cinema.- It is a list of `CinemaComment` objects, representing user comments on cinema movies.
-
createPieChart
private javafx.scene.chart.PieChart createPieChart(String cinemaName, Map<String, Integer> sentimentStatistics) Creates a PieChart object and sets its title based on a cinema name and sentiment statistics map. It then adds the chart data based on the map entries.- Parameters:
cinemaName
- name of the cinema for which sentiment statistics are being generated and displayed in the PieChart.sentimentStatistics
- sentiment statistics of a cinema, which is used to generate a pie chart displaying the distribution of sentiment scores for that cinema.- `Map<String, Integer>`: This map contains sentiment statistics for different cinema names, where each key represents a cinema name and the value represents the number of reviews with a positive sentiment towards that cinema.
-