Parameter Panel

From Informatics

Jump to: navigation, search

Contents

Parameter Panel

In geWorkbench, we have parameter panel for most of our analysis components. And also for Normalizers and Filters.

We need to implement three interfaces for that parameter panel to work correctly.

  1. Implement public Map<Serializable, Serializable> getParameters() to let others get parameters from it
  2. Implement public void setParameters(Map<Serializable, Serializable> parameters) to set parameters to GUI in that parameter panel
  3. Add ParameterActionListener to the GUI components which need to be monitored for changing highlights.

How To Implement a parameter panel

First

The class needs to extend AbstractSaveableParameterPanel

Implement getParameters

The output will be all the parameters for that parameter panel stored in a Map<Serializable, Serializable>.

The key of that Map will be the name of the parameter, and the value of that Map will be the value of that named parameter.

See getParameters() method in HierClustPanel.java or SOMPanel.java as an example.

Implement setParameters

The input will be all the parameters for that parameter panel stored in a Map<Serializable, Serializable>.

The key of that Map will be the name of the parameter, and the value of that Map will be the value of that named parameter.

You'll need to put those parameters not only into your variables, but also the GUI components.

See setParameters() method in HierClustPanel.java or SOMPanel.java as an example.

Add ParameterActionListener

When user change parameters in parameters panel, we'll need to tell analysis panel to refresh the high lighted saved-parameter-set. In order to do that without using Events (Since parameter panels are not Components in ComponentsRegistry, it can not publish or subscribe any event), we have a call back function implemented for you. You just need to add ParameterActionListener to your Swing component, other things will be handled automatically.

The way to add the ParameterActionListener depends on the type of your component; For example, you have a JFormattedTextField Swing component named alpha:

 private JFormattedTextField alpha = new JFormattedTextField();

You'll need to add a ParameterActionListener like this:

 ParameterActionListener parameterActionListener = new ParameterActionListener(this);
 alpha.addActionListener(parameterActionListener);

In another example, you have a JList and a DefaultListModel associate with it:

DefaultListModel selectedModel = new DefaultListModel();
JList jList1 = new JList(selectedModel);

In this case, you should monitor the change on the model instead of on the JList, like this:

ParameterActionListener parameterActionListener = new ParameterActionListener(this);
selectedModel.addListDataListener(parameterActionListener);

How We Save Parameter Panel

  1. When user click save button, we check if the parameter set exist in memory or not; If exist, we prompt user; If not, we ask user for the name.
  2. We check if the file of the given named exist or not; If exist, we prompt user; If not, or user insist, we do next step.
  3. We call parameter panel's getParameters() method, and get parameters back as a HashMap.
  4. We add another key-value pair ("ParameterKey",AnalysisName+SetName) in to the HashMap, so when we read from the file, we know which component use this saved parameters.
  5. We use XMLEncoder to output the HashMap to the xml file, with the name user given in step 1, and with extension .xml
  6. For now, the directories used to save those xml files, are determined by component's directory. Ex: If the directory for HierarchicalClustering is eclipse_geworkbench_workspace\hierarchicalclustering\, then the directory to save those xml files will be eclipse_geworkbench_workspace\hierarchicalclustering\savedParams

How We Load Parameter Panel

  1. When geWorkbench initialize Analysis Components, Analysis Components will call setDefaultPanel() to set the parameter panel.
  2. In setDefaultPanel(), we'll detect components path, and load .xml files in that directory.
  3. We'll deserialize all .xml back to HashMap, and put in to memory (parameterHash, and geWorkbench will generate JList from parameterHash later).
  4. We'll determine the last saved file using last modified time stamp.
  5. When user switch to that Analysis Component in Analysis Panel, geWorkbench will show the parameter panel associated with that component, and generate the JList from parameterHash. At that time, we'll highlight the last saved parameter set on the JList, and put the parameters stored inside of that parameter set in to the parameter panel, by calling that parameter panel's setParameters() method.

How We Switch Parameter Set

  1. When user click on a saved parameter set, it triggers namedParameterSelection_action().
  2. In namedParameterSelection_action(), we use the selected name to make a query: selectedAnalysis.getNamedParameterSet(name)
  3. We'll get parameters as HashMap, then we call selectedAnalysis.setParameters(parameters) to set the parameters in to that parameter panel's GUI.

How We Switch Parameter Panel

  1. When user select another analysis, analysisSelected_action() will be triggered.
  2. We'll get the parameter panel associated with this analysis by calling selectedAnalysis.getParameterPanel(), and show it to user.
  3. Get saved parameter sets associated with this analysis by calling availableAnalyses[index].getNamesOfStoredParameterSets(), and generate a new JList by calling setNamedParameters(storedParameterSetNames);
  4. If this is the first time user switch to this analysis, we'll highlight the last saved parameter set, and set the parameters in that set in to that parameter panel.

How To Prevent Cyclic Events

  1. Since changing the parameters in parameter panel will trigger analysis panel to check if there's any saved settings matching new parameters, and select the matched one;
  2. While on the other hand, select a saved parameter set in analysis panel will set the parameters in that set in to parameter panels, and trigger event mentioned in #1.

Parameters panel and Analysis Panel (or Normalization panel or Filtering panel) will keep trigger each other.

To prevent keep triggering each other you can use following code to stop the notification:

 if (getStopNotifyAnalysisPanelTemporaryFlag()==true) return;
 stopNotifyAnalysisPanelTemporary(true);
 	//Make changes to Swing components as you wish.
 stopNotifyAnalysisPanelTemporary(false);

Within the code block above, no notification will be sent to Analysis Panel.

This is useful when you modify values or status for Swings components in setParameters().

How To Handle Dependencies among Parameters

For example, in AracneParamPanel markerSetCombo depends on hubCombo and change in hubCombo value will reset or disable markerSetCombo value. setParameters() function iterate over Set of parameters and order of iteration is implementation dependent. We need to make sure that markerSetCombo is set after hubCombo. In AracneParamPanel solution was to save value of markerSetCombo in a temporary variable and set markerSetCombo after all parameters are set.

Personal tools