Search in sources :

Example 86 with GridPane

use of javafx.scene.layout.GridPane in project org.csstudio.display.builder by kasemir.

the class ImageConfigDialog method createContent.

private Node createContent() {
    final GridPane layout = new GridPane();
    layout.setHgap(5);
    layout.setVgap(5);
    // Debug layout
    // layout.setGridLinesVisible(true);
    // Row to use for the next elements
    int row = 0;
    Label label = new Label("Value Range");
    final Font font = label.getFont();
    final Font section_font = Font.font(font.getFamily(), FontWeight.BOLD, font.getSize());
    label.setFont(section_font);
    layout.add(label, 0, ++row);
    // Only show the color mapping selector when it's currently a named mapping.
    // Suppress when widget has a custom color map.
    final ColorMappingFunction selected_mapping = plot.internalGetImagePlot().getColorMapping();
    if (selected_mapping instanceof NamedColorMapping) {
        label = new Label("Mapping");
        layout.add(label, 1, row);
        final ComboBox<String> mappings = new ComboBox<>();
        mappings.setEditable(false);
        mappings.setMaxWidth(Double.MAX_VALUE);
        for (NamedColorMapping mapping : NamedColorMappings.getMappings()) mappings.getItems().add(mapping.getName());
        mappings.setValue(((NamedColorMapping) selected_mapping).getName());
        mappings.setOnAction(event -> {
            final NamedColorMapping mapping = NamedColorMappings.getMapping(mappings.getValue());
            plot.setColorMapping(mapping);
        });
        layout.add(mappings, 2, row++);
    }
    label = new Label("Minimum");
    layout.add(label, 1, row);
    final TextField min = new TextField(Double.toString(plot.getValueRange().getLow()));
    layout.add(min, 2, row);
    label = new Label("Maximum");
    layout.add(label, 1, ++row);
    final TextField max = new TextField(Double.toString(plot.getValueRange().getHigh()));
    layout.add(max, 2, row);
    final EventHandler<ActionEvent> update_range = event -> {
        try {
            plot.setValueRange(Double.parseDouble(min.getText().trim()), Double.parseDouble(max.getText().trim()));
            plot.internalGetImagePlot().fireChangedValueRange();
        } catch (NumberFormatException ex) {
            final ValueRange range = plot.getValueRange();
            min.setText(Double.toString(range.getLow()));
            max.setText(Double.toString(range.getHigh()));
        }
    };
    min.setOnAction(update_range);
    max.setOnAction(update_range);
    final CheckBox autoscale = new CheckBox("auto-scale");
    autoscale.setSelected(plot.isAutoscale());
    min.setDisable(autoscale.isSelected());
    max.setDisable(autoscale.isSelected());
    autoscale.setOnAction(event -> {
        plot.setAutoscale(autoscale.isSelected());
        min.setDisable(autoscale.isSelected());
        max.setDisable(autoscale.isSelected());
        plot.internalGetImagePlot().fireChangedAutoScale();
    });
    layout.add(autoscale, 2, ++row);
    final CheckBox show_color_bar = new CheckBox("show color bar");
    show_color_bar.setSelected(plot.isShowingColorMap());
    show_color_bar.setOnAction(event -> plot.showColorMap(show_color_bar.isSelected()));
    layout.add(show_color_bar, 2, ++row);
    final CheckBox logscale = new CheckBox("log scale");
    logscale.setSelected(plot.isLogscale());
    logscale.setOnAction(event -> {
        plot.setLogscale(logscale.isSelected());
        plot.internalGetImagePlot().fireChangedLogarithmic();
    });
    layout.add(logscale, 2, ++row);
    label = new Label("Horizontal Axis");
    label.setFont(section_font);
    layout.add(label, 0, ++row);
    row = addAxisContent(layout, row, plot.getXAxis());
    label = new Label("Vertical Axis");
    label.setFont(section_font);
    layout.add(label, 0, ++row);
    row = addAxisContent(layout, row, plot.getYAxis());
    return layout;
}
Also used : NamedColorMapping(org.csstudio.javafx.rtplot.NamedColorMapping) EventHandler(javafx.event.EventHandler) FontWeight(javafx.scene.text.FontWeight) Activator(org.csstudio.javafx.rtplot.Activator) NamedColorMappings(org.csstudio.javafx.rtplot.NamedColorMappings) TextField(javafx.scene.control.TextField) Modality(javafx.stage.Modality) Dialog(javafx.scene.control.Dialog) Label(javafx.scene.control.Label) ButtonType(javafx.scene.control.ButtonType) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) Font(javafx.scene.text.Font) ValueRange(org.csstudio.javafx.rtplot.data.ValueRange) ActionEvent(javafx.event.ActionEvent) ComboBox(javafx.scene.control.ComboBox) RTImagePlot(org.csstudio.javafx.rtplot.RTImagePlot) ImageView(javafx.scene.image.ImageView) ColorMappingFunction(org.csstudio.javafx.rtplot.ColorMappingFunction) Axis(org.csstudio.javafx.rtplot.Axis) GridPane(javafx.scene.layout.GridPane) GridPane(javafx.scene.layout.GridPane) ComboBox(javafx.scene.control.ComboBox) ActionEvent(javafx.event.ActionEvent) ColorMappingFunction(org.csstudio.javafx.rtplot.ColorMappingFunction) Label(javafx.scene.control.Label) Font(javafx.scene.text.Font) ValueRange(org.csstudio.javafx.rtplot.data.ValueRange) CheckBox(javafx.scene.control.CheckBox) NamedColorMapping(org.csstudio.javafx.rtplot.NamedColorMapping) TextField(javafx.scene.control.TextField)

