javafx.scene.control.Label#setTextAlignment ( )源码实例Demo

下面列出了javafx.scene.control.Label#setTextAlignment ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: OEE-Designer   文件: DateTileSkin.java
@Override protected void initGraphics() {
    super.initGraphics();

    final ZonedDateTime TIME = tile.getTime();

    titleText = new Text(DAY_FORMATTER.format(TIME));
    titleText.setFill(tile.getTitleColor());

    description = new Label(Integer.toString(TIME.getDayOfMonth()));
    description.setAlignment(Pos.CENTER);
    description.setTextAlignment(TextAlignment.CENTER);
    description.setWrapText(true);
    description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS);
    description.setTextFill(tile.getTextColor());
    description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.72);
    description.setFont(Fonts.latoLight(PREFERRED_HEIGHT * 0.65));

    text = new Text(MONTH_YEAR_FORMATTER.format(TIME));
    text.setFill(tile.getTextColor());

    getPane().getChildren().addAll(titleText, text, description);
}
 
源代码2 项目: OEE-Designer   文件: TextTileSkin.java
@Override protected void initGraphics() {
    super.initGraphics();

    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    description = new Label(tile.getDescription());
    description.setAlignment(tile.getDescriptionAlignment());
    description.setTextAlignment(TextAlignment.RIGHT);
    description.setWrapText(true);
    description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS);
    description.setTextFill(tile.getDescriptionColor());
    description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795);
    Helper.enableNode(description, tile.isTextVisible());

    text = new Text(tile.getText());
    text.setFill(tile.getUnitColor());
    Helper.enableNode(text, tile.isTextVisible());

    getPane().getChildren().addAll(titleText, text, description);
}
 
源代码3 项目: OEE-Designer   文件: CharacterTileSkin.java
@Override protected void initGraphics() {
    super.initGraphics();

    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    description = new Label(tile.getDescription());
    description.setAlignment(Pos.CENTER);
    description.setTextAlignment(TextAlignment.CENTER);
    description.setWrapText(true);
    description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS);
    description.setTextFill(tile.getTextColor());
    description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795);
    Helper.enableNode(description, tile.isTextVisible());

    text = new Text(tile.getText());
    text.setFill(tile.getUnitColor());
    Helper.enableNode(text, tile.isTextVisible());

    getPane().getChildren().addAll(titleText, text, description);
}
 
源代码4 项目: phoebus   文件: SnapshotTreeTable.java
private void setup(String text, String tooltip, int minWidth, int prefWidth, boolean resizable) {
            label = new Label(text);
            label.setTooltip(new Tooltip(tooltip));
            label.setTextAlignment(TextAlignment.CENTER);
            setGraphic(label);

            if (minWidth != -1) {
                setMinWidth(minWidth);
            }
            if (prefWidth != -1) {
                setPrefWidth(prefWidth);
            }
            setResizable(resizable);
//            setOnEditStart(e -> controller.suspend());
//            setOnEditCancel(e -> controller.resume());
//            setOnEditCommit(e -> controller.resume());
            this.text = text;
        }
 
源代码5 项目: phoebus   文件: SnapshotTable.java
private void setup(String text, String tooltip, int minWidth, int prefWidth, boolean resizable) {
            label = new Label(text);
            label.setTooltip(new Tooltip(tooltip));
            label.setTextAlignment(TextAlignment.CENTER);
            setGraphic(label);

            if (minWidth != -1) {
                setMinWidth(minWidth);
            }
            if (prefWidth != -1) {
                setPrefWidth(prefWidth);
            }
            setResizable(resizable);
//            setOnEditStart(e -> controller.suspend());
//            setOnEditCancel(e -> controller.resume());
//            setOnEditCommit(e -> controller.resume());
            this.text = text;
        }
 
