Skip to content

Commit

Permalink
Fixed the "center" spinner in the discrete panel: now updates as it s…
Browse files Browse the repository at this point in the history
…hould.
  • Loading branch information
carsonalh committed Jun 15, 2019
1 parent 2c65e40 commit c932713
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/gui/discrete/DiscreteSettings.java
Expand Up @@ -54,7 +54,7 @@ public DiscreteSettings() {
rangeStartSpinner.setModel(new SpinnerNumberModel(0, 0, 1e7, .1));
rangeStrideSpinner.setModel(new SpinnerNumberModel(1, 0, 1e7, .1));
sigmaXSpinner.setModel(new SpinnerNumberModel(1, 0, 1e7, .1));
centerSpinner.setModel(new DynamicSpinnerNumberModel<Double>(0.0, 0.0, 10.0, 0.01));
centerSpinner.setModel(new DynamicSpinnerNumberModel<Double>(0.0, 0.0, 10.0, 0.1));

// Set the spinners to the default values
DiscreteGenerator g = new DiscreteGenerator();
Expand Down
6 changes: 3 additions & 3 deletions src/gui/discrete/DynamicSpinnerNumberModel.java
Expand Up @@ -30,10 +30,10 @@ private boolean inRange(T number) {

tempMin = this.minimumValue.doubleValue();
tempMax = this.maximumValue.doubleValue();
tempOther = value.doubleValue();
tempOther = number.doubleValue();

// The new value is between the range
return tempMin < tempOther && tempOther < tempMax;
return tempMin <= tempOther && tempOther <= tempMax;
}

@Override
Expand All @@ -43,7 +43,7 @@ public Object getValue() {

@Override
public void setValue(Object value) {
if (inRange((T) value)) {
if (inRange((T) value) && !((T) value).equals(this.value)) {
this.value = (T) value;

fireChangeListeners();
Expand Down
2 changes: 2 additions & 0 deletions src/gui/discrete/MainPanel.java
Expand Up @@ -86,6 +86,8 @@ private void updateGraph(DiscreteSettings.SettingsData data) {
generator.setCenter(data.center);
generator.setCount(data.count);

updateCenter(generator);

this.data = generator.genData();
discreteGraph.setData(this.data);
}
Expand Down

0 comments on commit c932713

Please sign in to comment.