//==============================================================================
// 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 java.awt.event.*;
import javax.swing.*;

public class UserPanelTab_HealthInsuranceCompany extends JPanel
{
	private static final long serialVersionUID = 4L;

	JLabel 	label_Title,
			label_A1, label_A2,
			label_B1, label_B2,
			label_C1, label_C2;
	JTextField 	component_A1, component_A2,
				component_B1, component_B2,
				component_C1, component_C2;
	
	public UserPanelTab_HealthInsuranceCompany()
	{
		// Set the layout manager for the pane to be a "grid bag".
		// Grid bag is a flexible and easily modifiable layout format.		
		// (see: www.ugrad.cs.ubc.ca/~cs219/CourseNotes/Swing/swing-LayoutManagers-GridBag.html)
		// The Health Insurance Company panel has two columns.
		GridBagLayout gridBagLayout = new GridBagLayout();
		setLayout(gridBagLayout);

		// Title label
		label_Title = new JLabel("<html><b><i>Detailed parameters for Health Insurance Company agents</i></b><br>" +
				"<font color=\"blue\">(After making a change, be sure to press ENTER.)</font></html>");
		GridBagConstraints c = new GridBagConstraints();
		c.gridx 		= 0;
		c.gridy 		= 0;
		c.gridwidth 	= 1;
		c.gridheight 	= 1;
		c.weightx 		= 1.0;
		c.weighty 		= 1.0;
		c.anchor 		= GridBagConstraints.WEST;
		c.fill 			= GridBagConstraints.NONE;
		c.insets 		= new Insets(0,10,10,0);
		c.ipadx			= 0;
		c.ipady			= 0;
		gridBagLayout.setConstraints(label_Title, c);
		add(label_Title);

		// A1 label
		JLabel label_A1 = new JLabel("A1. Lapse threshold - Company A:");
		label_A1.setToolTipText("<html>Set the percentage of Person agents to drop (lapse) a plan <br>" +
				"for Company A to consider the lapse problematic.<br>" +
				"It can be any number between 0.0 and 1.0.</html>");
		c.gridx 		= 0;
		c.gridy 		= 1;
		c.gridwidth 	= 1;
		c.gridheight 	= 1;
		c.weightx 		= 1.0;
		c.weighty 		= 1.0;
		c.anchor 		= GridBagConstraints.EAST;
		c.fill 			= GridBagConstraints.NONE;
		c.insets 		= new Insets(0,0,0,10);
		c.ipadx			= 0;
		c.ipady			= 0;
		gridBagLayout.setConstraints(label_A1, c);
		add(label_A1);		
			
		// A1 component
		component_A1 = new JTextField(Double.toString(SimulationUserPanel.getLapseThreshold_CompanyA()), 10);
		component_A1.setToolTipText("<html>Set the percentage of Person agents to drop (lapse) a plan <br>" +
				"for Company A to consider the lapse problematic.<br>" +
				"It can be any number between 0.0 and 1.0.</html>");
		c.gridx 		= 1;
		c.gridy 		= 1;
		c.gridwidth 	= 1;
		c.gridheight 	= 1;
		c.weightx 		= 1.0;
		c.weighty 		= 1.0;
		c.anchor 		= GridBagConstraints.WEST;
		c.fill 			= GridBagConstraints.HORIZONTAL;
		c.insets 		= new Insets(0,0,0,10);
		c.ipadx			= 0;
		c.ipady			= 0;
		gridBagLayout.setConstraints(component_A1, c);
		component_A1.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				SimulationUserPanel.setLapseThreshold_CompanyA(
						Double.valueOf(component_A1.getText()));

				//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
				//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  					
//			     System.out.println("Health Insurance Company A1. lapseThresholdCompanyA:  " +
//			    		 SimulationUserPanel.getLapseThresholdCompanyA()); //Health Insurance Company: A1
			    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  	
			}//end actionPerformed()
		}
		);
		add(component_A1);	
	
		// A2 label
		JLabel label_A2 = new JLabel("A2. Lapse threshold - Company B:");
		label_A2.setToolTipText("<html>Set the percentage of Person agents to drop (lapse) a plan <br>" +
				"for Company B to consider the lapse problematic.<br>" +
				"It can be any number between 0.0 and 1.0.</html>");
		c.gridx 		= 0;
		c.gridy 		= 2;
		c.gridwidth 	= 1;
		c.gridheight 	= 1;
		c.weightx 		= 1.0;
		c.weighty 		= 1.0;
		c.anchor 		= GridBagConstraints.EAST;
		c.fill 			= GridBagConstraints.NONE;
		c.insets 		= new Insets(0,0,0,10);
		c.ipadx			= 0;
		c.ipady			= 0;
		gridBagLayout.setConstraints(label_A2, c);
		add(label_A2);		
			
		// A2 component
		component_A2 = new JTextField(Double.toString(SimulationUserPanel.getLapseThreshold_CompanyB()), 10);
		component_A2.setToolTipText("<html>Set the percentage of Person agents to drop (lapse) a plan <br>" +
				"for Company B to consider the lapse problematic.<br>" +
				"It can be any number between 0.0 and 1.0.</html>");
		c.gridx 		= 1;
		c.gridy 		= 2;
		c.gridwidth 	= 1;
		c.gridheight 	= 1;
		c.weightx 		= 1.0;
		c.weighty 		= 1.0;
		c.anchor 		= GridBagConstraints.WEST;
		c.fill 			= GridBagConstraints.HORIZONTAL;
		c.insets 		= new Insets(0,0,0,10);
		c.ipadx			= 0;
		c.ipady			= 0;
		gridBagLayout.setConstraints(component_A2, c);
		component_A2.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				SimulationUserPanel.setLapseThreshold_CompanyB(
						Double.valueOf(component_A2.getText()));

				//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
				//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  					
