本文整理汇总了Java中javafx.scene.text.Text.setTextOrigin方法的典型用法代码示例。如果您正苦于以下问题:Java Text.setTextOrigin方法的具体用法?Java Text.setTextOrigin怎么用?Java Text.setTextOrigin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.text.Text
的用法示例。
在下文中一共展示了Text.setTextOrigin方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLetter
import javafx.scene.text.Text; //导入方法依赖的package包/类
private void createLetter(String c) {
final Text letter = new Text(c);
letter.setFill(Color.BLACK);
letter.setFont(FONT_DEFAULT);
letter.setTextOrigin(VPos.TOP);
letter.setTranslateX((getWidth() - letter.getBoundsInLocal().getWidth()) / 2);
letter.setTranslateY((getHeight() - letter.getBoundsInLocal().getHeight()) / 2);
getChildren().add(letter);
// over 3 seconds move letter to random position and fade it out
final Timeline timeline = new Timeline();
timeline.getKeyFrames().add(
new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
// we are done remove us from scene
getChildren().remove(letter);
}
},
new KeyValue(letter.translateXProperty(), getRandom(0.0f, getWidth() - letter.getBoundsInLocal().getWidth()),INTERPOLATOR),
new KeyValue(letter.translateYProperty(), getRandom(0.0f, getHeight() - letter.getBoundsInLocal().getHeight()),INTERPOLATOR),
new KeyValue(letter.opacityProperty(), 0f)
));
timeline.play();
}
示例2: 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);
}
示例3: 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);
}
示例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: LettersPane
import javafx.scene.text.Text; //导入方法依赖的package包/类
public LettersPane() {
setId("LettersPane");
setPrefSize(480,480);
setFocusTraversable(true);
setOnMousePressed(new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent me) {
requestFocus();
me.consume();
}
});
setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override public void handle(KeyEvent ke) {
createLetter(ke.getText());
ke.consume();
}
});
// create press keys text
pressText = new Text("Press Keys");
pressText.setTextOrigin(VPos.TOP);
pressText.setFont(new Font(Font.getDefault().getFamily(), 40));
pressText.setLayoutY(5);
pressText.setFill(Color.rgb(80, 80, 80));
DropShadow effect = new DropShadow();
effect.setRadius(0);
effect.setOffsetY(1);
effect.setColor(Color.WHITE);
pressText.setEffect(effect);
getChildren().add(pressText);
}
示例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: 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);
}
示例8: initGraphics
import javafx.scene.text.Text; //导入方法依赖的package包/类
private void initGraphics() {
background = new Region();
background.getStyleClass().setAll("background");
frame = new Region();
frame.getStyleClass().setAll("frame");
frame.setStyle(getSkinnable().getAlarmed() ? "-fx-background-color: -warning-color" : "-fx-background-color: -frame-color");
warningIcon = new Region();
warningIcon.getStyleClass().setAll("warning-icon");
warningIcon.setOpacity(getSkinnable().getAlarmed() ? 1 : 0);
currentValueText = new Text(getSkinnable().getCurrentText());
currentValueText.getStyleClass().setAll("text");
currentValueText.setTextOrigin(VPos.BOTTOM);
currentValueText.setFill(getSkinnable().getTextFill());
unitText = new Text(getSkinnable().getUnit());
unitText.getStyleClass().setAll("text");
unitText.setOpacity(getSkinnable().getUnitVisible() ? 1 : 0);
unitText.setFill(getSkinnable().getTextFill());
unitText.setVisible(getSkinnable().getAlarmed());
titleText = new Text(getSkinnable().getTitle());
titleText.getStyleClass().setAll("text");
titleText.setFill(getSkinnable().getTextFill());
pane = new Pane();
pane.getChildren().setAll(background, frame, warningIcon, currentValueText, unitText, titleText);
getChildren().setAll(pane);
resize();
updateDisplay();
}
示例9: initInfoPanel
import javafx.scene.text.Text; //导入方法依赖的package包/类
private void initInfoPanel() {
infoPanel = new Group();
roundCaption = new Text();
roundCaption.setText("ROUND");
roundCaption.setTextOrigin(VPos.TOP);
roundCaption.setFill(Color.rgb(51, 102, 51));
Font f = new Font("Impact", 18);
roundCaption.setFont(f);
roundCaption.setTranslateX(30);
roundCaption.setTranslateY(128);
round = new Text();
round.setTranslateX(roundCaption.getTranslateX() +
roundCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
round.setTranslateY(roundCaption.getTranslateY());
round.setText(levelNumber + "");
round.setTextOrigin(VPos.TOP);
round.setFont(f);
round.setFill(Color.rgb(0, 204, 102));
scoreCaption = new Text();
scoreCaption.setText("SCORE");
scoreCaption.setFill(Color.rgb(51, 102, 51));
scoreCaption.setTranslateX(30);
scoreCaption.setTranslateY(164);
scoreCaption.setTextOrigin(VPos.TOP);
scoreCaption.setFont(f);
score = new Text();
score.setTranslateX(scoreCaption.getTranslateX() +
scoreCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
score.setTranslateY(scoreCaption.getTranslateY());
score.setFill(Color.rgb(0, 204, 102));
score.setTextOrigin(VPos.TOP);
score.setFont(f);
score.setText("");
livesCaption = new Text();
livesCaption.setText("LIFE");
livesCaption.setTranslateX(30);
livesCaption.setTranslateY(200);
livesCaption.setFill(Color.rgb(51, 102, 51));
livesCaption.setTextOrigin(VPos.TOP);
livesCaption.setFont(f);
Color INFO_LEGEND_COLOR = Color.rgb(0, 114, 188);
int infoWidth = Config.SCREEN_WIDTH - Config.FIELD_WIDTH;
Rectangle black = new Rectangle();
black.setWidth(infoWidth);
black.setHeight(Config.SCREEN_HEIGHT);
black.setFill(Color.BLACK);
ImageView verLine = new ImageView();
verLine.setImage(new Image(Level.class.getResourceAsStream(Config.IMAGE_DIR+"vline.png")));
verLine.setTranslateX(3);
ImageView logo = new ImageView();
logo.setImage(Config.getImages().get(Config.IMAGE_LOGO));
logo.setTranslateX(30);
logo.setTranslateY(30);
Text legend = new Text();
legend.setTranslateX(30);
legend.setTranslateY(310);
legend.setText("LEGEND");
legend.setFill(INFO_LEGEND_COLOR);
legend.setTextOrigin(VPos.TOP);
legend.setFont(new Font("Impact", 18));
infoPanel.getChildren().addAll(black, verLine, logo, roundCaption,
round, scoreCaption, score, livesCaption, legend);
for (int i = 0; i < Bonus.COUNT; i++) {
Bonus bonus = new Bonus(i);
Text text = new Text();
text.setTranslateX(100);
text.setTranslateY(350 + i * 40);
text.setText(Bonus.NAMES[i]);
text.setFill(INFO_LEGEND_COLOR);
text.setTextOrigin(VPos.TOP);
text.setFont(new Font("Arial", 12));
bonus.setTranslateX(30 + (820 - 750 - bonus.getWidth()) / 2);
bonus.setTranslateY(text.getTranslateY() -
(bonus.getHeight() - text.getBoundsInLocal().getHeight()) / 2);
// Workaround JFXC-2379
infoPanel.getChildren().addAll(bonus, text);
}
infoPanel.setTranslateX(Config.FIELD_WIDTH);
}
示例10: 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);
}