org.opensha.sha.gui.beans
Class IMR_MultiGuiBean

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.opensha.commons.gui.LabeledBoxPanel
                      extended by org.opensha.sha.gui.beans.IMR_MultiGuiBean
All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, IMTChangeListener

public class IMR_MultiGuiBean
extends LabeledBoxPanel
implements ActionListener, IMTChangeListener

This is a completely re-written IMR selection GUI which allows for multiple IMRs to be selected and edited, one for each Tectonic Region Type.

Author:
kevin
See Also:
Serialized Form

Nested Class Summary
 class IMR_MultiGuiBean.ChooserComboBox
          Internal sub-class for IMR chooser combo box
 class IMR_MultiGuiBean.EnableableCellRenderer
          This class is the cell renderer for the drop down chooser boxes.
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
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
protected  JCheckBox singleIMRBox
           
protected static Font supportedTRTFont
           
protected static Font unsupportedTRTFont
           
 
Fields inherited from class org.opensha.commons.gui.LabeledBoxPanel
addDefault, borderColor, C, D, editorPanel, GBL, headerLabel, headerPanel, headerPanelBackgroundColor, jScrollPane1, title
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
IMR_MultiGuiBean(List<? extends ScalarIMR> imrs)
          Initializes the GUI with the given list of IMRs
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void addIMRChangeListener(ScalarIMRChangeListener listener)
           
protected  IMR_MultiGuiBean.ChooserComboBox getChooser(TectonicRegionType trt)
           
 Map<TectonicRegionType,ScalarIMR> getIMRMap()
          This returns a clone of the current IMR map in the GUI.
 String getIMRMetadataHTML()
           
static String getIMRMetadataHTML(Map<TectonicRegionType,ScalarIMR> imrMap)
           
 List<? extends ScalarIMR> getIMRs()
          Returns the immutable List of IMRs used by this gui.
 Iterator<Parameter<?>> getMultiIMRSiteParamIterator()
          This returns an iterator over all of the IMR params in the current IMR map
static Iterator<Parameter<?>> getMultiIMRSiteParamIterator(HashMap<TectonicRegionType,ScalarIMR> imrMap)
          This returns an iterator over all of the IMR params in the given IMR map
 NtoNMap<TectonicRegionType,ScalarIMR> getNtoNMap()
           
static NtoNMap<TectonicRegionType,ScalarIMR> getNtoNMap(Map<TectonicRegionType,ScalarIMR> imrMap)
           
protected  IMR_ParamEditor getParamEdit()
           
 ScalarIMR getSelectedIMR()
          This returns the selected IMR if only a single one is selected.
 ArrayList<TectonicRegionType> getTectonicRegions()
           
 void imtChange(IMTChangeEvent e)
          This method will be called when the IMT is changed in an editor
 boolean isCheckBoxVisible()
           
 boolean isIMREnabled(String imrName)
           
 boolean isMultipleIMRs()
           
 void rebuildGUI()
          This rebuilds all components of the GUI for display
 void removeIMRChangeListener(ScalarIMRChangeListener listener)
           
 void setIMR(String imrName, TectonicRegionType trt)
           
 void setIMT(Parameter<Double> newIMT)
          Sets the IMT that this GUI should use.
 void setMaxChooserChars(int maxChooserChars)
          Sets the number of characters that should be displayed in the chooser lists.
 void setMultipleIMRs(boolean multipleIMRs)
          Sets the GUI to multiple/single IMR mode.
 void setMultipleIMRsEnabled(boolean enabled)
          this enables/disables the multiple IMR check box.
 void setSelectedSingleIMR(String imrName)
          Sets the GUI to single IMR mode, and sets the selected IMR to the given name.
 void setTectonicRegions(ArrayList<TectonicRegionType> regions)
          This sets the tectonic regions for the GUI.
 void showParamEditor(TectonicRegionType trt)
          In multiple IMR mode, shows the parameter editor for the IMR associated with the given tectonic region type.
 void updateIMRMap()
          This updates the current in-memory IMR map (the one returned by getIMRMap())
 
Methods inherited from class org.opensha.commons.gui.LabeledBoxPanel
add, add, add, add, add, addPanel, getBorderColor, getHeaderPanelBackgroundColor, getTitle, jbInit, remove, remove, removeAll, setHeaderPanelBackgroundColor, setLayout, setTitle
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

singleIMRBox

protected JCheckBox singleIMRBox

supportedTRTFont

protected static final Font supportedTRTFont

unsupportedTRTFont

protected static final Font unsupportedTRTFont
Constructor Detail

IMR_MultiGuiBean

