Skip to content

Commit 1116646

Browse files
committed
Merge pull request #224 from ThomasJClark/master
Correctly load range values
2 parents 14c3900 + ca924ea commit 1116646

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

ui/src/main/java/edu/wpi/grip/ui/pipeline/input/RangeInputSocketView.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public RangeInputSocketView(EventBus eventBus, InputSocket<List<Number>> socket)
2828
super(eventBus, socket);
2929

3030
final Object[] domain = socket.getSocketHint().getDomain().get();
31-
final List<Number> value = socket.getValue().get();
31+
final List<Number> initialValue = socket.getValue().get();
3232

3333
checkArgument(domain.length == 1 && domain[0] instanceof List,
3434
"Sliders must have a domain with a list of two numbers (min and max)");
@@ -38,12 +38,12 @@ public RangeInputSocketView(EventBus eventBus, InputSocket<List<Number>> socket)
3838
checkArgument(extremes.size() == 2 && extremes.get(0) instanceof Number && extremes.get(1) instanceof Number,
3939
"Sliders must have a domain with a list of two numbers (min and max)");
4040

41-
checkArgument(value.size() == 2, "Range sliders must contain two values (low and high)");
41+
checkArgument(initialValue.size() == 2, "Range sliders must contain two values (low and high)");
4242

4343
final double min = extremes.get(0).doubleValue();
4444
final double max = extremes.get(1).doubleValue();
45-
final double initialLow = value.get(0).doubleValue();
46-
final double initialHigh = value.get(1).doubleValue();
45+
final double initialLow = initialValue.get(0).doubleValue();
46+
final double initialHigh = initialValue.get(1).doubleValue();
4747

4848
this.slider = new RangeSlider(min, max, initialLow, initialHigh);
4949
this.slider.setShowTickMarks(true);
@@ -52,17 +52,18 @@ public RangeInputSocketView(EventBus eventBus, InputSocket<List<Number>> socket)
5252

5353
// Set the socket values whenever the range changes
5454
this.slider.lowValueProperty().addListener(o -> {
55-
value.set(0, this.slider.getLowValue());
56-
5755
// If the high value is also changing simultaneously, don't call setValue() twice
5856
if (!this.slider.isHighValueChanging()) {
59-
this.getSocket().setValue(value);
57+
List<Number> value = socket.getValue().get();
58+
value.set(0, slider.getLowValue());
59+
socket.setValue(value);
6060
}
6161
});
6262

6363
this.slider.highValueProperty().addListener(o -> {
64-
value.set(1, this.slider.getHighValue());
65-
this.getSocket().setValue(value);
64+
List<Number> range = socket.getValue().get();
65+
range.set(1, slider.getHighValue());
66+
socket.setValue(range);
6667
});
6768

6869
this.slider.disableProperty().bind(this.getHandle().connectedProperty());

0 commit comments

Comments
 (0)