Java Code Examples for javafx.scene.control.Label#setTextAlignment()

The following examples show how to use javafx.scene.control.Label#setTextAlignment() . 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: Watch.java    From jace with GNU General Public License v2.0 8 votes vote down vote up
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);
}
 
Example 2
Source File: DateTileSkin.java    From OEE-Designer with MIT License 6 votes vote down vote up
@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);
}
 
Example 3
Source File: MainScene.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: TextTileSkin.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 5
Source File: DateTileSkin.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 6
Source File: SnapshotTable.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
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;
        }
 
Example 7
Source File: SnapshotTreeTable.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
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;
        }
 
Example 8
Source File: CharacterTileSkin.java    From OEE-Designer with MIT License 6 votes vote down vote up
@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);
}
 
Example 9
Source File: TextTileSkin.java    From OEE-Designer with MIT License 6 votes vote down vote up
@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);
}
 
Example 10
Source File: BlackLevelGenerator.java    From testing-video with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example 11
Source File: TextFieldWithIcon.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 12
Source File: Tracker.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 13
Source File: TabController.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
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();
        }
    }
}
 
Example 14
Source File: IconSwitchSkin.java    From Enzo with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 15
Source File: PlaylistsController.java    From MusicPlayer with MIT License 5 votes vote down vote up
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);
}
 
Example 16
Source File: HeatTabController.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
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);
        }
    }
}
 
Example 17
Source File: StatusTileSkin.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example 18
Source File: FX.java    From FxDock with Apache License 2.0 4 votes vote down vote up
/** 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;
}
 
Example 19
Source File: LayersViewPane.java    From constellation with Apache License 2.0 4 votes vote down vote up
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();
    }
 
Example 20
Source File: UnitDescriptionStage.java    From mars-sim with GNU General Public License v3.0 3 votes vote down vote up
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;

    }