use of org.controlsfx.control.RangeSlider in project Smartcity-Smarthouse by TechnionYP5777.
the class Controller method initialize.
@Override
public void initialize(final URL location, final ResourceBundle __) {
sensor = new VitalsSensor(Random.sensorId(), 40001);
for (boolean res = false; !res; ) res = sensor.register();
pulseLabelSensor.setDisable(false);
bpLabelSensor.setDisable(false);
bpRSlider = new RangeSlider(0, 200, 80, 120);
mainVBox.getChildren().add(4, bpRSlider);
pulseSlider.valueProperty().addListener((ov, oldVal, newVal) -> {
if (Math.round(oldVal.doubleValue()) == Math.round(newVal.doubleValue()))
return;
final int pulse = (int) Math.round(newVal.doubleValue());
pulseLabelSensor.setText("Pulse: " + pulse);
sensor.updateSystem(pulse, (int) Math.round(bpRSlider.getHighValue()), (int) Math.round(bpRSlider.getLowValue()));
printUpdateMessage();
});
bpRSlider.lowValueProperty().addListener((ov, oldVal, newVal) -> {
if (Math.round(oldVal.doubleValue()) == Math.round(newVal.doubleValue()))
return;
final int diastolicBP = (int) Math.round(newVal.doubleValue());
bpLabelSensor.setText("Blood Pressure: " + (int) Math.round(bpRSlider.getHighValue()) + "/" + diastolicBP);
sensor.updateSystem((int) Math.round(pulseSlider.getValue()), (int) Math.round(bpRSlider.getHighValue()), diastolicBP);
printUpdateMessage();
});
bpRSlider.highValueProperty().addListener((ov, oldVal, newVal) -> {
if (Math.round(oldVal.doubleValue()) == Math.round(newVal.doubleValue()))
return;
final int systolicBP = (int) Math.round(newVal.doubleValue());
bpLabelSensor.setText("Blood Pressure: " + systolicBP + "/" + (int) Math.round(bpRSlider.getLowValue()));
sensor.updateSystem((int) Math.round(pulseSlider.getValue()), systolicBP, (int) Math.round(bpRSlider.getLowValue()));
printUpdateMessage();
});
}
use of org.controlsfx.control.RangeSlider in project Smartcity-Smarthouse by TechnionYP5777.
the class VitalsGuiTest method testVitalsSensor.
@Test
public void testVitalsSensor() throws Exception {
click("#appsTab");
ListView<String> l = find("#listView");
assert l.getItems().isEmpty();
installAppOnSystem(VitalsApp.class);
assertEquals(l.getItems().size(), 1);
click("Vitals Application");
Slider pulseSlider = find("#pulseSlider");
Stage stage1 = (Stage) find("#pulseLabelSensor").getScene().getWindow();
try {
FXTestUtils.bringToFront(stage1);
} catch (Exception e) {
log.error("Unable to show stage", e);
}
click("#pulseSlider");
moveBy(15, 0);
click();
int pulse = (int) Math.round(pulseSlider.getValue());
assertEquals("Pulse: " + pulse, ((Label) find("#pulseLabelSensor")).getText());
assertEquals("Pulse: " + pulse, ((Label) find("#pulseLabel")).getText());
VBox mainVBox = (VBox) find("#mainVBox");
RangeSlider bpRSlider = (RangeSlider) mainVBox.getChildren().get(4);
click(bpRSlider);
moveBy(70, 0);
click();
int systolicBP = (int) Math.round(bpRSlider.getHighValue());
moveBy(-140, 0);
click();
int diastolicBP = (int) Math.round(bpRSlider.getLowValue());
assertEquals("Blood Pressure: " + systolicBP + "/" + diastolicBP, ((Label) find("#bpLabelSensor")).getText());
assertEquals("Blood Pressure: " + systolicBP + "/" + diastolicBP, ((Label) find("#bpLabel")).getText());
TextFlow console = (TextFlow) find("#console");
assertEquals(Integer.valueOf(pulse), Integer.valueOf(((Text) console.getChildren().get(1)).getText()));
assertEquals(Integer.valueOf(systolicBP), Integer.valueOf(((Text) console.getChildren().get(3)).getText()));
assertEquals(Integer.valueOf(diastolicBP), Integer.valueOf(((Text) console.getChildren().get(5)).getText()));
}
Aggregations