Example usage for javafx.scene.text Text setTextAlignment

List of usage examples for javafx.scene.text Text setTextAlignment

Introduction

In this page you can find the example usage for javafx.scene.text Text setTextAlignment.

Prototype

public final void setTextAlignment(TextAlignment value) 

Source Link

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 150);
    stage.setScene(scene);//from  ww w . j  a va  2  s  . com
    stage.setTitle("Sample");

    Text t = new Text(10, 50, "This is a test");

    t.setTextAlignment(TextAlignment.JUSTIFY);
    t.setText("First row");
    t.setFont(new Font(20));

    root.getChildren().add(t);

    stage.show();
}

From source file:nars.rl.util.ThreeDView.java

public void addPoint(Object o, double radius, double x, double y, double z) {

    Term t = (Term) o;/*ww w.j a v  a 2  s . c o  m*/

    final PhongMaterial mat = new PhongMaterial();
    Color c = Color.hsb(255.0 * Video.hashFloat(o.toString().hashCode()), 0.75f, 0.85f);
    mat.setDiffuseColor(c);
    System.out.println(o.getClass());
    Sphere point = new Sphere(radius / t.complexity());
    point.setOpacity(0.85);
    point.setTranslateX(x);
    point.setTranslateY(y);
    point.setTranslateZ(z);
    point.setMaterial(mat);

    space.getChildren().add(point);

    Text text = new Text(o.toString());
    text.setFill(c);
    text.setFontSmoothingType(FontSmoothingType.LCD);
    text.setSmooth(true);
    text.setTextAlignment(TextAlignment.CENTER);
    text.setFont(font);
    /*
    text.setScaleX(0.05);
    text.setScaleY(0.05);
    text.setScaleZ(0.05);
    */
    text.setTranslateX(x);
    text.setTranslateY(y);
    text.setTranslateZ(z);
    space.getChildren().add(text);

}

From source file:org.pdfsam.ui.news.News.java

News(NewsData data) {
    this.getStyleClass().add("news-box");
    TextFlow flow = new TextFlow();
    if (data.isImportant()) {
        Text megaphone = GlyphsDude.createIcon(FontAwesomeIcon.BULLHORN, "1.2em");
        megaphone.getStyleClass().clear();
        megaphone.getStyleClass().add("news-box-title-important");
        flow.getChildren().addAll(megaphone, new Text(" "));
    }//from   ww w  .jav  a  2s .  c  o  m

    Text titleText = new Text(data.getTitle() + System.lineSeparator());
    titleText.setOnMouseClicked(e -> eventStudio().broadcast(new OpenUrlRequest(data.getLink())));
    titleText.getStyleClass().add("news-box-title");

    Text contentText = new Text(data.getContent());
    contentText.setTextAlignment(TextAlignment.JUSTIFY);
    contentText.getStyleClass().add("news-content");

    flow.getChildren().addAll(titleText, contentText);
    flow.setTextAlignment(TextAlignment.JUSTIFY);
    Label labelDate = new Label(FORMATTER.format(data.getDate()),
            GlyphsDude.createIcon(MaterialDesignIcon.CLOCK));
    labelDate.setPrefWidth(Integer.MAX_VALUE);
    HBox.setHgrow(labelDate, Priority.ALWAYS);
    HBox bottom = new HBox(labelDate);
    bottom.setAlignment(Pos.CENTER_LEFT);
    bottom.getStyleClass().add("news-box-footer");
    if (isNotBlank(data.getLink())) {
        Button link = UrlButton.urlButton(null, data.getLink(), FontAwesomeIcon.EXTERNAL_LINK_SQUARE,
                "pdfsam-toolbar-button");
        bottom.getChildren().add(link);
    }
    getChildren().addAll(flow, bottom);
}

From source file:org.sleuthkit.autopsy.timeline.ui.AbstractTimelineChart.java