public IMR_MultiGuiBean(List<? extends ScalarIMR> imrs)
Initializes the GUI with the given list of IMRs

Parameters:
imrs -
Method Detail

rebuildGUI

public void rebuildGUI()
This rebuilds all components of the GUI for display


isCheckBoxVisible

public boolean isCheckBoxVisible()
Returns:
true if the single IMR check box is visible in the GUI

setTectonicRegions

public void setTectonicRegions(ArrayList<TectonicRegionType> regions)
This sets the tectonic regions for the GUI. If regions is not null and contains multiple, TRTs, then the user can select multiple IMRs This triggers a GUI rebuild, and will fire an IMR Change Event if necessary

Parameters:
regions -

getTectonicRegions

public ArrayList<TectonicRegionType> getTectonicRegions()
Returns:
the list Tectonic Regions from the GUI

getChooser

protected IMR_MultiGuiBean.ChooserComboBox getChooser(TectonicRegionType trt)

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener

isMultipleIMRs

public boolean isMultipleIMRs()
Returns:
true if multiple IMRs are both enabled, and selected

setMultipleIMRsEnabled

public void setMultipleIMRsEnabled(boolean enabled)
this enables/disables the multiple IMR check box.

Parameters:
enabled -

getSelectedIMR

public ScalarIMR getSelectedIMR()
This returns the selected IMR if only a single one is selected. Otherwise, a RuntimeException is thrown.

Returns:

showParamEditor

public void showParamEditor(TectonicRegionType trt)
In multiple IMR mode, shows the parameter editor for the IMR associated with the given tectonic region type.

Parameters:
trt -

getParamEdit

protected IMR_ParamEditor getParamEdit()

getIMRMap

public Map<TectonicRegionType,ScalarIMR> getIMRMap()
This returns a clone of the current IMR map in the GUI. This internal IMR map is updated when certain actions are preformed, and should always be up to date.

Returns:

updateIMRMap

public void updateIMRMap()
This updates the current in-memory IMR map (the one returned by getIMRMap())


setMultipleIMRs

public void setMultipleIMRs(boolean multipleIMRs)
Sets the GUI to multiple/single IMR mode. If setting to multiple, but multiple isn't supported, a RundimeException is thrown. The GUI will be updated, and IMR an change event will be fired as needed.

Parameters:
multipleIMRs -

setSelectedSingleIMR

public void setSelectedSingleIMR(String imrName)
Sets the GUI to single IMR mode, and sets the selected IMR to the given name.

Parameters:
imrName -

setIMR

public void setIMR(String imrName,
                   TectonicRegionType trt)

addIMRChangeListener

public void addIMRChangeListener(ScalarIMRChangeListener listener)

removeIMRChangeListener

public void removeIMRChangeListener(ScalarIMRChangeListener listener)

getMultiIMRSiteParamIterator

public Iterator<Parameter<?>> getMultiIMRSiteParamIterator()
This returns an iterator over all of the IMR params in the current IMR map

Returns:

getMultiIMRSiteParamIterator

public static Iterator<Parameter<?>> getMultiIMRSiteParamIterator(HashMap<TectonicRegionType,ScalarIMR> imrMap)
This returns an iterator over all of the IMR params in the given IMR map

Parameters:
imrMap -
Returns:

isIMREnabled

public boolean isIMREnabled(String imrName)

setIMT

public void setIMT(Parameter<Double> newIMT)
Sets the IMT that this GUI should use. All IMRs that don't support this IMT will be disabled.

Parameters:
newIMT - - new IMT, or null to enable all IMRs

getIMRs

public List<? extends ScalarIMR> getIMRs()
Returns the immutable List of IMRs used by this gui.

Returns:
the List of IMRs

getNtoNMap

public NtoNMap<TectonicRegionType,ScalarIMR> getNtoNMap()

getNtoNMap

public static NtoNMap<TectonicRegionType,ScalarIMR> getNtoNMap(Map<TectonicRegionType,ScalarIMR> imrMap)

getIMRMetadataHTML

public static String getIMRMetadataHTML(Map<TectonicRegionType,ScalarIMR> imrMap)

getIMRMetadataHTML

public String getIMRMetadataHTML()
Returns:
IMR metadata as HTML for display

imtChange

public void imtChange(IMTChangeEvent e)
Description copied from interface: IMTChangeListener
This method will be called when the IMT is changed in an editor

Specified by:
imtChange in interface IMTChangeListener

setMaxChooserChars

public void setMaxChooserChars(int maxChooserChars)
Sets the number of characters that should be displayed in the chooser lists. This helps to constrain GUI width.

Parameters:
maxChooserChars -