//			     System.out.println("Health Insurance Company A2. lapseThreshold_CompanyB:  " +
//			    		 SimulationUserPanel.getLapseThreshold_CompanyB()); //Health Insurance Company: A2
			    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  	
			}//end actionPerformed()
		}
		);
		add(component_A2);	

		// B1 label
		JLabel label_B1 = new JLabel("B1. Premium discount factor - Company A:");
		label_B1.setToolTipText("<html>Set the discount factor to adjust competitor premiums to determine <br>" +
				"the level of premiums that Company A believes would be competitive.<br>" +
				"It can be any number between 0.0 and 2.0.</html>");
		c.gridx 		= 0;
		c.gridy 		= 3;
		c.gridwidth 	= 1;
		c.gridheight 	= 1;
		c.weightx 		= 1.0;
		c.weighty 		= 1.0;
		c.anchor 		= GridBagConstraints.EAST;
		c.fill 			= GridBagConstraints.NONE;
		c.insets 		= new Insets(15,0,0,10);
		c.ipadx			= 0;
		c.ipady			= 0;
		gridBagLayout.setConstraints(label_B1, c);
		add(label_B1);		
			
		// B1 component
		component_B1 = new JTextField(Double.toString(SimulationUserPanel.getPremiumDiscountFactor_CompanyA()), 10);
		component_B1.setToolTipText("<html>Set the discount factor to adjust competitor premiums to determine <br>" +
				"the level of premiums that Company A believes would be competitive.<br>" +
				"It can be any number between 0.0 and 2.0.</html>");
		c.gridx 		= 1;
		c.gridy 		= 3;
		c.gridwidth 	= 1;
		c.gridheight 	= 1;
		c.weightx 		= 1.0;
		c.weighty 		= 1.0;
		c.anchor 		= GridBagConstraints.WEST;
		c.fill 			= GridBagConstraints.HORIZONTAL;
		c.insets 		= new Insets(15,0,0,10);
		c.ipadx			= 0;
		c.ipady			= 0;
		gridBagLayout.setConstraints(component_B1, c);
		component_B1.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				SimulationUserPanel.setPremiumDiscountFactor_CompanyA(
						Double.valueOf(component_B1.getText()));

				//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
				//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  					
			     System.out.println("Health Insurance Company B1. premiumDiscountFactor_CompanyA:  " +
			    		 SimulationUserPanel.getPremiumDiscountFactor_CompanyA()); //Health Insurance Company: B1
			    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  	
			}//end actionPerformed()
		}
		);
		add(component_B1);

		// B2 label
		JLabel label_B2 = new JLabel("B2. Premium discount factor - Company B:");
		label_B2.setToolTipText("<html>Set the discount factor to adjust competitor premiums to determine <br>" +
				"the level of premiums that Company B believes would be competitive.<br>" +
				"It can be any number between 0.0 and 2.0.</html>");
		c.gridx 		= 0;
		c.gridy 		= 4;
		c.gridwidth 	= 1;
		c.gridheight 	= 1;
		c.weightx 		= 1.0;
		c.weighty 		= 1.0;
		c.anchor 		= GridBagConstraints.EAST;
		c.fill 			= GridBagConstraints.NONE;
		c.insets 		= new Insets(0,0,0,10);
		c.ipadx			= 0;
		c.ipady			= 0;
		gridBagLayout.setConstraints(label_B2, c);
		add(label_B2);		
			
		// B2 component
		component_B2 = new JTextField(Double.toString(SimulationUserPanel.getPremiumDiscountFactor_CompanyB()), 10);
		component_B2.setToolTipText("<html>Set the discount factor to adjust competitor premiums to determine <br>" +
				"the level of premiums that Company B believes would be competitive.<br>" +
				"It can be any number between 0.0 and 2.0.</html>");
		c.gridx 		= 1;
		c.gridy 		= 4;
		c.gridwidth 	= 1;
		c.gridheight 	= 1;
		c.weightx 		= 1.0;
		c.weighty 		= 1.0;
		c.anchor 		= GridBagConstraints.WEST;
		c.fill 			= GridBagConstraints.HORIZONTAL;
		c.insets 		= new Insets(0,0,0,10);
		c.ipadx			= 0;
		c.ipady			= 0;
		gridBagLayout.setConstraints(component_B2, c);
		component_B2.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				SimulationUserPanel.setPremiumDiscountFactor_CompanyB(
						Double.valueOf(component_B2.getText()));

				//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
				//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  					
			     System.out.println("Health Insurance Company B2. premiumDiscountFactor_CompanyB:  " +
			    		 SimulationUserPanel.getPremiumDiscountFactor_CompanyB()); //Health Insurance Company: B2
			    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  	
			}//end actionPerformed()
		}
		);
		add(component_B2);

		// C1 label
		JLabel label_C1 = new JLabel("C1. Maximum offer increase percent - Company A:");
		label_C1.setToolTipText("<html>Set the maximum percentage by which Company A <br>" +
				"will try to increase the prior period's treatment cost alpha.</html>");
		c.gridx 		= 0;
		c.gridy 		= 5;
		c.gridwidth 	= 1;
		c.gridheight 	= 1;
		c.weightx 		= 1.0;
		c.weighty 		= 1.0;
		c.anchor 		= GridBagConstraints.EAST;
		c.fill 			= GridBagConstraints.NONE;
		c.insets 		= new Insets(15,0,0,10);
		c.ipadx			= 0;
		c.ipady			= 0;
		gridBagLayout.setConstraints(label_C1, c);
		add(label_C1);
			
		// C1 component
		component_C1 = new JTextField(Double.toString(SimulationUserPanel.getMaximumOfferIncreasePercent_CompanyA()), 10);
		component_C1.setToolTipText("<html>Set the maximum percentage by which Company A <br>" +
				"will try to increase the prior period's treatment cost alpha.</html>");
		c.gridx 		= 1;
		c.gridy 		= 5;
		c.gridwidth 	= 1;
		c.gridheight 	= 1;
		c.weightx 		= 1.0;
		c.weighty 		= 1.0;
		c.anchor 		= GridBagConstraints.WEST;
		c.fill 			= GridBagConstraints.HORIZONTAL;
		c.insets 		= new Insets(15,0,0,10);
		c.ipadx			= 0;
		c.ipady			= 0;
		gridBagLayout.setConstraints(component_C1, c);
		component_C1.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				SimulationUserPanel.setMaximumOfferIncreasePercent_CompanyA(
						Double.valueOf(component_C1.getText()));

				//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
				//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  					