/**
 * Add a Text Node to the specific label container for the decluttered axis
 * labels.//from ww  w  .  j  a  v a  2  s. c om
 *
 * @param labelText  The String to add.
 * @param labelWidth The width, in pixels, of the space available for the
 *                   text.
 * @param labelX     The horizontal position, in pixels, in the specificPane
 *                   of the text.
 * @param bold       True if the text should be bold, false otherwise.
 */
private synchronized void addSpecificLabel(String labelText, double labelWidth, double labelX, boolean bold) {
    Text label = new Text(" " + labelText + " "); //NON-NLS
    label.setTextAlignment(TextAlignment.CENTER);
    label.setFont(Font.font(null, bold ? FontWeight.BOLD : FontWeight.NORMAL, 10));
    //position label accounting for width
    label.relocate(labelX + labelWidth / 2 - label.getBoundsInLocal().getWidth() / 2, 0);
    label.autosize();

    if (specificLabelPane.getChildren().isEmpty()) {
        //just add first label
        specificLabelPane.getChildren().add(label);
    } else {
        //otherwise don't actually add the label if it would intersect with previous label

        final Node lastLabel = specificLabelPane.getChildren().get(specificLabelPane.getChildren().size() - 1);

        if (false == lastLabel.getBoundsInParent().intersects(label.getBoundsInParent())) {
            specificLabelPane.getChildren().add(label);
        }
    }
}

From source file:org.sleuthkit.autopsy.timeline.ui.AbstractVisualization.java

/** add a {@link Text} node to the leaf container for the decluttered axis
 * labels/*w w  w  .j av a 2 s  . c  o  m*/
 *
 * @param labelText  the string to add
 * @param labelWidth the width of the space available for the text
 * @param labelX     the horizontal position in the partPane of the text
 * @param bold       true if the text should be bold, false otherwise
 */
private synchronized void assignLeafLabel(String labelText, double labelWidth, double labelX, boolean bold) {

    Text label = new Text(" " + labelText + " ");
    label.setTextAlignment(TextAlignment.CENTER);
    label.setFont(Font.font(null, bold ? FontWeight.BOLD : FontWeight.NORMAL, 10));
    //position label accounting for width
    label.relocate(labelX + labelWidth / 2 - label.getBoundsInLocal().getWidth() / 2, 0);
    label.autosize();

    if (leafPane.getChildren().isEmpty()) {
        //just add first label
        leafPane.getChildren().add(label);
    } else {
        //otherwise don't actually add the label if it would intersect with previous label
        final Text lastLabel = (Text) leafPane.getChildren().get(leafPane.getChildren().size() - 1);

        if (!lastLabel.getBoundsInParent().intersects(label.getBoundsInParent())) {
            leafPane.getChildren().add(label);
        }
    }
}

From source file:org.sleuthkit.autopsy.timeline.ui.AbstractVisualizationPane.java

/**
 * add a {@link Text} node to the leaf container for the decluttered axis
 * labels/*www  .j  a  v a 2  s. c om*/
 *
 * @param labelText  the string to add
 * @param labelWidth the width of the space available for the text
 * @param labelX     the horizontal position in the partPane of the text
 * @param bold       true if the text should be bold, false otherwise
 */
private synchronized void assignLeafLabel(String labelText, double labelWidth, double labelX, boolean bold) {

    Text label = new Text(" " + labelText + " "); //NOI18N
    label.setTextAlignment(TextAlignment.CENTER);
    label.setFont(Font.font(null, bold ? FontWeight.BOLD : FontWeight.NORMAL, 10));
    //position label accounting for width
    label.relocate(labelX + labelWidth / 2 - label.getBoundsInLocal().getWidth() / 2, 0);
    label.autosize();

    if (leafPane.getChildren().isEmpty()) {
        //just add first label
        leafPane.getChildren().add(label);
    } else {
        //otherwise don't actually add the label if it would intersect with previous label
        final Text lastLabel = (Text) leafPane.getChildren().get(leafPane.getChildren().size() - 1);

        if (!lastLabel.getBoundsInParent().intersects(label.getBoundsInParent())) {
            leafPane.getChildren().add(label);
        }
    }
}