//==============================================================================
// The Society of Actuaries (SOA) makes this computer model and its computer
// code available to its members for educational purposes. The model and its
// code may be modified and redistributed without prior authorization from the
// SOA. The SOA distributes this computer model and its computer code in the
// hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE.
//==============================================================================

package implementation;

import java.awt.*;
import javax.swing.*;
import repast.simphony.ui.RSApplication;
import resources.Constants;

public class SimulationUserPanel
{
    //==============================================================================
    // User panel parameter variables
    // These variables are available to other classes through "getter" methods.
    // They are the parameters entered by the user through the user pane of
    // the Repast GUI.
    // The identifier after the variable name refers to the tab and identifier
    // where the variable is located on the GUI user panel.
    //------------------------------------------------------------------------------    

    // Parameters on the Scenario tab
    private static int maximumSimulationPeriods; //Simulation: A1
    private static boolean parameterOverride; //Simulation: B1
    private static boolean fileOutput; //Simulation: C1
    private static String outputFileName; //Simulation: C2
    
    // Parameters on the Person tab
    private static boolean personLabels; //Person: A1
    private static int numberOfPersonAgents; //Person: B1
    private static String geographicLocationDistributionType; //Person: C1
    private static double geographicLocationNormalDistributionMean; //Person: C2
    private static double geographicLocationNormalDistributionSD; //Person: C3
    private static double neighborhoodRadius; //Person: C4
    private static double maximumIncome; //Person: D1
    private static String incomeDistributionType; //Person: D2
    private static double incomeLogNormalDistributionMean; //Person: D3
    private static double incomeLogNormalDistributionSD; //Person: D4
    private static String initialDiseaseDistributionType; //Person: E1
    private static double initialDiseaseLogNormalDistributionMean; //Person: E2
    private static double initialDiseaseLogNormalDistributionSD; //Person: E3
    private static double incrementalDiseaseMaximum; //Person: F1
    private static String incrementalDiseaseDistributionType; //Person: F2
    private static double incrementalDiseaseLogNormalDistributionMean; //Person: F3
    private static double incrementalDiseaseLogNormalDistributionSD; //Person: F4
    private static double healthImprovementPercentage; //Person: G1
    private static double healthDeteriorationPercentage; //Person: G2
    private static double decisionInertiaPercentage; //Person: H1
    private static double healthGravityThreshold; //Person: H2
    private static double advertisingImpactThreshold; //Person: H3

    // Parameters on the Person Goals tab
    private static double[][] personGoalPriorities = new double[5][5]; //Person Goals: A1
    
    // Parameters on the Health Insurance Company tab
    private static double lapseThreshold_CompanyA; //Health Insurance Company: A1
    private static double lapseThreshold_CompanyB; //Health Insurance Company: A2
    private static double premiumDiscountFactor_CompanyA; //Health Insurance Company: B1
    private static double premiumDiscountFactor_CompanyB; //Health Insurance Company: B2
    private static double maximumOfferIncreasePercent_CompanyA; //Health Insurance Company: C1
    private static double maximumOfferIncreasePercent_CompanyB; //Health Insurance Company: C2
    
    // Parameters on the Provider Network tab
    private static double minimumAlphaIncreasePercent_NetworkA; //Provider Network: A1
    private static double minimumAlphaIncreasePercent_NetworkB; //Provider Network: A2

    //Variables for setting up the user panel
    JTabbedPane tabbedPane;
    JPanel userPanel;

