Example usage for javafx.scene.input MouseEvent MOUSE_CLICKED

List of usage examples for javafx.scene.input MouseEvent MOUSE_CLICKED

Introduction

In this page you can find the example usage for javafx.scene.input MouseEvent MOUSE_CLICKED.

Prototype

EventType MOUSE_CLICKED

To view the source code for javafx.scene.input MouseEvent MOUSE_CLICKED.

Click Source Link

Document

This event occurs when mouse button has been clicked (pressed and released on the same node).

Usage

From source file:org.sleuthkit.autopsy.imagegallery.gui.GroupPane.java

/**
 * called automatically during constructor by FXMLConstructor.
 *
 * checks that FXML loading went ok and performs additional setup
 *//*  w  w  w .  ja v a  2  s. co  m*/
@FXML
void initialize() {
    assert gridView != null : "fx:id=\"tilePane\" was not injected: check your FXML file 'GroupPane.fxml'.";
    assert grpCatSplitMenu != null : "fx:id=\"grpCatSplitMenu\" was not injected: check your FXML file 'GroupHeader.fxml'.";
    assert grpTagSplitMenu != null : "fx:id=\"grpTagSplitMenu\" was not injected: check your FXML file 'GroupHeader.fxml'.";
    assert headerToolBar != null : "fx:id=\"headerToolBar\" was not injected: check your FXML file 'GroupHeader.fxml'.";
    assert segButton != null : "fx:id=\"previewList\" was not injected: check your FXML file 'GroupHeader.fxml'.";
    assert slideShowToggle != null : "fx:id=\"segButton\" was not injected: check your FXML file 'GroupHeader.fxml'.";
    assert tileToggle != null : "fx:id=\"tileToggle\" was not injected: check your FXML file 'GroupHeader.fxml'.";

    //configure flashing glow animation on next unseen group button
    flashAnimation.setCycleCount(Timeline.INDEFINITE);
    flashAnimation.setAutoReverse(true);

    //configure gridView cell properties
    gridView.cellHeightProperty().bind(Toolbar.getDefault().sizeSliderValue().add(75));
    gridView.cellWidthProperty().bind(Toolbar.getDefault().sizeSliderValue().add(75));
    gridView.setCellFactory((GridView<Long> param) -> new DrawableCell());

    //configure toolbar properties
    HBox.setHgrow(spacer, Priority.ALWAYS);
    spacer.setMinWidth(Region.USE_PREF_SIZE);

    try {
        grpTagSplitMenu.setText(TagUtils.getFollowUpTagName().getDisplayName());
        grpTagSplitMenu.setOnAction(createGrpTagMenuItem(TagUtils.getFollowUpTagName()).getOnAction());
    } catch (TskCoreException tskCoreException) {
        LOGGER.log(Level.WARNING, "failed to load FollowUpTagName", tskCoreException);
    }
    grpTagSplitMenu.setGraphic(new ImageView(DrawableAttribute.TAGS.getIcon()));
    grpTagSplitMenu.showingProperty()
            .addListener((ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) -> {
                if (t1) {
                    ArrayList<MenuItem> selTagMenues = new ArrayList<>();
                    for (final TagName tn : TagUtils.getNonCategoryTagNames()) {
                        MenuItem menuItem = TagUtils.createSelTagMenuItem(tn, grpTagSplitMenu);
                        selTagMenues.add(menuItem);
                    }
                    grpTagSplitMenu.getItems().setAll(selTagMenues);
                }
            });

    ArrayList<MenuItem> grpCategoryMenues = new ArrayList<>();
    for (final Category cat : Category.values()) {
        MenuItem menuItem = createGrpCatMenuItem(cat);
        grpCategoryMenues.add(menuItem);
    }
    grpCatSplitMenu.setText(Category.FIVE.getDisplayName());
    grpCatSplitMenu.setGraphic(new ImageView(DrawableAttribute.CATEGORY.getIcon()));
    grpCatSplitMenu.getItems().setAll(grpCategoryMenues);
    grpCatSplitMenu.setOnAction(createGrpCatMenuItem(Category.FIVE).getOnAction());

    Runnable syncMode = () -> {
        switch (groupViewMode.get()) {
        case SLIDE_SHOW:
            slideShowToggle.setSelected(true);
            break;
        case TILE:
            tileToggle.setSelected(true);
            break;
        }
    };
    syncMode.run();
    //make togle states match view state
    groupViewMode.addListener((o) -> {
        syncMode.run();
    });

    slideShowToggle.toggleGroupProperty().addListener((o) -> {
        slideShowToggle.getToggleGroup().selectedToggleProperty()
                .addListener((observable, oldToggle, newToggle) -> {
                    if (newToggle == null) {
                        oldToggle.setSelected(true);
                    }
                });
    });

    //listen to toggles and update view state
    slideShowToggle.setOnAction((ActionEvent t) -> {
        activateSlideShowViewer(globalSelectionModel.lastSelectedProperty().get());
    });

    tileToggle.setOnAction((ActionEvent t) -> {
        activateTileViewer();
    });

    controller.viewState().addListener((ObservableValue<? extends GroupViewState> observable,
            GroupViewState oldValue, GroupViewState newValue) -> {
        setViewState(newValue);
    });

    addEventFilter(KeyEvent.KEY_PRESSED, tileKeyboardNavigationHandler);
    gridView.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {

        private ContextMenu buildContextMenu() {
            ArrayList<MenuItem> menuItems = new ArrayList<>();

            menuItems.add(CategorizeAction.getPopupMenu());

            menuItems.add(AddDrawableTagAction.getInstance().getPopupMenu());

            Collection<? extends ContextMenuActionsProvider> menuProviders = Lookup.getDefault()
                    .lookupAll(ContextMenuActionsProvider.class);

            for (ContextMenuActionsProvider provider : menuProviders) {

                for (final Action act : provider.getActions()) {

                    if (act instanceof Presenter.Popup) {
                        Presenter.Popup aact = (Presenter.Popup) act;

                        menuItems.add(SwingMenuItemAdapter.create(aact.getPopupPresenter()));
                    }
                }
            }
            final MenuItem extractMenuItem = new MenuItem("Extract File(s)");
            extractMenuItem.setOnAction((ActionEvent t) -> {
                SwingUtilities.invokeLater(() -> {
                    TopComponent etc = WindowManager.getDefault()
                            .findTopComponent(ImageGalleryTopComponent.PREFERRED_ID);
                    ExtractAction.getInstance().actionPerformed(new java.awt.event.ActionEvent(etc, 0, null));
                });
            });
            menuItems.add(extractMenuItem);

            ContextMenu contextMenu = new ContextMenu(menuItems.toArray(new MenuItem[] {}));
            contextMenu.setAutoHide(true);
            return contextMenu;
        }

        @Override
        public void handle(MouseEvent t) {
            switch (t.getButton()) {
            case PRIMARY:
                if (t.getClickCount() == 1) {
                    globalSelectionModel.clearSelection();
                    if (contextMenu != null) {
                        contextMenu.hide();
                    }
                }
                t.consume();
                break;
            case SECONDARY:
                if (t.getClickCount() == 1) {
                    selectAllFiles();
                }
                if (globalSelectionModel.getSelected().isEmpty() == false) {
                    if (contextMenu == null) {
                        contextMenu = buildContextMenu();
                    }

                    contextMenu.hide();
                    contextMenu.show(GroupPane.this, t.getScreenX(), t.getScreenY());
                }
                t.consume();
                break;
            }
        }
    });

    ActionUtils.configureButton(nextGroupAction, nextButton);
    final EventHandler<ActionEvent> onAction = nextButton.getOnAction();
    nextButton.setOnAction((ActionEvent event) -> {
        flashAnimation.stop();
        nextButton.setEffect(null);
        onAction.handle(event);
    });

    ActionUtils.configureButton(forwardAction, forwardButton);
    ActionUtils.configureButton(backAction, backButton);

    nextGroupAction.disabledProperty().addListener(
            (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
                nextButton.setEffect(newValue ? null : DROP_SHADOW);
                if (newValue == false) {
                    flashAnimation.play();
                } else {
                    flashAnimation.stop();
                }
            });

    //listen to tile selection and make sure it is visible in scroll area
    //TODO: make sure we are testing complete visability not just bounds intersection
    globalSelectionModel.lastSelectedProperty().addListener((observable, oldFileID, newFileId) -> {
        if (groupViewMode.get() == GroupViewMode.SLIDE_SHOW) {
            slideShowPane.setFile(newFileId);
        } else {

            scrollToFileID(newFileId);
        }
    });

    setViewState(controller.viewState().get());
}