源代码6 项目: tilesfx   文件: DateTileSkin.java
@Override protected void initGraphics() {
    super.initGraphics();

    final ZonedDateTime TIME = tile.getTime();

    titleText = new Text(DAY_FORMATTER.format(TIME));
    titleText.setFill(tile.getTitleColor());

    description = new Label(Integer.toString(TIME.getDayOfMonth()));
    description.setAlignment(Pos.CENTER);
    description.setTextAlignment(TextAlignment.CENTER);
    description.setWrapText(true);
    description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS);
    description.setTextFill(tile.getTextColor());
    description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.72);
    description.setFont(Fonts.latoLight(PREFERRED_HEIGHT * 0.65));

    text = new Text(MONTH_YEAR_FORMATTER.format(TIME));
    text.setFill(tile.getTextColor());

    getPane().getChildren().addAll(titleText, text, description);
}
 
源代码7 项目: tilesfx   文件: TextTileSkin.java
@Override protected void initGraphics() {
    super.initGraphics();

    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    description = new Label(tile.getDescription());
    description.setAlignment(tile.getDescriptionAlignment());
    description.setTextAlignment(TextAlignment.RIGHT);
    description.setWrapText(true);
    description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS);
    description.setTextFill(tile.getTextColor());
    description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795);
    Helper.enableNode(description, tile.isTextVisible());

    text = new Text(tile.getText());
    text.setFill(tile.getUnitColor());
    Helper.enableNode(text, tile.isTextVisible());

    getPane().getChildren().addAll(titleText, text, description);
}
 
源代码8 项目: jace   文件: Watch.java
public Watch(int address, final MetacheatUI outer) {
    super();
    this.outer = outer;
    this.address = address;
    cell = outer.cheatEngine.getMemoryCell(address);
    redraw = outer.animationTimer.scheduleAtFixedRate(this::redraw, MetacheatUI.FRAME_RATE, MetacheatUI.FRAME_RATE, TimeUnit.MILLISECONDS);
    setBackground(new Background(new BackgroundFill(Color.NAVY, CornerRadii.EMPTY, Insets.EMPTY)));
    Label addrLabel = new Label("$" + Integer.toHexString(address));
    addrLabel.setOnMouseClicked((evt)-> outer.inspectAddress(address));
    addrLabel.setTextAlignment(TextAlignment.CENTER);
    addrLabel.setMinWidth(GRAPH_WIDTH);
    addrLabel.setFont(new Font(Font.getDefault().getFamily(), 14));
    addrLabel.setTextFill(Color.WHITE);
    graph = new Canvas(GRAPH_WIDTH, GRAPH_HEIGHT);
    getChildren().add(addrLabel);
    getChildren().add(graph);
    CheckBox hold = new CheckBox("Hold");
    holding = hold.selectedProperty();
    holding.addListener((prop, oldVal, newVal) -> this.updateHold());
    getChildren().add(hold);
    hold.setTextFill(Color.WHITE);
}
 
源代码9 项目: bisq   文件: TextFieldWithIcon.java
public TextFieldWithIcon() {
    textField = new JFXTextField();
    textField.setEditable(false);
    textField.setMouseTransparent(true);
    textField.setFocusTraversable(false);
    setLeftAnchor(textField, 0d);
    setRightAnchor(textField, 0d);

    dummyTextField = new Label();
    dummyTextField.setWrapText(true);
    dummyTextField.setAlignment(Pos.CENTER_LEFT);
    dummyTextField.setTextAlignment(TextAlignment.LEFT);
    dummyTextField.setMouseTransparent(true);
    dummyTextField.setFocusTraversable(false);
    setLeftAnchor(dummyTextField, 0d);
    dummyTextField.setVisible(false);

    iconLabel = new Label();
    iconLabel.setLayoutX(0);
    iconLabel.setLayoutY(3);

    dummyTextField.widthProperty().addListener((observable, oldValue, newValue) -> {
        iconLabel.setLayoutX(dummyTextField.widthProperty().get() + 20);
    });

    getChildren().addAll(textField, dummyTextField, iconLabel);
}
 
源代码10 项目: testing-video   文件: BlackLevelGenerator.java
private static Label text(Resolution res, ColorMatrix matrix, int col) {
    Label l = new Label(Integer.toString(getLuma(matrix, col)));
    l.setFont(font(res.height / 54));
    l.setTextFill(gray(matrix.fromLumaCode(matrix.YMIN * 4)));
    l.setTextAlignment(TextAlignment.CENTER);
    l.setAlignment(Pos.CENTER);
    l.setPrefSize(getW(res.width, col), getLabelH(res.height));
    return l;
}
 
