Java Code Examples for javafx.scene.text.TextFlow#setPadding()

The following examples show how to use javafx.scene.text.TextFlow#setPadding() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TopicsGallery.java    From helloiot with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void updateItem(TopicInfoFactory item, boolean empty) {
    super.updateItem(item, empty);
    if (item == null) {
        setGraphic(null);
        setText(null);
    } else {                 
        Text t = IconBuilder.create(item.getGlyph(), 18.0).build();
        t.setFill(Color.WHITE);
        TextFlow tf = new TextFlow(t);
        tf.setTextAlignment(TextAlignment.CENTER);
        tf.setPadding(new Insets(5, 5, 5, 5));
        tf.setStyle("-fx-background-color: #505050; -fx-background-radius: 5px;");
        tf.setPrefWidth(30.0);    
        
        setGraphic(tf);
        setText(item.getTypeName());
    }
}
 
Example 2
Source File: TopicsTemplate.java    From helloiot with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void updateItem(TemplateInfo item, boolean empty) {
    super.updateItem(item, empty);
    if (item == null) {
        setGraphic(null);
        setText(null);
    } else {               
        Text t = IconBuilder.create(IconFontGlyph.valueOf(item.icon), 18.0).build();
        t.setFill(Color.WHITE);
        TextFlow tf = new TextFlow(t);
        tf.setTextAlignment(TextAlignment.CENTER);
        tf.setPadding(new Insets(5, 5, 5, 5));
        tf.setStyle("-fx-background-color: #505050; -fx-background-radius: 5px;");
        tf.setPrefWidth(30.0);      
        
        setGraphic(tf);
        setText(item.name);
    }
}
 
Example 3
Source File: ClientLoginNode.java    From helloiot with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void updateItem(TopicInfo item, boolean empty) {
    super.updateItem(item, empty);
    if (item == null) {
        setGraphic(null);
        setText(null);
    } else {
        Text t = IconBuilder.create(item.getFactory().getGlyph(), 18.0).build();
        t.setFill(Color.WHITE);
        TextFlow tf = new TextFlow(t);
        tf.setTextAlignment(TextAlignment.CENTER);
        tf.setPadding(new Insets(5, 5, 5, 5));
        tf.setStyle("-fx-background-color: #505050; -fx-background-radius: 5px;");
        tf.setPrefWidth(30.0);              
        setGraphic(tf);
        
        String label = item.getLabel().getValue();
        setText(item.getFactory().getTypeName() + ((label == null || label.isEmpty()) ? "" : " : " + label));
    }
}
 
Example 4
Source File: PluginOptionsControlItem.java    From DeskChan with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void init(MessageDataMap options, Object value) {
	scrollPane = new ScrollPane();
	area = new TextFlow(new Text(Main.getString("empty-text")));
	area.setPadding(new Insets(0, 5, 0, 5));
	scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
	scrollPane.setContent(area);
	scrollPane.setFitToWidth(true);

	area.prefHeightProperty().bind(scrollPane.heightProperty());
	area.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY)));
	setValue(value);
}
 
Example 5
Source File: Controller.java    From game-of-life-java with MIT License 5 votes vote down vote up
@FXML
private void onAbout(Event evt) {
    // TEXT //
    Text text1 = new Text("Conway's Game of Life\n");
    text1.setFont(Font.font(30));
    Text text2 = new Text(
            "\nThe Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.\n"
                    + "The game is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input. One interacts with the Game of Life by creating an initial configuration and observing how it evolves or, for advanced players, by creating patterns with particular properties."
            );
    Text text3 = new Text("\n\nRules\n");
    text3.setFont(Font.font(20));
    Text text4 = new Text(
            "\nThe universe of the Game of Life is a two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead. Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:\n"
                    +"\n1) Any live cell with fewer than two live neighbours dies, as if caused by under-population.\n"
                    +"2) Any live cell with two or three live neighbours lives on to the next generation.\n"
                    +"3) Any live cell with more than three live neighbours dies, as if by overcrowding.\n"
                    +"4) Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.\n\nMore on Wikipedia:\n"
            );

    Hyperlink link = new Hyperlink("http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life <-------not working");
    TextFlow tf = new TextFlow(text1,text2,text3,text4,link);
    tf.setPadding(new Insets(10, 10, 10, 10));
    tf.setTextAlignment(TextAlignment.JUSTIFY);
    // END TEXT, START WINDOW //
    final Stage dialog = new Stage();
    dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.initOwner(new Stage());
    VBox dialogVbox = new VBox(20);
    dialogVbox.getChildren().add(tf);
    Scene dialogScene = new Scene(dialogVbox, 450, 500);
    dialog.setScene(dialogScene);
    dialog.show();
    // END WINDOW //
}
 