Example 87 with GridPane

use of javafx.scene.layout.GridPane in project org.csstudio.display.builder by kasemir.

the class PlotConfigDialog method createContent.

private Node createContent() {
    final GridPane layout = new GridPane();
    layout.setHgap(5);
    layout.setVgap(5);
    // Debug layout
    // layout.setGridLinesVisible(true);
    // Row to use for the next elements
    int row = 0;
    Label label = new Label("Value Axes");
    final Font font = label.getFont();
    final Font section_font = Font.font(font.getFamily(), FontWeight.BOLD, font.getSize());
    label.setFont(section_font);
    layout.add(label, 0, row++);
    for (Axis<?> axis : plot.getYAxes()) row = addAxisContent(layout, row, axis);
    label = new Label("Horizontal Axis");
    label.setFont(section_font);
    layout.add(label, 0, row++);
    row = addAxisContent(layout, row, plot.getXAxis());
    return layout;
}
Also used : GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) Font(javafx.scene.text.Font)

Example 88 with GridPane

use of javafx.scene.layout.GridPane in project kanonizo by kanonizo.

the class GuiUtils method setStandardSpacing.

public static void setStandardSpacing(Pane node) {
    node.setPadding(new Insets(INSETS_TOP, INSETS_RIGHT, INSETS_BOTTOM, INSETS_LEFT));
    if (node instanceof HBox) {
        ((HBox) node).setSpacing(10);
    } else if (node instanceof VBox) {
        ((VBox) node).setSpacing(10);
    } else if (node instanceof GridPane) {
        GridPane pane = (GridPane) node;
        pane.setHgap(GRID_PANE_H_GAP);
        pane.setVgap(GRID_PANE_V_GAP);
    }
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) GridPane(javafx.scene.layout.GridPane) VBox(javafx.scene.layout.VBox)

Example 89 with GridPane

use of javafx.scene.layout.GridPane in project org.csstudio.display.builder by kasemir.

the class ActionsDialog method createExecuteScriptDetails.

/**
 * @return Sub-pane for ExecuteScript action
 */