From source file:org.sleuthkit.autopsy.timeline.ui.AbstractVisualization.java

protected void setChartClickHandler() {
    chart.addEventHandler(MouseEvent.MOUSE_CLICKED, (MouseEvent event) -> {
        if (event.getButton() == MouseButton.PRIMARY && event.isStillSincePress()) {
            selectedNodes.clear();/*  ww  w  . j  a  v  a2 s.c  o  m*/
        }
    });
}

From source file:poe.trade.assist.SearchPane.java

private void setupTableClickListener() {
    searchTable.addEventFilter(MouseEvent.MOUSE_RELEASED, new EventHandler<MouseEvent>() {
        @Override/*from ww w  .  j  a v a2  s. c om*/
        public void handle(MouseEvent event) {
            if (event.getButton() == MouseButton.SECONDARY) {
                Search search = searchTable.getSelectionModel().getSelectedItem();
                if (search != null) {
                    search.markSeen();
                }
            }
        }
    });
    searchTable.addEventFilter(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            if (event.getClickCount() > 1 && event.getButton() == MouseButton.PRIMARY) {
                Search search = searchTable.getSelectionModel().getSelectedItem();
                if (search != null) {
                    SwingUtil.openUrlViaBrowser(search.getUrl());
                }
            }
        }
    });
}

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);/*  w ww  . j  a  v a 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:snpviewer.SnpViewer.java

private void drawSavedRegions(String chrom) {
    selectionOverlayPane.getChildren().clear();
    if (savedRegions.isEmpty()) {
        selectionOverlayPane.getChildren().add(dragSelectRectangle);
        return;/*from   w  ww. jav  a2 s. c  o m*/
    }
    for (RegionSummary r : savedRegions) {
        if (r.getChromosome() == null) {
            selectionOverlayPane.getChildren().add(dragSelectRectangle);
            return;
        }
        if (r.getChromosome().equalsIgnoreCase(chrom)) {
            drawRegionSummary(r, chrom);
        }
    }
    int rectCounter = 0;
    for (final Rectangle rect : savedRegionsDisplay) {
        final int counter = rectCounter;
        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(rect);

            }
        });
        final MenuItem scmItem2 = new MenuItem("Write 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 
                         * write SNPs in region to file
                         */
                        writeRegionToFile(rect);
                    }
                });
            }
        });
        final MenuItem scmItem3 = new MenuItem("Remove this Saved Region");
        scmItem3.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent e) {
                /* get coordinates of selection and 
                 * write SNPs in region to file
                 */
                removeSavedRegion(counter);

            }
        });
        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) {
                /* get coordinates of selection and report back
                 * write SNPs in region to file
                 */
                zoomRegion(rect);
            }
        });
        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);
        rect.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent e) {
                ocm.hide();

                if (scm.isShowing()) {
                    scm.hide();
                }
                if (e.getButton() == MouseButton.SECONDARY) {
                    if (chromosomeSelector.getSelectionModel().isEmpty()) {
                        for (MenuItem mi : scm.getItems()) {
                            mi.setDisable(true);
                        }
                    } else {
                        for (MenuItem mi : scm.getItems()) {
                            mi.setDisable(false);
                        }
                    }

                    scm.show(selectionOverlayPane, e.getScreenX(), e.getScreenY());
                }
            }

        });
        rect.setVisible(true);
        selectionOverlayPane.getChildren().add(rect);
        rectCounter++;
    }
    selectionOverlayPane.getChildren().add(dragSelectRectangle);
}

