org.opensha.sra.gui
Class LossEstimationApplication

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by org.opensha.sra.gui.LossEstimationApplication
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Runnable, EventListener, Accessible, RootPaneContainer, WindowConstants, ParameterChangeListener, IMR_GuiBeanAPI, CurveDisplayAppAPI

public class LossEstimationApplication
extends JFrame
implements Runnable, ParameterChangeListener, CurveDisplayAppAPI, IMR_GuiBeanAPI

Title: HazardCurveServerModeApplication

Description: This application computes Hazard Curve for selected AttenuationRelationship model , Site and Earthquake Rupture Forecast (ERF)model. This computed Hazard curve is shown in a panel using JFreechart. This application works with/without internet connection. If user using this application has network connection then it creates the instances of ERF on server and make all calls to server for any forecast updation. All the computation in this application is done using the server. Once the computations complete, it returns back the result. All the server client relationship has been established using RMI, which allows to make simple calls to the server similar to if things are existing on user's own machine. If network connection is not available to user then it will create all the objects on users local machine and do all computation there itself.

Version:
1.0
Author:
Nitin Gupta and Vipin Gupta Date : Sept 23 , 2002
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String APP_NAME
           
static String APP_SHORT_NAME
           
protected static String appURL
           
protected  JButton cancelCalcButton
           
protected static String CONTROL_PANELS
           
protected static String CVM_CONTROL
           
protected  SetSiteParamsFromWebServicesControlPanel cvmControlPanel
           
protected static boolean D
           
protected  Insets defaultInsets
           
protected static String DISTANCE_CONTROL
           
protected  SetMinSourceSiteDistanceControlPanel distanceControlPanel
           
protected  ERF_GuiBean erfGuiBean
           
protected  List<PlotElement> functionList
          List of ArbitrarilyDiscretized functions and Weighted funstions
protected static int H
           
protected  IMR_GuiBean imrGuiBean
           
protected  PEER_TestCaseSelectorControlPanel peerTestsControlPanel
           
protected  Site_GuiBean siteGuiBean
           
protected static String SITES_OF_INTEREST_CONTROL
           
protected  SitesOfInterestControlPanel sitesOfInterest
           
protected  CalcProgressBar startAppProgressClass
           
protected  String TITLE
           
protected static ApplicationVersion version
           
protected static String versionUpdateInfoURL
           
protected static String versionURL
           
protected  VulnerabilityBean vulnBean
           
protected static int W
           
protected static String XY_Values_Control
           
protected  XY_ValuesControlPanel xyPlotControl
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
LossEstimationApplication()
           
 
Method Summary
protected  void addButton()
          this function is called to draw the graph
 void addCurve(ArbitrarilyDiscretizedFunc function)
          Sets ArbitraryDiscretizedFunc inside list containing all the functions.
 void closeButton_actionPerformed(ActionEvent actionEvent)
           
protected  void computeHazardCurve()
          Gets the probabilities functiion based on selected parameters this function is called when add Graph is clicked
protected  void createCalcInstance()
          This method creates the HazardCurveCalc and Disaggregation Calc(if selected) instances.
protected  void drawGraph()
          to draw the graph
static List<AbstractVulnerability> fetchVulns()
           
protected  Component getApplicationComponent()
           
static ApplicationVersion getAppVersion()
          Returns the Application version
 List<PlotElement> getCurveFunctionList()
           
 ERF_GuiBean getEqkRupForecastGuiBeanInstance()
          This returns the Earthquake Forecast GuiBean which allows the the cybershake control panel to set the forecast parameters from cybershake control panel, similar to what they are set when calculating cybershaks curves.
 String getMapParametersInfoAsHTML()
           
 String getParametersInfoAsString()
           
 String getSelectedIMT()
          Get the selected IMT from the application, based on which it shows the default X Values for the chosen IMT.
 Site_GuiBean getSiteGuiBeanInstance()
          This returns the Site Guibean using which allows to set the site locations in the OpenSHA application from cybershake control panel.
 org.jfree.data.Range getX_AxisRange()
           
 org.jfree.data.Range getY_AxisRange()
           
 void init()
           
protected  void initControlList()
          Initialize the items to be added to the control list
protected  void initERF_GuiBean()
          Initialize the ERF Gui Bean
protected  void initIMR_GuiBean()
          Initialize the IMR Gui Bean
protected  void initSiteGuiBean()
          Initialize the site gui bean
protected  void jbInit()
           
static void main(String[] args)
           
 void parameterChange(ParameterChangeEvent event)
          Any time a control paramater or independent paramater is changed by the user in a GUI this function is called, and a paramater change event is passed in.
