Search in sources :

Example 61 with ScrollPane

use of javafx.scene.control.ScrollPane in project trex-stateless-gui by cisco-system-traffic-generator.

the class LogsView method buildUI.

private void buildUI() {
    contentWrapper = new ScrollPane();
    contentWrapper.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
    getChildren().add(contentWrapper);
    setTopAnchor(contentWrapper, 0d);
    setLeftAnchor(contentWrapper, 0d);
    setBottomAnchor(contentWrapper, 0d);
    setRightAnchor(contentWrapper, 0d);
    logsContent = new VBox();
    logsContent.setId("logs_view");
    logsContent.heightProperty().addListener((observable, oldValue, newValue) -> contentWrapper.setVvalue((Double) newValue));
    logsContent.setSpacing(5);
    contentWrapper.setContent(logsContent);
}
Also used : ScrollPane(javafx.scene.control.ScrollPane) VBox(javafx.scene.layout.VBox)

Example 62 with ScrollPane

use of javafx.scene.control.ScrollPane in project POL-POM-5 by PlayOnLinux.

the class ContainerEngineSettingsPanelSkin method initialise.

/**
 * {@inheritDoc}
 */
@Override
public void initialise() {
    final Text title = new Text(tr("Engine Settings"));
    title.getStyleClass().add("title");
    final GridPane engineSettingsGrid = new GridPane();
    engineSettingsGrid.getStyleClass().add("engine-settings-grid");
    // ensure that the shown engine settings are always up to date
    getControl().containerProperty().addListener((Observable invalidation) -> updateEngineSettingsGrid(engineSettingsGrid));
    getControl().getEngineSettings().addListener((Observable invalidation) -> updateEngineSettingsGrid(engineSettingsGrid));
    // ensure that the shown engine settings are correctly initialized
    updateEngineSettingsGrid(engineSettingsGrid);
    final ScrollPane engineSettingsScrollPane = new ScrollPane(engineSettingsGrid);
    engineSettingsScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    engineSettingsScrollPane.setFitToWidth(true);
    VBox.setVgrow(engineSettingsScrollPane, Priority.ALWAYS);
    final VBox container = new VBox(title, engineSettingsScrollPane);
    container.getStyleClass().addAll("container-details-panel", "container-engine-settings-panel");
    getChildren().setAll(container);
}
Also used : GridPane(javafx.scene.layout.GridPane) ScrollPane(javafx.scene.control.ScrollPane) Text(javafx.scene.text.Text) VBox(javafx.scene.layout.VBox) Observable(javafx.beans.Observable)

Example 63 with ScrollPane

use of javafx.scene.control.ScrollPane in project POL-POM-5 by PlayOnLinux.

the class ApplicationInformationPanelSkin method initialise.

/**
 * {@inheritDoc}
 */
@Override
public void initialise() {
    final WebView appDescription = new WebView();
    appDescription.getEngine().userStyleSheetLocationProperty().bind(getControl().webEngineStylesheetProperty());
    VBox.setVgrow(appDescription, Priority.ALWAYS);
    getControl().applicationProperty().addListener((Observable invalidation) -> updateDescription(appDescription));
    updateDescription(appDescription);
    final Label installers = new Label(tr("Installers"));
    installers.getStyleClass().add("descriptionTitle");
    final GridPane scriptGrid = new GridPane();
    filteredScripts.addListener((InvalidationListener) change -> updateScripts(scriptGrid));
    getControl().showScriptSourceProperty().addListener((Observable invalidation) -> updateScripts(scriptGrid));
    updateScripts(scriptGrid);
    final HBox miniaturesPane = new HBox();
    miniaturesPane.getStyleClass().add("appPanelMiniaturesPane");
    Bindings.bindContent(miniaturesPane.getChildren(), miniatures);
    final ScrollPane miniaturesPaneWrapper = new ScrollPane(miniaturesPane);
    miniaturesPaneWrapper.getStyleClass().add("appPanelMiniaturesPaneWrapper");
    miniatureHeight.bind(miniaturesPaneWrapper.heightProperty().multiply(0.8));
    final VBox container = new VBox(appDescription, installers, scriptGrid, miniaturesPaneWrapper);
    getChildren().add(container);
    // ensure that the content of the details panel changes when the to be shown application changes
    getControl().applicationProperty().addListener((Observable invalidation) -> updateApplication());
    // initialise the content of the details panel correct
    updateApplication();
}
Also used : Button(javafx.scene.control.Button) OperatingSystem(org.phoenicis.entities.OperatingSystem) javafx.scene.layout(javafx.scene.layout) MappedList(org.phoenicis.javafx.collections.MappedList) FXCollections(javafx.collections.FXCollections) DoubleProperty(javafx.beans.property.DoubleProperty) Bindings(javafx.beans.binding.Bindings) InvalidationListener(javafx.beans.InvalidationListener) ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog) ScrollPane(javafx.scene.control.ScrollPane) URI(java.net.URI) Tooltip(javafx.scene.control.Tooltip) SkinBase(org.phoenicis.javafx.components.common.skin.SkinBase) WebView(javafx.scene.web.WebView) Label(javafx.scene.control.Label) Value(org.graalvm.polyglot.Value) FilteredList(javafx.collections.transformation.FilteredList) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) Observable(javafx.beans.Observable) ApplicationInformationPanel(org.phoenicis.javafx.components.application.control.ApplicationInformationPanel) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) Platform(javafx.application.Platform) Installer(org.phoenicis.scripts.Installer) ImageView(javafx.scene.image.ImageView) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) OperatingSystemFetcher(org.phoenicis.tools.system.OperatingSystemFetcher) ObservableList(javafx.collections.ObservableList) Image(javafx.scene.image.Image) ScriptDTO(org.phoenicis.repository.dto.ScriptDTO) ScrollPane(javafx.scene.control.ScrollPane) Label(javafx.scene.control.Label) WebView(javafx.scene.web.WebView) Observable(javafx.beans.Observable)

