List of usage examples for javafx.scene.layout HBox setSpacing
public final void setSpacing(double value)
From source file:com.exalttech.trex.ui.views.PacketTableView.java
/** * Build component UI/*w w w. j a va 2s . c o m*/ */ private void buildUI(boolean addExportToYamlBtn) { setTopAnchor(this, 0d); setLeftAnchor(this, 0d); setBottomAnchor(this, 0d); setRightAnchor(this, 0d); // build btn bar HBox buttonContainer = new HBox(); buttonContainer.setSpacing(5); addPacketBtn = new StreamTableButton(StreamTableAction.ADD); initializeStreamButtons(addPacketBtn, false); buttonContainer.getChildren().add(addPacketBtn); // add build stream btn buildPacketBtn = new StreamTableButton(StreamTableAction.BUILD); buildPacketBtn.setId("buildStreamBtn"); initializeStreamButtons(buildPacketBtn, false); buttonContainer.getChildren().add(buildPacketBtn); editPacketBtn = new StreamTableButton(StreamTableAction.EDIT); editPacketBtn.setId("editStreanBtn"); initializeStreamButtons(editPacketBtn, true); buttonContainer.getChildren().add(editPacketBtn); deleteButtonBtn = new StreamTableButton(StreamTableAction.DELETE); initializeStreamButtons(deleteButtonBtn, true); buttonContainer.getChildren().add(deleteButtonBtn); importPcapButton = new StreamTableButton(StreamTableAction.IMPORT_PCAP); initializeStreamButtons(importPcapButton, false); buttonContainer.getChildren().add(importPcapButton); exportPcapButton = new StreamTableButton(StreamTableAction.EXPORT_TO_PCAP); initializeStreamButtons(exportPcapButton, true); buttonContainer.getChildren().add(exportPcapButton); if (addExportToYamlBtn) { exportToYaml = new StreamTableButton(StreamTableAction.EXPORT_TO_YAML); initializeStreamButtons(exportToYaml, false); buttonContainer.getChildren().add(exportToYaml); } getChildren().add(buttonContainer); setTopAnchor(buttonContainer, 5d); rightClickMenu = new ContextMenu(); addMenuItem(StreamTableAction.EDIT); addMenuItem(StreamTableAction.DELETE); addMenuItem(StreamTableAction.EXPORT_TO_PCAP); addMenuItem(StreamTableAction.EXPORT_TO_YAML); // add table view streamPacketTableView = new TableView<>(); streamPacketTableView.setId("streamTableView"); streamPacketTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); streamPacketTableView.setFixedCellSize(32); streamPacketTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); streamPacketTableView.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { handleTableRowClick(event); } }); streamPacketTableView.getSelectionModel().selectedItemProperty() .addListener((ObservableValue<? extends TableProfileStream> observable, TableProfileStream oldValue, TableProfileStream newValue) -> { boolean notSelected = !(newValue != null); exportPcapButton.setDisable(notSelected); editPacketBtn.setDisable(notSelected); deleteButtonBtn.setDisable(notSelected); }); streamPacketTableView.addEventFilter(KeyEvent.KEY_RELEASED, (KeyEvent event) -> { if (copyCombination.match(event)) { selectedProfile = tabledata.getProfiles() .get(streamPacketTableView.getSelectionModel().getSelectedIndex()); } else if (pasteCombination.match(event)) { handleDuplicateStream(); } else if (event.getCode() == KeyCode.DELETE) { handleDeletePacket(); } }); streamPacketTableView.setEditable(true); initializeTableColumn(); // disable table reordering streamPacketTableView.widthProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> source, Number oldWidth, Number newWidth) { TableHeaderRow header = (TableHeaderRow) streamPacketTableView.lookup("TableHeaderRow"); header.reorderingProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { header.setReordering(false); } }); } }); getChildren().add(streamPacketTableView); setTopAnchor(streamPacketTableView, 35d); setBottomAnchor(streamPacketTableView, 5d); setLeftAnchor(streamPacketTableView, 0d); setRightAnchor(streamPacketTableView, 0d); }
From source file:Main.java
private VBox getTransformationControls() { xSlider.setShowTickMarks(true);/*from w w w .j a v a2 s.c om*/ xSlider.setShowTickLabels(true); xSlider.snapToTicksProperty().set(true); ySlider.setShowTickMarks(true); ySlider.setShowTickLabels(true); ySlider.snapToTicksProperty().set(true); widthSlider.setShowTickMarks(true); widthSlider.setShowTickLabels(true); widthSlider.snapToTicksProperty().set(true); heightSlider.setShowTickMarks(true); heightSlider.setShowTickLabels(true); heightSlider.snapToTicksProperty().set(true); opacitySlider.setShowTickMarks(true); opacitySlider.setShowTickLabels(true); opacitySlider.snapToTicksProperty().set(true); opacitySlider.setMinorTickCount(5); opacitySlider.setMajorTickUnit(0.20d); strokeSlider.setShowTickMarks(true); strokeSlider.setShowTickLabels(true); strokeSlider.snapToTicksProperty().set(true); strokeSlider.setMinorTickCount(5); strokeSlider.setMajorTickUnit(1.0d); translateXSlider.setShowTickMarks(true); translateXSlider.setShowTickLabels(true); translateXSlider.snapToTicksProperty().set(true); translateYSlider.setShowTickMarks(true); translateYSlider.setShowTickLabels(true); translateYSlider.snapToTicksProperty().set(true); rotateSlider.setShowTickMarks(true); rotateSlider.setShowTickLabels(true); rotateSlider.snapToTicksProperty().set(true); rotateSlider.setMinorTickCount(5); rotateSlider.setMajorTickUnit(30.0); scaleXSlider.setShowTickMarks(true); scaleXSlider.setShowTickLabels(true); scaleXSlider.setMajorTickUnit(0.2d); scaleXSlider.setLabelFormatter(new DoubleStringConverter()); scaleXSlider.snapToTicksProperty().set(true); scaleYSlider.setShowTickMarks(true); scaleYSlider.setShowTickLabels(true); scaleYSlider.setMajorTickUnit(0.2d); scaleYSlider.setLabelFormatter(new DoubleStringConverter()); scaleYSlider.snapToTicksProperty().set(true); shearXSlider.setShowTickMarks(true); shearXSlider.setShowTickLabels(true); shearXSlider.setMajorTickUnit(0.2d); shearXSlider.setLabelFormatter(new DoubleStringConverter()); shearXSlider.snapToTicksProperty().set(true); shearYSlider.setShowTickMarks(true); shearYSlider.setShowTickLabels(true); shearYSlider.setMajorTickUnit(0.2d); shearYSlider.setLabelFormatter(new DoubleStringConverter()); shearYSlider.snapToTicksProperty().set(true); HBox xyBox = new HBox(); xyBox.setSpacing(5); xyBox.getChildren().addAll(VBoxBuilder.create().children(xLabel, xSlider).build(), VBoxBuilder.create().children(yLabel, ySlider).build()); HBox whBox = new HBox(); whBox.setSpacing(5); whBox.getChildren().addAll(VBoxBuilder.create().children(widthLabel, widthSlider).build(), VBoxBuilder.create().children(heightLabel, heightSlider).build()); HBox colorBox = new HBox(); colorBox.setSpacing(5); colorBox.getChildren().addAll(VBoxBuilder.create().children(strokeLabel, strokeSlider).build(), VBoxBuilder.create().children(new Label("Stroke Color"), rectStrokeColorChoiceBox).build()); HBox opacityBox = new HBox(); opacityBox.setSpacing(5); opacityBox.getChildren().addAll(VBoxBuilder.create().children(opacityLabel, opacitySlider).build(), VBoxBuilder.create().children(new Label("Fill Color"), rectFillColorChoiceBox).build()); HBox translateBox = new HBox(); translateBox.setSpacing(5); translateBox.getChildren().addAll(VBoxBuilder.create().children(translateXLabel, translateXSlider).build(), VBoxBuilder.create().children(translateYLabel, translateYSlider).build()); HBox rotateBox = new HBox(); rotateBox.setSpacing(5); rotateBox.getChildren().addAll(VBoxBuilder.create().children(rotateLabel, rotateSlider).build()); HBox scaleBox = new HBox(); scaleBox.setSpacing(5); scaleBox.getChildren().addAll(VBoxBuilder.create().children(scaleXLabel, scaleXSlider).build(), VBoxBuilder.create().children(scaleYLabel, scaleYSlider).build()); HBox shearBox = new HBox(); shearBox.setSpacing(5); shearBox.getChildren().addAll(VBoxBuilder.create().children(shearXLabel, shearXSlider).build(), VBoxBuilder.create().children(shearYLabel, shearYSlider).build()); VBox rectangleBox = new VBox(); rectangleBox.getChildren().addAll(xyBox, whBox, colorBox, opacityBox); TitledPane rectangleProps = new TitledPane("Rectangle", rectangleBox); VBox transformBox = new VBox(); transformBox.getChildren().addAll(translateBox, rotateBox, scaleBox, shearBox); TitledPane transformsProps = new TitledPane("Tranformations", transformBox); TitledPane showBoundsControls = getShowBoundsControls(); TitledPane effectPane = getEffectTitledPane(); Button resetAllButton = new Button("Reset All"); resetAllButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { resetAll(); } }); Button saveButton = new Button("Save Layout as Image"); saveButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { saveLayoutAsImage(); } }); Button exitButton = new Button("Exit"); exitButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { Platform.exit(); } }); /* Button printButton = new Button("Print"); printButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { String str = getDesc("layoutBounds", mainRect.getLayoutBounds()) + getDesc("\nboundsInLocal", mainRect.getBoundsInLocal()) + getDesc("\nboundsInParent", mainRect.getBoundsInParent()); //printDataTextArea.setText(str); } private String getDesc(String type, Bounds b) { String str = type + "[minX=" + b.getMinX() + ", minY=" + b.getMinY() + ", width=" + b.getWidth() + ", height=" + b.getHeight() + "]"; return str; } }); */ HBox buttonBox = new HBox(); buttonBox.setSpacing(10); buttonBox.getChildren().addAll(resetAllButton, saveButton, exitButton); VBox vBox = new VBox(); vBox.getChildren().addAll(buttonBox, showBoundsControls, rectangleProps, effectPane, transformsProps); return vBox; }
From source file:account.management.controller.NewVoucherController.java
@FXML private void onAddNewFieldButtonClick(ActionEvent event) { HBox row = new HBox(); row.setId("field_row"); ComboBox<Account> select_account = new ComboBox<>(); if (this.select_type.getSelectionModel().isEmpty()) { select_account.getItems().addAll(this.account_list); } else {//from ww w.jav a 2 s . c om select_account.getItems().addAll(this.filter_acc); } TextField dr = new TextField(); TextField cr = new TextField(); TextField remarks = new TextField(); Button del_row = new Button("Delete"); row.setSpacing(field_row.getSpacing()); ComboBox<Account> combo = (ComboBox) field_row.getChildren().get(0); select_account.setPrefWidth(combo.getPrefWidth()); select_account.setPromptText("Select account"); TextField tf = (TextField) field_row.getChildren().get(1); dr.setPrefWidth(tf.getPrefWidth()); dr.setPromptText("Dr"); tf = (TextField) field_row.getChildren().get(2); cr.setPrefWidth(tf.getPrefWidth()); cr.setPromptText("Cr"); tf = (TextField) field_row.getChildren().get(3); remarks.setPrefWidth(tf.getPrefWidth()); remarks.setPromptText("remarks"); row.getChildren().addAll(select_account, dr, cr, remarks, del_row); field_container.getChildren().add(row); del_row.setOnMouseClicked((MouseEvent event1) -> { field_container.getChildren().removeAll(row); validateFields(); }); combo.setOnAction((e) -> { if (!combo.getSelectionModel().isEmpty() && combo.getSelectionModel().getSelectedItem().getId() == 21) { combo.setPromptText("Select Party"); combo.getItems().clear(); combo.getItems().addAll(this.filter_party_rec); } if (!combo.getSelectionModel().isEmpty() && combo.getSelectionModel().getSelectedItem().getId() == 34) { combo.getItems().clear(); combo.getItems().addAll(this.filter_party_pay); combo.setPromptText("Select Party"); } }); new AutoCompleteComboBoxListener<>(select_account); select_account.setOnHiding((e) -> { Account a = select_account.getSelectionModel().getSelectedItem(); select_account.setEditable(false); select_account.getSelectionModel().select(a); }); select_account.setOnShowing((e) -> { select_account.setEditable(true); }); validateFields(); }
From source file:UI.MainStageController.java
/** * shows the correlation table in the analysis view *//*from ww w. j a v a 2 s. co m*/ @FXML private void displayCorrelationTable() { //Delete whatever's been in the table before TableView<String[]> analysisTable = new TableView<>(); //We want to display correlations and p-Values of every node combination double[][] correlationMatrix = AnalysisData.getCorrelationMatrix().getData(); double[][] pValueMatrix = AnalysisData.getPValueMatrix().getData(); LinkedList<TaxonNode> taxonList = SampleComparison.getUnifiedTaxonList(LoadedData.getSamplesToAnalyze(), AnalysisData.getLevelOfAnalysis()); //Table will consist of strings String[][] tableValues = new String[correlationMatrix.length][correlationMatrix[0].length + 1]; //Add the values as formatted strings for (int i = 0; i < tableValues.length; i++) { tableValues[i][0] = taxonList.get(i).getName(); for (int j = 1; j < tableValues[0].length; j++) { tableValues[i][j] = String.format("%.3f", correlationMatrix[i][j - 1]).replace(",", ".") + "\n(" + String.format("%.2f", pValueMatrix[i][j - 1]).replace(",", ".") + ")"; } } for (int i = 0; i < tableValues[0].length; i++) { String columnTitle; if (i > 0) { columnTitle = taxonList.get(i - 1).getName(); } else { columnTitle = ""; } TableColumn<String[], String> column = new TableColumn<>(columnTitle); final int columnIndex = i; column.setCellValueFactory(cellData -> { String[] row = cellData.getValue(); return new SimpleStringProperty(row[columnIndex]); }); analysisTable.getColumns().add(column); //First column contains taxon names and should be italic if (i == 0) column.setStyle("-fx-font-style:italic;"); } for (int i = 0; i < tableValues.length; i++) { analysisTable.getItems().add(tableValues[i]); } //Display table on a new stage Stage tableStage = new Stage(); tableStage.setTitle("Correlation Table"); BorderPane tablePane = new BorderPane(); Button exportCorrelationsButton = new Button("Save correlation table to CSV"); Button exportPValuesButton = new Button("Save p-value table to CSV"); exportCorrelationsButton.setOnAction(e -> exportTableToCSV(tableValues, false)); exportPValuesButton.setOnAction(e -> exportTableToCSV(tableValues, true)); HBox exportBox = new HBox(exportCorrelationsButton, exportPValuesButton); exportBox.setPadding(new Insets(10)); exportBox.setSpacing(10); tablePane.setTop(exportBox); tablePane.setCenter(analysisTable); Scene tableScene = new Scene(tablePane); tableStage.setScene(tableScene); tableStage.show(); }