protected  void peelOffCurves()
          Actual method implementation of the "Peel-Off" This function peels off the window from the current plot and shows in a new window.
 void plotGraphUsingPlotPreferences()
          plots the curves with defined color,line width and shape.
 void print()
          Creates a print job for the chart.
 void printButton_actionPerformed(ActionEvent actionEvent)
           
 void run()
          Implementing the run method in the Runnable interface that creates a new thread to do Hazard Curve Calculation, this thread created is seperate from the timer thread, so that progress bar updation does not conflicts with Calculations.
 void save()
          Opens a file chooser and gives the user an opportunity to save the chart in PNG format.
 void saveButton_actionPerformed(ActionEvent actionEvent)
           
protected  void setButtonsEnable(boolean b)
          Function to make the buttons enable or disable in the application.
 void setCurveXValues()
          Set the default X Values for the Hazard Curve for the selected IMT.
 void setCurveXValues(ArbitrarilyDiscretizedFunc func)
          Set the X Values from the ArbitrarilyDiscretizedFunc passed as the parameter
 void updateIM()
          Updates the IMT_GuiBean to reflect the chnaged IM for the selected AttenuationRelationship.
 void updateSiteParams()
          Updates the Site_GuiBean to reflect the chnaged SiteParams for the selected AttenuationRelationship.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

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

D

protected static final boolean D
See Also:
Constant Field Values

erfGuiBean

protected ERF_GuiBean erfGuiBean

imrGuiBean

protected IMR_GuiBean imrGuiBean

siteGuiBean

protected Site_GuiBean siteGuiBean

vulnBean

protected VulnerabilityBean vulnBean

CONTROL_PANELS

protected static final String CONTROL_PANELS
See Also:
Constant Field Values

DISTANCE_CONTROL

protected static final String DISTANCE_CONTROL
See Also:
Constant Field Values

SITES_OF_INTEREST_CONTROL

protected static final String SITES_OF_INTEREST_CONTROL
See Also:
Constant Field Values

CVM_CONTROL

protected static final String CVM_CONTROL
See Also:
Constant Field Values

XY_Values_Control

protected static final String XY_Values_Control
See Also:
Constant Field Values

peerTestsControlPanel

protected PEER_TestCaseSelectorControlPanel peerTestsControlPanel

distanceControlPanel

protected SetMinSourceSiteDistanceControlPanel distanceControlPanel

sitesOfInterest

protected SitesOfInterestControlPanel sitesOfInterest

cvmControlPanel

protected SetSiteParamsFromWebServicesControlPanel cvmControlPanel

xyPlotControl

protected XY_ValuesControlPanel xyPlotControl

defaultInsets

protected Insets defaultInsets

W

protected static final int W
See Also:
Constant Field Values

H

protected static final int H
See Also:
Constant Field Values

functionList

protected List<PlotElement> functionList
List of ArbitrarilyDiscretized functions and Weighted funstions


TITLE

protected String TITLE

startAppProgressClass

protected CalcProgressBar startAppProgressClass

cancelCalcButton

protected JButton cancelCalcButton

version

protected static ApplicationVersion version

versionURL

protected static final String versionURL
See Also:
Constant Field Values

appURL

protected static final String appURL
See Also:
Constant Field Values

versionUpdateInfoURL

protected static final String versionUpdateInfoURL
See Also:
Constant Field Values
Constructor Detail

LossEstimationApplication

public LossEstimationApplication()
Method Detail

getAppVersion

public static ApplicationVersion getAppVersion()
Returns the Application version

Returns:
ApplicationVersion

fetchVulns

public static List<AbstractVulnerability> fetchVulns()
                                              throws IOException
Throws:
IOException

init

public void init()

jbInit

protected void jbInit()
               throws Exception
Throws:
Exception

main

public static void main(String[] args)

run

public void run()
Implementing the run method in the Runnable interface that creates a new thread to do Hazard Curve Calculation, this thread created is seperate from the timer thread, so that progress bar updation does not conflicts with Calculations.

Specified by:
run in interface Runnable

createCalcInstance

protected void createCalcInstance()
This method creates the HazardCurveCalc and Disaggregation Calc(if selected) instances. If the internet connection is available then it creates a remote instances of the calculators on server where the calculations take place, else calculations are performed on the user's own machine.


addButton

protected void addButton()
this function is called to draw the graph


getApplicationComponent

protected Component getApplicationComponent()
Returns:
the application component

drawGraph

protected void drawGraph()
to draw the graph


plotGraphUsingPlotPreferences