From source file:sopho.Ofeloumenoi.AddOfeloumenoiController.java

@Override
public void initialize(URL url, ResourceBundle rb) {

    tekna.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {

        @Override/*from  w w  w.  j  ava  2 s  . c om*/
        public void handle(MouseEvent event) {
            if (prefs.getPrefs("tableTipOfeloumenoi").equals("true")) {
                sopho.Messages.CustomMessageController cm = new sopho.Messages.CustomMessageController(null,
                        "?",
                        "  ?       '?  '  ?  . ? ?    enter   ?  .         .",
                        "notify");
                cm.showAndWait();
                prefs.setPrefs("tableTipOfeloumenoi", "false");
            }
        }
    });

    anenergos.selectedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            if (newValue) {
                barcode.setStyle("-fx-background-color: #cc334a; -fx-text-fill:white;");
                if (showAnenergosTip.equals("true")) {
                    sopho.Messages.CustomMessageController cm = new sopho.Messages.CustomMessageController(null,
                            "?...",
                            "  ?   ?,    barcode      ?    ?   ? ?  ?? ?.        !",
                            "confirm");
                    cm.showAndWait();
                    prefs.setPrefs("showAnenergosTip", "false");
                }
            } else {
                barcode.setStyle("");
            }
        }
    });

    anergos.selectedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            epaggelma.setDisable(!newValue);//if the anergos checkbox is selected the epaggelma textFiels is disabled and vise versa
        }
    });

    //we use a listener to know if the user adds a photo using the TakePhoto class
    PhotoListener.strProperty().addListener(new ChangeListener() {
        @Override
        public void changed(ObservableValue o, Object oldVal, Object newVal) {
            if (PhotoListener.getStr() != null) {
                changePhotoButton.setText(" ?");
            }
            PhotoID = (String) newVal;

            BufferedImage bf = bfImage(PhotoID);

            if (bf != null) {
                Image im = SwingFXUtils.toFXImage(bf, null);
                image.setImage(im);
            }

        }
    });

    //initialzing tekna table
    data = getInitialTableData();

    tekna.setItems(data);
    tekna.setEditable(true);
    etosCol.setCellValueFactory(new PropertyValueFactory<tableManager, String>("etos"));

    //lets make the table cells editable
    etosCol.setCellFactory(TextFieldTableCell.forTableColumn());
    etosCol.setOnEditCommit(new EventHandler<CellEditEvent<tableManager, String>>() {

        @Override
        public void handle(CellEditEvent<tableManager, String> t) {
            if (!NumberUtils.isNumber(t.getNewValue())) {
                sopho.Messages.CustomMessageController cm = new sopho.Messages.CustomMessageController(null,
                        "?!",
                        "      ?  ?  ??. ?    ?  .",
                        "error");
                cm.showAndWait();
                ((tableManager) t.getTableView().getItems().get(t.getTablePosition().getRow()))
                        .setEtos("?  ");
            } else {
                ((tableManager) t.getTableView().getItems().get(t.getTablePosition().getRow()))
                        .setEtos(t.getNewValue());
            }
        }
    });

    tekna.getColumns().setAll(etosCol);
    //end of initialization of tekna table

    //initialize oikKatastasi combobox
    oikKatastasi.getItems().addAll("", "", "", "?");

    //initialize asfForeas comboBox
    asfForeas.getItems().addAll("", "", "", "", "",
            "", "", "", "  ", "");
}

