List of usage examples for javafx.scene.input KeyCode A
KeyCode A
To view the source code for javafx.scene.input KeyCode A.
Click Source Link
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Menus"); Group root = new Group(); Scene scene = new Scene(root, 300, 250, Color.WHITE); MenuBar menuBar = new MenuBar(); Menu menu = new Menu("File"); final MenuItem aboutMenuItem = MenuItemBuilder.create().text("About") .onAction(new EventHandler<ActionEvent>() { @Override/*w ww . j a v a 2s . co m*/ public void handle(ActionEvent e) { System.out.println("You clicked on About!"); } }).accelerator(new KeyCodeCombination(KeyCode.A, KeyCombination.CONTROL_DOWN)).build(); menu.getItems().add(aboutMenuItem); menuBar.getMenus().add(menu); menuBar.prefWidthProperty().bind(primaryStage.widthProperty()); root.getChildren().add(menuBar); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(final Stage stage) { final Keyboard keyboard = new Keyboard(new Key(KeyCode.A), new Key(KeyCode.S), new Key(KeyCode.D), new Key(KeyCode.F)); final Scene scene = new Scene(new Group(keyboard.createNode())); stage.setScene(scene);// w w w .j av a 2 s . c o m stage.setTitle("Keyboard Example"); stage.show(); }
From source file:Main.java
/** * Handle action related to input (in this case specifically only responds to * keyboard event CTRL-A).// www .ja v a2 s. c o m * * @param event Input event. */ @FXML private void handleKeyInput(final InputEvent event) { if (event instanceof KeyEvent) { final KeyEvent keyEvent = (KeyEvent) event; if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.A) { provideAboutFunctionality(); } } }
From source file:at.ac.tuwien.qse.sepm.gui.controller.impl.GridViewImpl.java
@FXML private void initialize() { LOGGER.debug("initializing"); this.grid = new PaginatedImageGrid(menu); content.setCenter(grid);/*from www.j a va 2s .c o m*/ menu.addListener(new MenuListener()); organizer.setFilterChangeAction(this::handleFilterChange); // Selected photos are shown in the inspector. grid.setSelectionChangeAction(inspector::setEntities); // CTRL+A select all photos. root.setOnMouseClicked((event) -> root.requestFocus()); root.addEventFilter(KeyEvent.KEY_PRESSED, event -> { if (event.isControlDown() && event.getCode() == KeyCode.A) { grid.selectAll(); } }); // Updated photos that no longer match the filter are removed from the grid. inspector.setUpdateHandler(() -> { Collection<Photo> photos = inspector.getEntities(); List<Photo> toRemove = new ArrayList<>(photos.size()); List<Photo> toUpdate = new ArrayList<>(photos.size()); photos.forEach(p -> { if (!organizer.accept(p)) { organizer.remove(p); toRemove.add(p); } else { toUpdate.add(p); } }); grid.removePhotos(toRemove); grid.updatePhotos(toUpdate); }); // Apply the initial filter. handleFilterChange(); // subscribe to photo events photoService.subscribeCreate(this::handlePhotoCreated); photoService.subscribeUpdate(this::handlePhotoUpdated); photoService.subscribeDelete(this::handlePhotoDeleted); root.setOnDragEntered(this::handleDragEntered); root.setOnDragOver(this::handleDragOver); root.setOnDragDropped(this::handleDragDropped); root.setOnDragExited(this::handleDragExited); try { if (workspaceService.getDirectories().isEmpty()) { folderDropTarget.setVisible(true); } } catch (ServiceException ex) { ErrorDialog.show(root, "Fehler beim Laden der Bildordner", ""); } }
From source file:com.esri.geoevent.test.performance.ui.OrchestratorController.java
/** * Handle action related to input (in this case specifically only responds * to keyboard event CTRL-A)./* ww w . j a v a 2 s . com*/ * * @param event Input event. */ @FXML public void handleKeyInput(final InputEvent event) { if (event instanceof KeyEvent) { final KeyEvent keyEvent = (KeyEvent) event; if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.A) { provideAboutFunctionality(); } else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.R) { showReportOptionsDialog(); } else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.O) { openFixturesFile(); } else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.S) { saveFixturesFile(); } else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.L) { showLoggerDialog(); } } }
From source file:Main.java
@Override public void start(final Stage stage) { stage.setTitle("Xylophone"); camOffset.getChildren().add(cam);/*from w w w. j a v a2 s . c om*/ resetCam(); final Scene scene = new Scene(camOffset, 800, 600, true); scene.setFill(new RadialGradient(225, 0.85, 300, 300, 500, false, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0f, Color.BLUE), new Stop(1f, Color.LIGHTBLUE) })); scene.setCamera(new PerspectiveCamera()); final AudioClip bar1Note = new AudioClip(Main.class.getResource("audio/Note1.wav").toString()); final AudioClip bar2Note = new AudioClip(Main.class.getResource("audio/Note2.wav").toString()); final AudioClip bar3Note = new AudioClip(Main.class.getResource("audio/Note3.wav").toString()); final AudioClip bar4Note = new AudioClip(Main.class.getResource("audio/Note4.wav").toString()); final AudioClip bar5Note = new AudioClip(Main.class.getResource("audio/Note5.wav").toString()); final AudioClip bar6Note = new AudioClip(Main.class.getResource("audio/Note6.wav").toString()); final AudioClip bar7Note = new AudioClip(Main.class.getResource("audio/Note7.wav").toString()); final AudioClip bar8Note = new AudioClip(Main.class.getResource("audio/Note8.wav").toString()); Group rectangleGroup = new Group(); rectangleGroup.getTransforms().add(shear); rectangleGroup.setDepthTest(DepthTest.ENABLE); double xStart = 260.0; double xOffset = 30.0; double yPos = 300.0; double zPos = 0.0; double barWidth = 22.0; double barDepth = 7.0; // Base1 Cube base1Cube = new Cube(1.0, new Color(0.2, 0.12, 0.1, 1.0), 1.0); base1Cube.setTranslateX(xStart + 135); base1Cube.setTranslateZ(yPos + 20.0); base1Cube.setTranslateY(11.0); base1Cube.setScaleX(barWidth * 11.5); base1Cube.setScaleZ(10.0); base1Cube.setScaleY(barDepth * 2.0); // Base2 Cube base2Cube = new Cube(1.0, new Color(0.2, 0.12, 0.1, 1.0), 1.0); base2Cube.setTranslateX(xStart + 135); base2Cube.setTranslateZ(yPos - 20.0); base2Cube.setTranslateY(11.0); base2Cube.setScaleX(barWidth * 11.5); base2Cube.setScaleZ(10.0); base2Cube.setScaleY(barDepth * 2.0); // Bar1 Cube bar1Cube = new Cube(1.0, Color.PURPLE, 1.0); bar1Cube.setTranslateX(xStart + 1 * xOffset); bar1Cube.setTranslateZ(yPos); bar1Cube.setScaleX(barWidth); bar1Cube.setScaleZ(100.0); bar1Cube.setScaleY(barDepth); // Bar2 Cube bar2Cube = new Cube(1.0, Color.BLUEVIOLET, 1.0); bar2Cube.setTranslateX(xStart + 2 * xOffset); bar2Cube.setTranslateZ(yPos); bar2Cube.setScaleX(barWidth); bar2Cube.setScaleZ(95.0); bar2Cube.setScaleY(barDepth); // Bar3 Cube bar3Cube = new Cube(1.0, Color.BLUE, 1.0); bar3Cube.setTranslateX(xStart + 3 * xOffset); bar3Cube.setTranslateZ(yPos); bar3Cube.setScaleX(barWidth); bar3Cube.setScaleZ(90.0); bar3Cube.setScaleY(barDepth); // Bar4 Cube bar4Cube = new Cube(1.0, Color.GREEN, 1.0); bar4Cube.setTranslateX(xStart + 4 * xOffset); bar4Cube.setTranslateZ(yPos); bar4Cube.setScaleX(barWidth); bar4Cube.setScaleZ(85.0); bar4Cube.setScaleY(barDepth); // Bar5 Cube bar5Cube = new Cube(1.0, Color.GREENYELLOW, 1.0); bar5Cube.setTranslateX(xStart + 5 * xOffset); bar5Cube.setTranslateZ(yPos); bar5Cube.setScaleX(barWidth); bar5Cube.setScaleZ(80.0); bar5Cube.setScaleY(barDepth); // Bar6 Cube bar6Cube = new Cube(1.0, Color.YELLOW, 1.0); bar6Cube.setTranslateX(xStart + 6 * xOffset); bar6Cube.setTranslateZ(yPos); bar6Cube.setScaleX(barWidth); bar6Cube.setScaleZ(75.0); bar6Cube.setScaleY(barDepth); // Bar7 Cube bar7Cube = new Cube(1.0, Color.ORANGE, 1.0); bar7Cube.setTranslateX(xStart + 7 * xOffset); bar7Cube.setTranslateZ(yPos); bar7Cube.setScaleX(barWidth); bar7Cube.setScaleZ(70.0); bar7Cube.setScaleY(barDepth); // Bar8 Cube bar8Cube = new Cube(1.0, Color.RED, 1.0); bar8Cube.setTranslateX(xStart + 8 * xOffset); bar8Cube.setTranslateZ(yPos); bar8Cube.setScaleX(barWidth); bar8Cube.setScaleZ(65.0); bar8Cube.setScaleY(barDepth); bar1Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar1Note.play(); } }); bar2Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar2Note.play(); } }); bar3Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar3Note.play(); } }); bar4Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar4Note.play(); } }); bar5Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar5Note.play(); } }); bar6Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar6Note.play(); } }); bar7Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar7Note.play(); } }); bar8Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar8Note.play(); } }); rectangleGroup.getChildren().addAll(base1Cube, base2Cube, bar1Cube, bar2Cube, bar3Cube, bar4Cube, bar5Cube, bar6Cube, bar7Cube, bar8Cube); rectangleGroup.setScaleX(2.5); rectangleGroup.setScaleY(2.5); rectangleGroup.setScaleZ(2.5); cam.getChildren().add(rectangleGroup); double halfSceneWidth = 375; // scene.getWidth()/2.0; double halfSceneHeight = 275; // scene.getHeight()/2.0; cam.p.setX(halfSceneWidth); cam.ip.setX(-halfSceneWidth); cam.p.setY(halfSceneHeight); cam.ip.setY(-halfSceneHeight); frameCam(stage, scene); scene.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { mousePosX = me.getX(); mousePosY = me.getY(); mouseOldX = me.getX(); mouseOldY = me.getY(); //System.out.println("scene.setOnMousePressed " + me); } }); scene.setOnMouseDragged(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { mouseOldX = mousePosX; mouseOldY = mousePosY; mousePosX = me.getX(); mousePosY = me.getY(); mouseDeltaX = mousePosX - mouseOldX; mouseDeltaY = mousePosY - mouseOldY; if (me.isAltDown() && me.isShiftDown() && me.isPrimaryButtonDown()) { double rzAngle = cam.rz.getAngle(); cam.rz.setAngle(rzAngle - mouseDeltaX); } else if (me.isAltDown() && me.isPrimaryButtonDown()) { double ryAngle = cam.ry.getAngle(); cam.ry.setAngle(ryAngle - mouseDeltaX); double rxAngle = cam.rx.getAngle(); cam.rx.setAngle(rxAngle + mouseDeltaY); } else if (me.isShiftDown() && me.isPrimaryButtonDown()) { double yShear = shear.getY(); shear.setY(yShear + mouseDeltaY / 1000.0); double xShear = shear.getX(); shear.setX(xShear + mouseDeltaX / 1000.0); } else if (me.isAltDown() && me.isSecondaryButtonDown()) { double scale = cam.s.getX(); double newScale = scale + mouseDeltaX * 0.01; cam.s.setX(newScale); cam.s.setY(newScale); cam.s.setZ(newScale); } else if (me.isAltDown() && me.isMiddleButtonDown()) { double tx = cam.t.getX(); double ty = cam.t.getY(); cam.t.setX(tx + mouseDeltaX); cam.t.setY(ty + mouseDeltaY); } } }); scene.setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(KeyEvent ke) { if (KeyCode.A.equals(ke.getCode())) { resetCam(); shear.setX(0.0); shear.setY(0.0); } if (KeyCode.F.equals(ke.getCode())) { frameCam(stage, scene); shear.setX(0.0); shear.setY(0.0); } if (KeyCode.SPACE.equals(ke.getCode())) { if (stage.isFullScreen()) { stage.setFullScreen(false); frameCam(stage, scene); } else { stage.setFullScreen(true); frameCam(stage, scene); } } } }); stage.setScene(scene); stage.show(); }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param vbRacine panel d'installation du menu * @throws Exception Exceptions//w w w . j a v a2 s. com */ private static void creeMenu(VBox vbRacine) throws Exception { VBox vbMonPanneau = new VBox(); vbMonPanneau.setPrefHeight(80); vbMonPanneau.setPrefWidth(3000); mbarPrincipal.setMinHeight(29); mbarPrincipal.setPrefHeight(29); mbarPrincipal.setMaxHeight(29); mbarPrincipal.setPrefWidth(3000); if (isMac()) { mbarPrincipal.setUseSystemMenuBar(true); } /* Menu projets */ Menu mnuProjet = new Menu(rbLocalisation.getString("projets")); mbarPrincipal.getMenus().add(mnuProjet); mniNouveauProjet = new MenuItem(rbLocalisation.getString("nouveauProjet")); mniNouveauProjet.setAccelerator(new KeyCodeCombination(KeyCode.N, KeyCombination.SHORTCUT_DOWN)); mnuProjet.getItems().add(mniNouveauProjet); mniChargeProjet = new MenuItem(rbLocalisation.getString("ouvrirProjet")); mniChargeProjet.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.SHORTCUT_DOWN)); mnuProjet.getItems().add(mniChargeProjet); mniSauveProjet = new MenuItem(rbLocalisation.getString("sauverProjet")); mniSauveProjet.setDisable(true); mniSauveProjet.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN)); mnuProjet.getItems().add(mniSauveProjet); mniSauveSousProjet = new MenuItem(rbLocalisation.getString("sauverProjetSous")); mniSauveSousProjet.setDisable(true); mniSauveSousProjet.setAccelerator( new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN, KeyCodeCombination.SHIFT_DOWN)); mnuProjet.getItems().add(mniSauveSousProjet); mnuDerniersProjets = new Menu(rbLocalisation.getString("derniersProjets")); mnuProjet.getItems().add(mnuDerniersProjets); fileHistoFichiers = new File(fileRepertConfig.getAbsolutePath() + File.separator + "derniersprojets.cfg"); nombreHistoFichiers = 0; if (fileHistoFichiers.exists()) { try (BufferedReader brHistoFichiers = new BufferedReader( new InputStreamReader(new FileInputStream(fileHistoFichiers), "UTF-8"))) { while ((strTexteHisto = brHistoFichiers.readLine()) != null) { MenuItem menuDerniersFichiers = new MenuItem(strTexteHisto); mnuDerniersProjets.getItems().add(menuDerniersFichiers); strHistoFichiers[nombreHistoFichiers] = strTexteHisto; nombreHistoFichiers++; menuDerniersFichiers.setOnAction((e) -> { MenuItem mniSousMenu = (MenuItem) e.getSource(); try { try { projetChargeNom(mniSousMenu.getText()); } catch (InterruptedException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); } } } SeparatorMenuItem sepMenu1 = new SeparatorMenuItem(); mnuProjet.getItems().add(sepMenu1); mniFermerProjet = new MenuItem(rbLocalisation.getString("quitterApplication")); mniFermerProjet.setAccelerator(new KeyCodeCombination(KeyCode.A, KeyCombination.SHORTCUT_DOWN)); mnuProjet.getItems().add(mniFermerProjet); /* Menu affichage */ Menu mnuAffichage = new Menu(rbLocalisation.getString("affichage")); mbarPrincipal.getMenus().add(mnuAffichage); mniAffichageVisite = new MenuItem(rbLocalisation.getString("main.creationVisite")); mniAffichageVisite.setAccelerator(new KeyCodeCombination(KeyCode.DIGIT1, KeyCombination.SHORTCUT_DOWN)); mnuAffichage.getItems().add(mniAffichageVisite); mniAffichageInterface = new MenuItem(rbLocalisation.getString("main.creationInterface")); mniAffichageInterface.setAccelerator(new KeyCodeCombination(KeyCode.DIGIT2, KeyCombination.SHORTCUT_DOWN)); mnuAffichage.getItems().add(mniAffichageInterface); setMniAffichagePlan(new MenuItem(rbLocalisation.getString("main.tabPlan"))); getMniAffichagePlan().setAccelerator(new KeyCodeCombination(KeyCode.DIGIT3, KeyCombination.SHORTCUT_DOWN)); getMniAffichagePlan().setDisable(true); mnuAffichage.getItems().add(getMniAffichagePlan()); mniOutilsLoupe = new MenuItem(rbLocalisation.getString("main.loupe")); mniOutilsLoupe.setAccelerator(new KeyCodeCombination(KeyCode.L, KeyCombination.SHORTCUT_DOWN)); mnuAffichage.getItems().add(mniOutilsLoupe); SeparatorMenuItem sep3 = new SeparatorMenuItem(); mnuAffichage.getItems().add(sep3); mniConfigTransformation = new MenuItem(rbLocalisation.getString("affichageConfiguration")); mnuAffichage.getItems().add(mniConfigTransformation); /* Menu panoramiques */ mnuPanoramique = new Menu(rbLocalisation.getString("panoramiques")); mnuPanoramique.setDisable(true); mbarPrincipal.getMenus().add(mnuPanoramique); mniAjouterPano = new MenuItem(rbLocalisation.getString("ajouterPanoramiques")); mniAjouterPano.setAccelerator(new KeyCodeCombination(KeyCode.A, KeyCombination.SHORTCUT_DOWN)); mnuPanoramique.getItems().add(mniAjouterPano); setMniAjouterPlan(new MenuItem(rbLocalisation.getString("ajouterPlan"))); getMniAjouterPlan().setAccelerator(new KeyCodeCombination(KeyCode.P, KeyCombination.SHORTCUT_DOWN)); mnuPanoramique.getItems().add(getMniAjouterPlan()); getMniAjouterPlan().setDisable(true); SeparatorMenuItem sep2 = new SeparatorMenuItem(); mnuPanoramique.getItems().add(sep2); mniVisiteGenere = new MenuItem(rbLocalisation.getString("genererVisite")); mniVisiteGenere.setDisable(true); mniVisiteGenere.setAccelerator(new KeyCodeCombination(KeyCode.V, KeyCombination.SHORTCUT_DOWN)); mnuPanoramique.getItems().add(mniVisiteGenere); /* Menu Modles */ mnuModeles = new Menu(rbLocalisation.getString("menuModele")); mbarPrincipal.getMenus().add(mnuModeles); mniChargerModele = new MenuItem(rbLocalisation.getString("modeleCharger")); mnuModeles.getItems().add(mniChargerModele); mniSauverModele = new MenuItem(rbLocalisation.getString("modeleSauver")); mnuModeles.getItems().add(mniSauverModele); /* Menu transformations */ mnuTransformation = new Menu(rbLocalisation.getString("outils")); mbarPrincipal.getMenus().add(mnuTransformation); mniEqui2CubeTransformation = new MenuItem(rbLocalisation.getString("outilsEqui2Cube")); mnuTransformation.getItems().add(mniEqui2CubeTransformation); mniCube2EquiTransformation = new MenuItem(rbLocalisation.getString("outilsCube2Equi")); mnuTransformation.getItems().add(mniCube2EquiTransformation); SeparatorMenuItem sep6 = new SeparatorMenuItem(); mnuTransformation.getItems().add(sep6); mniOutilsBarre = new MenuItem(rbLocalisation.getString("outilsBarre")); mniOutilsBarre.setAccelerator(new KeyCodeCombination(KeyCode.B, KeyCombination.SHORTCUT_DOWN)); mnuTransformation.getItems().add(mniOutilsBarre); mniOutilsDiaporama = new MenuItem(rbLocalisation.getString("outilsDiaporama")); mniOutilsDiaporama.setAccelerator(new KeyCodeCombination(KeyCode.D, KeyCombination.SHORTCUT_DOWN)); mnuTransformation.getItems().add(mniOutilsDiaporama); /* Menu Aide */ Menu mnuAide = new Menu(rbLocalisation.getString("aide")); mbarPrincipal.getMenus().add(mnuAide); mniAide = new MenuItem(rbLocalisation.getString("aideAide")); mniAide.setAccelerator(new KeyCodeCombination(KeyCode.H, KeyCombination.SHORTCUT_DOWN)); mnuAide.getItems().add(mniAide); SeparatorMenuItem sep4 = new SeparatorMenuItem(); mnuAide.getItems().add(sep4); mniAPropos = new MenuItem(rbLocalisation.getString("aideAPropos")); mnuAide.getItems().add(mniAPropos); // // } // /* barre de boutons */ hbBarreBouton = new HBox(); hbBarreBouton.getStyleClass().add("menuBarreOutils1"); hbBarreBouton.setPrefHeight(50); hbBarreBouton.setMinHeight(50); hbBarreBouton.setPrefWidth(3000); /* Bouton nouveau Projet */ ScrollPane spBtnNouvprojet = new ScrollPane(); spBtnNouvprojet.getStyleClass().add("menuBarreOutils"); spBtnNouvprojet.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spBtnNouvprojet.setPrefHeight(35); spBtnNouvprojet.setMaxHeight(35); spBtnNouvprojet.setPadding(new Insets(2)); spBtnNouvprojet.setPrefWidth(35); HBox.setMargin(spBtnNouvprojet, new Insets(5, 15, 0, 15)); ivNouveauProjet = new ImageView( new Image("file:" + getStrRepertAppli() + File.separator + "images/nouveauProjet.png")); spBtnNouvprojet.setContent(ivNouveauProjet); Tooltip tltpNouveauProjet = new Tooltip(rbLocalisation.getString("nouveauProjet")); tltpNouveauProjet.setStyle(getStrTooltipStyle()); spBtnNouvprojet.setTooltip(tltpNouveauProjet); hbBarreBouton.getChildren().add(spBtnNouvprojet); /* Bouton ouvrir Projet */ ScrollPane spBtnOuvrirProjet = new ScrollPane(); spBtnOuvrirProjet.getStyleClass().add("menuBarreOutils"); spBtnOuvrirProjet.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spBtnOuvrirProjet.setPrefHeight(35); spBtnOuvrirProjet.setMaxHeight(35); spBtnOuvrirProjet.setPadding(new Insets(2)); spBtnOuvrirProjet.setPrefWidth(35); HBox.setMargin(spBtnOuvrirProjet, new Insets(5, 15, 0, 0)); ivChargeProjet = new ImageView( new Image("file:" + getStrRepertAppli() + File.separator + "images/ouvrirProjet.png")); spBtnOuvrirProjet.setContent(ivChargeProjet); Tooltip tltpOuvrirProjet = new Tooltip(rbLocalisation.getString("ouvrirProjet")); tltpOuvrirProjet.setStyle(getStrTooltipStyle()); spBtnOuvrirProjet.setTooltip(tltpOuvrirProjet); hbBarreBouton.getChildren().add(spBtnOuvrirProjet); /* Bouton sauve Projet */ ScrollPane spBtnSauveProjet = new ScrollPane(); spBtnSauveProjet.getStyleClass().add("menuBarreOutils"); spBtnSauveProjet.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spBtnSauveProjet.setPrefHeight(35); spBtnSauveProjet.setMaxHeight(35); spBtnSauveProjet.setPadding(new Insets(2)); spBtnSauveProjet.setPrefWidth(35); HBox.setMargin(spBtnSauveProjet, new Insets(5, 15, 0, 0)); ivSauveProjet = new ImageView( new Image("file:" + getStrRepertAppli() + File.separator + "images/sauveProjet.png")); spBtnSauveProjet.setContent(ivSauveProjet); Tooltip tltpSauverProjet = new Tooltip(rbLocalisation.getString("sauverProjet")); tltpSauverProjet.setStyle(getStrTooltipStyle()); spBtnSauveProjet.setTooltip(tltpSauverProjet); hbBarreBouton.getChildren().add(spBtnSauveProjet); Separator sepImages = new Separator(Orientation.VERTICAL); sepImages.prefHeight(200); hbBarreBouton.getChildren().add(sepImages); ivSauveProjet.setDisable(true); ivSauveProjet.setOpacity(0.3); /* Bouton Ajoute Panoramique */ ScrollPane spBtnAjoutePano = new ScrollPane(); spBtnAjoutePano.getStyleClass().add("menuBarreOutils"); spBtnAjoutePano.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spBtnAjoutePano.setPrefHeight(35); spBtnAjoutePano.setMaxHeight(35); spBtnAjoutePano.setPadding(new Insets(2)); spBtnAjoutePano.setPrefWidth(35); HBox.setMargin(spBtnAjoutePano, new Insets(5, 15, 0, 15)); ivAjouterPano = new ImageView( new Image("file:" + getStrRepertAppli() + File.separator + "images/ajoutePanoramique.png")); spBtnAjoutePano.setContent(ivAjouterPano); Tooltip tltpAjouterPano = new Tooltip(rbLocalisation.getString("ajouterPanoramiques")); tltpAjouterPano.setStyle(getStrTooltipStyle()); spBtnAjoutePano.setTooltip(tltpAjouterPano); hbBarreBouton.getChildren().add(spBtnAjoutePano); ivAjouterPano.setDisable(true); ivAjouterPano.setOpacity(0.3); /* Bouton Ajoute Panoramique */ ScrollPane spBtnAjoutePlan = new ScrollPane(); spBtnAjoutePlan.getStyleClass().add("menuBarreOutils"); spBtnAjoutePlan.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spBtnAjoutePlan.setPrefHeight(35); spBtnAjoutePlan.setMaxHeight(35); spBtnAjoutePlan.setPadding(new Insets(2)); spBtnAjoutePlan.setPrefWidth(35); HBox.setMargin(spBtnAjoutePlan, new Insets(5, 15, 0, 15)); setIvAjouterPlan( new ImageView(new Image("file:" + getStrRepertAppli() + File.separator + "images/ajoutePlan.png"))); spBtnAjoutePlan.setContent(getIvAjouterPlan()); Tooltip tltpAjouterPlan = new Tooltip(rbLocalisation.getString("ajouterPlan")); tltpAjouterPlan.setStyle(getStrTooltipStyle()); spBtnAjoutePlan.setTooltip(tltpAjouterPlan); hbBarreBouton.getChildren().add(spBtnAjoutePlan); getIvAjouterPlan().setDisable(true); getIvAjouterPlan().setOpacity(0.3); /* Bouton Gnre */ ScrollPane spBtnGenereVisite = new ScrollPane(); spBtnGenereVisite.getStyleClass().add("menuBarreOutils"); spBtnGenereVisite.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spBtnGenereVisite.setPrefHeight(35); spBtnGenereVisite.setMaxHeight(35); spBtnGenereVisite.setPadding(new Insets(2)); spBtnGenereVisite.setPrefWidth(70); HBox.setMargin(spBtnGenereVisite, new Insets(5, 15, 0, 0)); ivVisiteGenere = new ImageView( new Image("file:" + getStrRepertAppli() + File.separator + "images/genereVisite.png")); spBtnGenereVisite.setContent(ivVisiteGenere); Tooltip tltpGenererVisite = new Tooltip(rbLocalisation.getString("genererVisite")); tltpGenererVisite.setStyle(getStrTooltipStyle()); spBtnGenereVisite.setTooltip(tltpGenererVisite); hbBarreBouton.getChildren().add(spBtnGenereVisite); ivVisiteGenere.setDisable(true); ivVisiteGenere.setOpacity(0.3); Separator sepImages1 = new Separator(Orientation.VERTICAL); sepImages1.prefHeight(200); hbBarreBouton.getChildren().add(sepImages1); /* Bouton equi -> faces de Cube */ ScrollPane spBtnEqui2Cube = new ScrollPane(); spBtnEqui2Cube.getStyleClass().add("menuBarreOutils"); spBtnEqui2Cube.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spBtnEqui2Cube.setPrefHeight(35); spBtnEqui2Cube.setMaxHeight(35); spBtnEqui2Cube.setPadding(new Insets(2)); spBtnEqui2Cube.setPrefWidth(109); HBox.setMargin(spBtnEqui2Cube, new Insets(5, 15, 0, 250)); ivEqui2Cube = new ImageView( new Image("file:" + getStrRepertAppli() + File.separator + "images/equi2cube.png")); spBtnEqui2Cube.setContent(ivEqui2Cube); Tooltip tltpEqui2Cube = new Tooltip(rbLocalisation.getString("outilsEqui2Cube")); tltpEqui2Cube.setStyle(getStrTooltipStyle()); spBtnEqui2Cube.setTooltip(tltpEqui2Cube); hbBarreBouton.getChildren().add(spBtnEqui2Cube); /* Bouton faces de cube -> equi */ ScrollPane spBtnCube2Equi = new ScrollPane(); spBtnCube2Equi.getStyleClass().add("menuBarreOutils"); spBtnCube2Equi.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spBtnCube2Equi.setPrefHeight(35); spBtnCube2Equi.setMaxHeight(35); spBtnCube2Equi.setPadding(new Insets(2)); spBtnCube2Equi.setPrefWidth(109); HBox.setMargin(spBtnCube2Equi, new Insets(5, 25, 0, 0)); ivCube2Equi = new ImageView( new Image("file:" + getStrRepertAppli() + File.separator + "images/cube2equi.png")); spBtnCube2Equi.setContent(ivCube2Equi); Tooltip tltpCube2Equi = new Tooltip(rbLocalisation.getString("outilsCube2Equi")); tltpCube2Equi.setStyle(getStrTooltipStyle()); spBtnCube2Equi.setTooltip(tltpCube2Equi); hbBarreBouton.getChildren().add(spBtnCube2Equi); if (isMac()) { mbarPrincipal.setMaxHeight(0); hbBarreBouton.setTranslateY(-30); } vbMonPanneau.getChildren().addAll(mbarPrincipal, hbBarreBouton); vbRacine.getChildren().add(vbMonPanneau); mniNouveauProjet.setOnAction((e) -> { projetsNouveau(); }); mniChargeProjet.setOnAction((e) -> { try { try { projetCharge(); } catch (InterruptedException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); mniSauveProjet.setOnAction((e) -> { try { projetSauve(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); mniSauveSousProjet.setOnAction((e) -> { try { projetSauveSous(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); mniVisiteGenere.setOnAction((e) -> { try { genereVisite(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); mniFermerProjet.setOnAction((e) -> { try { projetsFermer(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); mniAjouterPano.setOnAction((e) -> { try { panoramiquesAjouter(); } catch (InterruptedException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); getMniAjouterPlan().setOnAction((e) -> { planAjouter(); }); mniAPropos.setOnAction((e) -> { aideapropos(); }); mniAide.setOnAction((e) -> { AideDialogController.affiche(); }); mniChargerModele.setOnAction((e) -> { try { modeleCharger(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); mniSauverModele.setOnAction((e) -> { try { modeleSauver(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); mniCube2EquiTransformation.setOnAction((e) -> { transformationCube2Equi(); }); mniEqui2CubeTransformation.setOnAction((e) -> { transformationEqui2Cube(); }); mniOutilsBarre.setOnAction((e) -> { creerEditerBarre(""); }); mniOutilsDiaporama.setOnAction((e) -> { creerEditerDiaporama(""); }); mniOutilsLoupe.setOnAction((e) -> { e.consume(); setAfficheLoupe(!isAfficheLoupe()); apLoupe.setVisible(isAfficheLoupe()); Point p = MouseInfo.getPointerInfo().getLocation(); if (p.x < getiTailleLoupe() + 80 && p.y < getiTailleLoupe() + 160) { apLoupe.setLayoutX(ivImagePanoramique.getFitWidth() - getiTailleLoupe() + 5); apLoupe.setLayoutY(35); strPositLoupe = "droite"; } else { apLoupe.setLayoutX(35); apLoupe.setLayoutY(35); strPositLoupe = "gauche"; } }); mniAffichageVisite.setOnAction((e) -> { tpEnvironnement.getSelectionModel().select(0); }); mniAffichageInterface.setOnAction((e) -> { tpEnvironnement.getSelectionModel().select(1); }); getMniAffichagePlan().setOnAction((e) -> { if (!tabPlan.isDisabled()) { tpEnvironnement.getSelectionModel().select(2); } }); mniConfigTransformation.setOnAction((e) -> { try { ConfigDialogController cfg = new ConfigDialogController(); cfg.afficheFenetre(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); spBtnNouvprojet.setOnMouseClicked((t) -> { projetsNouveau(); }); spBtnOuvrirProjet.setOnMouseClicked((t) -> { try { try { projetCharge(); } catch (InterruptedException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); spBtnSauveProjet.setOnMouseClicked((t) -> { try { projetSauve(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); spBtnAjoutePano.setOnMouseClicked((t) -> { try { panoramiquesAjouter(); } catch (InterruptedException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); spBtnAjoutePlan.setOnMouseClicked((t) -> { planAjouter(); }); spBtnGenereVisite.setOnMouseClicked((t) -> { try { genereVisite(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); spBtnEqui2Cube.setOnMouseClicked((t) -> { transformationEqui2Cube(); }); spBtnCube2Equi.setOnMouseClicked((t) -> { transformationCube2Equi(); }); }
From source file:snpviewer.SnpViewer.java
@Override public void initialize(URL url, ResourceBundle rb) { labelSplitPane.setDividerPositions(); chromSplitPane.setDividerPositions(); Pane lpane = (Pane) horizontalSplit.getItems().get(0); SplitPane.setResizableWithParent(lpane, false); //mnemonics/shortcuts for menus mainMenu.useSystemMenuBarProperty().set(true); fileMenu.setMnemonicParsing(true);/* ww w. ja va 2 s . c o m*/ sampleMenu.setMnemonicParsing(true); goMenu.setMnemonicParsing(true); helpMenu.setMnemonicParsing(true); newProjectMenu.setAccelerator(new KeyCodeCombination(KeyCode.N, KeyCombination.SHORTCUT_DOWN)); loadProjectMenu.setAccelerator(new KeyCodeCombination(KeyCode.L, KeyCombination.SHORTCUT_DOWN)); addAffSampleMenu.setAccelerator( new KeyCodeCombination(KeyCode.A, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); addUnSampleMenu.setAccelerator( new KeyCodeCombination(KeyCode.U, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); nextChromMenu.setAccelerator(new KeyCodeCombination(KeyCode.EQUALS, KeyCombination.SHORTCUT_DOWN)); prevChromMenu.setAccelerator(new KeyCodeCombination(KeyCode.MINUS, KeyCombination.SHORTCUT_DOWN)); firstChromMenu.setAccelerator(new KeyCodeCombination(KeyCode.DIGIT1, KeyCombination.SHORTCUT_DOWN)); lastChromMenu.setAccelerator(new KeyCodeCombination(KeyCode.DIGIT0, KeyCombination.SHORTCUT_DOWN)); redrawMenu.setAccelerator(new KeyCodeCombination(KeyCode.R, KeyCombination.SHORTCUT_DOWN)); cacheChromsMenu.setAccelerator( new KeyCodeCombination(KeyCode.C, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); saveToPngMenu.setAccelerator( new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); autoFindRegions.setAccelerator(new KeyCodeCombination(KeyCode.F, KeyCombination.SHORTCUT_DOWN)); //need to disable hideSavedRegionsMenu accelerator for linux - doesn't work for check menus hideSavedRegionsMenu.setAccelerator( new KeyCodeCombination(KeyCode.H, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); clearSavedRegionsMenu.setAccelerator( new KeyCodeCombination(KeyCode.X, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); displaySavedsRegionsMenu.setAccelerator(new KeyCodeCombination(KeyCode.T, KeyCombination.SHORTCUT_DOWN)); outputSavedRegionsMenu.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.SHORTCUT_DOWN)); removeSampleMenu.setAccelerator( new KeyCodeCombination(KeyCode.R, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); //set radio menu item toggle group ArrayList<RadioMenuItem> callQualityRadios = new ArrayList<>( Arrays.asList(noFilteringRadio, filter99, filter95, filter90, filter85)); ToggleGroup callQualityToggle = new ToggleGroup(); for (RadioMenuItem r : callQualityRadios) { r.setToggleGroup(callQualityToggle); } noFilteringRadio.setOnAction(new EventHandler() { @Override public void handle(Event ev) { setQualityFilter(null); } }); filter99.setOnAction(new EventHandler() { @Override public void handle(Event ev) { setQualityFilter(0.01); } }); filter95.setOnAction(new EventHandler() { @Override public void handle(Event ev) { setQualityFilter(0.05); } }); filter90.setOnAction(new EventHandler() { @Override public void handle(Event ev) { setQualityFilter(0.10); } }); filter85.setOnAction(new EventHandler() { @Override public void handle(Event ev) { setQualityFilter(0.15); } }); nextChromMenu.setOnAction(new EventHandler() { @Override public void handle(Event ev) { selectNextChromosome(true); } }); prevChromMenu.setOnAction(new EventHandler() { @Override public void handle(Event ev) { selectNextChromosome(false); } }); firstChromMenu.setOnAction(new EventHandler() { @Override public void handle(Event ev) { if (!cancelButton.isDisabled()) { cancelButton.fire(); } if (!chromosomeSelector.isDisabled()) { chromosomeSelector.getSelectionModel().selectFirst(); } } }); lastChromMenu.setOnAction(new EventHandler() { @Override public void handle(Event ev) { if (!cancelButton.isDisabled()) { cancelButton.fire(); } if (!chromosomeSelector.isDisabled()) { chromosomeSelector.getSelectionModel().selectLast(); } } }); hideSavedRegionsMenu.setOnAction(new EventHandler() { @Override public void handle(Event ev) { showHideSavedRegions(); } }); colorComp.addAll(Arrays.asList(colorComponants)); //selection context menu final ContextMenu scm = new ContextMenu(); final MenuItem scmItem1 = new MenuItem("Display Flanking SNP IDs"); scmItem1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { /* get coordinates of selection and report back * flanking snp ids and coordinates */ displayFlankingSnpIDs(dragSelectRectangle); } }); final MenuItem scmItem2 = new MenuItem("Write Selected Region to File"); scmItem2.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { Platform.runLater(new Runnable() { @Override public void run() { /* get coordinates of selection and report back * write SNPs in region to file */ writeRegionToFile(dragSelectRectangle); } }); } }); final MenuItem scmItem3 = new MenuItem("Add To Saved Regions"); scmItem3.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { /* get coordinates of selection and report back * write SNPs in region to file */ saveSelection(); } }); final MenuItem scmItem4 = new MenuItem("Show/Hide Saved Regions"); scmItem4.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { /* get coordinates of selection and report back * write SNPs in region to file */ hideSavedRegionsMenu.selectedProperty().setValue(!hideSavedRegionsMenu.isSelected()); hideSavedRegionsMenu.fire(); } }); final MenuItem scmItem5 = new MenuItem("Zoom Region"); scmItem5.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { Platform.runLater(new Runnable() { @Override public void run() { /* get coordinates of selection and report back * write SNPs in region to file */ zoomRegion(dragSelectRectangle); } }); } }); final MenuItem scmItem6 = new MenuItem("Write Saved Regions to File"); scmItem6.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { Platform.runLater(new Runnable() { @Override public void run() { /* get coordinates of selection and report back * write SNPs in region to file */ writeSavedRegionsToFile(); } }); } }); scm.getItems().add(scmItem1); scm.getItems().add(scmItem2); scm.getItems().add(scmItem3); scm.getItems().add(scmItem4); scm.getItems().add(scmItem5); scm.getItems().add(scmItem6); //overlayPane context menu ocm = new ContextMenu(); final MenuItem ocmItem1 = new MenuItem("Save Image to File"); ocmItem1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { Platform.runLater(new Runnable() { @Override public void run() { drawPaneToPng(); } }); } }); ocm.getItems().add(ocmItem1); ocm.getItems().add(scmItem4); ocm.getItems().add(scmItem6); //color selections colorComponantSelector.getItems().clear(); colorComponantSelector.getItems().add("AA"); colorComponantSelector.getItems().add("BB"); colorComponantSelector.getItems().add("AB"); colorComponantSelector.getItems().add("Selection Outline"); colorComponantSelector.getItems().add("Selection Fill"); colorComponantSelector.getItems().add("Saved Region Outline"); colorComponantSelector.getItems().add("Saved Region Fill"); colorComponantSelector.getSelectionModel().selectFirst(); colorPicker.setValue(colorComponants[0]); colorComponantSelector.getSelectionModel().selectedIndexProperty() .addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue ov, Number value, Number new_value) { colorPicker.setValue(colorComp.get(new_value.intValue())); colorPicker.fireEvent(new ActionEvent()); } }); colorPicker.setOnAction(new EventHandler() { @Override public void handle(Event t) { if (!colorComp.get(colorComponantSelector.getSelectionModel().getSelectedIndex()) .equals(colorPicker.getValue())) { colorComp.set(colorComponantSelector.getSelectionModel().getSelectedIndex(), colorPicker.getValue()); saveProject(); //colorComponants[colorComponantSelector.getSelectionModel().getSelectedIndex()] = colorPicker.getValue(); if (colorComponantSelector.getSelectionModel().getSelectedIndex() == Colors.fill.value) { dragSelectRectangle.setFill(colorPicker.getValue()); } else if (colorComponantSelector.getSelectionModel().getSelectedIndex() == Colors.line.value) { dragSelectRectangle.setStroke(colorPicker.getValue()); } else if (colorComponantSelector.getSelectionModel() .getSelectedIndex() == Colors.saveLine.value) { for (Rectangle r : savedRegionsDisplay) { r.setStroke(colorPicker.getValue()); } } else if (colorComponantSelector.getSelectionModel() .getSelectedIndex() == Colors.saveFill.value) { for (Rectangle r : savedRegionsDisplay) { r.setFill(colorPicker.getValue()); } } else { removeSavedChromosomeImages(); if (redrawCheckBox.isSelected()) { refreshView(null, true); } } } } }); /*perform appropriate action when user selects a chromosome * from the chromosome choice box */ chromosomeSelector.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue ov, Number value, Number new_value) { chromosomeBoxList = chromosomeSelector.getItems().toArray(); if (new_value.intValue() > -1) { chromosomeSelected((String) chromosomeBoxList[new_value.intValue()]); } } }); chromosomeSelector.addEventFilter(KeyEvent.ANY, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent ke) { if (ke.getCode() == KeyCode.UP) { ke.consume(); chromosomeSelector.show(); } } }); selectionOverlayPane.heightProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth, Number newSceneWidth) { windowResized(new ActionEvent()); } }); selectionOverlayPane.widthProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth, Number newSceneWidth) { windowResized(new ActionEvent()); } }); /*upon addition of a new affected file adjust components accordingly * i.e. ensure appropriate chromosomes are in the choice box * adjust the split panes to fit all files and redisplay */ affObserve.addListener(new ListChangeListener() { @Override public void onChanged(ListChangeListener.Change change) { change.next();/*from the javadoc * 'Go to the next change. In initial state is invalid a require * a call to next() before calling other methods. The first * next() call will make this object represent the first change. */ if (change.getRemovedSize() > 0) { List<SnpFile> both = new ArrayList<>(unFiles); both.addAll(affFiles); recheckChromosomeSelector(both);//need to check all files again, not just affFiles } else if (change.getAddedSize() > 0) { addToChromosomeSelector(affFiles); } } }); /*as above * but for unaffected files */ unObserve.addListener(new ListChangeListener() { @Override public void onChanged(ListChangeListener.Change change) { change.next(); if (change.getRemovedSize() > 0) { List<SnpFile> both = new ArrayList<>(unFiles); both.addAll(affFiles); recheckChromosomeSelector(both);//need to check all files again, not just unFiles } else if (change.getAddedSize() > 0) { addToChromosomeSelector(unFiles); } } }); selectionOverlayPane.addEventHandler(MouseEvent.MOUSE_MOVED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { if (!genomeVersion.equals("") && chromosomeSelector.getSelectionModel().getSelectedIndex() > -1) { try { ChromosomeLength chromLength = new ChromosomeLength(genomeVersion); String currentChrom = (String) chromosomeBoxList[chromosomeSelector.getSelectionModel() .getSelectedIndex()]; double coordinate = chromLength.getLength(currentChrom) / chromSplitPane.getWidth() * e.getX(); positionIndicator.setText(nf.format(coordinate)); } catch (Exception ex) { positionIndicator.setText("Build Error!"); } } } }); /*handle mouse dragging and effect on dragSelectRectangle * */ dragSelectRectangle.widthProperty().bind(dragSelectRectX.subtract(dragSelectRectInitX)); dragSelectRectangle.heightProperty().bind(selectionOverlayPane.heightProperty()); //dragSelectRectangle.strokeProperty().set(colorComponants[Colors.line.value]); dragSelectRectangle.setStrokeWidth(4.0); //dragSelectRectangle.setBlendMode(BlendMode.SCREEN); dragSelectRectangle.setOpacity(0.45); dragSelectRectangle.setVisible(false); selectionOverlayPane.getChildren().add(dragSelectRectangle); selectionOverlayPane.addEventHandler(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { if (scm.isShowing()) { scm.hide(); } if (!e.isPrimaryButtonDown()) { if (e.isSecondaryButtonDown()) { //check we're not overlapping selection if (e.getX() >= dragSelectRectangle.getX() && e.getX() <= (dragSelectRectangle.getX() + dragSelectRectangle.getWidth())) { return; } //check we're not overlapping saved regions for (Rectangle r : savedRegionsDisplay) { if (r.isVisible() && e.getX() >= r.getX() && e.getX() <= r.getX() + r.getWidth()) { return; } } if (chromosomeSelector.getSelectionModel().isEmpty()) { ocmItem1.setDisable(true); } else { ocmItem1.setDisable(false); } ocm.show(selectionOverlayPane, e.getScreenX(), e.getScreenY()); return; } } if (ocm.isShowing()) { ocm.hide(); } dragSelectRectangle.strokeProperty().set(colorComp.get(Colors.line.value)); dragSelectRectangle.fillProperty().set(colorComp.get(Colors.fill.value)); dragSelectRectX.set(0); dragSelectRectangle.setVisible(true); dragSelectRectangle.setX(e.getX()); dragSelectRectangle.setY(0); dragSelectRectInitX.set(e.getX()); anchorInitX.set(e.getX()); } }); selectionOverlayPane.addEventHandler(MouseEvent.MOUSE_DRAGGED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { if (!e.isPrimaryButtonDown()) { return; } dragSelectRectangle.setVisible(true); if (e.getX() > anchorInitX.doubleValue()) {//dragging to the right if (e.getX() <= selectionOverlayPane.getLayoutX() + selectionOverlayPane.getWidth()) { //mouse is before the edge of the pane dragSelectRectInitX.set(anchorInitX.doubleValue()); dragSelectRectX.set(e.getX()); } else { //mouse is over the edge dragSelectRectX.set(selectionOverlayPane.getWidth()); } } else { if (e.getX() > selectionOverlayPane.getLayoutX()) { dragSelectRectInitX.set(e.getX()); dragSelectRectangle.setX(e.getX()); dragSelectRectX.set(anchorInitX.doubleValue()); } else { dragSelectRectInitX.set(0); dragSelectRectangle.setX(0); /* the two lines below are just to trigger * dragSelectRectangle.widthProperty listener * so that start coordinate changes to 1 */ dragSelectRectX.set(anchorInitX.doubleValue() + 1); dragSelectRectX.set(anchorInitX.doubleValue() + 1); } } } }); selectionOverlayPane.addEventHandler(MouseEvent.MOUSE_RELEASED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { //dragSelectRectX.set(e.getX()); if (!e.isPrimaryButtonDown()) { return; } dragSelectRectangle.setVisible(true); if (dragSelectRectangle.getWidth() == 0) { clearDragSelectRectangle(); } } }); dragSelectRectangle.widthProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observableValue, Object oldValue, Object newRectWidth) { if (!genomeVersion.equals("") && chromosomeSelector.getSelectionModel().getSelectedIndex() > -1 && dragSelectRectangle.getWidth() > 0) { try { ChromosomeLength chromLength = new ChromosomeLength(genomeVersion); String currentChrom = (String) chromosomeBoxList[chromosomeSelector.getSelectionModel() .getSelectedIndex()]; double startCoordinate = chromLength.getLength(currentChrom) / selectionOverlayPane.getWidth() * dragSelectRectangle.getX(); double selectionWidth = chromLength.getLength(currentChrom) / selectionOverlayPane.getWidth() * dragSelectRectangle.getWidth(); if (dragSelectRectangle.getX() == 0) { startCoordinate = 1; } selectionIndicator.setText("chr" + currentChrom + ":" + nf.format(startCoordinate) + "-" + nf.format(startCoordinate + selectionWidth)); } catch (Exception ex) { selectionIndicator.setText("Build Error!"); } } else { selectionIndicator.setText(""); } } }); dragSelectRectangle.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { if (e.getButton() == MouseButton.SECONDARY) { if (chromosomeSelector.getSelectionModel().isEmpty()) { scmItem1.setDisable(true); scmItem2.setDisable(true); } else { scmItem1.setDisable(false); scmItem2.setDisable(false); } if (ocm.isShowing()) { ocm.hide(); } scm.show(selectionOverlayPane, e.getScreenX(), e.getScreenY()); } } }); }
From source file:view.EditorView.java
@FXML // This method is called by the FXMLLoader when initialization is complete void initialize() { assert insertRoom != null : "fx:id=\"insertRoom\" was not injected: check your FXML file 'EditorMain.fxml'."; assert drawing != null : "fx:id=\"drawing\" was not injected: check your FXML file 'EditorMain.fxml'."; assert insertPath != null : "fx:id=\"insertPath\" was not injected: check your FXML file 'EditorMain.fxml'."; currentEditorInstance = this; // modify the default exception handler to show the ReportingDialog on every uncaught exception final Thread.UncaughtExceptionHandler currentUncaughtExceptionHandler = Thread .getDefaultUncaughtExceptionHandler(); Thread.setDefaultUncaughtExceptionHandler((thread, exception) -> { if (currentUncaughtExceptionHandler != null) { // execute current handler as we only want to append it currentUncaughtExceptionHandler.uncaughtException(thread, exception); }/*from w w w .j a v a 2 s .c o m*/ Platform.runLater(() -> { new ExceptionAlert(exception).showAndWait(); new ReportingDialog(stage.getScene()).show(AppConfig.gitHubUserName, AppConfig.gitHubRepoName, exception); }); }); currentGame.addListener((observable, oldValue, newValue) -> { if (newValue != null) { newValue.modifiedProperty().addListener((observable1, oldValue1, newValue1) -> { this.menuItemSave.setDisable(!newValue1); setWindowTitle(newValue); }); } setWindowTitle(newValue); }); initGame(); scrollPane.hvalueProperty().addListener((observable, oldValue, newValue) -> unselectingDisabled = true); scrollPane.vvalueProperty().addListener((observable, oldValue, newValue) -> unselectingDisabled = true); // add button icons insertRoom.setGraphic(new ImageView(new Image(EditorView.class.getResourceAsStream("add-room.png")))); moveButton.setGraphic(new ImageView(new Image(EditorView.class.getResourceAsStream("move-arrows.png")))); insertPath.setGraphic( new ImageView(new Image(EditorView.class.getResourceAsStream("connecting-points.png")))); autoLayoutButton .setGraphic(new ImageView(new Image(EditorView.class.getResourceAsStream("autoLayout.png")))); refreshViewButton .setGraphic(new ImageView(new Image(EditorView.class.getResourceAsStream("refreshView.png")))); // add tooltips insertRoom.setTooltip(new Tooltip("Insert a new room")); moveButton.setTooltip(new Tooltip("Move rooms")); insertPath.setTooltip(new Tooltip("Connect rooms to create walk paths")); autoLayoutButton.setTooltip(new Tooltip("Automatically rearrange the rooms in the view below")); refreshViewButton.setTooltip(new Tooltip("Refresh the current view")); // forward events to all selected items // drawing.setOnMouseClicked(forwardEventsToSelectableNodesHandler); // drawing.setOnMousePressed(forwardEventsToSelectableNodesHandler); // drawing.setOnMouseReleased(forwardEventsToSelectableNodesHandler); // drawing.setOnDragDetected(forwardEventsToSelectableNodesHandler); // drawing.setOnMouseDragged(forwardEventsToSelectableNodesHandler); scrollPane.setOnKeyPressed(event -> { if (event.getCode().equals(KeyCode.DELETE)) { for (Node child : new ArrayList<>(drawing.getChildren())) { if (child instanceof Disposable) { if (((Disposable) child).isSelected() && event.getTarget() != child) { FOKLogger.fine(EditorView.class.getName(), "Sending disposal command to child, Child is: " + child.toString() + "\ntarget is: " + event.getTarget().toString()); try { ((Disposable) child).dispose(); } catch (IllegalStateException e) { FOKLogger.log(EditorView.class.getName(), Level.INFO, "User tried to remove the current room (not allowed)", e); new Alert(Alert.AlertType.ERROR, "Could not perform delete operation: \n\n" + ExceptionUtils.getRootCauseMessage(e)).show(); } } } } } else if (event.getCode().equals(KeyCode.A) && event.isControlDown()) { // select everything for (Node child : new ArrayList<>(drawing.getChildren())) { if (child instanceof Selectable) { ((Selectable) child).setSelected(true); } } } }); }
From source file:view.FXApplicationController.java
public void keyAction(KeyEvent ke) { if (ke.getCode() == KeyCode.RIGHT) { goToEpoch(currentEpoch + 1);/*from w ww.ja v a 2s .c o m*/ } if (ke.getCode() == KeyCode.LEFT) { goToEpoch(currentEpoch - 1); } if (ke.getCode() == KeyCode.H) { hypnogramAction(); } if (ke.getCode() == KeyCode.E) { showEvaluationWindowAction(); } if (ke.getCode() == KeyCode.L) { help1OnAction(); } if (ke.getCode() == KeyCode.K) { kComplexOnAction(); } if (ke.getCode() == KeyCode.UP) { refreshZoom(+1); } if (ke.getCode() == KeyCode.DOWN) { refreshZoom(-1); } if (ke.getCode() == KeyCode.W) { awakeButtonOnAction(); if (featureModel.getLabel(currentEpoch) == -1) { goToEpoch(currentEpoch + 1); } } if (ke.getCode() == KeyCode.R) { remButtonOnAction(); if (featureModel.getLabel(currentEpoch) == -1) { goToEpoch(currentEpoch + 1); } } if (ke.getCode() == KeyCode.DIGIT1) { s1ButtonOnAction(); if (featureModel.getLabel(currentEpoch) == -1) { goToEpoch(currentEpoch + 1); } } if (ke.getCode() == KeyCode.DIGIT2) { s2ButtonOnAction(); if (featureModel.getLabel(currentEpoch) == -1) { goToEpoch(currentEpoch + 1); } } if (ke.getCode() == KeyCode.DIGIT3) { s3ButtonOnAction(); if (featureModel.getLabel(currentEpoch) == -1) { goToEpoch(currentEpoch + 1); } } if (ke.getCode() == KeyCode.A) { artefactButtonOnAction(); } if (ke.getCode() == KeyCode.M) { arousalButtonOnAction(); } if (ke.getCode() == KeyCode.D) { stimulationButtonOnAction(); } if (ke.getCode() == KeyCode.C) { clearButtonOnAction(); } if (ke.getCode() == KeyCode.PAGE_DOWN) { goToEpoch(currentEpoch - 10); } if (ke.getCode() == KeyCode.PAGE_UP) { goToEpoch(currentEpoch + 10); } if (ke.getCode() == KeyCode.END) { goToEpoch(dataModel.getNumberOf30sEpochs() - 1); } if (ke.getCode() == KeyCode.HOME) { goToEpoch(0); } if (ke.getCode() == KeyCode.F6) { visualizeButtonAction(); } if (ke.getCode() == KeyCode.F7) { filterButtonAction(); } if (ke.getCode() == KeyCode.F8) { dcRemoveButtonAction(); } if (ke.getCode() == KeyCode.F9) { kcMarkersButtonAction(); } if (ke.getCode() == KeyCode.F12) { electrodeConfiguratorButtonAction(); } }