org.opensha.sha.imr.param.PropagationEffectParams
Class WarningDoublePropagationEffectParameter

java.lang.Object
  extended by org.opensha.commons.param.AbstractParameter<E>
      extended by org.opensha.sha.imr.param.PropagationEffectParams.PropagationEffectParameter<java.lang.Double>
          extended by org.opensha.sha.imr.param.PropagationEffectParams.WarningDoublePropagationEffectParameter
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Parameter<?>>, Named, XMLSaveable, Parameter<java.lang.Double>, WarningParameter<java.lang.Double>, PropagationEffectParameterAPI<java.lang.Double>

public abstract class WarningDoublePropagationEffectParameter
extends PropagationEffectParameter<java.lang.Double>
implements WarningParameter<java.lang.Double>

Title: WarningDoublePropagationEffectParameter

Description: Base Propagation Effect Parameter that implements the WarningParameterAPI. This class is only needed and distinct from the WarningDoubleParameter because multiple inheritance is not supported in Java. These PropagationEffect Parameters need a different base class (PropagationEffectParameter) than the WarningDoubleParameter ( DoubleParameter ). It basically has the same functionality. See WarningDoublepParameter for further documentation.

Version:
1.0
Author:
Steven W. Rock
See Also:
Serialized Form

Field Summary
protected  boolean ignoreWarning
          Set to true to turn off warnings, will automatically set the value, unless exceeds Absolute contrsints.
protected  DoubleConstraint warningConstraint
          The warning constraint for this Parameter.
protected  java.util.ArrayList warningListeners
          Listeners that are interested in receiveing warnings when the warning constraints are exceeded.
 
Fields inherited from class org.opensha.sha.imr.param.PropagationEffectParams.PropagationEffectParameter
C, D, eqkRupture, site
 
Fields inherited from class org.opensha.commons.param.AbstractParameter
constraint, defaultValue, editable, independentParameters, info, metadataString, name, units, value, XML_COMPLEX_VAL_EL_NAME, XML_GROUP_METADATA_NAME, XML_METADATA_NAME, XML_NULL_VALUE
 
Fields inherited from interface org.opensha.commons.param.Parameter
XML_INDEPENDENT_PARAMS_NAME
 
Fields inherited from interface org.opensha.commons.metadata.XMLSaveable
XML_METADATA_NAME
 
Constructor Summary
WarningDoublePropagationEffectParameter()
           
 
Method Summary
 void addParameterChangeWarningListener(ParameterChangeWarningListener listener)
          Adds a listener to receive warning events when the warning constraints are exceeded.
abstract  java.lang.Object clone()
          Standard Java function.
 int compareTo(Parameter<?> obj)
          Compares the values to if this is less than, equal to, or greater than the comparing objects.
 boolean equals(java.lang.Object obj)
          Compares value to see if equal.
 void fireParameterChangeWarning(ParameterChangeWarningEvent event)
          Notifes all listeners of a ChangeWarningEvent has occured.
 ParameterEditor<java.lang.Double> getEditor()
          Returns the Editor for this Parameter.
 AbstractParameterConstraint getWarningConstraint()
          Returns the warning constraint.
 java.lang.Double getWarningMax()
          Returns the maximum allowed value of the constraint object.
 java.lang.Double getWarningMin()
          Gets the min value of the constraint object.
 boolean isIgnoreWarning()
          Returns warning constraint enabled/disabled.
 boolean isRecommended(java.lang.Double obj)
          Uses the constraint object to determine if the new value being set is within recommended range.
 void removeParameterChangeWarningListener(ParameterChangeWarningListener listener)
          Adds a listener to receive warning events when the warning constraints are exceeded.
 void setIgnoreWarning(boolean ignoreWarning)
          Set to true to turn off warnings, will automatically set the value, unless exceeds Absolute contrsints.
 void setValue(java.lang.Double value)
          Set's the parameter's value.
 void setValueIgnoreWarning(java.lang.Double value)
          Set's the parameter's value bypassing all checks including the absolute constraint check.
 void setWarningConstraint(AbstractParameterConstraint warningConstraint)
          Sets the constraint if it is a DoubleConstraint and the parameter is currently editable.
 
Methods inherited from class org.opensha.sha.imr.param.PropagationEffectParams.PropagationEffectParameter
calcValueFromSiteAndEqkRup, getType, getValue, setValue
 