    //==============================================================================
    // Method:  SimulationUserPanel() constructor
    //------------------------------------------------------------------------------        
    public SimulationUserPanel()
    {
        // Set parameter defaults
        // Note that the defaults must be set before creating the User Panel
        setMaximumSimulationPeriods(100); //Simulation: A1
        setParameterOverride(false); //Simulation: B1
        setFileOutput(false); //Simulation: C1
        setOutputFileName("None");
        
        setPersonLabels(false); //Person:  A1
        setNumberOfPersonAgents(1000); //Person: B1
        setGeographicLocationDistributionType(Constants.NORMAL_DISTRIBUTION); //Person: C1
        setGeographicLocationNormalDistributionMean(50.0); //Person: C2
        setGeographicLocationNormalDistributionSD(15.0); //Person: C3
        setNeighborhoodRadius(10.0); //Person: C4    
        setMaximumIncome(200.0); //Person: D1  
        setIncomeDistributionType(Constants.LOG_NORMAL_DISTRIBUTION); //Person: D2
        setIncomeLogNormalDistributionMean(40.0); //Person: D3
        setIncomeLogNormalDistributionSD(35.0); //Person: D4
        setInitialDiseaseDistributionType(Constants.LOG_NORMAL_DISTRIBUTION); //Person: E1
        setInitialDiseaseLogNormalDistributionMean(3.00); //Person: E2
        setInitialDiseaseLogNormalDistributionSD(4.00); //Person: E3
        setIncrementalDiseaseMaximum(3.0); //Person: F1
        setIncrementalDiseaseDistributionType(Constants.LOG_NORMAL_DISTRIBUTION); //Person: F2
        setIncrementalDiseaseLogNormalDistributionMean(1.00); //Person: F3
        setIncrementalDiseaseLogNormalDistributionSD(2.00); //Person: F4
        setHealthImprovementPercentage(0.20); //Person: G1
        setHealthDeteriorationPercentage(0.05); //Person: G2
        setDecisionInertiaPercentage(0.40); //Person: H1
        setHealthGravityThreshold(3.0); //Person: H2
        setAdvertisingImpactThreshold(5.0); //Person: H3
        
        double[][] goalPriorityTableDefaults = {    {0.40, 0.20, 0.20, 0.20, 0.00},
                                                    {0.20, 0.40, 0.10, 0.20, 0.10},
                                                    {0.20, 0.20, 0.20, 0.10, 0.30},
                                                    {0.10, 0.10, 0.30, 0.20, 0.30},
                                                    {0.10, 0.10, 0.20, 0.30, 0.30} };
        setPersonGoalPriorities(goalPriorityTableDefaults); //Person Goals: A1
        
        setLapseThreshold_CompanyA(0.2); //Health Insurance Company: A1
        setLapseThreshold_CompanyB(0.15); //Health Insurance Company: A2
        setPremiumDiscountFactor_CompanyA(1.05); //Health Insurance Company: B1
        setPremiumDiscountFactor_CompanyB(1.00); //Health Insurance Company: B2
        setMaximumOfferIncreasePercent_CompanyA(0.03); //Health Insurance Company: C1
        setMaximumOfferIncreasePercent_CompanyB(0.02); //Health Insurance Company: C2
        
        setMinimumAlphaIncreasePercent_NetworkA(0.03); //Provider Network:  A1
        setMinimumAlphaIncreasePercent_NetworkB(0.04); //Provider Network:  A2
        
        // Create the User Panel
        RSApplication.getRSApplicationInstance().addCustomUserPanel(createPanel());
         
    }//end SimulationUserPanel()
    
    public JPanel createPanel()
    {
        userPanel = new JPanel();
        
        tabbedPane = new JTabbedPane();
        tabbedPane.setPreferredSize(new Dimension(600, 800));
        userPanel.add(tabbedPane);
        
        tabbedPane.addTab("Simulation", new UserPanelTab_Simulation());
        tabbedPane.addTab("Person", new UserPanelTab_Person());
        tabbedPane.addTab("Person goals", new UserPanelTab_PersonGoals());
        tabbedPane.addTab("Health Insurance Company", new UserPanelTab_HealthInsuranceCompany());
        tabbedPane.addTab("Provider Network", new UserPanelTab_ProviderNetwork());
        
        return userPanel;
        
    }//end createPanel()
    

//==============================================================================
// Methods: getter and setter methods
//------------------------------------------------------------------------------   
    // Simulation: A1    
    public static int getMaximumSimulationPeriods()
    {
        return maximumSimulationPeriods;
    }

