本文整理汇总了Java中javafx.scene.text.Text.setLayoutX方法的典型用法代码示例。如果您正苦于以下问题:Java Text.setLayoutX方法的具体用法?Java Text.setLayoutX怎么用?Java Text.setLayoutX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.text.Text
的用法示例。
在下文中一共展示了Text.setLayoutX方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createIconContent
import javafx.scene.text.Text; //导入方法依赖的package包/类
public static Node createIconContent() {
Text htmlStart = new Text("<html>");
Text htmlEnd = new Text("</html>");
htmlStart.setFont(Font.font(null, FontWeight.BOLD, 20));
htmlStart.setStyle("-fx-font-size: 20px;");
htmlStart.setTextOrigin(VPos.TOP);
htmlStart.setLayoutY(11);
htmlStart.setLayoutX(20);
htmlEnd.setFont(Font.font(null, FontWeight.BOLD, 20));
htmlEnd.setStyle("-fx-font-size: 20px;");
htmlEnd.setTextOrigin(VPos.TOP);
htmlEnd.setLayoutY(31);
htmlEnd.setLayoutX(20);
return new Group(htmlStart, htmlEnd);
}
示例2: createIconContent
import javafx.scene.text.Text; //导入方法依赖的package包/类
public static Node createIconContent() {
Text text = new Text("abc");
text.setTextOrigin(VPos.TOP);
text.setLayoutX(10);
text.setLayoutY(11);
text.setFill(Color.BLACK);
text.setOpacity(0.5);
text.setFont(Font.font(null, FontWeight.BOLD, 20));
text.setStyle("-fx-font-size: 20px;");
Text text2 = new Text("abc");
text2.setTextOrigin(VPos.TOP);
text2.setLayoutX(28);
text2.setLayoutY(51);
text2.setFill(Color.BLACK);
text2.setFont(javafx.scene.text.Font.font(null, FontWeight.BOLD, 20));
text2.setStyle("-fx-font-size: 20px;");
Line line = new Line(30, 32, 45, 57);
line.setStroke(Color.DARKMAGENTA);
return new javafx.scene.Group(text, line, text2);
}
示例3: createNumber
import javafx.scene.text.Text; //导入方法依赖的package包/类
private Text createNumber(String number, double layoutX, double layoutY) {
Text text = new Text(number);
text.setLayoutX(layoutX);
text.setLayoutY(layoutY);
text.setTextAlignment(TextAlignment.CENTER);
text.setFill(FILL_COLOR);
text.setFont(NUMBER_FONT);
return text;
}
示例4: createDot
import javafx.scene.text.Text; //导入方法依赖的package包/类
private Text createDot(String string) {
Text text = new Text(string);
text.setFill(Color.web("#000000"));
text.setFont(FONT);
text.setTextOrigin(VPos.TOP);
text.setLayoutX(1);
text.setLayoutY(-4);
return text;
}
示例5: MyEnsembleNode
import javafx.scene.text.Text; //导入方法依赖的package包/类
public MyEnsembleNode(String name) {
text = new Text(name);
text.setTextOrigin(VPos.TOP);
text.setLayoutX(4);
text.setLayoutY(2);
rectangle = new Rectangle(50, 20, Color.WHITESMOKE);
rectangle.setStroke(Color.BLACK);
//add nodes as childrens, order matters, first is on the bottom
getChildren().addAll(rectangle, text);
}
示例6: createIconContent
import javafx.scene.text.Text; //导入方法依赖的package包/类
public static Node createIconContent() {
MyEnsembleNode myNode = new MyEnsembleNode("MyNode");
myNode.setLayoutY(50);
MyEnsembleNode parent = new MyEnsembleNode("Parent");
Polygon arrow = createUMLArrow();
arrow.setLayoutY(20);
arrow.setLayoutX(25-7.5);
Text text = new Text("<<extends>>");
text.setTextOrigin(VPos.TOP);
text.setLayoutY(31);
text.setLayoutX(30);
return new Group(parent, arrow, text, myNode);
}
示例7: WelcomeScene
import javafx.scene.text.Text; //导入方法依赖的package包/类
public WelcomeScene(PongApplication application) throws NullPointerException {
super(new Group(), RESOLUTION_WIDTH, RESOLUTION_HEIGHT);
requireNonNull(application, "The application cannot be null!");
topicText = new Text("JavaFX Pong");
topicText.setTextOrigin(VPos.CENTER);
topicText.setFont(BIG_FONT);
topicText.setLayoutX((RESOLUTION_WIDTH - topicText.prefWidth(-1)) / 2);
topicText.setLayoutY(RESOLUTION_HEIGHT / 6);
topicText.setFill(Color.WHITE);
leftControlsTopicText = new Text("Controls for the left player:");
leftControlsTopicText.setTextOrigin(VPos.CENTER);
leftControlsTopicText.setFont(SMALL_FONT);
leftControlsTopicText.setLayoutX((RESOLUTION_WIDTH - leftControlsTopicText.prefWidth(-1)) / 2);
leftControlsTopicText.setLayoutY(topicText.getLayoutY() + 100);
leftControlsTopicText.setFill(Color.WHITE);
leftControlsText = new Text("W and S");
leftControlsText.setTextOrigin(VPos.CENTER);
leftControlsText.setFont(SMALL_FONT);
leftControlsText.setLayoutX((RESOLUTION_WIDTH - leftControlsText.prefWidth(-1)) / 2);
leftControlsText.setLayoutY(leftControlsTopicText.getLayoutY() + 40);
leftControlsText.setFill(Color.WHITE);
rightControlsTopicText = new Text("Controls for the right player:");
rightControlsTopicText.setTextOrigin(VPos.CENTER);
rightControlsTopicText.setFont(SMALL_FONT);
rightControlsTopicText.setLayoutX((RESOLUTION_WIDTH - rightControlsTopicText.prefWidth(-1)) / 2);
rightControlsTopicText.setLayoutY(leftControlsText.getLayoutY() + 60);
rightControlsTopicText.setFill(Color.WHITE);
rightControlsText = new Text("UP-ARROW and DOWN-ARROW");
rightControlsText.setTextOrigin(VPos.CENTER);
rightControlsText.setFont(SMALL_FONT);
rightControlsText.setLayoutX((RESOLUTION_WIDTH - rightControlsText.prefWidth(-1)) / 2);
rightControlsText.setLayoutY(rightControlsTopicText.getLayoutY() + 40);
rightControlsText.setFill(Color.WHITE);
proceedInstructionsText = new Text("Press [ENTER] to start the match");
proceedInstructionsText.setTextOrigin(VPos.CENTER);
proceedInstructionsText.setFont(SMALL_FONT);
proceedInstructionsText.setLayoutX((RESOLUTION_WIDTH - proceedInstructionsText.prefWidth(-1)) / 2);
proceedInstructionsText.setLayoutY(rightControlsTopicText.getLayoutY() + 160);
proceedInstructionsText.setFill(Color.WHITE);
Parent root = getRoot();
if (!(root instanceof Group)) {
throw new AssertionError("The scene root is not a Group instance!");
}
Group rootGroup = (Group) root;
ObservableList<Node> children = rootGroup.getChildren();
children.add(topicText);
children.add(leftControlsTopicText);
children.add(leftControlsText);
children.add(rightControlsTopicText);
children.add(rightControlsText);
children.add(proceedInstructionsText);
setOnKeyReleased(x -> {
if (x.getCode() == KeyCode.ENTER) {
// move into the court scene so we can start the game.
Stage primaryStage = application.getPrimaryStage();
primaryStage.setScene(new CourtScene(application));
}
});
setFill(Color.BLACK);
}
示例8: EndGameScene
import javafx.scene.text.Text; //导入方法依赖的package包/类
public EndGameScene(PongApplication application) throws NullPointerException {
super(new Group(), RESOLUTION_WIDTH, RESOLUTION_HEIGHT);
requireNonNull(application, "The application cannot be null!");
// get player scores from the session context.
PongContext ctx = requireNonNull(application.getContext(), "The context cannot be null!");
int p1Score = ctx.getPlayer1Score();
int p2Score = ctx.getPlayer2Score();
topicText = new Text("JavaFX Pong - Results");
topicText.setTextOrigin(VPos.CENTER);
topicText.setFont(BIG_FONT);
topicText.setLayoutX((RESOLUTION_WIDTH - topicText.prefWidth(-1)) / 2);
topicText.setLayoutY(RESOLUTION_HEIGHT / 6);
topicText.setFill(Color.WHITE);
gameHasEndedText = new Text("Game has ended");
gameHasEndedText.setTextOrigin(VPos.CENTER);
gameHasEndedText.setFont(SMALL_FONT);
gameHasEndedText.setLayoutX((RESOLUTION_WIDTH - gameHasEndedText.prefWidth(-1)) / 2);
gameHasEndedText.setLayoutY(topicText.getLayoutY() + 100);
gameHasEndedText.setFill(Color.WHITE);
winnerText = new Text((p1Score > p2Score ? "Right" : "Left") + " player won the game!");
winnerText.setTextOrigin(VPos.CENTER);
winnerText.setFont(SMALL_FONT);
winnerText.setLayoutX((RESOLUTION_WIDTH - winnerText.prefWidth(-1)) / 2);
winnerText.setLayoutY(gameHasEndedText.getLayoutY() + 40);
winnerText.setFill(Color.WHITE);
resultsTopicText = new Text("End results:");
resultsTopicText.setTextOrigin(VPos.CENTER);
resultsTopicText.setFont(SMALL_FONT);
resultsTopicText.setLayoutX((RESOLUTION_WIDTH - resultsTopicText.prefWidth(-1)) / 2);
resultsTopicText.setLayoutY(winnerText.getLayoutY() + 40);
resultsTopicText.setFill(Color.WHITE);
resultsText = new Text("" + ctx.getPlayer2Score() + " - " + ctx.getPlayer1Score());
resultsText.setTextOrigin(VPos.CENTER);
resultsText.setFont(SMALL_FONT);
resultsText.setLayoutX((RESOLUTION_WIDTH - resultsText.prefWidth(-1)) / 2);
resultsText.setLayoutY(resultsTopicText.getLayoutY() + 40);
resultsText.setFill(Color.WHITE);
proceedInstructionsText = new Text("Press [ENTER] to proceed");
proceedInstructionsText.setTextOrigin(VPos.CENTER);
proceedInstructionsText.setFont(SMALL_FONT);
proceedInstructionsText.setLayoutX((RESOLUTION_WIDTH - proceedInstructionsText.prefWidth(-1)) / 2);
proceedInstructionsText.setLayoutY(resultsText.getLayoutY() + 160);
proceedInstructionsText.setFill(Color.WHITE);
Parent root = getRoot();
if (!(root instanceof Group)) {
throw new AssertionError("The scene root is not a Group instance!");
}
Group rootGroup = (Group) root;
ObservableList<Node> children = rootGroup.getChildren();
children.add(topicText);
children.add(gameHasEndedText);
children.add(winnerText);
children.add(resultsTopicText);
children.add(resultsText);
children.add(proceedInstructionsText);
setOnKeyReleased(x -> {
if (x.getCode() == KeyCode.ENTER) {
// reset the game state and move into the welcoming scene.
ctx.reset();
Stage primaryStage = application.getPrimaryStage();
primaryStage.setScene(new WelcomeScene(application));
}
});
setFill(Color.BLACK);
}