org.opensha.commons.param.editor
Class AbstractParameterEditorConverter<E,F>

java.lang.Object
  extended by org.opensha.commons.param.editor.AbstractParameterEditorConverter<E,F>
Type Parameters:
E -
F -
All Implemented Interfaces:
EventListener, ParameterEditor<E>, ParameterChangeListener
Direct Known Subclasses:
ConstrainedDiscreteLocationParameterEditor, LocationParameterEditor

public abstract class AbstractParameterEditorConverter<E,F>
extends Object
implements ParameterEditor<E>, ParameterChangeListener

This class is used to quickly create an editor of one type which uses a parameter editor of another type. For example, a LocationParameter might need to be edited with a StringParameterEditor or a ParameterListEditor. This makes it really easy to wrap parameter editors.

Author:
Kevin

Constructor Summary
AbstractParameterEditorConverter()
           
AbstractParameterEditorConverter(Parameter<E> nativeParam)
           
 
Method Summary
protected abstract  Parameter<F> buildParameter(Parameter<E> myParam)
          This will be called to build a parameter of the editor type from the parameter type
protected abstract  F convertFromNative(E value)
          Converts a native value to a converted value
protected abstract  E convertToNative(F value)
          Converts a converted value back to a native value.
 JComponent getComponent()
           
 Parameter<E> getParameter()
          Returns the parameter that is stored internally that this GUI widget is editing
 E getValue()
          Returns the value of the parameter object.
 boolean isFocusEnabled()
          Returns the focusEnabled boolean indicating this is the GUI componet with the current focus
 boolean isVisible()
           
 void parameterChange(ParameterChangeEvent event)
          Function that must be implemented by all Listeners for ParameterChangeEvents.
 void refreshParamEditor()
          Called when the parameter has changed independently from the editor.
 void setEditorBorder(Border b)
           
 void setEnabled(boolean isEnabled)
           
 void setFocusEnabled(boolean newFocusEnabled)
          Sets the focusEnabled boolean indicating this is the GUI componet with the current focus
 void setParameter(Parameter<E> model)
          Sets the parameter that is stored internally for this GUI widget to edit
 void setValue(E object)
          Set the value of the Parameter this editor is editing.
 void setVisible(boolean isVisible)
           
 void unableToSetValue(Object object)
          Needs to be called by subclasses when editable widget field change fails due to constraint problems.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractParameterEditorConverter

public AbstractParameterEditorConverter()

AbstractParameterEditorConverter

public AbstractParameterEditorConverter(Parameter<E> nativeParam)
Method Detail

buildParameter

protected abstract Parameter<F> buildParameter(Parameter<E> myParam)
This will be called to build a parameter of the editor type from the parameter type

Parameters:
myParam -
Returns:

convertFromNative

protected abstract F convertFromNative(E value)
Converts a native value to a converted value

Parameters:
value -
Returns:

convertToNative

protected abstract E convertToNative(F value)
Converts a converted value back to a native value.

Parameters:
value -
Returns:

setValue

public void setValue(E object)
Description copied from interface: ParameterEditor
Set the value of the Parameter this editor is editing.

Specified by:
setValue in interface ParameterEditor<E>

getValue

public E getValue()
Description copied from interface: ParameterEditor
Returns the value of the parameter object.

Specified by:
getValue in interface ParameterEditor<E>

unableToSetValue

public void unableToSetValue(Object object)
Description copied from interface: ParameterEditor
Needs to be called by subclasses when editable widget field change fails due to constraint problems. Allows rollback to the previous good value.

Specified by:
unableToSetValue in interface ParameterEditor<E>

refreshParamEditor

public void refreshParamEditor()
Description copied from interface: ParameterEditor
Called when the parameter has changed independently from the editor. This function needs to be called to to update the GUI component ( text field, picklsit, etc. ) with the new parameter value.

Specified by:
refreshParamEditor in interface ParameterEditor<E>

getParameter

public Parameter<E> getParameter()
Description copied from interface: ParameterEditor
Returns the parameter that is stored internally that this GUI widget is editing

Specified by:
getParameter in interface ParameterEditor<E>

setParameter

public void setParameter(Parameter<E> model)
Description copied from interface: ParameterEditor
Sets the parameter that is stored internally for this GUI widget to edit

Specified by:
setParameter in interface ParameterEditor<E>

parameterChange

public void parameterChange(ParameterChangeEvent event)
Description copied from interface: ParameterChangeListener
Function that must be implemented by all Listeners for ParameterChangeEvents.

Specified by:
parameterChange in interface ParameterChangeListener
Parameters:
event - The Event which triggered this function call

setFocusEnabled

public void setFocusEnabled(boolean newFocusEnabled)
Description copied from interface: ParameterEditor
Sets the focusEnabled boolean indicating this is the GUI componet with the current focus

Specified by:
setFocusEnabled in interface ParameterEditor<E>

isFocusEnabled

public boolean isFocusEnabled()
Description copied from interface: ParameterEditor
Returns the focusEnabled boolean indicating this is the GUI componet with the current focus

Specified by:
isFocusEnabled in interface ParameterEditor<E>

setEnabled

public void setEnabled(boolean isEnabled)
Specified by:
setEnabled in interface ParameterEditor<E>

setVisible

public void setVisible(boolean isVisible)
Specified by:
setVisible in interface ParameterEditor<E>

isVisible

public boolean isVisible()
Specified by:
isVisible in interface ParameterEditor<E>

getComponent

public JComponent getComponent()
Specified by:
getComponent in interface ParameterEditor<E>

setEditorBorder

public void setEditorBorder(Border b)
Specified by:
setEditorBorder in interface ParameterEditor<E>