Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Commit

Permalink
Fix toggle/reset of weights with clear/pick actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Diana Norgaard committed Jul 6, 2017
1 parent 24acb83 commit 912182c
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions src/main/java/gov/usgs/volcanoes/swarm/event/PickMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ private void createPickMenu() {
mi[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Pick pick = createPick(phase, onset, j2k, weight);
propagatePick(phase, pick);
setWeightButton(phase, onset, weight);
pickChannels.put(phase, true);
wvp.repaint();
propagatePick(phase, pick);
propagateUncertainty(phase, onset, weight);
}
});
Expand Down Expand Up @@ -308,8 +309,7 @@ public void propagateUncertainty(String phase, Pick.Onset onset, int weight) {
continue;
}
if (wvp.isSameStation(otherWvp)) {
String key = phase + onset.toString().substring(0, 1);
otherWvp.getPickMenu().getWeightButtons().get(key)[weight].setSelected(true);
otherWvp.getPickMenu().setWeightButton(phase, onset, weight);
otherWvp.repaint();
}
}
Expand Down Expand Up @@ -504,13 +504,34 @@ private void clearPick(String pickType) {
if (pickType.equals(P) || pickType.equals(S)) {
propagatePick(pickType, null);
// reset weights to 0
weightButtons.get(pickType + "E")[0].setSelected(true);
weightButtons.get(pickType + "I")[0].setSelected(true);
setWeightButton(pickType, Pick.Onset.EMERGENT, 0); // I done automatically
propagateUncertainty(pickType, Pick.Onset.EMERGENT, 0);
propagateUncertainty(pickType, Pick.Onset.IMPULSIVE, 0);
repaint();
}
}

/**
* Toggle weight for a given phase/onset combination.
* @param phase P or S
* @param onset Emergent or Impulsive
* @param weight 0 to 4
*/
private void setWeightButton(String phase, Pick.Onset onset, int weight) {
for (Pick.Onset o : Pick.Onset.values()) {
if (o == Pick.Onset.QUESTIONABLE) {
continue;
}
if (o == onset) {
String key = phase + onset.toString().substring(0, 1);
weightButtons.get(key)[weight].setSelected(true);
} else {
String key = phase + o.toString().substring(0, 1);
weightButtons.get(key)[0].setSelected(true);
}
}
}

/**
* Get enabled/disabled option for hiding coda.
*
Expand Down Expand Up @@ -568,9 +589,5 @@ public boolean isPlot() {
public void setPlot(boolean plot) {
plotMenu.setSelected(plot);
}

public HashMap<String, JRadioButtonMenuItem[]> getWeightButtons() {
return weightButtons;
}

}

0 comments on commit 912182c

Please sign in to comment.