當前位置: 首頁>>代碼示例>>Java>>正文


Java Text.setTextOrigin方法代碼示例

本文整理匯總了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();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:KeyStrokeMotion.java

示例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);
    }
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:19,代碼來源:HTMLEditorSample.java

示例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);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:24,代碼來源:StringBindingSample.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:StopWatch.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:KeyStrokeMotion.java

示例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);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:14,代碼來源:CustomNodeSample.java

示例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);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:11,代碼來源:CustomNodeSample.java

示例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();
}
 
開發者ID:assemblits,項目名稱:dynamo,代碼行數:35,代碼來源:DisplaySkin.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:80,代碼來源:Level.java

示例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);
}
 
開發者ID:toivjon,項目名稱:javafx-pong,代碼行數:72,代碼來源:WelcomeScene.java


注:本文中的javafx.scene.text.Text.setTextOrigin方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。