Example 6
Source File: About.java    From Game2048FX with GNU General Public License v3.0 4 votes vote down vote up
public About() {
    
    HBox title = new HBox(10);
    title.setAlignment(Pos.CENTER_LEFT);
    title.getChildren().add(new ImageView());
    title.getChildren().add(new Label("About the App"));
    
    Dialog<ButtonType> dialog = new Dialog<>();
    
    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 - " + Platform.getCurrent().name() + " version\n\n");
    t1.getStyleClass().setAll("game-label", "game-lblAboutSub");
    Text t20 = new Text("Powered by ");
    t20.getStyleClass().setAll("game-label", "game-lblAboutSub");
    Hyperlink link11 = new Hyperlink();
    link11.setText("JavaFXPorts");
    link11.setOnAction(e -> browse("http://gluonhq.com/open-source/javafxports/"));
    link11.getStyleClass().setAll("game-label", "game-lblAboutSub2");
    Text t210 = new Text(" & ");
    t210.getStyleClass().setAll("game-label", "game-lblAboutSub");
    Hyperlink link12 = new Hyperlink();
    link12.setText("Gluon Mobile");
    link12.setOnAction(e -> browse("https://gluonhq.com/products/mobile/"));
    link12.getStyleClass().setAll("game-label", "game-lblAboutSub2");
    Text t21 = new Text(" Projects \n\n");
    t21.getStyleClass().setAll("game-label", "game-lblAboutSub");
    Text t23 = new Text("\u00A9 ");
    t23.getStyleClass().setAll("game-label", "game-lblAboutSub");
    Hyperlink link2 = new Hyperlink();
    link2.setText("José Pereda");
    link2.setOnAction(e -> browse("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("Bruno Borges");
    link3.setOnAction(e -> browse("https://twitter.com/brunoborges"));
    Text t32 = new Text(" & ");
    t32.getStyleClass().setAll("game-label", "game-lblAboutSub");
    link3.getStyleClass().setAll("game-label", "game-lblAboutSub2");
    Hyperlink link4 = new Hyperlink();
    link4.setText("Jens Deters");
    link4.setOnAction(e -> browse("https://twitter.com/Jerady"));
    link4.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 + " - " + Year.now().toString() + "\n\n");
    t31.getStyleClass().setAll("game-label", "game-lblAboutSub");

    TextFlow flow = new TextFlow();
    flow.setTextAlignment(TextAlignment.CENTER);
    flow.setPadding(new Insets(10,0,0,0));

    flow.getChildren().setAll(t00, t01, t02, t1, t20, link11, t210, link12, t21, t23, link2, t22, link3);
    flow.getChildren().addAll(t32, link4);
    flow.getChildren().addAll(t24, t31);
    
    final ImageView imageView = new ImageView();
    imageView.getStyleClass().add("about");
    
    double scale = Services.get(DisplayService.class)
            .map(display -> {
                if (display.isTablet()) {
                    flow.setTranslateY(30);
                    return 1.3;
                } else {
                    flow.setTranslateY(25);
                    return 1.0;
                }
            })
            .orElse(1.0);
    
    imageView.setFitWidth(270 * scale);
    imageView.setFitHeight(270 * scale);
    imageView.setOpacity(0.1);
    
    dialog.setContent(new StackPane(imageView, flow));
    dialog.setTitle(title);
    
    Button yes = new Button("Accept");
    yes.setOnAction(e -> {
        dialog.setResult(ButtonType.YES); 
        dialog.hide();
    });
    yes.setDefaultButton(true);
    dialog.getButtons().addAll(yes);
    javafx.application.Platform.runLater(dialog::showAndWait);
}