org.opensha.sha.imr.attenRelImpl.gui
Class AttenuationRelationshipGuiBean

java.lang.Object
  extended by org.opensha.sha.imr.attenRelImpl.gui.AttenuationRelationshipGuiBean
All Implemented Interfaces:
EventListener, Named, ParameterChangeFailListener, ParameterChangeListener

public class AttenuationRelationshipGuiBean
extends Object
implements Named, ParameterChangeListener, ParameterChangeFailListener

Title: AttenuationRelationshipGuiBean

Description: This class is a java bean container for all the Gui elements and controller elements for one particular AttenuationRelationship. This allows all the components to be packaged up in this one class and then for every AttenuationRelationship that is created there will be one instance of this bean. This allows these beans to be easily swapped in and out when you are examining different AttenuationRelationship's in the main tester applet application.

Version:
1.0
Author:
Steven W. Rock
See Also:
BJF_1997_AttenRel, AS_1997_AttenRel

Field Summary
protected  ScalarIMR attenRel
          The AttenuationRelationship is what will perform the exceedence probability calculations as needed by the Gui.
protected static String C
           
protected  ParameterListEditor controlsEditor
          This is the paramater list editor that contains all the control paramaters such as x axis y axis.
protected  ParameterList controlsParamList
          Parameters that control the graphing gui, specifically the IM Types picklist, the Y-axis options picklist, and the X-axis options picklist.
protected static boolean D
           
static int EXCEED_PROB
           
static int IM
           
static String IM_NAME
           
static int IML_AT_EXCEED_PROB
           
protected  ParameterList independentParams
          ParameterList of all independent parameters
protected  ParameterListEditor independentsEditor
          This is the paramater list editor that contains all the independent paramaters depending on which x axis and y axis are chosen some paramaters will be made visible or invisible.
static int MEAN
           
protected  String name
          Just a placeholder name for this particular AttenuationRelationshipGUI Bean.
protected  Parameter selectedIM
          Placeholder for currently selected IM
static int STD_DEV
           
protected  ArrayList translatedList
           
static int X_AXIS
           
static String X_AXIS_NAME
           
static String X_AXIS_SINGLE_VAL
           
static int Y_AXIS
           
static String Y_AXIS_NAME
           
static String Y_AXIS_V1
           
static String Y_AXIS_V2
           
static String Y_AXIS_V3
           
static String Y_AXIS_V4
           
protected static HashMap yAxisMap
           
 
Constructor Summary
AttenuationRelationshipGuiBean(String className, String name, AttenuationRelationshipApplet applet)
          Constructor for the AttenuationRelationshipGuiBean object.
 
Method Summary
static Object createAttenRelClassInstance(String className, ParameterChangeWarningListener listener)
          Creates a class instance from a string of the full class name including packages.
 ScalarIMR getAttenRel()
          Gets the attenRel attribute of the AttenuationRelationshipGuiBean object
 DiscretizedFunc getChoosenFunction()
          Controller function.
 double getChosenValue()
          This method is very similar to the getChoosenFunction(), but only varies in the fact that it return back single double value where as getChoosenfunction returns a function.
 ParameterListEditor getControlsEditor()
          Gets the controlsEditor attribute of the AttenuationRelationshipGuiBean object
 ListIterator getControlsIterator()
          Returns the iterator over all controls parameters, such as x and y axis values.
protected  String getGraphControlsParamValue(int type)
          Returns the value of a graph picklist control as a string, dermined by type.
 String getGraphIMYAxisLabel()
          Builds the Y-Axis Name, which may include units, and includes the IM Type choosen, either "SA" or "PGM".
 String getGraphXAxisLabel()
          Returns which X-Axis were choosen, appending the units if present in the parameter.
 String getGraphXYAxisTitle()
          Builds a Plot title string of the form "y-axis label vs.
 ParameterListEditor getIndependentsEditor()
          Gets the independentsEditor attribute of the AttenuationRelationshipGuiBean object
 URL getInfoURL()
           
 String getName()
          Gets the name attribute of the AttenuationRelationshipGuiBean object
 Parameter getSelectedIMParam()
          Used by the GUI to get the selected Intensity Measure
protected  void initControlsParamListAndEditor(AttenuationRelationshipApplet applet)
           FIX *** FIX *** FIX This needs to be fixed along with the whole function package.
 boolean isTranslateAttenRel()
           
 void parameterChange(ParameterChangeEvent event)
          This is the main function of this interface.
 void parameterChangeFailed(ParameterChangeFailEvent event)
          Function that must be implemented by all Listeners for ParameterChangeFailEvents.
 void refreshParamEditor()
          Resets all GUI controls back to the model values.