Methods inherited from class org.opensha.commons.param.AbstractParameter
addIndependentParameter, addParameterChangeFailListener, addParameterChangeListener, checkEditable, containsIndependentParameter, firePropertyChange, firePropertyChangeFailed, getConstraint, getConstraintName, getDefaultValue, getDependentParamMetadataString, getIndependentParameter, getIndependentParameterList, getIndependentParametersKey, getInfo, getMetadataString, getName, getNumIndependentParameters, getUnits, getValue, isAllowed, isEditable, isNullAllowed, removeIndependentParameter, removeParameterChangeFailListener, removeParameterChangeListener, setConstraint, setDefaultValue, setDependentParamMetadataString, setIndependentParameters, setIndepParamsFromXML, setIndividualParamValueFromXML, setInfo, setName, setNonEditable, setUnits, setValueAsDefault, setValueFromXMLMetadata, toXMLMetadata, toXMLMetadata, unableToSetValue, valueToXML
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opensha.commons.param.Parameter
addIndependentParameter, addParameterChangeFailListener, addParameterChangeListener, containsIndependentParameter, firePropertyChange, firePropertyChangeFailed, getConstraint, getConstraintName, getDefaultValue, getDependentParamMetadataString, getIndependentParameter, getIndependentParameterList, getIndependentParametersKey, getInfo, getMetadataString, getNumIndependentParameters, getType, getUnits, getValue, isAllowed, isEditable, isNullAllowed, removeIndependentParameter, removeParameterChangeFailListener, removeParameterChangeListener, setConstraint, setDefaultValue, setIndependentParameters, setInfo, setName, setNonEditable, setUnits, setValueAsDefault, setValueFromXMLMetadata, toXMLMetadata, unableToSetValue
 
Methods inherited from interface org.opensha.commons.data.Named
getName
 
Methods inherited from interface org.opensha.commons.metadata.XMLSaveable
toXMLMetadata
 

Field Detail

warningConstraint

protected DoubleConstraint warningConstraint
The warning constraint for this Parameter.


warningListeners

protected transient java.util.ArrayList warningListeners
Listeners that are interested in receiveing warnings when the warning constraints are exceeded. Only created if needed, else kept null, i.e. "Lazy Instantiation".


ignoreWarning

protected boolean ignoreWarning
Set to true to turn off warnings, will automatically set the value, unless exceeds Absolute contrsints.

Constructor Detail

WarningDoublePropagationEffectParameter

public WarningDoublePropagationEffectParameter()
Method Detail

setIgnoreWarning

public void setIgnoreWarning(boolean ignoreWarning)
Set to true to turn off warnings, will automatically set the value, unless exceeds Absolute contrsints. Set to false so that warning constraints are enabled, i.e. throw a WarningConstraintException if exceed recommened warnings.

Specified by:
setIgnoreWarning in interface WarningParameter<java.lang.Double>

isIgnoreWarning

public boolean isIgnoreWarning()
Returns warning constraint enabled/disabled. If true warnings are turned off , will automatically set the value, unless exceeds Absolute contrsints. If set to false warning constraints are enabled, i.e. throw a WarningConstraintException if exceed recommened warnings.

Specified by:
isIgnoreWarning in interface WarningParameter<java.lang.Double>

addParameterChangeWarningListener

public void addParameterChangeWarningListener(ParameterChangeWarningListener listener)
                                       throws EditableException
Adds a listener to receive warning events when the warning constraints are exceeded. Only permitted if this parameter is currenlty editable, else an EditableException is thrown.

Specified by:
addParameterChangeWarningListener in interface WarningParameter<java.lang.Double>
Throws:
EditableException

removeParameterChangeWarningListener

public void removeParameterChangeWarningListener(ParameterChangeWarningListener listener)
                                          throws EditableException
Adds a listener to receive warning events when the warning constraints are exceeded. Only permitted if this parameter is currenlty editable, else an EditableException is thrown.

Specified by:
removeParameterChangeWarningListener in interface WarningParameter<java.lang.Double>
Throws:
EditableException

setWarningConstraint

public void setWarningConstraint(AbstractParameterConstraint warningConstraint)
                          throws ParameterException,
                                 EditableException
Sets the constraint if it is a DoubleConstraint and the parameter is currently editable.

Specified by:
setWarningConstraint in interface WarningParameter<java.lang.Double>
Parameters:
warningConstraint - The new constraint for warnings
Throws:
ParameterException - Thrown if the constraint is not a DoubleConstraint
EditableException - Thrown if the isEditable flag set to false.