From source file:sopho.Ofeloumenoi.EditOfeloumenoiController.java

@Override
public void initialize(URL url, ResourceBundle rb) {

    tekna.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {

        @Override/*from  w  w w.j  a v a  2  s.c  o m*/
        public void handle(MouseEvent event) {
            if (prefs.getPrefs("tableTipOfeloumenoi").equals("true")) {
                sopho.Messages.CustomMessageController cm = new sopho.Messages.CustomMessageController(null,
                        "?",
                        "  ?       '?  '  ?  . ? ?    enter   ?  .         .",
                        "notify");
                cm.showAndWait();
                prefs.setPrefs("tableTipOfeloumenoi", "false");
            }
        }
    });

    //initialize oikKatastasi combobox
    oikKatastasi.getItems().addAll("", "", "", "?");

    //initialize asfForeas comboBox
    asfForeas.getItems().addAll("", "", "", "", "",
            "", "", "", "  ", "");

    try {

        rs.first();//move the cursor to the first row
        if (selectedIndex > 0) {//only if we need to move from the first line
            rs.relative(selectedIndex);//move to the row that we selected at the previous scene
        }

        //keep the selected ofeloumenos id
        selID = rs.getInt("id");

        System.out.println("The selected rs row is " + rs.getRow());

        oldBarcode = rs.getString("barcode");

        //now we will set all the fields using the data from database
        barcode.setText(rs.getString("barcode"));
        eponimo.setText(rs.getString("eponimo"));
        onoma.setText(rs.getString("onoma"));
        patronimo.setText(rs.getString("patronimo"));
        mitronimo.setText(rs.getString("mitronimo"));

        if (rs.getDate("imGennisis") != null) {
            imGennisis.setValue(rs.getDate("imGennisis").toLocalDate());
        }

        dieuthinsi.setText(rs.getString("dieuthinsi"));
        dimos.setText(rs.getString("dimos"));
        tilefono.setText(rs.getString("tilefono"));
        anergos.setSelected((rs.getInt("anergos") != 0)); //if 0 set false, else set true
        epaggelma.setText(rs.getString("epaggelma"));
        eisodima.setText(rs.getString("eisodima"));
        eksartiseis.setText(rs.getString("eksartiseis"));

        PhotoID = rs.getString("PhotoID");
        if (PhotoID != null) {
            //we have a picture stored at the database.
            BufferedImage bf = bfImage(PhotoID);

            if (bf != null) {
                Image im = SwingFXUtils.toFXImage(bf, null);
                image.setImage(im);
            }

            //and we set the button bellow image to " ?"
            changePhotoButton.setText(" ?");
        }

        afm.setText(rs.getString("afm"));
        tautotita.setText(rs.getString("tautotita"));
        ethnikotita.setText(rs.getString("ethnikotita"));
        metanastis.setSelected(rs.getInt("metanastis") != 0);
        roma.setSelected(rs.getInt("roma") != 0);
        int oikKatIndex = rs.getInt("oikKatastasi");
        if (oikKatIndex >= 0) {
            oikKatastasi.getSelectionModel().select(oikKatIndex);
        }

        //we add data to tekna table using the tableManager class bellow

        politeknos.setSelected(rs.getInt("politeknos") != 0);
        monogoneiki.setSelected(rs.getInt("monogoneiki") != 0);
        mellousaMama.setSelected(rs.getInt("mellousaMama") != 0);
        amea.setSelected(rs.getInt("amea") != 0);
        int asfForeasIndex = rs.getInt("asfForeas");
        if (asfForeasIndex >= 0) {
            asfForeas.getSelectionModel().select(asfForeasIndex);
        }
        xronios.setSelected(rs.getInt("xronios") != 0);
        pathisi.setText(rs.getString("pathisi"));
        anoTon60.setSelected(rs.getInt("anoTon60") != 0);
        monaxiko.setSelected(rs.getInt("monaxikos") != 0);
        emfiliVia.setSelected(rs.getInt("emfiliVia") != 0);
        spoudastis.setSelected(rs.getInt("spoudastis") != 0);
        int anenergosFlag = rs.getInt("anenergos");
        if (anenergosFlag == 1) {
            barcode.setStyle("-fx-background-color: #cc334a; -fx-text-fill:white;");
        }
        anenergos.setSelected(anenergosFlag != 0);
        loipa.setText(rs.getString("loipa"));

    } catch (SQLException ex) {
        Logger.getLogger(EditOfeloumenoiController.class.getName()).log(Level.SEVERE, null, ex);
    }

    //adding a listener to anenergos checkbox to know if the user checks it
    anenergos.selectedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            if (newValue) {
                barcode.setStyle("-fx-background-color: #cc334a; -fx-text-fill:white;");
                if (showAnenergosTip.equals("true")) {
                    sopho.Messages.CustomMessageController cm = new sopho.Messages.CustomMessageController(null,
                            "?...",
                            "  ?   ?,    barcode      ?    ?   ? ?  ?? ?.        !",
                            "confirm");
                    cm.showAndWait();
                    prefs.setPrefs("showAnenergosTip", "false");
                }
            } else {
                barcode.setStyle("");
            }
        }
    });

    //we use a listener to know if the user adds a photo using the TakePhoto class
    PhotoListener.strProperty().addListener(new ChangeListener() {
        @Override
        public void changed(ObservableValue o, Object oldVal, Object newVal) {
            PhotoID = (String) newVal;
            BufferedImage bf = bfImage(PhotoID);

            if (bf != null) {
                Image im = SwingFXUtils.toFXImage(bf, null);
                image.setImage(im);
            }
        }
    });

    //initialzing tekna table
    data = getInitialTableData();

    tekna.setItems(data);
    tekna.setEditable(true);
    etosCol.setCellValueFactory(new PropertyValueFactory<tableManager, String>("etos"));

    //lets make the table cells editable
    etosCol.setCellFactory(TextFieldTableCell.forTableColumn());
    etosCol.setOnEditCommit(new EventHandler<CellEditEvent<tableManager, String>>() {

        @Override
        public void handle(CellEditEvent<tableManager, String> t) {
            if (!NumberUtils.isNumber(t.getNewValue())) {
                sopho.Messages.CustomMessageController cm = new sopho.Messages.CustomMessageController(null,
                        "?!",
                        "      ?  ?  ??. ?    ?  .",
                        "error");
                cm.showAndWait();
                ((tableManager) t.getTableView().getItems().get(t.getTablePosition().getRow()))
                        .setEtos("?  ");
            } else {
                ((tableManager) t.getTableView().getItems().get(t.getTablePosition().getRow()))
                        .setEtos(t.getNewValue());
            }
        }
    });

    tekna.getColumns().setAll(etosCol);
    //end of initialization of tekna table

}