    public static void setMaximumSimulationPeriods(int maximumSimulationPeriods)
    {
        SimulationUserPanel.maximumSimulationPeriods = maximumSimulationPeriods;
    }

    // Simulation: B1    
    public static boolean isParameterOverride()
    {
        return parameterOverride;
    }

    public static void setParameterOverride(boolean parameterOverride)
    {
        SimulationUserPanel.parameterOverride = parameterOverride;
    }

    // Simulation: C1    
    public static boolean isFileOutput()
    {
        return fileOutput;
    }

    public static void setFileOutput(boolean fileOutput)
    {
        SimulationUserPanel.fileOutput = fileOutput;
    }

    // Simulation: C2    
    public static String getOutputFileName()
    {
        return outputFileName;
    }

    public static void setOutputFileName(String outputFileName)
    {
        SimulationUserPanel.outputFileName = outputFileName;
    }

    // Person: A1
    public static boolean isPersonLabels()
    {
        return personLabels;
    }

    public static void setPersonLabels(boolean personLabels)
    {
        SimulationUserPanel.personLabels = personLabels;
    }

    // Person: B1    
    public static int getNumberOfPersonAgents()
    {
        return numberOfPersonAgents;
    }

    public static void setNumberOfPersonAgents(int numberOfPersonAgents)
    {
        SimulationUserPanel.numberOfPersonAgents = numberOfPersonAgents;
    }

    // Person: C1    
    public static String getGeographicLocationDistributionType()
    {
        return geographicLocationDistributionType;
    }

    public static void setGeographicLocationDistributionType(
            String geographicLocationDistributionType)
    {
        SimulationUserPanel.geographicLocationDistributionType = geographicLocationDistributionType;
    }

    // Person: C2    
    public static double getGeographicLocationNormalDistributionMean()
    {
        return geographicLocationNormalDistributionMean;
    }

    public static void setGeographicLocationNormalDistributionMean(
            double geographicLocationNormalDistributionMean)
    {
        SimulationUserPanel.geographicLocationNormalDistributionMean = geographicLocationNormalDistributionMean;
    }

    // Person: C3    
    public static double getGeographicLocationNormalDistributionSD()
    {
        return geographicLocationNormalDistributionSD;
    }

    public static void setGeographicLocationNormalDistributionSD(
            double geographicLocationNormalDistributionSD)
    {
        SimulationUserPanel.geographicLocationNormalDistributionSD = geographicLocationNormalDistributionSD;
    }

    // Person: C4    
    public static double getNeighborhoodRadius()
    {
        return neighborhoodRadius;
    }

    public static void setNeighborhoodRadius(double neighborhoodRadius)
    {
        SimulationUserPanel.neighborhoodRadius = neighborhoodRadius;
    }

    // Person: D1    
    public static double getMaximumIncome()
    {
        return maximumIncome;
    }

    public static void setMaximumIncome(double maximumIncome)
    {
        SimulationUserPanel.maximumIncome = maximumIncome;
    }

    // Person: D2    
    public static String getIncomeDistributionType()
    {
        return incomeDistributionType;
    }

    public static void setIncomeDistributionType(String incomeDistributionType)
    {
        SimulationUserPanel.incomeDistributionType = incomeDistributionType;
    }

    // Person: D3    
    public static double getIncomeLogNormalDistributionMean()
    {
        return incomeLogNormalDistributionMean;
    }

    public static void setIncomeLogNormalDistributionMean(
            double incomeLogNormalDistributionMean)
    {
        SimulationUserPanel.incomeLogNormalDistributionMean = incomeLogNormalDistributionMean;
    }

    // Person: D4    
    public static double getIncomeLogNormalDistributionSD()
    {
        return incomeLogNormalDistributionSD;
    }

    public static void setIncomeLogNormalDistributionSD(
            double incomeLogNormalDistributionSD)
    {
        SimulationUserPanel.incomeLogNormalDistributionSD = incomeLogNormalDistributionSD;
    }