private GridPane createExecuteScriptDetails() {
    final InvalidationListener update = whatever -> {
        if (updating || selected_action_index < 0)
            return;
        actions.set(selected_action_index, getExecuteScriptAction());
    };
    final GridPane execute_script_details = new GridPane();
    execute_script_details.setHgap(10);
    execute_script_details.setVgap(10);
    execute_script_details.add(new Label(Messages.ActionsDialog_Description), 0, 0);
    execute_script_description = new TextField();
    execute_script_description.textProperty().addListener(update);
    execute_script_details.add(execute_script_description, 1, 0);
    GridPane.setHgrow(execute_script_description, Priority.ALWAYS);
    execute_script_details.add(new Label(Messages.ActionsDialog_ScriptPath), 0, 1);
    execute_script_file = new TextField();
    execute_script_file.textProperty().addListener(update);
    final Button select = new Button("...");
    select.setOnAction(event -> {
        try {
            final String path = FilenameSupport.promptForRelativePath(widget, execute_script_file.getText());
            if (path != null)
                execute_script_file.setText(path);
            FilenameSupport.performMostAwfulTerribleNoGoodHack(action_list);
        } catch (Exception ex) {
            logger.log(Level.WARNING, "Cannot prompt for filename", ex);
        }
    });
    final HBox path_box = new HBox(execute_script_file, select);
    HBox.setHgrow(execute_script_file, Priority.ALWAYS);
    execute_script_details.add(path_box, 1, 1);
    final Button btn_embed_py = new Button(Messages.ScriptsDialog_BtnEmbedPy, JFXUtil.getIcon("embedded_script.png"));
    btn_embed_py.setOnAction(event -> {
        execute_script_file.setText(ScriptInfo.EMBEDDED_PYTHON);
        final String text = execute_script_text.getText();
        if (text == null || text.trim().isEmpty() || text.trim().equals(ScriptInfo.EXAMPLE_JAVASCRIPT))
            execute_script_text.setText(ScriptInfo.EXAMPLE_PYTHON);
    });
    final Button btn_embed_js = new Button(Messages.ScriptsDialog_BtnEmbedJS, JFXUtil.getIcon("embedded_script.png"));
    btn_embed_js.setOnAction(event -> {
        execute_script_file.setText(ScriptInfo.EMBEDDED_JAVASCRIPT);
        final String text = execute_script_text.getText();
        if (text == null || text.trim().isEmpty() || text.trim().equals(ScriptInfo.EXAMPLE_PYTHON))
            execute_script_text.setText(ScriptInfo.EXAMPLE_JAVASCRIPT);
    });
    execute_script_details.add(new HBox(10, btn_embed_py, btn_embed_js), 1, 2);
    execute_script_details.add(new Label(Messages.ActionsDialog_ScriptText), 0, 3);
    execute_script_text = new TextArea();
    execute_script_text.setText(null);
    execute_script_text.textProperty().addListener(update);
    execute_script_details.add(execute_script_text, 0, 4, 2, 1);
    GridPane.setVgrow(execute_script_text, Priority.ALWAYS);
    return execute_script_details;
}
Also used : Button(javafx.scene.control.Button) ActionInfo(org.csstudio.display.builder.model.properties.ActionInfo) OpenWebpageActionInfo(org.csstudio.display.builder.model.properties.OpenWebpageActionInfo) ListView(javafx.scene.control.ListView) TextArea(javafx.scene.control.TextArea) ButtonType(javafx.scene.control.ButtonType) ListCell(javafx.scene.control.ListCell) FXCollections(javafx.collections.FXCollections) StackPane(javafx.scene.layout.StackPane) VBox(javafx.scene.layout.VBox) Level(java.util.logging.Level) WritePVActionInfo(org.csstudio.display.builder.model.properties.WritePVActionInfo) InvalidationListener(javafx.beans.InvalidationListener) Insets(javafx.geometry.Insets) GridPane(javafx.scene.layout.GridPane) HBox(javafx.scene.layout.HBox) ScriptInfo(org.csstudio.display.builder.model.properties.ScriptInfo) TextField(javafx.scene.control.TextField) OpenFileActionInfo(org.csstudio.display.builder.model.properties.OpenFileActionInfo) Dialog(javafx.scene.control.Dialog) Label(javafx.scene.control.Label) MenuItem(javafx.scene.control.MenuItem) Target(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo.Target) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) ToolkitRepresentation.logger(org.csstudio.display.builder.representation.ToolkitRepresentation.logger) Priority(javafx.scene.layout.Priority) List(java.util.List) ExecuteScriptActionInfo(org.csstudio.display.builder.model.properties.ExecuteScriptActionInfo) ToggleGroup(javafx.scene.control.ToggleGroup) Macros(org.csstudio.display.builder.model.macros.Macros) ActionType(org.csstudio.display.builder.model.properties.ActionInfo.ActionType) RadioButton(javafx.scene.control.RadioButton) ImageView(javafx.scene.image.ImageView) Preferences(org.csstudio.display.builder.model.Preferences) MenuButton(javafx.scene.control.MenuButton) ActionInfos(org.csstudio.display.builder.model.properties.ActionInfos) OpenDisplayActionInfo(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo) Toggle(javafx.scene.control.Toggle) ExecuteCommandActionInfo(org.csstudio.display.builder.model.properties.ExecuteCommandActionInfo) ObservableList(javafx.collections.ObservableList) Widget(org.csstudio.display.builder.model.Widget) Collections(java.util.Collections) Image(javafx.scene.image.Image) HBox(javafx.scene.layout.HBox) GridPane(javafx.scene.layout.GridPane) Button(javafx.scene.control.Button) RadioButton(javafx.scene.control.RadioButton) MenuButton(javafx.scene.control.MenuButton) TextArea(javafx.scene.control.TextArea) Label(javafx.scene.control.Label) InvalidationListener(javafx.beans.InvalidationListener) TextField(javafx.scene.control.TextField)

