Java Code Examples for javafx.scene.layout.FlowPane#setHgap()

The following examples show how to use javafx.scene.layout.FlowPane#setHgap() . 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: AwesomeFontDemo.java    From bisq with GNU Affero General Public License v3.0 8 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    FlowPane flowPane = new FlowPane();
    flowPane.setStyle("-fx-background-color: #ddd;");
    flowPane.setHgap(2);
    flowPane.setVgap(2);
    List<AwesomeIcon> values = new ArrayList<>(Arrays.asList(AwesomeIcon.values()));
    values.sort((o1, o2) -> o1.name().compareTo(o2.name()));
    for (AwesomeIcon icon : values) {
        Label label = new Label();
        Button button = new Button(icon.name(), label);
        button.setStyle("-fx-background-color: #fff;");
        AwesomeDude.setIcon(label, icon, "12");
        flowPane.getChildren().add(button);
    }

    primaryStage.setScene(new Scene(flowPane, 1200, 950));
    primaryStage.show();
}
 
Example 2
Source File: MaterialDesignIconDemo.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setFitToWidth(true);

    FlowPane flowPane = new FlowPane();
    flowPane.setStyle("-fx-background-color: #ddd;");
    flowPane.setHgap(2);
    flowPane.setVgap(2);
    List<MaterialDesignIcon> values = new ArrayList<>(Arrays.asList(MaterialDesignIcon.values()));
    values.sort(Comparator.comparing(Enum::name));
    for (MaterialDesignIcon icon : values) {
        Button button = MaterialDesignIconFactory.get().createIconButton(icon, icon.name());
        flowPane.getChildren().add(button);
    }

    scrollPane.setContent(flowPane);

    primaryStage.setScene(new Scene(scrollPane, 1200, 950));
    primaryStage.show();
}
 
Example 3
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple2<Label, FlowPane> addTopLabelFlowPane(GridPane gridPane,
                                                          int rowIndex,
                                                          String title,
                                                          double top,
                                                          double bottom) {
    FlowPane flowPane = new FlowPane();
    flowPane.setPadding(new Insets(10, 10, 10, 10));
    flowPane.setVgap(10);
    flowPane.setHgap(10);
    final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, flowPane, top);

    GridPane.setMargin(topLabelWithVBox.second, new Insets(top + Layout.FLOATING_LABEL_DISTANCE,
            0, bottom, 0));

    return new Tuple2<>(topLabelWithVBox.first, flowPane);
}
 
Example 4
Source File: IssuePickerDialog.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
private FlowPane createRepoPane(Insets padding) {
    FlowPane repo = new FlowPane();
    repo.setHgap(5);
    repo.setVgap(5);
    repo.setPadding(padding);
    return repo;
}
 
Example 5
Source File: LabelPickerDialog.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
private FlowPane createGroupPane(Insets padding) {
    FlowPane group = new FlowPane();
    group.setHgap(5);
    group.setVgap(5);
    group.setPadding(padding);
    return group;
}
 
Example 6
Source File: PluginParametersDialog.java    From constellation with Apache License 2.0 5 votes vote down vote up
/**
 * Display a dialog box containing the parameters that allows the user to
 * enter values.
 *
 * @param owner The owner for this stage.
 * @param title The dialog box title.
 * @param parameters The plugin parameters.
 * @param options The dialog box button labels, one for each button.
 */