Example 64 with ScrollPane

use of javafx.scene.control.ScrollPane in project jvarkit by lindenb.

the class IndexCovJfx method doWork.

@Override
public int doWork(final Stage primaryStage, final List<String> args) {
    final Rectangle2D screen = Screen.getPrimary().getVisualBounds();
    final Pattern tab = Pattern.compile("[\t]");
    BufferedReader r = null;
    try {
        final File inputFile;
        if (args.isEmpty()) {
            // open gui
            final FileChooser fc = new FileChooser();
            inputFile = fc.showOpenDialog(null);
            if (inputFile == null) {
                return 0;
            }
        } else if (args.size() == 1) {
            inputFile = new File(args.get(0));
        } else {
            LOG.error("Illegal Number of arguments: " + args);
            return -1;
        }
        r = IOUtils.openFileForBufferedReading(inputFile);
        String line = r.readLine();
        if (line == null) {
            new Alert(AlertType.ERROR, "Cannot read first line of " + inputFile, ButtonType.OK).showAndWait();
            return -1;
        }
        String[] tokens = tab.split(line);
        if (tokens.length < 4 || !tokens[0].equals("#chrom") || !tokens[1].equals("start") || !tokens[2].equals("end")) {
            new Alert(AlertType.ERROR, "bad first line " + line + " in " + inputFile, ButtonType.OK).showAndWait();
            return -1;
        }
        this.sampleNames.addAll(Arrays.asList(tokens).subList(3, tokens.length).stream().map(S -> new Sample(S)).collect(Collectors.toList()));
        this.sampleListView = new ListView<>(this.sampleNames);
        final MultipleSelectionModel<Sample> sampleSelectionModel = this.sampleListView.getSelectionModel();
        sampleSelectionModel.setSelectionMode(SelectionMode.MULTIPLE);
        // this.sampleListView.setPrefWidth(200);
        final SmartComparator smartCmp = new SmartComparator();
        this.orignalndexCovRows.addAll(r.lines().filter(L -> !StringUtil.isBlank(L)).map(L -> Arrays.asList(tab.split(L))).map(T -> new IndexCovRow(T)).sorted((A, B) -> {
            int i = smartCmp.compare(A.getContig(), B.getContig());
            if (i != 0)
                return i;
            return A.getStart() - B.getStart();
        }).collect(Collectors.toList()));
        this.visibleIndexCovRows.addAll(orignalndexCovRows);
        String lastContig = null;
        for (final IndexCovRow row : this.visibleIndexCovRows) {
            if (lastContig == null || !lastContig.equals(row.getContig())) {
                this.contig2color.put(row.getContig(), this.contig2color.size() % 2 == 0 ? gray(0.96) : gray(0.98));
                lastContig = row.getContig();
            }
        }
        this.canvas = new Canvas(screen.getWidth() - 400, screen.getHeight() - 200);
        this.canvasSrollPane = new ScrollPane(canvas);
        this.canvasSrollPane.setFitToHeight(true);
        this.canvasSrollPane.setFitToWidth(true);
        this.canvasSrollPane.setHbarPolicy(ScrollBarPolicy.ALWAYS);
        this.canvasSrollPane.setHmin(0);
        // NOT HERE: see adjustScollPane();
        // this.canvasSrollPane.setHmax(this.visibleIndexCovRows.size()*CHUNK_WIDTH);
        // this.canvasSrollPane.setHvalue(0);
        this.canvasSrollPane.hvalueProperty().addListener(E -> repaintCanvas());
        final VBox root = new VBox();
        final MenuBar menuBar = new MenuBar();
        Menu menu = new Menu("Tools");
        MenuItem item = new MenuItem("Goto");
        item.setOnAction(AE -> askGoto());
        item.setAccelerator(new KeyCodeCombination(KeyCode.G, KeyCombination.CONTROL_DOWN));
        menu.getItems().add(item);
        menu.getItems().add(new SeparatorMenuItem());
        // 
        item = new MenuItem("Cleanup: remove data > DEL && data < DUP");
        item.setOnAction(AE -> askCleanup());
        menu.getItems().add(item);
        // 
        item = new MenuItem("Cleanup: remove ALL samples <= DEL or ALL samples >= DUP");
        item.setOnAction(AE -> askEveryWhere());
        menu.getItems().add(item);
        // 
        item = new MenuItem("Cleanup: keep selected samples having <= DEL or ALL samples >= DUP");
        item.setOnAction(AE -> filterForSampleSet(false));
        menu.getItems().add(item);
        // 
        item = new MenuItem("Cleanup: keep selected samples having <= DEL or ALL samples >= DUP and only those samples.");
        item.setOnAction(AE -> filterForSampleSet(true));
        menu.getItems().add(item);
        // 
        item = new MenuItem("Filter: Keep data overlapping BED file");
        item.setOnAction(AE -> filterBed(false));
        menu.getItems().add(item);
        // 
        item = new MenuItem("Filter: Keep data NOT overlapping BED file");
        item.setOnAction(AE -> filterBed(true));
        menu.getItems().add(item);
        // 
        item = new MenuItem("Revert: Restore original data");
        item.setOnAction(AE -> doRestoreOriginalData());
        item.setAccelerator(new KeyCodeCombination(KeyCode.R, KeyCombination.CONTROL_DOWN));
        menu.getItems().add(item);
        menu.getItems().add(new SeparatorMenuItem());
        item = new MenuItem("Next Interesting");
        item.setOnAction(AE -> goToNextInteresting(1));
        item.setAccelerator(new KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN));
        menu.getItems().add(item);
        item = new MenuItem("Previous Interesting");
        item.setOnAction(AE -> goToNextInteresting(-1));
        item.setAccelerator(new KeyCodeCombination(KeyCode.P, KeyCombination.CONTROL_DOWN));
        menu.getItems().add(item);
        menu.getItems().add(new SeparatorMenuItem());
        item = new MenuItem("Quit");
        menu.getItems().add(item);
        item.setOnAction(AE -> {
            Platform.exit();
        });
        menuBar.getMenus().add(menu);
        root.getChildren().add(menuBar);
        final HBox toolboxPane = new HBox();
        Label label = new Label("DEL when \u2264 :");
        toolboxPane.getChildren().add(label);
        this.deletionSpinner = new Spinner<>(0.0, 0.9, DEFAULT_deletionTreshold, 0.05);
        label.setLabelFor(this.deletionSpinner);
        this.deletionSpinner.valueProperty().addListener((a, b, c) -> repaintCanvas());
        toolboxPane.getChildren().add(this.deletionSpinner);
        label = new Label("DUP when \u2265 :");
        toolboxPane.getChildren().add(label);
        this.duplicationSpinner = new Spinner<>(1.1, 10.0, DEFAULT_duplicationTreshold, 0.05);
        this.duplicationSpinner.valueProperty().addListener((a, b, c) -> repaintCanvas());
        label.setLabelFor(this.duplicationSpinner);
        toolboxPane.getChildren().add(this.duplicationSpinner);
        label = new Label(" Jump to :");
        toolboxPane.getChildren().add(label);
        final TextField jumpToTextField = new TextField();
        jumpToTextField.setPromptText("chrom:pos");
        jumpToTextField.setPrefColumnCount(15);
        toolboxPane.getChildren().add(jumpToTextField);
        label.setLabelFor(jumpToTextField);
        jumpToTextField.setOnAction(AE -> askGoto(jumpToTextField.getText()));
        final Button goButton = new Button("Go");
        toolboxPane.getChildren().add(goButton);
        goButton.setOnAction(AE -> askGoto(jumpToTextField.getText()));
        root.getChildren().add(toolboxPane);
        // HBox hbox = new HBox(sampleListView,this.canvasSrollPane);
        final GridPane grid = new GridPane();
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(5, 5, 5, 5));
        grid.add(this.sampleListView, 0, 0, 1, 1);
        grid.add(this.canvasSrollPane, 1, 0, 9, 1);
        // final StackPane root = new StackPane();
        root.getChildren().add(grid);
        final Scene scene = new Scene(root);
        primaryStage.setTitle(IndexCovJfx.class.getSimpleName() + " " + this.sampleNames.size() + " Sample(s) " + this.visibleIndexCovRows.size() + " Point(s).");
        primaryStage.setOnShown(E -> {
            adjustScollPane();
            this.canvasSrollPane.requestFocus();
            repaintCanvas();
            if (this.isUnitText()) {
                Platform.exit();
            }
        });
        this.canvasSrollPane.setOnKeyPressed(e -> {
            if (e.getCode() == KeyCode.LEFT) {
                canvasSrollPane.setHvalue(Math.max(canvasSrollPane.getHmin(), canvasSrollPane.getHvalue() - CHUNK_WIDTH));
            }
            if (e.getCode() == KeyCode.RIGHT) {
                canvasSrollPane.setHvalue(Math.min(canvasSrollPane.getHmax(), canvasSrollPane.getHvalue() + CHUNK_WIDTH));
            }
        });
        primaryStage.setScene(scene);
        primaryStage.show();
        /*sampleSelectionModel.selectedItemProperty().addListener(E->{
	        	repaintCanvas();
				});
	        sampleSelectionModel.selectedItemProperty().addListener(E->repaintCanvas());*/
        sampleSelectionModel.getSelectedIndices().addListener(new ListChangeListener<Integer>() {

            @Override
            public void onChanged(Change<? extends Integer> c) {
                repaintCanvas();
            }
        });
    } catch (final Exception err) {
        LOG.error(err);
        new Alert(AlertType.ERROR, "Error " + err, ButtonType.OK).showAndWait();
        return -1;
    } finally {
        CloserUtil.close(r);
    }
    return 0;
}
Also used : Button(javafx.scene.control.Button) Arrays(java.util.Arrays) Program(com.github.lindenb.jvarkit.util.jcommander.Program) AbstractList(java.util.AbstractList) VBox(javafx.scene.layout.VBox) MultipleSelectionModel(javafx.scene.control.MultipleSelectionModel) KeyCombination(javafx.scene.input.KeyCombination) Application(javafx.application.Application) ScrollPane(javafx.scene.control.ScrollPane) StringUtil(htsjdk.samtools.util.StringUtil) ListChangeListener(javafx.collections.ListChangeListener) AlertType(javafx.scene.control.Alert.AlertType) Locale(java.util.Locale) Map(java.util.Map) Hershey(com.github.lindenb.jvarkit.util.Hershey) CloserUtil(htsjdk.samtools.util.CloserUtil) Alert(javafx.scene.control.Alert) HBox(javafx.scene.layout.HBox) Rectangle2D(javafx.geometry.Rectangle2D) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) GraphicsContext(javafx.scene.canvas.GraphicsContext) JfxLauncher(com.github.lindenb.jvarkit.util.jcommander.JfxLauncher) Logger(com.github.lindenb.jvarkit.util.log.Logger) Set(java.util.Set) Canvas(javafx.scene.canvas.Canvas) Spinner(javafx.scene.control.Spinner) Screen(javafx.stage.Screen) Collectors(java.util.stream.Collectors) Platform(javafx.application.Platform) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) List(java.util.List) SmartComparator(com.github.lindenb.jvarkit.lang.SmartComparator) ScrollBarPolicy(javafx.scene.control.ScrollPane.ScrollBarPolicy) TextInputDialog(javafx.scene.control.TextInputDialog) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) ObservableList(javafx.collections.ObservableList) IntStream(java.util.stream.IntStream) Scene(javafx.scene.Scene) ListView(javafx.scene.control.ListView) ButtonType(javafx.scene.control.ButtonType) BedLineCodec(com.github.lindenb.jvarkit.util.bio.bed.BedLineCodec) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) NumberFormat(java.text.NumberFormat) ArrayList(java.util.ArrayList) Interval(htsjdk.samtools.util.Interval) Insets(javafx.geometry.Insets) IOUtils(com.github.lindenb.jvarkit.io.IOUtils) GridPane(javafx.scene.layout.GridPane) Locatable(htsjdk.samtools.util.Locatable) KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) Label(javafx.scene.control.Label) MenuBar(javafx.scene.control.MenuBar) File(java.io.File) Menu(javafx.scene.control.Menu) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) FileChooser(javafx.stage.FileChooser) SelectionMode(javafx.scene.control.SelectionMode) Stage(javafx.stage.Stage) BufferedReader(java.io.BufferedReader) HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) Label(javafx.scene.control.Label) MenuBar(javafx.scene.control.MenuBar) Button(javafx.scene.control.Button) FileChooser(javafx.stage.FileChooser) TextField(javafx.scene.control.TextField) Menu(javafx.scene.control.Menu) Pattern(java.util.regex.Pattern) GridPane(javafx.scene.layout.GridPane) Canvas(javafx.scene.canvas.Canvas) Rectangle2D(javafx.geometry.Rectangle2D) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Scene(javafx.scene.Scene) SmartComparator(com.github.lindenb.jvarkit.lang.SmartComparator) ScrollPane(javafx.scene.control.ScrollPane) BufferedReader(java.io.BufferedReader) Alert(javafx.scene.control.Alert) File(java.io.File) VBox(javafx.scene.layout.VBox)