    // Person: E1    
    public static String getInitialDiseaseDistributionType()
    {
        return initialDiseaseDistributionType;
    }

    public static void setInitialDiseaseDistributionType(
            String initialDiseaseDistributionType)
    {
        SimulationUserPanel.initialDiseaseDistributionType = initialDiseaseDistributionType;
    }

    // Person: E2    
    public static double getInitialDiseaseLogNormalDistributionMean()
    {
        return initialDiseaseLogNormalDistributionMean;
    }

    public static void setInitialDiseaseLogNormalDistributionMean(
            double initialDiseaseLogNormalDistributionMean)
    {
        SimulationUserPanel.initialDiseaseLogNormalDistributionMean = initialDiseaseLogNormalDistributionMean;
    }

    // Person: E3    
    public static double getInitialDiseaseLogNormalDistributionSD()
    {
        return initialDiseaseLogNormalDistributionSD;
    }

    public static void setInitialDiseaseLogNormalDistributionSD(
            double initialDiseaseLogNormalDistributionSD)
    {
        SimulationUserPanel.initialDiseaseLogNormalDistributionSD = initialDiseaseLogNormalDistributionSD;
    }

    // Person: F1    
    public static double getIncrementalDiseaseMaximum()
    {
        return incrementalDiseaseMaximum;
    }

    public static void setIncrementalDiseaseMaximum(double incrementalDiseaseMaximum)
    {
        SimulationUserPanel.incrementalDiseaseMaximum = incrementalDiseaseMaximum;
    }

    // Person: F2    
    public static String getIncrementalDiseaseDistributionType()
    {
        return incrementalDiseaseDistributionType;
    }


    public static void setIncrementalDiseaseDistributionType(
            String incrementalDiseaseDistributionType)
    {
        SimulationUserPanel.incrementalDiseaseDistributionType = incrementalDiseaseDistributionType;
    }

    // Person: F3    
    public static double getIncrementalDiseaseLogNormalDistributionMean()
    {
        return incrementalDiseaseLogNormalDistributionMean;
    }

    public static void setIncrementalDiseaseLogNormalDistributionMean(
            double incrementalDiseaseLogNormalDistributionMean)
    {
        SimulationUserPanel.incrementalDiseaseLogNormalDistributionMean = incrementalDiseaseLogNormalDistributionMean;
    }

    // Person: F4    
    public static double getIncrementalDiseaseLogNormalDistributionSD()
    {
        return incrementalDiseaseLogNormalDistributionSD;
    }

    public static void setIncrementalDiseaseLogNormalDistributionSD(
            double incrementalDiseaseLogNormalDistributionSD)
    {
        SimulationUserPanel.incrementalDiseaseLogNormalDistributionSD = incrementalDiseaseLogNormalDistributionSD;
    }

    // Person: G1    
    public static double getHealthImprovementPercentage()
    {
        return healthImprovementPercentage;
    }

    public static void setHealthImprovementPercentage(
            double healthImprovementPercentage)
    {
        SimulationUserPanel.healthImprovementPercentage = healthImprovementPercentage;
    }

    // Person: G2    
    public static double getHealthDeteriorationPercentage()
    {
        return healthDeteriorationPercentage;
    }

    public static void setHealthDeteriorationPercentage(
            double healthDeteriorationPercentage)
    {
        SimulationUserPanel.healthDeteriorationPercentage = healthDeteriorationPercentage;
    }

    // Person: H1    
    public static double getDecisionInertiaPercentage()
    {
        return decisionInertiaPercentage;
    }

    public static void setDecisionInertiaPercentage(double decisionInertiaPercentage)
    {
        SimulationUserPanel.decisionInertiaPercentage = decisionInertiaPercentage;
    }

    // Person: H2    
    public static double getHealthGravityThreshold()
    {
        return healthGravityThreshold;
    }

    public static void setHealthGravityThreshold(double healthGravityThreshold)
    {
        SimulationUserPanel.healthGravityThreshold = healthGravityThreshold;
    }