From source file:ui.main.MainViewController.java

private synchronized void paintReceivedFile(Chat chat, String path, String time) {
    //this method paints the recieved picture message
    Task<HBox> recievedMessages = new Task<HBox>() {
        @Override/* w ww . j  a  v  a 2  s  . c  om*/
        protected HBox call() throws Exception {
            Thread.sleep(100);
            VBox vbox = new VBox(); //to add text

            ImageView imageRec = new ImageView(chatterAvatar.getImage()); //image
            imageRec.setFitHeight(60);
            imageRec.setFitWidth(50);

            String strChatterName = chat.getParticipant(); //add name of the chatter with light color
            strChatterName = Character.toUpperCase(strChatterName.charAt(0))
                    + strChatterName.substring(1, strChatterName.indexOf("@"));
            Label chatterName = new Label(strChatterName);
            chatterName.setDisable(true);

            Label timeL = new Label(time);
            timeL.setDisable(true);
            timeL.setFont(new Font("Arial", 10));

            Hyperlink link = new Hyperlink("File Recieved: " + path);
            link.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<javafx.scene.input.MouseEvent>() {
                @Override
                public void handle(javafx.scene.input.MouseEvent event) {
                    try {
                        if (event.getButton() == MouseButton.PRIMARY) {
                            Runtime.getRuntime().exec("explorer.exe /select," + path);
                        }
                    } catch (IOException ex) {
                        Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            });
            vbox.getChildren().addAll(chatterName, link, timeL);
            vbox.setAlignment(Pos.CENTER_RIGHT);
            HBox hbox = new HBox();
            //bbl.setBubbleSpec(BubbleSpec.FACE_LEFT_CENTER);
            hbox.getChildren().addAll(imageRec, vbox);
            return hbox;
        }
    };

    recievedMessages.setOnSucceeded(event -> {
        chatList.getChildren().add(recievedMessages.getValue());
    });

    if (chat.getParticipant().contains(currentChat.getParticipant())) {
        Thread t = new Thread(recievedMessages);
        //t.setDaemon(true);
        t.start();
        try {
            t.join();
        } catch (InterruptedException ex) {
            Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    //set the received chat message appear on the screen
    if (chat.getParticipant().contains(currentChat.getParticipant())) {
        Thread t = new Thread(recievedMessages);
        t.start();
    }
    Task t = new Task() {
        @Override
        protected Object call() throws Exception {
            Thread.sleep(2500);
            return new Object();
        }
    };

    t.setOnSucceeded(value -> scrollPane.setVvalue(scrollPane.getHmax()));

    Thread thread1 = new Thread(t);
    thread1.start();

}

From source file:ui.main.MainViewController.java

private synchronized void paintSentFile(Chat chat, String path, String time) {
    //this method paints the recieved picture message
    Task<HBox> recievedMessages = new Task<HBox>() {
        @Override// ww w .  j a va 2s .  c  o m
        protected HBox call() throws Exception {
            Thread.sleep(100);
            VBox vbox = new VBox(); //to add text

            ImageView imageRec = new ImageView(myAvatar.getImage()); //image
            imageRec.setFitHeight(60);
            imageRec.setFitWidth(50);

            Label timeL = new Label(time);
            timeL.setDisable(true);
            timeL.setFont(new Font("Arial", 10));

            Label chatterName = new Label(name.getText());
            chatterName.setDisable(true);

            Hyperlink link = new Hyperlink("File Sent: " + path);
            link.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<javafx.scene.input.MouseEvent>() {
                @Override
                public void handle(javafx.scene.input.MouseEvent event) {
                    try {
                        if (event.getButton() == MouseButton.PRIMARY) {
                            Runtime.getRuntime().exec("explorer.exe /select," + path);
                        }
                    } catch (IOException ex) {
                        Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            });
            vbox.getChildren().addAll(chatterName, link, timeL);
            vbox.setAlignment(Pos.CENTER_LEFT);
            HBox hbox = new HBox();
            hbox.setAlignment(Pos.CENTER_RIGHT);
            //bbl.setBubbleSpec(BubbleSpec.FACE_LEFT_CENTER);
            hbox.getChildren().addAll(vbox, imageRec);
            return hbox;
        }
    };

    recievedMessages.setOnSucceeded(event -> {
        chatList.getChildren().add(recievedMessages.getValue());
    });

    if (chat.getParticipant().contains(currentChat.getParticipant())) {
        Thread t = new Thread(recievedMessages);
        t.start();
        try {
            t.join();
        } catch (InterruptedException ex) {
            Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}