public PluginParametersDialog(final Stage owner, final String title, final PluginParameters parameters, final String... options) {
    initStyle(StageStyle.UTILITY);
    initModality(Modality.WINDOW_MODAL);
    initOwner(owner);

    setTitle(title);

    final BorderPane root = new BorderPane();
    root.setPadding(new Insets(10));
    root.setStyle("-fx-background-color: #DDDDDD;");
    final Scene scene = new Scene(root);
    setScene(scene);

    final PluginParametersPane parametersPane = PluginParametersPane.buildPane(parameters, null);
    root.setCenter(parametersPane);

    final FlowPane buttonPane = new FlowPane();
    buttonPane.setAlignment(Pos.BOTTOM_RIGHT);
    buttonPane.setPadding(new Insets(5));
    buttonPane.setHgap(5);
    root.setBottom(buttonPane);

    final String[] labels = options != null && options.length > 0 ? options : new String[]{OK, CANCEL};
    for (final String option : labels) {
        final Button okButton = new Button(option);
        okButton.setOnAction(event -> {
            result = option;
            parameters.storeRecentValues();
            PluginParametersDialog.this.hide();
        });
        buttonPane.getChildren().add(okButton);
    }

    // Without this, some parameter panes have a large blank area at the bottom. Huh?
    this.sizeToScene();

    result = null;
}
 
Example 7
Source File: AssigneePickerDialog.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
private FlowPane createAssignedUserPane() {
    FlowPane assignedUserPane = new FlowPane();
    assignedUserPane.setPadding(new Insets(5, 5, 5, 5));
    assignedUserPane.setHgap(3);
    assignedUserPane.setVgap(5);
    assignedUserPane.setStyle("-fx-border-radius: 3;");
    assignedUserPane.setId(IdGenerator.getAssigneePickerAssignedUserPaneId());
    return assignedUserPane;
}
 
Example 8
Source File: IssueCard.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
private FlowPane createDetailsPane() {
    FlowPane detailsPane = new FlowPane();
    detailsPane.setMaxWidth(CARD_WIDTH);
    detailsPane.setPrefWrapLength(CARD_WIDTH);
    detailsPane.setHgap(3);
    detailsPane.setVgap(3);
    return detailsPane;
}
 
Example 9
Source File: CheckBoxDemo.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) {

    FlowPane main = new FlowPane();
    main.setVgap(20);
    main.setHgap(20);

    CheckBox cb = new CheckBox("CheckBox");
    JFXCheckBox jfxCheckBox = new JFXCheckBox("JFX CheckBox");
    JFXCheckBox customJFXCheckBox = new JFXCheckBox("Custom JFX CheckBox");
    customJFXCheckBox.getStyleClass().add("custom-jfx-check-box");

    main.getChildren().add(cb);
    main.getChildren().add(jfxCheckBox);
    main.getChildren().add(customJFXCheckBox);

    StackPane pane = new StackPane();
    pane.getChildren().add(main);
    StackPane.setMargin(main, new Insets(100));
    pane.setStyle("-fx-background-color:WHITE");

    final Scene scene = new Scene(pane, 600, 200);
    scene.getStylesheets().add(CheckBoxDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
    stage.setTitle("JFX CheckBox Demo ");
    stage.setScene(scene);
    stage.setResizable(false);
    stage.show();

}
 
Example 10
Source File: DatePickerDemo.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) {

    FlowPane main = new FlowPane();
    main.setVgap(20);
    main.setHgap(20);


    DatePicker datePicker = new DatePicker();

    main.getChildren().add(datePicker);
    JFXDatePicker datePickerFX = new JFXDatePicker();

    main.getChildren().add(datePickerFX);
    datePickerFX.setPromptText("pick a date");
    JFXTimePicker blueDatePicker = new JFXTimePicker();
    blueDatePicker.setDefaultColor(Color.valueOf("#3f51b5"));
    blueDatePicker.setOverLay(true);
    main.getChildren().add(blueDatePicker);


    StackPane pane = new StackPane();
    pane.getChildren().add(main);
    StackPane.setMargin(main, new Insets(100));
    pane.setStyle("-fx-background-color:WHITE");

    final Scene scene = new Scene(pane, 400, 700);
    final ObservableList<String> stylesheets = scene.getStylesheets();
    stylesheets.addAll(MainDemo.class.getResource("/css/jfoenix-fonts.css").toExternalForm(),
                       MainDemo.class.getResource("/css/jfoenix-design.css").toExternalForm());
    stage.setTitle("JFX Date Picker Demo");
    stage.setScene(scene);
    stage.show();

}
 