Example 65 with ScrollPane

use of javafx.scene.control.ScrollPane in project jvarkit by lindenb.

the class JfxNgs method showExceptionDialog.

static void showExceptionDialog(final Window owner, Object err) {
    final Alert alert = new Alert(AlertType.WARNING);
    alert.setTitle("Error");
    if (err != null && err instanceof Throwable) {
        alert.setHeaderText("Error");
        final Throwable error = (Throwable) err;
        alert.setContentText(String.valueOf(error.getMessage()));
        error.printStackTrace();
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        error.printStackTrace(pw);
        String exceptionText = sw.toString();
        final Label label = new Label("The exception stacktrace was:");
        final TextArea textArea = new TextArea(exceptionText);
        textArea.setEditable(false);
        textArea.setWrapText(false);
        textArea.setMaxWidth(Double.MAX_VALUE);
        textArea.setMaxHeight(Double.MAX_VALUE);
        GridPane.setVgrow(textArea, Priority.ALWAYS);
        GridPane.setHgrow(textArea, Priority.ALWAYS);
        final BorderPane expContent = new BorderPane(new ScrollPane(textArea));
        expContent.setTop(label);
        expContent.setMinHeight(500);
        expContent.setMinWidth(800);
        expContent.setPrefWidth(1000);
        expContent.setPrefHeight(900);
        // Set expandable Exception into the dialog pane.
        alert.getDialogPane().setExpandableContent(expContent);
    } else {
        final String msg = String.valueOf(err);
        alert.setHeaderText(msg);
        alert.setContentText(msg);
        alert.getDialogPane().setExpandableContent(new Label(msg));
    }
    alert.showAndWait();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) StringWriter(java.io.StringWriter) TextArea(javafx.scene.control.TextArea) ScrollPane(javafx.scene.control.ScrollPane) Label(javafx.scene.control.Label) Alert(javafx.scene.control.Alert) PrintWriter(java.io.PrintWriter)

Aggregations

ScrollPane (javafx.scene.control.ScrollPane)71 VBox (javafx.scene.layout.VBox)18 Text (javafx.scene.text.Text)15 Scene (javafx.scene.Scene)14 Label (javafx.scene.control.Label)13 Insets (javafx.geometry.Insets)11 Button (javafx.scene.control.Button)11 BorderPane (javafx.scene.layout.BorderPane)11 HBox (javafx.scene.layout.HBox)10 GridPane (javafx.scene.layout.GridPane)9 TextFlow (javafx.scene.text.TextFlow)8 FXCollections (javafx.collections.FXCollections)7 Node (javafx.scene.Node)7 TextArea (javafx.scene.control.TextArea)7 javafx.scene.layout (javafx.scene.layout)7 Pane (javafx.scene.layout.Pane)7 InvalidationListener (javafx.beans.InvalidationListener)6 Observable (javafx.beans.Observable)6 ObservableList (javafx.collections.ObservableList)6 Alert (javafx.scene.control.Alert)6