Skip to content

Commit

Permalink
Merge pull request #454 from AAVSO/452-magnitude-and-time-shifter-plu…
Browse files Browse the repository at this point in the history
…g-in-contrintuitive-behaviour

#452: added guards in select/deselect all button listener methods to …
  • Loading branch information
dbenn authored Oct 26, 2024
2 parents a3a8022 + db50b1b commit 4a383ba
Show file tree
Hide file tree
Showing 3 changed files with 2,275 additions and 2,286 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,71 +39,67 @@
@SuppressWarnings("serial")
public class MultipleSeriesSelectionDialog extends AbstractOkCancelDialog {

protected JPanel seriesPane;
protected JPanel seriesPane;

protected ObservationAndMeanPlotModel obsPlotModel;
protected ObservationAndMeanPlotModel obsPlotModel;

protected SeriesVisibilityPane seriesVisibilityPane;
protected SeriesVisibilityPane seriesVisibilityPane;

/**
* Constructor.
*
* @param obsPlotModel
* An observation plot model including means.
*/
public MultipleSeriesSelectionDialog(
ObservationAndMeanPlotModel obsPlotModel) {
super(LocaleProps.get("SELECT_SINGLE_SERIES_DLG_TITLE"));
/**
* Constructor
*
* @param seriesVisibilityPane The series visibility pane to be composed with
* this this dialog.
*/
public MultipleSeriesSelectionDialog(SeriesVisibilityPane seriesVisibilityPane) {
super(LocaleProps.get("SELECT_SINGLE_SERIES_DLG_TITLE"));

this.obsPlotModel = obsPlotModel;
Container contentPane = this.getContentPane();

Container contentPane = this.getContentPane();
// This pane contains a series pane and buttons.

// This pane contains a series pane and buttons.
JPanel topPane = new JPanel();
topPane.setLayout(new BoxLayout(topPane, BoxLayout.PAGE_AXIS));
topPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

JPanel topPane = new JPanel();
topPane.setLayout(new BoxLayout(topPane, BoxLayout.PAGE_AXIS));
topPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
seriesPane = new JPanel();
seriesPane.setLayout(new BoxLayout(seriesPane, BoxLayout.LINE_AXIS));
this.seriesVisibilityPane = seriesVisibilityPane;
seriesPane.add(seriesVisibilityPane);

seriesPane = new JPanel();
seriesPane.setLayout(new BoxLayout(seriesPane, BoxLayout.LINE_AXIS));
seriesVisibilityPane = new SeriesVisibilityPane(obsPlotModel, Mediator
.getInstance().getAnalysisType(), true, false, false);
seriesPane.add(seriesVisibilityPane);
topPane.add(new JScrollPane(seriesPane));

topPane.add(new JScrollPane(seriesPane));
topPane.add(Box.createRigidArea(new Dimension(10, 10)));
topPane.add(createButtonPane());

topPane.add(Box.createRigidArea(new Dimension(10, 10)));
topPane.add(createButtonPane());
contentPane.add(topPane);

contentPane.add(topPane);
this.pack();
this.setLocationRelativeTo(Mediator.getUI().getContentPane());
this.setVisible(true);
}

this.pack();
this.setLocationRelativeTo(Mediator.getUI().getContentPane());
this.setVisible(true);
}
/**
* @return has the dialog been cancelled?
*/
public boolean isCancelled() {
return cancelled;
}

/**
* @return has the dialog been cancelled?
*/
public boolean isCancelled() {
return cancelled;
}
protected void cancelAction() {
// Nothing to do
}

protected void cancelAction() {
// Nothing to do
}
protected void okAction() {
cancelled = false;
setVisible(false);
dispose();
}

protected void okAction() {
cancelled = false;
setVisible(false);
dispose();
}

/**
* @return The selected series.
*/
public Set<SeriesType> getSelectedSeries() {
return seriesVisibilityPane.getSelectedSeries();
}
/**
* @return The selected series.
*/
public Set<SeriesType> getSelectedSeries() {
return seriesVisibilityPane.getSelectedSeries();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ public class SeriesVisibilityPane extends JPanel {
private JCheckBox modelCheckBox;
private JCheckBox residualsCheckBox;

private int discrepantCount;
private int excludedCount;

private boolean includeSynthetic;
private boolean modifyVisibility;

Expand Down Expand Up @@ -133,18 +130,6 @@ public SeriesVisibilityPane(ObservationAndMeanPlotModel obsPlotModel,

addSeriesCheckBoxes();

// Get initial discrepant and excluded counts, if any.

Integer discrepantSeriesNum = obsPlotModel.getSrcTypeToSeriesNumMap()
.get(SeriesType.DISCREPANT);
discrepantCount = obsPlotModel.getSeriesNumToObSrcListMap()
.get(discrepantSeriesNum).size();

Integer excludedSeriesNum = obsPlotModel.getSrcTypeToSeriesNumMap()
.get(SeriesType.Excluded);
excludedCount = obsPlotModel.getSeriesNumToObSrcListMap()
.get(excludedSeriesNum).size();

obsPlotModel.getMeansChangeNotifier().addListener(
createMeanObsChangeListener());

Expand Down Expand Up @@ -190,11 +175,11 @@ private void addSeriesCheckBoxes() {
panel.add(createDataSeriesCheckboxes());
if (includeSynthetic) {
panel.add(createDerivedSeriesCheckboxes());
JPanel userPanel = createUserDefinedSeriesCheckboxes();
if (userPanel != null) {
panel.add(userPanel);
}
}
JPanel userPanel = createUserDefinedSeriesCheckboxes();
if (userPanel != null) {
panel.add(userPanel);
}
this.add(panel);
}

Expand Down Expand Up @@ -462,11 +447,15 @@ public void actionPerformed(ActionEvent e) {
for (JCheckBox checkBox : checkBoxes) {
if (checkBox.isEnabled()) {
checkBox.setSelected(target);
updateSeriesVisibilityMap(checkBox);
if (modifyVisibility) {
updateSeriesVisibilityMap(checkBox);
}
}
}

seriesVisibilityChange(getVisibilityDeltaMap());
if (modifyVisibility) {
seriesVisibilityChange(getVisibilityDeltaMap());
}
}
};
}
Expand Down
Loading

0 comments on commit 4a383ba

Please sign in to comment.