|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.opensha.commons.param.AbstractParameter<Double>
org.opensha.commons.param.impl.DoubleParameter
org.opensha.commons.param.impl.WarningDoubleParameter
org.opensha.commons.param.impl.TranslatedWarningDoubleParameter
public class TranslatedWarningDoubleParameter
Title: TranslatedWarningDoubleParameter
Description: A subclass of a warning double parameter so it inherits all behavior of the parent class. See the parent class javadocs for a full description of it's behavior. Only the added features of this subclass will be outlined here.
The whole purpose of a TranslatedWarningDoubleParameter is to be a "wrapper" for a WarningDoubleParameter and translate all setting, getting values to the warning parameter. This Translated parameter becomes a proxy to the "wrapped" WarningParameter. In object-oriented design patterns this is called the "Decorator Pattern". Instead of subclassing you "wrap" (maintain a variable reference ) to the clss of interest. This class then slightly modifies the behavior of the "wrapped" class transparently. This helps eliminate proliferation of subclasses.
The TranslatedWarningDoubleParameter makes use of a second class, a TranslatorAPI that actually performs the translation back and fourth internally. An API was defined so that any type of implementation translation class could be passed in. This translation class is simply some function. The class acts as a pointer to a function, so you can swap out different functions without changing this class. Currently the only concrete translator class implemented is the LogTranslator.
The logical purpose of this class is to input values in one form, then translate them to the desired form, and use the translated values in a calculation. So with this in mind it is really the input values that are translated, and the translator puts them back in the correct form.
An example is that in our IMRTesterApplet we let users edit the IMR level in normal space using this Parameter class. The values are internally translated to log space in the contained WarningDoubleParameter. So the user only sees normal values for the current IMR level, and it's constraints, but internally the values are really in log space. The IMR needs the parameter in log space to perform it's calculations. It is much easier for a user to input normal values say 1-200, than the log of this range.
If the translate flag is set to false, this class then acts as a transparent proxy to the underlying WarningDoubleParameter. No translations are made.
WarningDoubleParameter,
TranslatorAPI,
LogTranslator,
Serialized Form| Field Summary | |
|---|---|
protected static String |
C
Class name for debugging. |
protected static boolean |
D
If true print out debug statements. |
protected WarningDoubleParameter |
param
Internal reference to the wrapped parameter |
protected TranslatorAPI |
trans
Default translator is LogTranslator. |
protected boolean |
translate
If true, translation will occur on get, and setValue operations. |
| Fields inherited from class org.opensha.commons.param.impl.WarningDoubleParameter |
|---|
warningConstraint, warningListeners |
| 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 | |
|---|---|
TranslatedWarningDoubleParameter(WarningDoubleParameter param)
Allows setting the parameter upon construction. |
|
TranslatedWarningDoubleParameter(WarningDoubleParameter param,
TranslatorAPI trans)
Allows setting the parameter for translation access, and setting the translator function upon construction. |
|
| Method Summary | |
|---|---|
void |
addIndependentParameter(Parameter parameter)
Direct proxy to wrapped parameter. |
void |
addParameterChangeFailListener(ParameterChangeFailListener listener)
Adds a feature to the ParameterChangeFailListener attribute of the ParameterEditor object |
void |
addParameterChangeListener(ParameterChangeListener listener)
Adds a feature to the ParameterChangeListener attribute of the ParameterEditor object |
void |
addParameterChangeWarningListener(ParameterChangeWarningListener listener)
Direct proxy to wrapped parameter. |
Object |
clone()
Returns a copy so you can't edit or damage the origial. |
boolean |
containsIndependentParameter(String name)
Direct proxy to wrapped parameter. |
void |
fireParameterChangeWarning(ParameterChangeWarningEvent event)
Description of the Method |
void |
firePropertyChange(ParameterChangeEvent event)
Description of the Method |
void |
firePropertyChangeFailed(ParameterChangeFailEvent event)
Description of the Method |
ParameterConstraint |
getConstraint()
Gets the constraints of this parameter. |
String |
getConstraintName()
Direct proxy to wrapped parameter. |
Double |
getDefaultValue()
Returns the parameter's default value. |
String |
getDependentParamMetadataString()
Rather than giving the name and value info, this returns the name and the name/value pairs for all the parameters in the IndependentParameterList of this parameter. |
ParameterEditor<Double> |
getEditor()
Returns the Editor for this Parameter. |
Parameter |
getIndependentParameter(String name)
Direct proxy to wrapped parameter. |
ListIterator |
getIndependentParametersIterator()
Direct proxy to wrapped parameter. |
String |
getIndependentParametersKey()
Direct proxy to wrapped parameter. |
String |
getInfo()
Direct proxy to wrapped parameter. |
Double |
getMax()
Returns the maximum allowed value of the constraint object. |
String |
getMetadataString()
|
Double |
getMin()
Gets the min value of the constraint object. |
String |
getName()
Direct proxy to wrapped parameter. |
int |
getNumIndependentParameters()
Direct proxy to wrapped parameter. |
WarningDoubleParameter |
getParameter()
Public access to the wrapped parameter, allows getting the parameter. |
TranslatorAPI |
getTrans()
|
String |
getType()
Returns the data type of the value object. |
String |
getUnits()
Direct proxy to wrapped parameter. |
Double |
getValue()
Returns the parameter's value. |
AbstractParameterConstraint |
getWarningConstraint()
Direct proxy to wrapped parameter. |
Double |
getWarningMax()
Gets the max value of the constraint object. |
Double |
getWarningMin()
Gets the min value of the constraint object. |
boolean |
isAllowed(Double value)
Translated proxy values to constraint check when setting a value. |
boolean |
isEditable()
Determines if the value can be edited, i.e. |
boolean |
isIgnoreWarning()
Direct proxy to wrapped parameter. |
boolean |
isNullAllowed()
Proxy function call to the constraint to see if null values are permitted |
boolean |
isRecommended(Double obj)
Uses the constraint object to determine if the new value being set is within recommended range. |
boolean |
isTranslate()
Returns true if translation is in affect, false otherwise |
void |
removeIndependentParameter(String name)
Direct proxy to wrapped parameter. |
void |
removeParameterChangeFailListener(ParameterChangeFailListener listener)
Description of the Method |
void |
removeParameterChangeListener(ParameterChangeListener listener)
Description of the Method |
void |
removeParameterChangeWarningListener(ParameterChangeWarningListener listener)
Direct proxy to wrapped parameter. |
void |
setConstraint(ParameterConstraint constraint)
Direct proxy to wrapped parameter. |
void |
setDefaultValue(Double defaultValue)
Set's the default value. |
void |
setIgnoreWarning(boolean ignoreWarning)
Direct proxy to wrapped parameter. |
void |
setIndependentParameters(ParameterList list)
Direct proxy to wrapped parameter. |
void |
setInfo(String info)
Direct proxy to wrapped parameter. |
void |
setName(String name)
Direct proxy to wrapped parameter. |
void |
setNonEditable()
Disables editing the value once it is set. |
void |
setParameter(WarningDoubleParameter param)
Public access to the wrapped parameter, allows setting the parameter. |
void |
setTranslate(boolean translate)
Public api that allows enabling or disabling translation. |
void |
setUnits(String units)
Direct proxy to wrapped parameter. |
void |
setValue(Double value)
Set's the parameter's value in the underlying parameter. |
void |
setValueAsDefault()
This sets the value as the default setting |
void |
setValueIgnoreWarning(Double value)
Set's the parameter's value in the underlying parameter. |
void |
setWarningConstraint(AbstractParameterConstraint warningConstraint)
Direct proxy to wrapped parameter. |
Element |
toXMLMetadata(Element root)
|
Element |
toXMLMetadata(Element root,
String elementName)
Saves this parameter into the supplied XML metadata Element using the specified name
instead of the default. |
void |
unableToSetValue(Object value)
Needs to be called by subclasses when field change fails due to constraint problems |
| Methods inherited from class org.opensha.commons.param.impl.WarningDoubleParameter |
|---|
setIndividualParamValueFromXML |
| Methods inherited from class org.opensha.commons.param.impl.DoubleParameter |
|---|
setValue |
| Methods inherited from class org.opensha.commons.param.AbstractParameter |
|---|
checkEditable, compareTo, equals, getIndependentParameterList, setDependentParamMetadataString, setIndepParamsFromXML, setValueFromXMLMetadata, 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.WarningParameter |
|---|
equals |
| Methods inherited from interface org.opensha.commons.param.Parameter |
|---|
setValueFromXMLMetadata |
| Methods inherited from interface java.lang.Comparable |
|---|
compareTo |
| Field Detail |
|---|
protected static final String C
protected static final boolean D
protected TranslatorAPI trans
protected boolean translate
protected WarningDoubleParameter param
| Constructor Detail |
|---|
public TranslatedWarningDoubleParameter(WarningDoubleParameter param)
Note: No translation changes are applied to the passed in parameter. It is assumed that the parameter is already in translated log space.
public TranslatedWarningDoubleParameter(WarningDoubleParameter param,
TranslatorAPI trans)
Note: No translation changes are applied to the passed in parameter. It is assumed that the parameter is already in translated space.
| Method Detail |
|---|
public boolean isTranslate()
public void setTranslate(boolean translate)
public void setParameter(WarningDoubleParameter param)
Note: No translation changes are applied to the passed in parameter. It is assumed that the parameter is already in translated space.
public WarningDoubleParameter getParameter()
Note: No translation changes are applied to the fetched parameter. It is assumed that the parameter is returned in translated space.
public Double getWarningMin()
throws Exception
getWarningMin in interface WarningParameter<Double>getWarningMin in class WarningDoubleParameterException - Thrown if any mathmatical exceptions occur.public boolean isAllowed(Double value)
isAllowed in interface Parameter<Double>isAllowed in class DoubleParametervalue - Description of the Parameter
public Double getWarningMax()
getWarningMax in interface WarningParameter<Double>getWarningMax in class WarningDoubleParameterException - Thrown if any mathmatical exceptions occur.
public void setValue(Double value)
throws ConstraintException,
WarningException
setValue in interface Parameter<Double>setValue in class WarningDoubleParametervalue - The new value for this Parameter
ParameterException - Thrown if the object is currenlty not
editable
ConstraintException - Thrown if the object value is not allowed
WarningException - Thrown if the new value is beyond the warning levels.
public void unableToSetValue(Object value)
throws ConstraintException
unableToSetValue in interface Parameter<Double>unableToSetValue in class AbstractParameter<Double>value - Description of the Parameter
ConstraintException - Description of the Exceptionpublic Double getValue()
getValue in interface Parameter<Double>getValue in class AbstractParameter<Double>
public void setDefaultValue(Double defaultValue)
throws ConstraintException
setDefaultValue in interface Parameter<Double>setDefaultValue in class AbstractParameter<Double>defaultValue - The default value for this Parameter.
ConstraintException - Thrown if the object value is not allowed.
public void setValueAsDefault()
throws ConstraintException,
ParameterException
setValueAsDefault in interface Parameter<Double>setValueAsDefault in class AbstractParameter<Double>value -
ConstraintException
ParameterExceptionpublic Double getDefaultValue()
getDefaultValue in interface Parameter<Double>getDefaultValue in class AbstractParameter<Double>
public void setValueIgnoreWarning(Double value)
throws ConstraintException,
ParameterException
Note, if this object is not a Double, it is passed through without translation. WarningDoubleParameter constraint will fail.
setValueIgnoreWarning in interface WarningParameter<Double>setValueIgnoreWarning in class WarningDoubleParametervalue - The new value for this Parameter
ParameterException - Thrown if the object is currenlty not
editable
ConstraintException - Thrown if the object value is not allowedpublic boolean isRecommended(Double obj)
isRecommended in interface WarningParameter<Double>isRecommended in class WarningDoubleParameterobj - Object to check if allowed via constraints
public Double getMin()
throws Exception
getMin in class DoubleParameterException - Description of the Exceptionpublic Double getMax()
getMax in class DoubleParameterpublic void setIgnoreWarning(boolean ignoreWarning)
setIgnoreWarning in interface WarningParameter<Double>setIgnoreWarning in class WarningDoubleParameterpublic boolean isIgnoreWarning()
isIgnoreWarning in interface WarningParameter<Double>isIgnoreWarning in class WarningDoubleParameterpublic void setWarningConstraint(AbstractParameterConstraint warningConstraint)
setWarningConstraint in interface WarningParameter<Double>setWarningConstraint in class WarningDoubleParameter
public AbstractParameterConstraint getWarningConstraint()
throws ParameterException
getWarningConstraint in interface WarningParameter<Double>getWarningConstraint in class WarningDoubleParameterParameterExceptionpublic void addParameterChangeWarningListener(ParameterChangeWarningListener listener)
addParameterChangeWarningListener in interface WarningParameter<Double>addParameterChangeWarningListener in class WarningDoubleParameterlistener - The feature to be added to the
ParameterChangeFailListener attributepublic void removeParameterChangeWarningListener(ParameterChangeWarningListener listener)
removeParameterChangeWarningListener in interface WarningParameter<Double>removeParameterChangeWarningListener in class WarningDoubleParameterpublic void addParameterChangeFailListener(ParameterChangeFailListener listener)
addParameterChangeFailListener in interface Parameter<Double>addParameterChangeFailListener in class AbstractParameter<Double>listener - The feature to be added to the
ParameterChangeFailListener attributepublic void removeParameterChangeFailListener(ParameterChangeFailListener listener)
removeParameterChangeFailListener in interface Parameter<Double>removeParameterChangeFailListener in class AbstractParameter<Double>listener - Description of the Parameterpublic void addParameterChangeListener(ParameterChangeListener listener)
addParameterChangeListener in interface Parameter<Double>addParameterChangeListener in class AbstractParameter<Double>listener - The feature to be added to the ParameterChangeListener
attributepublic void removeParameterChangeListener(ParameterChangeListener listener)
removeParameterChangeListener in interface Parameter<Double>removeParameterChangeListener in class AbstractParameter<Double>listener - Description of the Parameterpublic void firePropertyChange(ParameterChangeEvent event)
firePropertyChange in interface Parameter<Double>firePropertyChange in class AbstractParameter<Double>event - Description of the Parameterpublic void firePropertyChangeFailed(ParameterChangeFailEvent event)
firePropertyChangeFailed in interface Parameter<Double>firePropertyChangeFailed in class AbstractParameter<Double>event - Description of the Parameterpublic void fireParameterChangeWarning(ParameterChangeWarningEvent event)
fireParameterChangeWarning in interface WarningParameter<Double>fireParameterChangeWarning in class WarningDoubleParameterevent - Description of the Parameterpublic Object clone()
clone in interface Parameter<Double>clone in class WarningDoubleParameterpublic ListIterator getIndependentParametersIterator()
getIndependentParametersIterator in interface Parameter<Double>getIndependentParametersIterator in class AbstractParameter<Double>
public Parameter getIndependentParameter(String name)
throws ParameterException
getIndependentParameter in interface Parameter<Double>getIndependentParameter in class AbstractParameter<Double>name - Parameter name to lookup.
ParameterException - Thrown if not one of the independent parameters.public void setIndependentParameters(ParameterList list)
setIndependentParameters in interface Parameter<Double>setIndependentParameters in class AbstractParameter<Double>
public void addIndependentParameter(Parameter parameter)
throws ParameterException
addIndependentParameter in interface Parameter<Double>addIndependentParameter in class AbstractParameter<Double>ParameterExceptionpublic boolean containsIndependentParameter(String name)
containsIndependentParameter in interface Parameter<Double>containsIndependentParameter in class AbstractParameter<Double>
public void removeIndependentParameter(String name)
throws ParameterException
removeIndependentParameter in interface Parameter<Double>removeIndependentParameter in class AbstractParameter<Double>ParameterExceptionpublic String getIndependentParametersKey()
getIndependentParametersKey in interface Parameter<Double>getIndependentParametersKey in class AbstractParameter<Double>public int getNumIndependentParameters()
getNumIndependentParameters in interface Parameter<Double>getNumIndependentParameters in class AbstractParameter<Double>public String getName()
getName in interface NamedgetName in class AbstractParameter<Double>public void setName(String name)
setName in interface Parameter<Double>setName in class AbstractParameter<Double>name - to setpublic String getConstraintName()
getConstraintName in interface Parameter<Double>getConstraintName in class AbstractParameter<Double>public ParameterConstraint getConstraint()
getConstraint in interface Parameter<Double>getConstraint in class AbstractParameter<Double>public void setConstraint(ParameterConstraint constraint)
setConstraint in interface Parameter<Double>setConstraint in class DoubleParameterconstraint - The new constraint.public String getUnits()
getUnits in interface Parameter<Double>getUnits in class AbstractParameter<Double>public void setUnits(String units)
setUnits in interface Parameter<Double>setUnits in class AbstractParameter<Double>units - to setpublic String getInfo()
getInfo in interface Parameter<Double>getInfo in class AbstractParameter<Double>Parameterpublic void setInfo(String info)
setInfo in interface Parameter<Double>setInfo in class AbstractParameter<Double>info - to setpublic String getType()
getType in interface Parameter<Double>getType in class DoubleParameterpublic boolean isEditable()
isEditable in interface Parameter<Double>isEditable in class AbstractParameter<Double>public void setNonEditable()
setNonEditable in interface Parameter<Double>setNonEditable in class AbstractParameter<Double>public String getMetadataString()
getMetadataString in interface Parameter<Double>getMetadataString in class AbstractParameter<Double>public String getDependentParamMetadataString()
getDependentParamMetadataString in interface Parameter<Double>getDependentParamMetadataString in class AbstractParameter<Double>public boolean isNullAllowed()
AbstractParameter
isNullAllowed in interface Parameter<Double>isNullAllowed in class AbstractParameter<Double>public TranslatorAPI getTrans()
public Element toXMLMetadata(Element root)
toXMLMetadata in interface XMLSaveabletoXMLMetadata in class AbstractParameter<Double>
public Element toXMLMetadata(Element root,
String elementName)
ParameterElement using the specified name
instead of the default.
toXMLMetadata in interface Parameter<Double>toXMLMetadata in class AbstractParameter<Double>public ParameterEditor<Double> getEditor()
ParameterEditor for this Parameter. It is
recommended that editors be lazily instantiated.
getEditor in interface Parameter<Double>getEditor in class DoubleParameterEditor
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||