//			     System.out.println("Health Insurance Company C1. maximumOfferIncreasePercent_CompanyA:  " +
//			    		 SimulationUserPanel.getMaximumOfferIncreasePercent_CompanyA()); //Health Insurance Company: C1
			    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  	
			}//end actionPerformed()
		}
		);
		add(component_C1);

		// C2 label
		JLabel label_C2 = new JLabel("C2. Maximum offer increase percent - Company B:");
		label_C2.setToolTipText("<html>Set the maximum percentage by which Company B <br>" +
				"will try to increase the prior period's treatment cost alpha.</html>");
		c.gridx 		= 0;
		c.gridy 		= 6;
		c.gridwidth 	= 1;
		c.gridheight 	= 1;
		c.weightx 		= 1.0;
		c.weighty 		= 1.0;
		c.anchor 		= GridBagConstraints.EAST;
		c.fill 			= GridBagConstraints.NONE;
		c.insets 		= new Insets(0,0,550,10);
		c.ipadx			= 0;
		c.ipady			= 0;
		gridBagLayout.setConstraints(label_C2, c);
		add(label_C2);
			
		// C2 component
		component_C2 = new JTextField(Double.toString(SimulationUserPanel.getMaximumOfferIncreasePercent_CompanyB()), 10);
		component_C2.setToolTipText("<html>Set the maximum percentage by which Company B <br>" +
				"will try to increase the prior period's treatment cost alpha.</html>");
		c.gridx 		= 1;
		c.gridy 		= 6;
		c.gridwidth 	= 1;
		c.gridheight 	= 1;
		c.weightx 		= 1.0;
		c.weighty 		= 1.0;
		c.anchor 		= GridBagConstraints.WEST;
		c.fill 			= GridBagConstraints.HORIZONTAL;
		c.insets 		= new Insets(0,0,550,10);
		c.ipadx			= 0;
		c.ipady			= 0;
		gridBagLayout.setConstraints(component_C2, c);
		component_C2.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				SimulationUserPanel.setMaximumOfferIncreasePercent_CompanyB(
						Double.valueOf(component_C2.getText()));

				//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
				//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  					
//			     System.out.println("Health Insurance Company C2. maximumOfferIncreasePercent_CompanyB:  " +
//			    		 SimulationUserPanel.getMaximumOfferIncreasePercent_CompanyB()); //Health Insurance Company: C2
			    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  	
			}//end actionPerformed()
		}
		);
		add(component_C2);
		
	}//end UserPanelTab_HealthInsuranceCompany
	
}//end UserPanelTab_HealthInsuranceCompany class