Example 90 with GridPane

use of javafx.scene.layout.GridPane in project org.csstudio.display.builder by kasemir.

the class ScaledSliderRepresentation method createJFXNode.

@Override
protected GridPane createJFXNode() throws Exception {
    slider.setFocusTraversable(true);
    slider.setOnKeyPressed((final KeyEvent event) -> {
        switch(event.getCode()) {
            case PAGE_UP:
                slider.adjustValue(value + slider.getBlockIncrement());
                event.consume();
                break;
            case PAGE_DOWN:
                slider.adjustValue(value - slider.getBlockIncrement());
                event.consume();
                break;
            default:
                break;
        }
    });
    slider.setValue(value);
    final GridPane pane = new GridPane();
    // pane.setGridLinesVisible(true);
    pane.add(markers, 0, 0);
    pane.getChildren().add(slider);
    return pane;
}
Also used : KeyEvent(javafx.scene.input.KeyEvent) GridPane(javafx.scene.layout.GridPane)

Aggregations

GridPane (javafx.scene.layout.GridPane)147 Label (javafx.scene.control.Label)83 Insets (javafx.geometry.Insets)67 Button (javafx.scene.control.Button)46 TextField (javafx.scene.control.TextField)42 VBox (javafx.scene.layout.VBox)37 Scene (javafx.scene.Scene)36 HBox (javafx.scene.layout.HBox)26 ButtonType (javafx.scene.control.ButtonType)25 Text (javafx.scene.text.Text)24 Node (javafx.scene.Node)23 Dialog (javafx.scene.control.Dialog)23 ColumnConstraints (javafx.scene.layout.ColumnConstraints)18 Stage (javafx.stage.Stage)18 TextWithStyle (org.phoenicis.javafx.views.common.TextWithStyle)17 List (java.util.List)16 CheckBox (javafx.scene.control.CheckBox)16 ImageView (javafx.scene.image.ImageView)14 ActionEvent (javafx.event.ActionEvent)13 ComboBox (javafx.scene.control.ComboBox)13