org.opensha.sra.gui.portfolioeal
Class PortfolioEALCalculatorController

java.lang.Object
  extended by org.opensha.sra.gui.portfolioeal.PortfolioEALCalculatorController
All Implemented Interfaces:
ActionListener, ItemListener, Runnable, EventListener, CalculationExceptionHandler

public class PortfolioEALCalculatorController
extends Object
implements ActionListener, ItemListener, Runnable, CalculationExceptionHandler

The controller for the Portfolio EAL calculator. This class is used to define the underlying functionality of the calculator.

Author:
Jeremy Leakakos
See Also:
PortfolioEALCalculatorView

Field Summary
static String APP_NAME
           
static String APP_SHORT_NAME
           
 
Constructor Summary
PortfolioEALCalculatorController()
          The default constructor.
 
Method Summary
 void actionPerformed(ActionEvent event)
          Listen for the JButtons and the JComboBox.
 void calculationException(String errorMessage)
          Exceptions occur during a calculation; this method gets the program back to its start state
 double computeEAL()
          This computes the EAL for a portfolio.
static HashMap<String,Vulnerability> getVulnerabilities()
           
static HashMap<String,Vulnerability> getVulnerabilities(File file)
           
 void itemStateChanged(ItemEvent event)
          ItemListener for the JCheckBox
static void main(String[] args)
          The main method which drives the whole program.
 void run()
          This method is used when new thread is started on an object of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

APP_NAME

public static final String APP_NAME
See Also:
Constant Field Values

APP_SHORT_NAME

public static final String APP_SHORT_NAME
See Also:
Constant Field Values
Constructor Detail

PortfolioEALCalculatorController

public PortfolioEALCalculatorController()
The default constructor. The main class of the program, which start the program, It creates and displays the view.

Method Detail

getVulnerabilities

public static HashMap<String,Vulnerability> getVulnerabilities()

getVulnerabilities

public static HashMap<String,Vulnerability> getVulnerabilities(File file)

main

public static void main(String[] args)
The main method which drives the whole program.

Parameters:
args - The command line arguments - These should be null.

computeEAL

public double computeEAL()
This computes the EAL for a portfolio.


actionPerformed

public void actionPerformed(ActionEvent event)
Listen for the JButtons and the JComboBox. "Compute" starts up a new thread that calls computeEAL(), which computes the EAL for a portfolio.>
"Clear Results" goes to clearResults(), which clears the I/O text area.
"Open Portfolio" opens up a new dialog that allows you to open a portfolio file.
"Cancel" stops the thread running the calculations and resets the buttons. JComboBox: "comboBoxSelection" Calls a method in view based on the selection

Specified by:
actionPerformed in interface ActionListener
Parameters:
event - The ActionEvent fired when the buttons/combo box are selected.

itemStateChanged

public void itemStateChanged(ItemEvent event)
ItemListener for the JCheckBox

Specified by:
itemStateChanged in interface ItemListener
Parameters:
event - The ItemEvent The event fired whent the check box is selected.

run

public void run()
This method is used when new thread is started on an object of this class. It starts the computation for the EAL, and then changes the buttons back to their default state. It also prints the calculation information to the I/O pane.

Specified by:
run in interface Runnable

calculationException

public void calculationException(String errorMessage)
Exceptions occur during a calculation; this method gets the program back to its start state

Specified by:
calculationException in interface CalculationExceptionHandler
Parameters:
errorMessage - The string representation of the exception's error message.