Example 11
Source File: ButtonDemo.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) {
    FlowPane main = new FlowPane();
    main.setVgap(20);
    main.setHgap(20);

    main.getChildren().add(new Button("Java Button"));
    JFXButton jfoenixButton = new JFXButton("JFoenix Button");
    main.getChildren().add(jfoenixButton);

    JFXButton button = new JFXButton("RAISED BUTTON");
    button.getStyleClass().add("button-raised");
    main.getChildren().add(button);

    JFXButton button1 = new JFXButton("DISABLED");
    button1.setDisable(true);
    main.getChildren().add(button1);

    StackPane pane = new StackPane();
    pane.getChildren().add(main);
    StackPane.setMargin(main, new Insets(100));
    pane.setStyle("-fx-background-color:WHITE");

    final Scene scene = new Scene(pane, 800, 200);
    scene.getStylesheets().add(ButtonDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
    stage.setTitle("JFX Button Demo");
    stage.setScene(scene);
    stage.show();
}
 
Example 12
Source File: HamburgerDemo.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {


    FlowPane main = new FlowPane();
    main.setVgap(20);
    main.setHgap(20);

    JFXHamburger h1 = new JFXHamburger();
    HamburgerSlideCloseTransition burgerTask = new HamburgerSlideCloseTransition(h1);
    burgerTask.setRate(-1);
    h1.addEventHandler(MouseEvent.MOUSE_PRESSED, e -> {
        burgerTask.setRate(burgerTask.getRate() * -1);
        burgerTask.play();
    });

    JFXHamburger h2 = new JFXHamburger();
    HamburgerBasicCloseTransition burgerTask1 = new HamburgerBasicCloseTransition(h2);
    burgerTask1.setRate(-1);
    h2.addEventHandler(MouseEvent.MOUSE_PRESSED, e -> {
        burgerTask1.setRate(burgerTask1.getRate() * -1);
        burgerTask1.play();
    });

    JFXHamburger h3 = new JFXHamburger();
    HamburgerBackArrowBasicTransition burgerTask2 = new HamburgerBackArrowBasicTransition(h3);
    burgerTask2.setRate(-1);
    h3.addEventHandler(MouseEvent.MOUSE_PRESSED, e -> {
        burgerTask2.setRate(burgerTask2.getRate() * -1);
        burgerTask2.play();
    });

    JFXHamburger h4 = new JFXHamburger();
    HamburgerNextArrowBasicTransition burgerTask3 = new HamburgerNextArrowBasicTransition(h4);
    burgerTask3.setRate(-1);
    h4.addEventHandler(MouseEvent.MOUSE_PRESSED, e -> {
        burgerTask3.setRate(burgerTask3.getRate() * -1);
        burgerTask3.play();
    });


    main.getChildren().add(h1);
    main.getChildren().add(h2);
    main.getChildren().add(h3);
    main.getChildren().add(h4);

    StackPane pane = new StackPane();
    pane.getChildren().add(main);
    StackPane.setMargin(main, new Insets(60));
    pane.setStyle("-fx-background-color:WHITE");

    final Scene scene = new Scene(pane, 400, 200);
    scene.getStylesheets().add(HamburgerDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
    stage.setTitle("JFX Burgers Demo :) ");
    stage.setScene(scene);
    stage.setResizable(false);

    stage.show();

}
 
Example 13
Source File: ConsolidatedDialog.java    From constellation with Apache License 2.0 4 votes vote down vote up
/**
 * A generic multiple matches dialog which can be used to display a
 * collection of ObservableList items
 *
 * @param title The title of the dialog
 * @param observableMap The map of {@code ObservableList} objects
 * @param message The (help) message that will be displayed at the top of
 * the dialog window
 * @param listItemHeight The height of each list item. If you have a single
 * row of text then set this to 24.
 */
public ConsolidatedDialog(String title, Map<String, ObservableList<Container<K, V>>> observableMap, String message, int listItemHeight) {
    final BorderPane root = new BorderPane();
    root.setStyle("-fx-background-color: #DDDDDD;-fx-border-color: #3a3e43;-fx-border-width: 4px;");

    // add a title
    final Label titleLabel = new Label();
    titleLabel.setText(title);
    titleLabel.setStyle("-fx-font-size: 11pt;-fx-font-weight: bold;");
    titleLabel.setAlignment(Pos.CENTER);
    titleLabel.setPadding(new Insets(5));
    root.setTop(titleLabel);

    final Accordion accordion = new Accordion();
    for (String identifier : observableMap.keySet()) {
        final ObservableList<Container<K, V>> objects = observableMap.get(identifier);
        ListView<Container<K, V>> listView = new ListView<>(objects);
        listView.setEditable(false);
        listView.setPrefHeight((listItemHeight * objects.size()));
        listView.getSelectionModel().selectedItemProperty().addListener(event -> {
            listView.getItems().get(0).getKey();
            final Container<K, V> container = listView.getSelectionModel().getSelectedItem();
            if (container != null) {
                selectedObjects.add(new Pair<>(container.getKey(), container.getValue()));
            } else {
                // the object was unselected so go through the selected objects and remove them all because we don't know which one was unselected
                for (Container<K, V> object : listView.getItems()) {
                    selectedObjects.remove(new Pair<>(object.getKey(), object.getValue()));
                }
            }
        });

        final TitledPane titledPane = new TitledPane(identifier, listView);
        accordion.getPanes().add(titledPane);
    }

    final HBox help = new HBox();
    help.getChildren().add(helpMessage);
    help.getChildren().add(new ImageView(UserInterfaceIconProvider.HELP.buildImage(16, ConstellationColor.AZURE.getJavaColor())));
    help.setPadding(new Insets(10, 0, 10, 0));
    helpMessage.setText(message + "\n\nNote: To deselect hold Ctrl when you click.");
    helpMessage.setStyle("-fx-font-size: 11pt;");
    helpMessage.setWrapText(true);
    helpMessage.setPadding(new Insets(5));

    final VBox box = new VBox();
    box.getChildren().add(help);

    // add the multiple matching accordion
    box.getChildren().add(accordion);

    final ScrollPane scroll = new ScrollPane();
    scroll.setContent(box);
    scroll.setFitToWidth(true);
    scroll.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
    root.setCenter(scroll);

    final FlowPane buttonPane = new FlowPane();
    buttonPane.setAlignment(Pos.BOTTOM_RIGHT);
    buttonPane.setPadding(new Insets(5));
    buttonPane.setHgap(5);
    root.setBottom(buttonPane);

    useButton = new Button("Continue");
    buttonPane.getChildren().add(useButton);
    accordion.expandedPaneProperty().set(null);

    final Scene scene = new Scene(root);
    fxPanel.setScene(scene);
    fxPanel.setPreferredSize(new Dimension(500, 500));
}
 
Example 14
Source File: AnimationDemo.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {

    FlowPane main = new FlowPane();
    main.setVgap(20);
    main.setHgap(20);

    StackPane colorPane = new StackPane();
    colorPane.setStyle(STYLE);
    colorPane.getStyleClass().add("red-500");
    main.getChildren().add(colorPane);

    StackPane colorPane1 = new StackPane();
    colorPane1.setStyle(STYLE);
    colorPane1.getStyleClass().add("blue-500");

    StackPane placeHolder = new StackPane(colorPane1);
    placeHolder.setStyle(STYLE);
    main.getChildren().add(placeHolder);


    StackPane colorPane2 = new StackPane();
    colorPane2.setStyle(STYLE);
    colorPane2.getStyleClass().add("green-500");
    main.getChildren().add(colorPane2);

    StackPane colorPane3 = new StackPane();
    colorPane3.setStyle(STYLE);
    colorPane3.getStyleClass().add("yellow-500");
    main.getChildren().add(colorPane3);


    StackPane colorPane4 = new StackPane();
    colorPane4.setStyle(STYLE);
    colorPane4.getStyleClass().add("purple-500");
    main.getChildren().add(colorPane4);


    StackPane wizard = new StackPane();
    wizard.getChildren().add(main);
    StackPane.setMargin(main, new Insets(100));
    wizard.setStyle("-fx-background-color:WHITE");

    StackPane nextPage = new StackPane();

    StackPane newPlaceHolder = new StackPane();
    newPlaceHolder.setStyle("-fx-background-radius:50; -fx-max-width:50; -fx-max-height:50;");
    nextPage.getChildren().add(newPlaceHolder);
    StackPane.setAlignment(newPlaceHolder, Pos.TOP_LEFT);


    JFXHamburger h4 = new JFXHamburger();
    h4.setMaxSize(40, 40);
    HamburgerBackArrowBasicTransition burgerTask3 = new HamburgerBackArrowBasicTransition(h4);
    burgerTask3.setRate(-1);
    h4.addEventHandler(MouseEvent.MOUSE_PRESSED, e -> {
        burgerTask3.setRate(burgerTask3.getRate() * -1);
        burgerTask3.play();
    });
    nextPage.getChildren().add(h4);
    StackPane.setAlignment(h4, Pos.TOP_LEFT);
    StackPane.setMargin(h4, new Insets(10));


    JFXNodesAnimation<FlowPane, StackPane> animation = new FlowPaneStackPaneJFXNodesAnimation(main,
                                                                                              nextPage,
                                                                                              wizard,
                                                                                              colorPane1);

    colorPane1.setOnMouseClicked((click) -> animation.animate());

    final Scene scene = new Scene(wizard, 800, 200);
    final ObservableList<String> stylesheets = scene.getStylesheets();
    stylesheets.addAll(ButtonDemo.class.getResource("/css/jfoenix-design.css").toExternalForm(),
                       ButtonDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
    stage.setTitle("JFX Button Demo");
    stage.setScene(scene);
    stage.show();

}
 
Example 15
Source File: RipplerDemo.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {

    //TODO drop shadow changes the width and height thus need to be considered
    FlowPane main = new FlowPane();
    main.setVgap(20);
    main.setHgap(20);

    Label label = new Label("Click Me");
    label.setStyle(FX_BACKGROUND_COLOR_WHITE);
    label.setPadding(new Insets(20));
    JFXRippler rippler = new JFXRippler(label);
    rippler.setEnabled(false);
    main.getChildren().add(rippler);

    label.setOnMousePressed((e) -> {
        if (counter == 5) {
            step = -1;
        } else if (counter == 0) {
            step = 1;
        }
        JFXDepthManager.setDepth(label, counter += step % JFXDepthManager.getLevels());
    });

    Label l1 = new Label("TEST");
    l1.setStyle(FX_BACKGROUND_COLOR_WHITE);
    l1.setPadding(new Insets(20));
    JFXRippler rippler1 = new JFXRippler(l1);
    main.getChildren().add(rippler1);
    JFXDepthManager.setDepth(rippler1, 1);

    Label l2 = new Label("TEST1");
    l2.setStyle(FX_BACKGROUND_COLOR_WHITE);
    l2.setPadding(new Insets(20));
    JFXRippler rippler2 = new JFXRippler(l2);
    main.getChildren().add(rippler2);
    JFXDepthManager.setDepth(rippler2, 2);


    Label l3 = new Label("TEST2");
    l3.setStyle(FX_BACKGROUND_COLOR_WHITE);
    l3.setPadding(new Insets(20));
    JFXRippler rippler3 = new JFXRippler(l3);
    main.getChildren().add(rippler3);
    JFXDepthManager.setDepth(rippler3, 3);

    Label l4 = new Label("TEST3");
    l4.setStyle(FX_BACKGROUND_COLOR_WHITE);
    l4.setPadding(new Insets(20));
    JFXRippler rippler4 = new JFXRippler(l4);
    main.getChildren().add(rippler4);
    JFXDepthManager.setDepth(rippler4, 4);

    Label l5 = new Label("TEST4");
    l5.setStyle(FX_BACKGROUND_COLOR_WHITE);
    l5.setPadding(new Insets(20));
    JFXRippler rippler5 = new JFXRippler(l5);
    main.getChildren().add(rippler5);
    JFXDepthManager.setDepth(rippler5, 5);

    StackPane pane = new StackPane();
    pane.getChildren().add(main);
    StackPane.setMargin(main, new Insets(100));
    pane.setStyle("-fx-background-color:WHITE");

    final Scene scene = new Scene(pane, 600, 400);

    stage.setTitle("JavaFX Ripple effect and shadows ");
    stage.setScene(scene);
    stage.setResizable(false);
    stage.show();

}
 
Example 16
Source File: CObjectArrayField.java    From Open-Lowcode with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Node getNode(
		PageActionManager actionmanager,
		CPageData inputdata,
		Window parentwindow,
		TabPane[] parenttabpanes,
		CollapsibleNode nodetocollapsewhenactiontriggered) {
	logger.fine("built node CObjectArrayField " + this.name);
	this.actionmanager = actionmanager;
	if (this.inlinefeeding) {
		inputdata.addInlineActionDataRef(this.feedinginlineactionoutputdata);

	}
	this.tooltip = new Tooltip("click to open object\nShift+click to unlink object.");
	HBox thispane = new HBox();

	if (label != null)
		if (label.length() > 0) {
			Label thislabel = new Label(label);
			if (helper != null)
				if (helper.length() > 0)
					thislabel.setTooltip(new Tooltip(helper));
			thislabel.setFont(
					Font.font(thislabel.getFont().getName(), FontPosture.ITALIC, thislabel.getFont().getSize()));
			thislabel.setMinWidth(120);
			thislabel.setWrapText(true);
			thislabel.setMaxWidth(120);
			thispane.getChildren().add(thislabel);
		}

	datapane = new FlowPane();
	boolean nolabel = true;
	if (label != null)
		if (label.length() > 0) {
			FlowPane flowdatapane = new FlowPane();
			thispane.setAlignment(Pos.TOP_LEFT);
			flowdatapane.setPrefWrapLength(400);
			// for object workflow tasks.
			flowdatapane.setVgap(4);
			flowdatapane.setHgap(8);
			this.datapane = flowdatapane;
			nolabel = false;
		}

	if (nolabel) {
		HBox boxdatapane = new HBox();
		thispane.setAlignment(Pos.CENTER_LEFT);
		boxdatapane.setAlignment(Pos.CENTER_LEFT);
		this.datapane = boxdatapane;
	}

	// this is to keep the widget tiny when used as right of title

	thiselementarray = getExternalContent(inputdata, datareference);
	if (objectatendoffielddata != null)
		dataatendoffielddata = objectatendoffielddata.getNode(actionmanager, inputdata, parentwindow,
				parenttabpanes,nodetocollapsewhenactiontriggered);
	refreshDisplay();

	thispane.getChildren().add(datapane);

	return thispane;
}
 
Example 17
Source File: TransactionGraphLabelsEditorFactory.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
protected Node createEditorControls() {
    // get all transaction attributes currently in the graph
    final ReadableGraph rg = GraphManager.getDefault().getActiveGraph().getReadableGraph();
    try {
        for (int i = 0; i < rg.getAttributeCount(GraphElementType.TRANSACTION); i++) {
            attributeNames.add(rg.getAttributeName(rg.getAttribute(GraphElementType.TRANSACTION, i)));
        }
    } finally {
        rg.release();
    }
    attributeNames.sort(String::compareTo);

    final HBox labelTitles = new HBox();
    final Label attrLabel = new Label("Attribute");
    attrLabel.setAlignment(Pos.CENTER);
    attrLabel.setPrefWidth(150);
    final Label colorLabel = new Label("Colour");
    colorLabel.setPrefWidth(40);
    colorLabel.setAlignment(Pos.CENTER);
    final Label sizeLabel = new Label("Size");
    sizeLabel.setPrefWidth(50);
    sizeLabel.setAlignment(Pos.CENTER);
    final Label positionLabel = new Label("Position");
    positionLabel.setPrefWidth(115);
    positionLabel.setAlignment(Pos.CENTER);
    labelTitles.getChildren().addAll(attrLabel, colorLabel, sizeLabel, positionLabel);
    labelPaneContent.setPadding(new Insets(5));
    labelPaneContent.getChildren().addAll(labelTitles, labelEntries);

    final ScrollPane labelsScrollPane = new ScrollPane();
    labelsScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    labelsScrollPane.setPrefHeight(200);
    labelsScrollPane.setPrefWidth(400);
    labelsScrollPane.setContent(labelPaneContent);

    addButton.setOnAction(e -> {
        new LabelEntry(labels, labelEntries, attributeNames.isEmpty() ? "" : attributeNames.get(0), ConstellationColor.LIGHT_BLUE, 1);
        addButton.setDisable(labels.size() == GraphLabels.MAX_LABELS);
        update();
    });
    final Label addButtonLabel = new Label("Add Label");
    final FlowPane addPane = new FlowPane();
    addPane.setHgap(10);
    addPane.setAlignment(Pos.CENTER_RIGHT);
    addPane.getChildren().addAll(addButtonLabel, addButton);

    final VBox controls = new VBox(10);
    controls.setPrefWidth(400);
    controls.getChildren().addAll(labelsScrollPane, addPane);

    return controls;
}
 
Example 18
Source File: VertexGraphLabelsEditorFactory.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
protected Node createEditorControls() {
    // get all vertex attributes currently in the graph
    final ReadableGraph rg = GraphManager.getDefault().getActiveGraph().getReadableGraph();
    try {
        for (int i = 0; i < rg.getAttributeCount(GraphElementType.VERTEX); i++) {
            attributeNames.add(rg.getAttributeName(rg.getAttribute(GraphElementType.VERTEX, i)));
        }
    } finally {
        rg.release();
    }
    attributeNames.sort(String::compareTo);

    HBox labelTitles = new HBox();
    final Label attrLabel = new Label("Attribute");
    attrLabel.setAlignment(Pos.CENTER);
    attrLabel.setPrefWidth(150);
    final Label colorLabel = new Label("Colour");
    colorLabel.setPrefWidth(40);
    colorLabel.setAlignment(Pos.CENTER);
    final Label sizeLabel = new Label("Size");
    sizeLabel.setPrefWidth(50);
    sizeLabel.setAlignment(Pos.CENTER);
    final Label positionLabel = new Label("Position");
    positionLabel.setPrefWidth(115);
    positionLabel.setAlignment(Pos.CENTER);
    labelTitles.getChildren().addAll(attrLabel, colorLabel, sizeLabel, positionLabel);
    labelPaneContent.setPadding(new Insets(5));
    labelPaneContent.getChildren().addAll(labelTitles, labelEntries);

    final ScrollPane labelsScrollPane = new ScrollPane();
    labelsScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    labelsScrollPane.setPrefHeight(200);
    labelsScrollPane.setPrefWidth(400);
    labelsScrollPane.setContent(labelPaneContent);

    addButton.setOnAction(e -> {
        new LabelEntry(labels, labelEntries, attributeNames.isEmpty() ? "" : attributeNames.get(0), ConstellationColor.LIGHT_BLUE, 1);
        addButton.setDisable(labels.size() == GraphLabels.MAX_LABELS);
        update();
    });
    final Label addButtonLabel = new Label("Add Label");
    final FlowPane addPane = new FlowPane();
    addPane.setHgap(10);
    addPane.setAlignment(Pos.CENTER_RIGHT);
    addPane.getChildren().addAll(addButtonLabel, addButton);

    final VBox controls = new VBox(10);
    controls.setPrefWidth(400);
    controls.getChildren().addAll(labelsScrollPane, addPane);

    return controls;
}