源代码11 项目: phoebus   文件: Tracker.java
private Label createLabel(final TextAlignment talign, final Pos align)
{
    // Initial text is used to determine size
    final Label lbl = new Label("\u00A0\u00A000, 00\u00A0\u00A0");

    lbl.getStyleClass().add("location_size");
    lbl.setTextAlignment(talign);
    lbl.setAlignment(align);
    // When clicking/dragging the tracker,
    // don't allow the label to capture mouse clicks.
    lbl.setMouseTransparent(true);

    return lbl;
}
 
源代码12 项目: mars-sim   文件: TabController.java
private void configureTab(Tab tab, String title, String iconPath, AnchorPane containerPane, URL resourceURL, EventHandler<Event> onSelectionChangedEvent) {
    double imageWidth = 40.0;

    ImageView imageView = new ImageView(new Image(iconPath));
    imageView.setFitHeight(imageWidth);
    imageView.setFitWidth(imageWidth);

    Label label = new Label(title);
    label.setMaxWidth(tabWidth - 20);
    label.setPadding(new Insets(5, 0, 0, 0));
    label.setStyle("-fx-text-fill: black; -fx-font-size: 10pt; -fx-font-weight: bold;");
    label.setTextAlignment(TextAlignment.CENTER);

    BorderPane tabPane = new BorderPane();
    tabPane.setRotate(90.0);
    tabPane.setMaxWidth(tabWidth);
    tabPane.setCenter(imageView);
    tabPane.setBottom(label);

    tab.setText("");
    tab.setGraphic(tabPane);

    tab.setOnSelectionChanged(onSelectionChangedEvent);

    if (containerPane != null && resourceURL != null) {
        try {
            Parent contentView = FXMLLoader.load(resourceURL);
            containerPane.getChildren().add(contentView);
            AnchorPane.setTopAnchor(contentView, 0.0);
            AnchorPane.setBottomAnchor(contentView, 0.0);
            AnchorPane.setRightAnchor(contentView, 0.0);
            AnchorPane.setLeftAnchor(contentView, 0.0);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
源代码13 项目: mars-sim   文件: MainScene.java
public Label createLabelLeft(String name, String tip) {
	Label l = new Label(name);
	// upTimeLabel0.setEffect(blend);
	l.setAlignment(Pos.CENTER_RIGHT);
	l.setTextAlignment(TextAlignment.RIGHT);
	l.setStyle(LABEL_CSS_STYLE);
	l.setPadding(new Insets(1, 1, 1, 2));
	setQuickToolTip(l, tip);
	return l;
}
 
源代码14 项目: Enzo   文件: IconSwitchSkin.java
private void initGraphics() {
    Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/opensans-semibold.ttf"), (0.5 * PREFERRED_HEIGHT)); // "OpenSans"
    font = Font.font("Open Sans", 0.5 * PREFERRED_HEIGHT);

    background = new Region();
    background.getStyleClass().setAll("background");
    background.setStyle("-switch-color: " + Util.colorToCss((Color) getSkinnable().getSwitchColor()) + ";");

    symbol = getSkinnable().getSymbol();
    symbol.setMouseTransparent(true);

    text = new Label(getSkinnable().getText());
    text.setTextAlignment(TextAlignment.CENTER);
    text.setAlignment(Pos.CENTER);
    text.setTextFill(getSkinnable().getSymbolColor());
    text.setFont(font);

    thumb = new Region();
    thumb.getStyleClass().setAll("thumb");
    thumb.setStyle("-thumb-color: " + Util.colorToCss((Color) getSkinnable().getThumbColor()) + ";");
    thumb.setMouseTransparent(true);

    pane = new Pane(background, symbol, text, thumb);
    pane.getStyleClass().setAll("icon-switch");

    moveToDeselected = new TranslateTransition(Duration.millis(180), thumb);
    moveToSelected = new TranslateTransition(Duration.millis(180), thumb);

    // Add all nodes
    getChildren().setAll(pane);
}
 
源代码15 项目: MusicPlayer   文件: PlaylistsController.java
void selectPlaylist(Playlist playlist) {
    // Displays the delete button only if the user has not selected one of the default playlists.
    if (playlist instanceof MostPlayedPlaylist || playlist instanceof RecentlyPlayedPlaylist) {
        deleteButton.setVisible(false);
    }

    // Sets the text on the play list title label.
    playlistTitleLabel.setText(playlist.getTitle());

    // Updates the currently selected play list.
    selectedPlaylist = playlist;

    // Retrieves the songs in the selected play list.
    ObservableList<Song> songs = playlist.getSongs();
    
    // Clears the song table.
    tableView.getSelectionModel().clearSelection();
    
    // Populates the song table with the playlist's songs.
    tableView.setItems(songs);

    Label message = new Label(selectedPlaylist.getPlaceholder());
    message.setTextAlignment(TextAlignment.CENTER);

    ImageView image = new ImageView();
    image.setFitHeight(150);
    image.setFitWidth(150);
    image.setImage(new Image(Resources.IMG + "playlistsIcon.png"));

    VBox placeholder = new VBox();
    placeholder.setAlignment(Pos.CENTER);
    placeholder.getChildren().addAll(image, message);
    VBox.setMargin(image, new Insets(0, 0, 50, 0));

    tableView.setPlaceholder(placeholder);
}
 
源代码16 项目: constellation   文件: LayersViewPane.java
public LayersViewPane(final LayersViewController controller) {

        // create controller
        this.controller = controller;

        // create layer headings
        final Label layerIdHeadingText = new Label("Layer\nID");
        final Label visibilityHeadingText = new Label("Visibility");
        final Label queryHeadingText = new Label("Query");
        final Label descriptionHeadingText = new Label("Description");

        // create gridpane and alignments
        layersGridPane = new GridPane();
        layersGridPane.setHgap(5);
        layersGridPane.setVgap(5);
        layersGridPane.setPadding(new Insets(0, 10, 10, 10));
        layersGridPane.addRow(0, layerIdHeadingText, visibilityHeadingText,
                queryHeadingText, descriptionHeadingText);

        // set heading alignments
        GridPane.setMargin(layerIdHeadingText, new Insets(15, 0, 0, 0));
        layerIdHeadingText.setTextAlignment(TextAlignment.CENTER);
        layerIdHeadingText.setMinWidth(40);
        layerIdHeadingText.setMinHeight(25);
        layerIdHeadingText.setPrefWidth(30);
        visibilityHeadingText.setPrefWidth(55);
        visibilityHeadingText.setMinWidth(50);
        queryHeadingText.setPrefWidth(10000);
        queryHeadingText.setMinWidth(80);
        descriptionHeadingText.setPrefWidth(10000);
        descriptionHeadingText.setMinWidth(80);

        // instantiate list of layers
        layers = new ArrayList<>();

        // set default layers
        setDefaultLayers();

        // create options
        final Button addButton = new Button("Add New Layer");
        addButton.setAlignment(Pos.CENTER_RIGHT);
        addButton.setOnAction(event -> {
            if (layersGridPane.getRowCount() <= 32) {
                createLayer(layers.size() + 1, false, "", "");
                controller.writeState();
            } else {
                final NotifyDescriptor nd = new NotifyDescriptor.Message(
                        "You cannot have more than 32 layers", NotifyDescriptor.WARNING_MESSAGE);
                DialogDisplayer.getDefault().notify(nd);
            }
            event.consume();
        });
        HBox.setHgrow(addButton, Priority.ALWAYS);

        final Button deselectAllButton = new Button("Deselect All Layers");
        deselectAllButton.setAlignment(Pos.CENTER_RIGHT);
        deselectAllButton.setOnAction(event -> {
            for (final LayerDescription layer : layers) {
                layer.setCurrentLayerVisibility(false);
            }
            if (this.layers.isEmpty()) {
                setDefaultLayers();
            } else {
                setLayers(List.copyOf(layers));
            }
            controller.submit();
            controller.execute();

            event.consume();
        });
        HBox.setHgrow(deselectAllButton, Priority.ALWAYS);

        this.options = new HBox(5, addButton, deselectAllButton);
        options.setAlignment(Pos.TOP_LEFT);
        options.setPadding(new Insets(0, 0, 0, 10));

        // add layers grid and options to pane
        this.layersViewPane = new VBox(5, layersGridPane, options);

        // create layout bindings
        layersViewPane.prefWidthProperty().bind(this.widthProperty());
        options.prefWidthProperty().bind(layersViewPane.widthProperty());

        this.setCenter(layersViewPane);
        controller.writeState();
    }
 
源代码17 项目: marathonv5   文件: HeatTabController.java
private void createStateLabels() {
    Group overlay = map.getOverlayGroup();
    for(String state: Region.ALL_STATES) {
        Node stateNode = map.lookup("#"+state);
        if (stateNode != null) {
            Label label = new Label("+10");
            label.getStyleClass().add("heatmap-label");
            label.setTextAlignment(TextAlignment.CENTER);
            label.setAlignment(Pos.CENTER);
            label.setManaged(false);
            label.setOpacity(0);
            label.setVisible(false);
            Bounds stateBounds = stateNode.getBoundsInParent();
            if ("DE".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()-25, stateBounds.getMinY(), 
                        stateBounds.getWidth()+50, stateBounds.getHeight());
            } else if ("VT".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()-25, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("NH".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()+30, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("MA".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()-20, stateBounds.getMinY()-18, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("RI".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY(), 
                        stateBounds.getWidth()+40, stateBounds.getHeight());
            } else if ("ID".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()+60, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("MI".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()+60, stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("FL".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()+95, stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("LA".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()-50, stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            }
            stateLabelMap.put(state, label);
            overlay.getChildren().add(label);
        }
    }
}
 
源代码18 项目: tilesfx   文件: StatusTileSkin.java
@Override protected void initGraphics() {
    super.initGraphics();

    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    description = new Label(tile.getDescription());
    description.setAlignment(tile.getDescriptionAlignment());
    description.setTextAlignment(TextAlignment.RIGHT);
    description.setWrapText(true);
    description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS);
    description.setTextFill(tile.getTextColor());
    description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795);
    Helper.enableNode(description, tile.isTextVisible());

    Color foregroundColor = getSkinnable().getForegroundColor();
    Color halfTranslucent = Helper.getColorWithOpacity(foregroundColor, 0.5);

    verticalDivider = new Line(0, PREFERRED_HEIGHT * 0.35, PREFERRED_WIDTH, PREFERRED_HEIGHT * 0.35);
    verticalDivider.getStrokeDashArray().addAll(2.0, 2.0);
    verticalDivider.setStrokeDashOffset(1);
    verticalDivider.setStroke(halfTranslucent);
    verticalDivider.setStrokeWidth(1);

    horizontal1Divider = new Line(PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.45, PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.85);
    horizontal1Divider.getStrokeDashArray().addAll(2.0, 2.0);
    horizontal1Divider.setStrokeDashOffset(1);
    horizontal1Divider.setStroke(halfTranslucent);
    horizontal1Divider.setStrokeWidth(1);

    horizontal2Divider = new Line(2 * PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.45, 2 * PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.85);
    horizontal2Divider.getStrokeDashArray().addAll(2.0, 2.0);
    horizontal2Divider.setStrokeDashOffset(1);
    horizontal2Divider.setStroke(halfTranslucent);
    horizontal2Divider.setStrokeWidth(1);

    leftGraphicsPane = new StackPane();
    middleGraphicsPane = new StackPane();
    rightGraphicsPane = new StackPane();

    if (null != tile.getLeftGraphics()) { leftGraphicsPane.getChildren().setAll(tile.getLeftGraphics()); }
    if (null != tile.getMiddleGraphics()) { middleGraphicsPane.getChildren().setAll(tile.getMiddleGraphics()); }
    if (null != tile.getRightGraphics()) { rightGraphicsPane.getChildren().setAll(tile.getRightGraphics()); }

    leftValueLabel = new Label();
    leftValueLabel.setAlignment(Pos.CENTER);

    middleValueLabel = new Label();
    middleValueLabel.setAlignment(Pos.CENTER);

    rightValueLabel = new Label();
    rightValueLabel.setAlignment(Pos.CENTER);

    leftLabel = new Label();
    leftLabel.setAlignment(Pos.CENTER);

    middleLabel = new Label();
    middleLabel.setAlignment(Pos.CENTER);

    rightLabel = new Label();
    rightLabel.setAlignment(Pos.CENTER);

    text = new Text(tile.getText());
    text.setFill(tile.getUnitColor());
    Helper.enableNode(text, tile.isTextVisible());

    getPane().getChildren().addAll(titleText, description,
                                   verticalDivider, horizontal1Divider, horizontal2Divider, leftGraphicsPane, middleGraphicsPane, rightGraphicsPane,
                                   leftValueLabel, middleValueLabel, rightValueLabel,
                                   leftLabel, middleLabel, rightLabel,
                                   text);
}
 
源代码19 项目: FxDock   文件: FX.java
/** creates a label.  accepts: CssStyle, CssID, FxCtl, Insets, OverrunStyle, Pos, TextAlignment, Color, Node, Background */
public static Label label(Object ... attrs)
{
	Label n = new Label();
	
	for(Object a: attrs)
	{
		if(a == null)
		{
			// ignore
		}
		else if(a instanceof CssStyle)
		{
			n.getStyleClass().add(((CssStyle)a).getName());
		}
		else if(a instanceof CssID)
		{
			n.setId(((CssID)a).getID());
		}
		else if(a instanceof FxCtl)
		{
			switch((FxCtl)a)
			{
			case BOLD:
				n.getStyleClass().add(CssTools.BOLD.getName());
				break;
			case FOCUSABLE:
				n.setFocusTraversable(true);
				break;
			case FORCE_MAX_WIDTH:
				n.setMaxWidth(Double.MAX_VALUE);
				break;
			case FORCE_MIN_HEIGHT:
				n.setMinHeight(Control.USE_PREF_SIZE);
				break;
			case FORCE_MIN_WIDTH:
				n.setMinWidth(Control.USE_PREF_SIZE);
				break;
			case NON_FOCUSABLE:
				n.setFocusTraversable(false);
				break;
			case WRAP_TEXT:
				n.setWrapText(true);
				break;
			default:
				throw new Error("?" + a);
			}
		}
		else if(a instanceof Insets)
		{
			n.setPadding((Insets)a);
		}
		else if(a instanceof OverrunStyle)
		{
			n.setTextOverrun((OverrunStyle)a);
		}
		else if(a instanceof Pos)
		{
			n.setAlignment((Pos)a);
		}
		else if(a instanceof String)
		{
			n.setText((String)a);
		}
		else if(a instanceof TextAlignment)
		{
			n.setTextAlignment((TextAlignment)a);
		}
		else if(a instanceof Color)
		{
			n.setTextFill((Color)a);
		}
		else if(a instanceof StringProperty)
		{
			n.textProperty().bind((StringProperty)a);
		}
		else if(a instanceof Node)
		{
			n.setGraphic((Node)a);
		}
		else if(a instanceof Background)
		{
			n.setBackground((Background)a);
		}
		else
		{
			throw new Error("?" + a);
		}			
	}
	
	return n;
}
 
源代码20 项目: mars-sim   文件: UnitDescriptionStage.java
public BorderPane init(String unitName, String unitType, String unitDescription) {

    	//this.setSize(350, 400); // undecorated 301, 348 ; decorated : 303, 373

        mainPane = new BorderPane();

        name = new Label(unitName);
        name.setPadding(new Insets(5,5,5,5));
        name.setTextAlignment(TextAlignment.CENTER);
        name.setContentDisplay(ContentDisplay.TOP);

        box0 = new VBox();
        box0.setAlignment(Pos.CENTER);
        box0.setPadding(new Insets(5,5,5,5));
	    box0.getChildren().addAll(name);

        mainPane.setTop(box0);

        String type = "TYPE :";
        String description = "DESCRIPTION :";

        box1 = new VBox();
        ta = new TextArea();

        ta.setEditable(false);
        ta.setWrapText(true);
        box1.getChildren().add(ta);

        ta.setText(System.lineSeparator() + type + System.lineSeparator() + unitType + System.lineSeparator() + System.lineSeparator());
        ta.appendText(description + System.lineSeparator() + unitDescription + System.lineSeparator() + System.lineSeparator());
        ta.setScrollTop(300);

        applyTheme();

        mainPane.setCenter(ta);

        return mainPane;

    }