Example usage for javafx.scene.input KeyCode Z

List of usage examples for javafx.scene.input KeyCode Z

Introduction

In this page you can find the example usage for javafx.scene.input KeyCode Z.

Prototype

KeyCode Z

To view the source code for javafx.scene.input KeyCode Z.

Click Source Link

Document

Constant for the Z key.

Usage

From source file:jviewmda.JViewMda.java

@Override
public void start(Stage primaryStage) {
    m_stage = primaryStage;//from www. j  a va2s .c  o m

    String array_path = "";
    Parameters params = getParameters();
    List<String> unnamed_params = params.getUnnamed();
    if (unnamed_params.size() > 0) {
        array_path = unnamed_params.get(0);
    }
    // FOR DEBUGING PURPOSES
    if (array_path.length() == 0) {
        //String debug_path = "/home/magland/wisdm/www/wisdmfileserver/files/fetalmri/sessions/SESSION1/crops/FNP001A-coronal.crop.mda";
        String debug_path = "/home/magland/data/LesionProbe/Images/ID001_FLAIR.nii";
        if ((new File(debug_path)).exists()) {
            array_path = debug_path;
        }
    }

    Menu menu;
    MenuItem item;

    MenuBar menubar = new MenuBar();

    //file menu
    menu = new Menu("File");
    menubar.getMenus().add(menu);
    item = new MenuItem("Open...");
    item.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.CONTROL_DOWN));
    item.setOnAction(e -> on_file_open());
    menu.getItems().add(item);
    item = new MenuItem("Save As...");
    item.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN));
    item.setOnAction(e -> on_file_saveas());
    menu.getItems().add(item);
    menu.getItems().add(new SeparatorMenuItem()); /////////////////////////////////////////////
    item = new MenuItem("Exit");
    item.setAccelerator(new KeyCodeCombination(KeyCode.X, KeyCombination.CONTROL_DOWN));
    item.setOnAction(e -> on_file_exit());
    menu.getItems().add(item);

    //view menu
    menu = new Menu("View");
    menubar.getMenus().add(menu);
    item = new MenuItem("Zoom In");
    item.setAccelerator(new KeyCodeCombination(KeyCode.Z, KeyCombination.CONTROL_DOWN));
    item.setOnAction(e -> on_zoom_in());
    menu.getItems().add(item);
    item = new MenuItem("Zoom Out");
    item.setAccelerator(
            new KeyCodeCombination(KeyCode.Z, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN));
    item.setOnAction(e -> on_zoom_out());
    menu.getItems().add(item);
    menu.getItems().add(new SeparatorMenuItem()); /////////////////////////////////////////////
    {
        CheckMenuItem item0 = new CheckMenuItem("Top Controls");
        item0.setSelected(true);
        item0.setOnAction(e -> {
            m_widget.setTopControlsVisible(item0.isSelected());
        });
        menu.getItems().add(item0);
    }
    {
        CheckMenuItem item0 = new CheckMenuItem("Bottom Controls");
        item0.setSelected(true);
        item0.setOnAction(e -> {
            m_widget.setBottomControlsVisible(item0.isSelected());
        });
        menu.getItems().add(item0);
    }
    {
        CheckMenuItem item0 = new CheckMenuItem("Brightness/Contrast");
        item0.setSelected(true);
        item0.setOnAction(e -> {
            m_widget.setBrightnessContrastVisible(item0.isSelected());
        });
        menu.getItems().add(item0);
    }
    {
        CheckMenuItem item0 = new CheckMenuItem("Slice Slider");
        item0.setSelected(true);
        item0.setOnAction(e -> {
            m_widget.setSliceSliderVisible(item0.isSelected());
        });
        menu.getItems().add(item0);
    }

    //selection menu
    menu = new Menu("Selection");
    menubar.getMenus().add(menu);
    Map<String, CheckMenuItem> mode_items = new HashMap<>();
    m_selection_mode_items = mode_items;
    mode_items.put("rectangle", new CheckMenuItem("Rectangle"));
    mode_items.put("ellipse", new CheckMenuItem("Ellipse"));
    Set<String> keys = mode_items.keySet();
    for (String key : keys) {
        CheckMenuItem item0 = mode_items.get(key);
        menu.getItems().add(item0);
        item0.setOnAction(evt -> {
            on_selection_mode_changed(key);
        });

    }
    mode_items.get("rectangle").setSelected(true);

    VBox root = new VBox();
    root.getChildren().addAll(menubar, m_widget);

    Scene scene = new Scene(root, 500, 450);

    primaryStage.setTitle("JViewMda");
    primaryStage.setScene(scene);
    primaryStage.show();

    if (array_path.length() > 0) {
        open_file(array_path);
    }

    m_prefs = Preferences.userNodeForPackage(this.getClass());

}