getWarningConstraint

public AbstractParameterConstraint getWarningConstraint()
                                                 throws ParameterException
Returns the warning constraint. May return null.

Specified by:
getWarningConstraint in interface WarningParameter<java.lang.Double>
Throws:
ParameterException

getWarningMin

public java.lang.Double getWarningMin()
                               throws java.lang.Exception
Gets the min value of the constraint object. If the constraint is not set returns null.

Specified by:
getWarningMin in interface WarningParameter<java.lang.Double>
Returns:
The min value
Throws:
java.lang.Exception - Description of the Exception

getWarningMax

public java.lang.Double getWarningMax()
Returns the maximum allowed value of the constraint object. If the constraint is not set returns null.

Specified by:
getWarningMax in interface WarningParameter<java.lang.Double>
Returns:
The max value

setValue

public void setValue(java.lang.Double value)
              throws ConstraintException,
                     WarningException
Set's the parameter's value. There are several checks that must pass before the value can be set. The parameter must be currently editable, else an EditableException is thrown. The warning constraints, if set will throw a WarningException if exceeded. Finally if all other checks pass, if the absoulte constraints are set, they cannot be exceeded. If they are a Constraint Exception is thrown.

Specified by:
setValue in interface Parameter<java.lang.Double>
Overrides:
setValue in class AbstractParameter<java.lang.Double>
Parameters:
value - The new value for this Parameter
Throws:
ParameterException - Thrown if the object is currenlty not editable
ConstraintException - Thrown if the object value is not allowed
WarningException

setValueIgnoreWarning

public void setValueIgnoreWarning(java.lang.Double value)
                           throws ConstraintException,
                                  ParameterException
Set's the parameter's value bypassing all checks including the absolute constraint check. WARNING: SWR: This may be a bug. Should we bypass the Absolute Constraints. ???

Specified by:
setValueIgnoreWarning in interface WarningParameter<java.lang.Double>
Parameters:
value - The new value for this Parameter
Throws:
ConstraintException - Thrown if the object value is not allowed as determined by the absolute constraints.
ParameterException - Thrown if the object is currenlty not editable

isRecommended

public boolean isRecommended(java.lang.Double obj)
Uses the constraint object to determine if the new value being set is within recommended range. If no Constraints are present all values are recommended, including null.

Specified by:
isRecommended in interface WarningParameter<java.lang.Double>
Parameters:
obj - Object to check if allowed via constraints
Returns:
True if the value is allowed.

fireParameterChangeWarning

public void fireParameterChangeWarning(ParameterChangeWarningEvent event)
Notifes all listeners of a ChangeWarningEvent has occured.

Specified by:
fireParameterChangeWarning in interface WarningParameter<java.lang.Double>

compareTo

public int compareTo(Parameter<?> obj)
Compares the values to if this is less than, equal to, or greater than the comparing objects.

Specified by:
compareTo in interface java.lang.Comparable<Parameter<?>>
Overrides:
compareTo in class AbstractParameter<java.lang.Double>
Parameters:
obj - The object to compare this to
Returns:
-1 if this value < obj value, 0 if equal, +1 if this value > obj value
Throws:
java.lang.ClassCastException - Is thrown if the comparing object is not a DoubleParameter, or DoubleDiscreteParameter.

equals

public boolean equals(java.lang.Object obj)
               throws java.lang.ClassCastException
Compares value to see if equal.

Specified by:
equals in interface Parameter<java.lang.Double>
Specified by:
equals in interface WarningParameter<java.lang.Double>
Overrides:
equals in class AbstractParameter<java.lang.Double>
Parameters:
obj - The object to compare this to
Returns:
True if the values are identical
Throws:
java.lang.ClassCastException - Is thrown if the comparing object is not a DoubleParameter, or DoubleDiscreteParameter.

clone

public abstract java.lang.Object clone()
Standard Java function. Creates a copy of this class instance so originaly can not be modified

Specified by:
clone in interface Parameter<java.lang.Double>
Specified by:
clone in class AbstractParameter<java.lang.Double>

getEditor

public ParameterEditor<java.lang.Double> getEditor()
Description copied from interface: Parameter
Returns the Editor for this Parameter. It is recommended that editors be lazily instantiated.

Specified by:
getEditor in interface Parameter<java.lang.Double>
Returns:
the Editor