protected  void setIgnoreWarnings(boolean ignoreWarning)
           
 void setName(String newName)
          Sets the name attribute of the AttenuationRelationshipGuiBean object
 void setTranslateAttenRel(boolean translateAttenRel)
           
protected  void synchRequiredVisibleParameters()
          Description of the Method
protected  void toggleSigmaLevelBasedOnTypeValue(String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

C

protected static final String C
See Also:
Constant Field Values

D

protected static final boolean D
See Also:
Constant Field Values

IM_NAME

public static final String IM_NAME
See Also:
Constant Field Values

X_AXIS_NAME

public static final String X_AXIS_NAME
See Also:
Constant Field Values

Y_AXIS_NAME

public static final String Y_AXIS_NAME
See Also:
Constant Field Values

Y_AXIS_V1

public static final String Y_AXIS_V1
See Also:
Constant Field Values

Y_AXIS_V2

public static final String Y_AXIS_V2
See Also:
Constant Field Values

Y_AXIS_V3

public static final String Y_AXIS_V3
See Also:
Constant Field Values

Y_AXIS_V4

public static final String Y_AXIS_V4
See Also:
Constant Field Values

X_AXIS_SINGLE_VAL

public static final String X_AXIS_SINGLE_VAL
See Also:
Constant Field Values

MEAN

public static final int MEAN
See Also:
Constant Field Values

STD_DEV

public static final int STD_DEV
See Also:
Constant Field Values

EXCEED_PROB

public static final int EXCEED_PROB
See Also:
Constant Field Values

IML_AT_EXCEED_PROB

public static final int IML_AT_EXCEED_PROB
See Also:
Constant Field Values

IM

public static final int IM
See Also:
Constant Field Values

Y_AXIS

public static final int Y_AXIS
See Also:
Constant Field Values

X_AXIS

public static final int X_AXIS
See Also:
Constant Field Values

yAxisMap

protected static HashMap yAxisMap

attenRel

protected ScalarIMR attenRel
The AttenuationRelationship is what will perform the exceedence probability calculations as needed by the Gui.


controlsEditor

protected ParameterListEditor controlsEditor
This is the paramater list editor that contains all the control paramaters such as x axis y axis.


independentsEditor

protected ParameterListEditor independentsEditor
This is the paramater list editor that contains all the independent paramaters depending on which x axis and y axis are chosen some paramaters will be made visible or invisible. This is done through this editor.


name

protected String name
Just a placeholder name for this particular AttenuationRelationshipGUI Bean.


controlsParamList

protected ParameterList controlsParamList
Parameters that control the graphing gui, specifically the IM Types picklist, the Y-axis options picklist, and the X-axis options picklist. Some of these are dynamically generated from particular independent parameters.


selectedIM

protected Parameter selectedIM
Placeholder for currently selected IM


independentParams

protected ParameterList independentParams
ParameterList of all independent parameters


translatedList

protected ArrayList translatedList
Constructor Detail

AttenuationRelationshipGuiBean

public AttenuationRelationshipGuiBean(String className,
                                      String name,
                                      AttenuationRelationshipApplet applet)
Constructor for the AttenuationRelationshipGuiBean object. This constructor is passed in a AttenRel class name, a name for the Gui bean, and the main applet. From this info. the AttenRel class is created at run time along with the paramater change listener just by the name of the classes.Finally the paramater editors are created for the independent and control paramaters.

Parameters:
className - Fully qualified package and class name of the AttenRel class
name - Placeholder name for this Gui bean so it could be referenced in a hash table or hash map.
applet - The main applet application that will use these beans to swap in and out different AttenuationRelationship's.
Method Detail

getInfoURL

public URL getInfoURL()
               throws MalformedURLException
Returns:
the URL to the selected AttenuationRelationship document on the Web. If AttenuationRelationship specific URL does not exist then it returns generic AttenuationRelationship URL.
Throws:
MalformedURLException - if returned URL is not a valid URL.

createAttenRelClassInstance

public static Object createAttenRelClassInstance(String className,
                                                 ParameterChangeWarningListener listener)
Creates a class instance from a string of the full class name including packages. This is how you dynamically make objects at runtime if you don't know which\ class beforehand. For example, if you wanted to create a BJF_1997_AttenRel you can do it the normal way:

BJF_1997_AttenRel attenRel = new BJF_1997_AttenRel()

If your not sure the user wants this one or AS_1997_AttenRel you can use this function instead to create the same class by:

BJF_1997_AttenRel attenRel = (BJF_1997_AttenRel)ClassUtils.createNoArgConstructorClassInstance("org.opensha.sha.imt.attenRelImpl.BJF_1997_AttenRel");


setName

public void setName(String newName)
Sets the name attribute of the AttenuationRelationshipGuiBean object

Parameters:
newName - The new name value

getControlsIterator

public ListIterator getControlsIterator()
Returns the iterator over all controls parameters, such as x and y axis values.

Returns:
The Controls Iterator

getSelectedIMParam

public Parameter getSelectedIMParam()
Used by the GUI to get the selected Intensity Measure

Returns:
The selectedIMParameter value

getName

public String getName()
Gets the name attribute of the AttenuationRelationshipGuiBean object

Specified by:
getName in interface Named
Returns:
The name value

getAttenRel

public ScalarIMR getAttenRel()
Gets the attenRel attribute of the AttenuationRelationshipGuiBean object

Returns:
The attenRel value

getControlsEditor

public ParameterListEditor getControlsEditor()
Gets the controlsEditor attribute of the AttenuationRelationshipGuiBean object

Returns:
The controlsEditor value

getIndependentsEditor

public ParameterListEditor getIndependentsEditor()
Gets the independentsEditor attribute of the AttenuationRelationshipGuiBean object

Returns:
The independentsEditor value

getGraphControlsParamValue

protected String getGraphControlsParamValue(int type)
                                     throws ParameterException
Returns the value of a graph picklist control as a string, dermined by type.

Parameters:
type - 1 for Intensity Measure Choice, 2 for Y-Axis choice and 3 for X-Axis choice.
Returns:
The string value of the desired picklist.
Throws:
ParameterException - Thrown if an invalid type, must be 1-3.

getGraphIMYAxisLabel

public String getGraphIMYAxisLabel()
Builds the Y-Axis Name, which may include units, and includes the IM Type choosen, either "SA" or "PGM". Solely used for labeling the graph

Returns:
The iMTYAxisLabel value

getGraphXAxisLabel

public String getGraphXAxisLabel()
Returns which X-Axis were choosen, appending the units if present in the parameter. Used for Plot labeling of the x-axis.

Returns:
The xAxisLabel value

getGraphXYAxisTitle

public String getGraphXYAxisTitle()
                           throws ConstraintException
Builds a Plot title string of the form "y-axis label vs. x-axis label". The x and y axis labels are obtained by calling getXAxisLabel() and getIMYAxisLabel()

Returns:
The xYAxisTitle value
Throws:
ConstraintException - Description of the Exception

setIgnoreWarnings

protected void setIgnoreWarnings(boolean ignoreWarning)

getChoosenFunction

public DiscretizedFunc getChoosenFunction()
                                   throws ConstraintException
Controller function. Dispacter function. Based on which Y-Axis was choosen, determines which dependent variable discretized function to return. Once the discretized function has been calculated (by other functions), the x-axis and y-axis name is set in the Discretized function, and the independent parameters that were used in the model calculation are set in the function.

Returns:
The choosenFunction value
Throws:
ConstraintException - Description of the Exception

getChosenValue

public double getChosenValue()
This method is very similar to the getChoosenFunction(), but only varies in the fact that it return back single double value where as getChoosenfunction returns a function.

Returns:
the single value if the user has selected the choice to "Individual Value" on the X-Axis. It then calls the corresponding Y-Axis selected method.

refreshParamEditor

public void refreshParamEditor()
Resets all GUI controls back to the model values. Some models have been changed when iterating over an independent variable. This function ensures these changes are reflected in the independent parameter list.


parameterChange

public void parameterChange(ParameterChangeEvent event)
This is the main function of this interface. 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 -

toggleSigmaLevelBasedOnTypeValue

protected void toggleSigmaLevelBasedOnTypeValue(String value)

initControlsParamListAndEditor

protected void initControlsParamListAndEditor(AttenuationRelationshipApplet applet)
FIX *** FIX *** FIX This needs to be fixed along with the whole function package. Right now only Doubles can be plotted on x-axis as seen by DiscretizedFunction2DAPI.

One thing to note is that all graph constrols in this list are Parameters with String constraints.

Then a new controls paramater editor list for these paramaters are created.

Parameters:
applet - Description of the Parameter

synchRequiredVisibleParameters

protected void synchRequiredVisibleParameters()
                                       throws ParameterException
Description of the Method

Throws:
ParameterException - Description of the Exception

setTranslateAttenRel

public void setTranslateAttenRel(boolean translateAttenRel)

isTranslateAttenRel

public boolean isTranslateAttenRel()

parameterChangeFailed

public void parameterChangeFailed(ParameterChangeFailEvent event)
Description copied from interface: ParameterChangeFailListener
Function that must be implemented by all Listeners for ParameterChangeFailEvents.

Specified by:
parameterChangeFailed in interface ParameterChangeFailListener
Parameters:
event - The Event which triggered this function call