Class Controller

java.lang.Object
comp3111.covid.Controller
All Implemented Interfaces:
javafx.fxml.Initializable

public class Controller
extends java.lang.Object
implements javafx.fxml.Initializable
  • Field Summary

    Fields 
    Modifier and Type Field Description
    (package private) javafx.beans.property.DoubleProperty aShift  
    (package private) javafx.beans.property.DoubleProperty bShift  
    (package private) javafx.scene.text.Text chartReportC1Title  
    (package private) javafx.scene.text.Text chartReportC2Title  
    (package private) javafx.scene.text.Text chartReportC3Title  
    (package private) javafx.scene.control.Slider countryASlider  
    (package private) javafx.scene.control.ListView<java.lang.String> countryListView  
    (package private) UIDataModel dataInstance  
    (package private) javafx.beans.value.ChangeListener<javafx.scene.control.Tab> onTabChanged  
    (package private) javafx.scene.control.ToggleGroup ratioButtonGroups  
    (package private) javafx.scene.control.Label regressionReport  
    (package private) javafx.scene.control.ScrollPane reportA  
    (package private) javafx.scene.control.ScrollPane reportB  
    (package private) javafx.scene.control.ScrollPane reportC  
    (package private) javafx.collections.ObservableList<javafx.scene.chart.XYChart.Series<java.lang.String,​java.lang.Float>> shifted  
    (package private) javafx.scene.control.TabPane tabGroup  
    (package private) javafx.collections.ObservableList<javafx.scene.chart.XYChart.Series<java.lang.String,​java.lang.Float>> unshifted  
  • Constructor Summary

    Constructors 
    Constructor Description
    Controller()  
  • Method Summary

    Modifier and Type Method Description
    (package private) InterestedData buttonDataMapping​(javafx.scene.control.RadioButton btn)
    Get the interested data that the button represents.
    (package private) boolean errorCheckOneCountry()
    Error check - to check the number of country selected is one or not
    (package private) void generateChart​(UIDataModel data)  
    (package private) void generateChartB1​(UIDataModel data)
    UI output - Scatter Plot of the death cases and the confirmed rate.
    (package private) void generateChartB2​(UIDataModel data)
    UI output - Scatter Plot of the death cases and the vaccination rate that could the citizens be immediately vaccinated during a breakout.
    (package private) void generateChartB3​(UIDataModel data)
    UI output - Scatter Plot of the vaccination rate and the death cases to verify the efficiency of vaccines.
    (package private) void generateChartC1​(UIDataModel data)  
    (package private) void generateChartC2​(UIDataModel data)  
    (package private) void generateChartC3​(UIDataModel data)  
    (package private) void generateComparisonChart​(UIDataModel data)
    Fetches the confirmed cases for two selected countries and display the results on the chart.
    (package private) void generateRegressionChart​(UIDataModel data)
    Generates regression model and display on the chart.
    (package private) void generateRegressionReport​(LinearRegression rgA, LinearRegression rgB, java.lang.String countryA, java.lang.String countryB)
    Compares regression model and generate a conclusion that which country is better.
    (package private) void generateTable​(UIDataModel data)
    Generate a table and display via TableView UI.
    (package private) InterestedData getFocusedData()
    Gets current selected data.
    void initialize()
    Initialize the cotroller.
    void initialize​(java.net.URL location, java.util.ResourceBundle resources)  
    void initializeUIDataModel()
    Gets the default values from UI and initialize the data model with the values.
    void ratioButtonInitialize()
    Groups all ratio buttons.
    (package private) void removeFromStack​(javafx.scene.Node e)
    Removes a node from stackPane.
    (package private) void resetSliderRange​(int days)
    Reconfigure the range of slider.
    void setStage​(javafx.stage.Stage stage)
    Sets the stage that the controller belongs to.
    (package private) void shiftCountryData​(javafx.scene.chart.XYChart.Series<java.lang.String,​java.lang.Float> original, javafx.scene.chart.XYChart.Series<java.lang.String,​java.lang.Float> updated, long days)
    Shifts a series of confirmed cases data for a country.
    (package private) void shiftingData()
    Shifting the data according to countryASlider and countryBSlider.
    (package private) void showPickDateUI()
    Hides period UI and display single date picker UI.
    (package private) void showPickPeriodUI()
    Hides single date picker UI and display period UI.
    (package private) void showReportUI​(InterestedData type)
    Shows report UI.
    (package private) void showTaskUI​(boolean isTask1)  
    (package private) void stackShow​(javafx.scene.Node e)
    Shows the UI in stack.
    (package private) void tabTaskA3Initialize()
    Initialize UI components for tab A3.
    (package private) void tabTaskB3Initialize()
    Initialize UI components for tab B3.
    (package private) void tabTaskC3Initialize()
    Initialize UI components for tab C3.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ratioButtonGroups

      javafx.scene.control.ToggleGroup ratioButtonGroups
    • dataInstance

      UIDataModel dataInstance
    • unshifted

      javafx.collections.ObservableList<javafx.scene.chart.XYChart.Series<java.lang.String,​java.lang.Float>> unshifted
    • shifted

      javafx.collections.ObservableList<javafx.scene.chart.XYChart.Series<java.lang.String,​java.lang.Float>> shifted
    • aShift

      javafx.beans.property.DoubleProperty aShift
    • bShift

      javafx.beans.property.DoubleProperty bShift
    • countryListView

      javafx.scene.control.ListView<java.lang.String> countryListView
    • reportB

      javafx.scene.control.ScrollPane reportB
    • reportC

      javafx.scene.control.ScrollPane reportC
    • chartReportC1Title

      javafx.scene.text.Text chartReportC1Title
    • chartReportC2Title

      javafx.scene.text.Text chartReportC2Title
    • chartReportC3Title

      javafx.scene.text.Text chartReportC3Title
    • tabGroup

      javafx.scene.control.TabPane tabGroup
    • countryASlider

      javafx.scene.control.Slider countryASlider
    • regressionReport

      javafx.scene.control.Label regressionReport
    • reportA

      javafx.scene.control.ScrollPane reportA
    • onTabChanged

      javafx.beans.value.ChangeListener<javafx.scene.control.Tab> onTabChanged
  • Constructor Details

  • Method Details

    • setStage

      public void setStage​(javafx.stage.Stage stage)
      Sets the stage that the controller belongs to.
      Parameters:
      stage - stage that the controller belongs to
    • initialize

      public void initialize()
      Initialize the cotroller.
    • tabTaskB3Initialize

      void tabTaskB3Initialize()
      Initialize UI components for tab B3.
    • tabTaskC3Initialize

      void tabTaskC3Initialize()
      Initialize UI components for tab C3.
    • tabTaskA3Initialize

      void tabTaskA3Initialize()
      Initialize UI components for tab A3.
    • generateRegressionChart

      void generateRegressionChart​(UIDataModel data) throws java.lang.Exception
      Generates regression model and display on the chart.
      Parameters:
      data - data model
      Throws:
      java.lang.Exception - the error occurs during the generation, can be caught to get the fail message
    • generateRegressionReport

      void generateRegressionReport​(LinearRegression rgA, LinearRegression rgB, java.lang.String countryA, java.lang.String countryB)
      Compares regression model and generate a conclusion that which country is better.
      Parameters:
      rgA - regression model of the first country.
      rgB - regression model of the second country.
      countryA - first country's name.
      countryB - second country's name.
    • resetSliderRange

      void resetSliderRange​(int days)
      Reconfigure the range of slider.
      Parameters:
      days - the maximum days that a slider can represent.
    • ratioButtonInitialize

      public void ratioButtonInitialize()
      Groups all ratio buttons.
    • initializeUIDataModel

      public void initializeUIDataModel()
      Gets the default values from UI and initialize the data model with the values.
    • getFocusedData

      InterestedData getFocusedData()
      Gets current selected data.
      Returns:
      current selected data
    • buttonDataMapping

      InterestedData buttonDataMapping​(javafx.scene.control.RadioButton btn)
      Get the interested data that the button represents.
      Parameters:
      btn - button to check
      Returns:
      interested data
    • generateTable

      void generateTable​(UIDataModel data)
      Generate a table and display via TableView UI.
      Parameters:
      data - data that indicates dataset to search for, and the interested data
    • shiftingData

      void shiftingData()
      Shifting the data according to countryASlider and countryBSlider.
    • shiftCountryData

      void shiftCountryData​(javafx.scene.chart.XYChart.Series<java.lang.String,​java.lang.Float> original, javafx.scene.chart.XYChart.Series<java.lang.String,​java.lang.Float> updated, long days)
      Shifts a series of confirmed cases data for a country.
      Parameters:
      original - unshifted data
      updated - reference to the shifted data, will be modified
      days - days to shift
    • generateComparisonChart

      void generateComparisonChart​(UIDataModel data) throws java.lang.Exception
      Fetches the confirmed cases for two selected countries and display the results on the chart.
      Parameters:
      data - data model
      Throws:
      java.lang.Exception - the reason why cannot generate the result
    • generateChart

      void generateChart​(UIDataModel data)
      Parameters:
      data - User input for all controls
    • showTaskUI

      void showTaskUI​(boolean isTask1)
      Parameters:
      isTask1 - Check if user chooses Task 1
    • showPickDateUI

      void showPickDateUI()
      Hides period UI and display single date picker UI.
    • showPickPeriodUI

      void showPickPeriodUI()
      Hides single date picker UI and display period UI.
    • showReportUI

      void showReportUI​(InterestedData type)
      Shows report UI.
      Parameters:
      type - data user is interested in
    • removeFromStack

      void removeFromStack​(javafx.scene.Node e)
      Removes a node from stackPane.
      Parameters:
      e - UI to be removed
    • stackShow

      void stackShow​(javafx.scene.Node e)
      Shows the UI in stack. This method will ensure only the given is shown on stack.
      Parameters:
      e - UI to be displayed.
    • errorCheckOneCountry

      boolean errorCheckOneCountry()
      Error check - to check the number of country selected is one or not
      Returns:
      boolean value that error exist or not
    • generateChartB1

      void generateChartB1​(UIDataModel data)
      UI output - Scatter Plot of the death cases and the confirmed rate.
      Parameters:
      data - user inputed for all controls
    • generateChartB2

      void generateChartB2​(UIDataModel data)
      UI output - Scatter Plot of the death cases and the vaccination rate that could the citizens be immediately vaccinated during a breakout.
      Parameters:
      data - user inputed for all controls
    • generateChartB3

      void generateChartB3​(UIDataModel data)
      UI output - Scatter Plot of the vaccination rate and the death cases to verify the efficiency of vaccines.
      Parameters:
      data - user inputed for all controls
    • generateChartC1

      void generateChartC1​(UIDataModel data)
    • generateChartC2

      void generateChartC2​(UIDataModel data)
      Parameters:
      data - User input for all controls
    • generateChartC3

      void generateChartC3​(UIDataModel data)
      Parameters:
      data - User input for all controls
    • initialize

      public void initialize​(java.net.URL location, java.util.ResourceBundle resources)
      Specified by:
      initialize in interface javafx.fxml.Initializable