use of javafx.scene.text.TextFlow 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()));
}
use of javafx.scene.text.TextFlow in project fx2048 by brunoborges.
the class Board method initGameProperties.
private void initGameProperties() {
overlay.setMinSize(gridWidth, gridWidth);
overlay.setAlignment(Pos.CENTER);
overlay.setTranslateY(TOP_HEIGHT + GAP_HEIGHT);
overlay.getChildren().setAll(txtOverlay);
txtOverlay.setAlignment(Pos.CENTER);
buttonsOverlay.setAlignment(Pos.CENTER);
buttonsOverlay.setTranslateY(TOP_HEIGHT + GAP_HEIGHT + gridWidth / 2);
buttonsOverlay.setMinSize(gridWidth, gridWidth / 2);
buttonsOverlay.setSpacing(10);
bTry.getStyleClass().add("game-button");
bTry.setOnTouchPressed(e -> btnTryAgain());
bTry.setOnAction(e -> btnTryAgain());
bTry.setOnKeyPressed(e -> {
if (e.getCode().equals(KeyCode.ENTER) || e.getCode().equals(KeyCode.SPACE)) {
btnTryAgain();
}
});
bContinue.getStyleClass().add("game-button");
bContinue.setOnTouchPressed(e -> keepGoing());
bContinue.setOnMouseClicked(e -> keepGoing());
bContinue.setOnKeyPressed(e -> {
if (e.getCode().equals(KeyCode.ENTER) || e.getCode().equals(KeyCode.SPACE)) {
keepGoing();
}
});
bContinueNo.getStyleClass().add("game-button");
bContinueNo.setOnTouchPressed(e -> keepGoing());
bContinueNo.setOnMouseClicked(e -> keepGoing());
bContinueNo.setOnKeyPressed(e -> {
if (e.getCode().equals(KeyCode.ENTER) || e.getCode().equals(KeyCode.SPACE)) {
keepGoing();
}
});
bSave.getStyleClass().add("game-button");
bSave.setOnTouchPressed(e -> saveGame.set(true));
bSave.setOnMouseClicked(e -> saveGame.set(true));
bSave.setOnKeyPressed(e -> {
if (e.getCode().equals(KeyCode.ENTER) || e.getCode().equals(KeyCode.SPACE)) {
saveGame.set(true);
}
});
bRestore.getStyleClass().add("game-button");
bRestore.setOnTouchPressed(e -> restoreGame.set(true));
bRestore.setOnMouseClicked(e -> restoreGame.set(true));
bRestore.setOnKeyPressed(e -> {
if (e.getCode().equals(KeyCode.ENTER) || e.getCode().equals(KeyCode.SPACE)) {
restoreGame.set(true);
}
});
bQuit.getStyleClass().add("game-button");
bQuit.setOnTouchPressed(e -> quit());
bQuit.setOnMouseClicked(e -> quit());
bQuit.setOnKeyPressed(e -> {
if (e.getCode().equals(KeyCode.ENTER) || e.getCode().equals(KeyCode.SPACE)) {
quit();
}
});
timerPause = new Timeline(new KeyFrame(Duration.seconds(1), e -> time = time.plusNanos(1_000_000_000)));
timerPause.setCycleCount(Animation.INDEFINITE);
gameWonProperty.addListener(wonListener);
gameOverProperty.addListener(new Overlay("Game over!", "", bTry, null, "game-overlay-over", "game-lblOver", false));
gamePauseProperty.addListener(new Overlay("Game Paused", "", bContinue, null, "game-overlay-pause", "game-lblPause", true));
gameTryAgainProperty.addListener(new Overlay("Try Again?", "Current game will be deleted", bTry, bContinueNo, "game-overlay-pause", "game-lblPause", true));
gameSaveProperty.addListener(new Overlay("Save?", "Previous saved data will be overwritten", bSave, bContinueNo, "game-overlay-pause", "game-lblPause", true));
gameRestoreProperty.addListener(new Overlay("Restore?", "Current game will be deleted", bRestore, bContinueNo, "game-overlay-pause", "game-lblPause", true));
gameAboutProperty.addListener((observable, oldValue, newValue) -> {
if (newValue) {
timer.stop();
timerPause.play();
overlay.getStyleClass().setAll("game-overlay", "game-overlay-quit");
TextFlow flow = new TextFlow();
flow.setTextAlignment(TextAlignment.CENTER);
flow.setPadding(new Insets(10, 0, 0, 0));
flow.setMinSize(gridWidth, gridWidth);
flow.setPrefSize(gridWidth, gridWidth);
flow.setMaxSize(gridWidth, gridWidth);
flow.setPrefSize(BASELINE_OFFSET_SAME_AS_HEIGHT, BASELINE_OFFSET_SAME_AS_HEIGHT);
Text t00 = new Text("2048");
t00.getStyleClass().setAll("game-label", "game-lblAbout");
Text t01 = new Text("FX");
t01.getStyleClass().setAll("game-label", "game-lblAbout2");
Text t02 = new Text(" Game\n");
t02.getStyleClass().setAll("game-label", "game-lblAbout");
Text t1 = new Text("JavaFX game - Desktop version\n\n");
t1.getStyleClass().setAll("game-label", "game-lblAboutSub");
Text t20 = new Text("Powered by ");
t20.getStyleClass().setAll("game-label", "game-lblAboutSub");
Hyperlink link1 = new Hyperlink();
link1.setText("JavaFXPorts");
link1.setOnAction(e -> hostServices.showDocument("http://javafxports.org/page/home"));
link1.getStyleClass().setAll("game-label", "game-lblAboutSub2");
Text t21 = new Text(" Project \n\n");
t21.getStyleClass().setAll("game-label", "game-lblAboutSub");
Text t23 = new Text("© ");
t23.getStyleClass().setAll("game-label", "game-lblAboutSub");
Hyperlink link2 = new Hyperlink();
link2.setText("@JPeredaDnr");
link2.setOnAction(e -> hostServices.showDocument("https://twitter.com/JPeredaDnr"));
link2.getStyleClass().setAll("game-label", "game-lblAboutSub2");
Text t22 = new Text(" & ");
t22.getStyleClass().setAll("game-label", "game-lblAboutSub");
Hyperlink link3 = new Hyperlink();
link3.setText("@brunoborges");
link3.setOnAction(e -> hostServices.showDocument("https://twitter.com/brunoborges"));
Text t32 = new Text(" & ");
t32.getStyleClass().setAll("game-label", "game-lblAboutSub");
link3.getStyleClass().setAll("game-label", "game-lblAboutSub2");
Text t24 = new Text("\n\n");
t24.getStyleClass().setAll("game-label", "game-lblAboutSub");
Text t31 = new Text(" Version " + Game2048.VERSION + " - 2015\n\n");
t31.getStyleClass().setAll("game-label", "game-lblAboutSub");
flow.getChildren().setAll(t00, t01, t02, t1, t20, link1, t21, t23, link2, t22, link3);
flow.getChildren().addAll(t24, t31);
txtOverlay.getChildren().setAll(flow);
buttonsOverlay.getChildren().setAll(bContinue);
this.getChildren().removeAll(overlay, buttonsOverlay);
this.getChildren().addAll(overlay, buttonsOverlay);
layerOnProperty.set(true);
}
});
gameQuitProperty.addListener(new Overlay("Quit Game?", "Non saved data will be lost", bQuit, bContinueNo, "game-overlay-quit", "game-lblQuit", true));
restoreRecord();
gameScoreProperty.addListener((ov, i, i1) -> {
if (i1.intValue() > gameBestProperty.get()) {
gameBestProperty.set(i1.intValue());
}
});
layerOnProperty.addListener((ov, b, b1) -> {
if (!b1) {
getChildren().removeAll(overlay, buttonsOverlay);
// Keep the focus on the game when the layer is removed:
getParent().requestFocus();
} else if (b1) {
// Set focus on the first button
buttonsOverlay.getChildren().get(0).requestFocus();
}
});
}
Aggregations