    // Person: H3    
    public static double getAdvertisingImpactThreshold()
    {
        return advertisingImpactThreshold;
    }

    public static void setAdvertisingImpactThreshold(
            double advertisingImpactThreshold)
    {
        SimulationUserPanel.advertisingImpactThreshold = advertisingImpactThreshold;
    }

    // Person Goals: A1        
    public static double[][] getPersonGoalPriorities()
    {
        return personGoalPriorities;
    }

    public static void setPersonGoalPriorities(double[][] personGoalPriorities)
    {
        SimulationUserPanel.personGoalPriorities = personGoalPriorities;
    }

    // Health Insurance Company: A1    
    public static double getLapseThreshold_CompanyA()
    {
        return lapseThreshold_CompanyA;
    }

    public static void setLapseThreshold_CompanyA(double lapseThreshold_CompanyA)
    {
        SimulationUserPanel.lapseThreshold_CompanyA = lapseThreshold_CompanyA;
    }

    // Health Insurance Company: A2    
    public static double getLapseThreshold_CompanyB()
    {
        return lapseThreshold_CompanyB;
    }

    public static void setLapseThreshold_CompanyB(double lapseThreshold_CompanyB)
    {
        SimulationUserPanel.lapseThreshold_CompanyB = lapseThreshold_CompanyB;
    }

    // Health Insurance Company: B1    
    public static double getPremiumDiscountFactor_CompanyA()
    {
        return premiumDiscountFactor_CompanyA;
    }

    public static void setPremiumDiscountFactor_CompanyA(
            double premiumDiscountFactor_CompanyA)
    {
        SimulationUserPanel.premiumDiscountFactor_CompanyA = premiumDiscountFactor_CompanyA;
    }

    // Health Insurance Company: B2    
    public static double getPremiumDiscountFactor_CompanyB()
    {
        return premiumDiscountFactor_CompanyB;
    }

    public static void setPremiumDiscountFactor_CompanyB(
            double premiumDiscountFactor_CompanyB)
    {
        SimulationUserPanel.premiumDiscountFactor_CompanyB = premiumDiscountFactor_CompanyB;
    }

    // Health Insurance Company: C1    
    public static double getMaximumOfferIncreasePercent_CompanyA()
    {
        return maximumOfferIncreasePercent_CompanyA;
    }

    public static void setMaximumOfferIncreasePercent_CompanyA(
            double maximumOfferIncreasePercent_CompanyA)
    {
        SimulationUserPanel.maximumOfferIncreasePercent_CompanyA = maximumOfferIncreasePercent_CompanyA;
    }

    // Health Insurance Company: C2    
    public static double getMaximumOfferIncreasePercent_CompanyB()
    {
        return maximumOfferIncreasePercent_CompanyB;
    }

    public static void setMaximumOfferIncreasePercent_CompanyB(
            double maximumOfferIncreasePercent_CompanyB)
    {
        SimulationUserPanel.maximumOfferIncreasePercent_CompanyB = maximumOfferIncreasePercent_CompanyB;
    }

    // Provider Network: A1    
    public static double getMinimumAlphaIncreasePercent_NetworkA()
    {
        return minimumAlphaIncreasePercent_NetworkA;
    }

    public static void setMinimumAlphaIncreasePercent_NetworkA(
            double minimumAlphaIncreasePercent_NetworkA)
    {
        SimulationUserPanel.minimumAlphaIncreasePercent_NetworkA = minimumAlphaIncreasePercent_NetworkA;
    }

    // Provider Network: A2    
    public static double getMinimumAlphaIncreasePercent_NetworkB()
    {
        return minimumAlphaIncreasePercent_NetworkB;
    }

    public static void setMinimumAlphaIncreasePercent_NetworkB(
            double minimumAlphaIncreasePercent_NetworkB)
    {
        SimulationUserPanel.minimumAlphaIncreasePercent_NetworkB = minimumAlphaIncreasePercent_NetworkB;
    }

}//end SimulationUserPanel