public void plotGraphUsingPlotPreferences()
plots the curves with defined color,line width and shape.


parameterChange

public void parameterChange(ParameterChangeEvent event)
Any time a control paramater or independent paramater is changed by the user in a GUI this function is called, and a paramater change event is passed in. This function then determines what to do with the information ie. show some paramaters, set some as invisible, basically control the paramater lists.

Specified by:
parameterChange in interface ParameterChangeListener
Parameters:
event -

setButtonsEnable

protected void setButtonsEnable(boolean b)
Function to make the buttons enable or disable in the application. It is used in application to disable the button in the buttons panel if some computation is already going on.

Parameters:
b -

computeHazardCurve

protected void computeHazardCurve()
Gets the probabilities functiion based on selected parameters this function is called when add Graph is clicked


initIMR_GuiBean

protected void initIMR_GuiBean()
Initialize the IMR Gui Bean


initSiteGuiBean

protected void initSiteGuiBean()
Initialize the site gui bean


initERF_GuiBean

protected void initERF_GuiBean()
Initialize the ERF Gui Bean


initControlList

protected void initControlList()
Initialize the items to be added to the control list


updateIM

public void updateIM()
Updates the IMT_GuiBean to reflect the chnaged IM for the selected AttenuationRelationship. This method is called from the IMR_GuiBean to update the application with the Attenuation's supported IMs.

Specified by:
updateIM in interface IMR_GuiBeanAPI

getX_AxisRange

public org.jfree.data.Range getX_AxisRange()
Returns:
the Range for the X-Axis

getY_AxisRange

public org.jfree.data.Range getY_AxisRange()
Returns:
the Range for the Y-Axis

addCurve

public void addCurve(ArbitrarilyDiscretizedFunc function)
Sets ArbitraryDiscretizedFunc inside list containing all the functions.

Specified by:
addCurve in interface CurveDisplayAppAPI
Parameters:
function - ArbitrarilyDiscretizedFunc

getParametersInfoAsString

public String getParametersInfoAsString()
Returns:
the String containing the values selected for different parameters

getMapParametersInfoAsHTML

public String getMapParametersInfoAsHTML()
Returns:
the String containing the values selected for different parameters

getCurveFunctionList

public List<PlotElement> getCurveFunctionList()
Returns:
the List for all the ArbitrarilyDiscretizedFunctions and Weighted Function list.

peelOffCurves

protected void peelOffCurves()
Actual method implementation of the "Peel-Off" This function peels off the window from the current plot and shows in a new window. The current plot just shows empty window.


save

public void save()
          throws IOException
Opens a file chooser and gives the user an opportunity to save the chart in PNG format.

Throws:
IOException - if there is an I/O error.

print

public void print()
Creates a print job for the chart.


closeButton_actionPerformed

public void closeButton_actionPerformed(ActionEvent actionEvent)

printButton_actionPerformed

public void printButton_actionPerformed(ActionEvent actionEvent)

saveButton_actionPerformed

public void saveButton_actionPerformed(ActionEvent actionEvent)

getEqkRupForecastGuiBeanInstance

public ERF_GuiBean getEqkRupForecastGuiBeanInstance()
This returns the Earthquake Forecast GuiBean which allows the the cybershake control panel to set the forecast parameters from cybershake control panel, similar to what they are set when calculating cybershaks curves.


getSiteGuiBeanInstance

public Site_GuiBean getSiteGuiBeanInstance()
This returns the Site Guibean using which allows to set the site locations in the OpenSHA application from cybershake control panel.


updateSiteParams

public void updateSiteParams()
Updates the Site_GuiBean to reflect the chnaged SiteParams for the selected AttenuationRelationship. This method is called from the IMR_GuiBean to update the application with the Attenuation's Site Params.

Specified by:
updateSiteParams in interface IMR_GuiBeanAPI

getSelectedIMT

public String getSelectedIMT()
Description copied from interface: CurveDisplayAppAPI
Get the selected IMT from the application, based on which it shows the default X Values for the chosen IMT.

Specified by:
getSelectedIMT in interface CurveDisplayAppAPI
Returns:

setCurveXValues

public void setCurveXValues(ArbitrarilyDiscretizedFunc func)
Description copied from interface: CurveDisplayAppAPI
Set the X Values from the ArbitrarilyDiscretizedFunc passed as the parameter

Specified by:
setCurveXValues in interface CurveDisplayAppAPI

setCurveXValues

public void setCurveXValues()
Description copied from interface: CurveDisplayAppAPI
Set the default X Values for the Hazard Curve for the selected IMT.

Specified by:
setCurveXValues in interface CurveDisplayAppAPI