javafx.scene.input.MouseEvent Java Examples

The following examples show how to use javafx.scene.input.MouseEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RadialGlobalMenu.java    From RadialFx with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void addMenuItem(final String iconPath,
    final EventHandler<MouseEvent> eventHandler) {

final RadialGradient backGradient = new RadialGradient(0, 0, 0, 0,
	radius.get(), false, CycleMethod.NO_CYCLE, new Stop(0,
		BACK_GRADIENT_COLOR), new Stop(1, Color.TRANSPARENT));

final RadialGradient backSelectGradient = new RadialGradient(0, 0, 0,
	0, radius.get(), false, CycleMethod.NO_CYCLE, new Stop(0,
		BACK_SELECT_GRADIENT_COLOR), new Stop(1,
		Color.TRANSPARENT));

final RadialMenuItem item = RadialMenuItemBuilder.create()
	.length(length).graphic(new Group(getImageView(iconPath)))
	.backgroundFill(backGradient)
	.backgroundMouseOnFill(backSelectGradient)
	.innerRadius(innerRadius).radius(radius).offset(offset)
	.clockwise(true).backgroundVisible(true).strokeVisible(false)
	.build();

item.setOnMouseClicked(eventHandler);

items.add(item);
itemsContainer.getChildren().addAll(item);
   }
 
Example #2
Source File: ResultList.java    From iliasDownloaderTool with GNU General Public License v2.0 6 votes vote down vote up
private void showContextMenu(MouseEvent event) {
	menu.hide();
	final List<IliasTreeNode> selectedNodes = ((ResultList) event.getSource())
			.getSelectionModel().getSelectedItems();
	if (selectedNodes.isEmpty() || selectedNodes == null) {
		return;
	}
	if (selectedNodes.size() == 1) {
		dashboard.getCoursesTreeView().selectFile((IliasFile) selectedNodes.get(0));
	}

	if (event.getButton() == MouseButton.SECONDARY) {
		menu = new FileContextMenu(dashboard).createMenu(selectedNodes, event);
		menu.show(this, event.getScreenX(), event.getScreenY());
	}
}
 
Example #3
Source File: SkinAction.java    From DashboardFx with GNU General Public License v3.0 6 votes vote down vote up
private void setupListeners() {

        final TextField textField = getSkinnable();

        button.setOnMouseReleased(event -> mouseReleased());
        button.setOnMousePressed(event -> mousePressed());
        button.addEventFilter(MouseEvent.MOUSE_CLICKED, event -> {
            if(graphic.isVisible())button.setCursor(Cursor.HAND);
            else button.setCursor(Cursor.DEFAULT);

        });
        button.setOnMouseMoved(event -> {
            if(graphic.isVisible())button.setCursor(Cursor.HAND);
            else button.setCursor(Cursor.DEFAULT);
        });
        textField.textProperty().addListener((observable, oldValue, newValue) -> textChanged());
        textField.focusedProperty().addListener((observable, oldValue, newValue) -> focusChanged());

        button.setMinWidth(10);
        button.setMinHeight(10);
        graphic.setMinWidth(10);
        graphic.setMinHeight(10);
    }
 
Example #4
Source File: Scene3DHandler.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void drag(final MouseEvent event)
{
	synchronized (getTransformLock())
	{
		LOG.trace("drag - translate");
		final double dX = event.getX() - getStartX();
		final double dY = event.getY() - getStartY();

		LOG.trace("dx " + dX + " dy: " + dY);

		final Affine target = affine.clone();
		target.prependTranslation(2 * dX / viewer.getHeight(), 2 * dY / viewer.getHeight());

		InvokeOnJavaFXApplicationThread.invoke(() -> setAffine(target));

		setStartX(getStartX() + dX);
		setStartY(getStartY() + dY);
	}
}
 
Example #5
Source File: Resumen.java    From uip-pc2 with MIT License 6 votes vote down vote up
public void salir(MouseEvent mouseEvent) {
    Stage stage = (Stage) salir.getScene().getWindow();
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Login.fxml"));
    Parent root = null;
    try {
        root = fxmlLoader.load();
    } catch (Exception e) {
        Alert alerta = new Alert(Alert.AlertType.ERROR);
        alerta.setTitle("Error de Aplicación");
        alerta.setContentText("Llama al lapecillo de sistemas.");
        alerta.showAndWait();
        Platform.exit();
    }
    FadeTransition ft = new FadeTransition(Duration.millis(1500), root);
    ft.setFromValue(0.0);
    ft.setToValue(1.0);
    ft.play();
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();
}
 
Example #6
Source File: OpenNestedGraphOnDoubleClickHandler.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void click(MouseEvent event) {
	if (event.getClickCount() == 2) {
		// double click, so open nested graph, if it exists
		final Graph nestedGraph = getHost().getContent().getNestedGraph();
		if (nestedGraph != null) {
			IViewer viewer = getHost().getRoot().getViewer();
			try {
				// navigate to nested graph
				viewer.getDomain().execute(new NavigateOperation(viewer, nestedGraph, true),
						new NullProgressMonitor());
			} catch (ExecutionException e) {
				throw new RuntimeException(e);
			}
		}
	}
}
 
Example #7
Source File: ExtensionItemContainer.java    From G-Earth with MIT License 6 votes vote down vote up
void initExtension(){
    if (onExit != null) {
        exitButton.removeEventHandler(MouseEvent.MOUSE_CLICKED, onExit);
        clickButton.removeEventHandler(MouseEvent.MOUSE_CLICKED, onClick);
    }
    onExit = event -> item.getRemoveClickObservable().fireEvent();
    onClick = event -> item.getClickedObservable().fireEvent();

    exitButton.addEventHandler(MouseEvent.MOUSE_CLICKED, onExit);
    clickButton.addEventHandler(MouseEvent.MOUSE_CLICKED, onClick);

    ExtensionItemContainer this2 = this;
    item.getDeletedObservable().addListener(() -> Platform.runLater(() -> {
        if (item.isInstalledExtension()) {
            setBackground(new Background(new BackgroundFill(Paint.valueOf("#cccccc"),null, null)));
            getChildren().remove(buttonsBox);
            add(additionalButtonBox, 4, 0);
            reloadButton.setVisible(true);
        }
        else {
            parent.getChildren().remove(this2);
        }
    }));
}
 
Example #8
Source File: CrosshairIndicator.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
private void updateLabel(final MouseEvent event, final Bounds plotAreaBounds) {
    coordinatesLabel.setText(formatLabelText(getLocationInPlotArea(event)));

    final double width = coordinatesLabel.prefWidth(-1);
    final double height = coordinatesLabel.prefHeight(width);

    double xLocation = event.getX() + CrosshairIndicator.LABEL_X_OFFSET;
    double yLocation = event.getY() + CrosshairIndicator.LABEL_Y_OFFSET;

    if (xLocation + width > plotAreaBounds.getMaxX()) {
        xLocation = event.getX() - CrosshairIndicator.LABEL_X_OFFSET - width;
    }
    if (yLocation + height > plotAreaBounds.getMaxY()) {
        yLocation = event.getY() - CrosshairIndicator.LABEL_Y_OFFSET - height;
    }
    coordinatesLabel.resizeRelocate(xLocation, yLocation, width, height);
}
 
Example #9
Source File: TargetEditorController.java    From ShootOFF with GNU General Public License v3.0 6 votes vote down vote up
@FXML
public void mouseMoved(MouseEvent event) {
	if (freeformButton.isSelected()) {
		drawTempPolygonEdge(event);
	}

	if (!cursorRegion.isPresent() || cursorButton.isSelected()) return;

	final Node selected = cursorRegion.get();

	lastMouseX = event.getX() - (selected.getLayoutBounds().getWidth() / 2);
	lastMouseY = event.getY() - (selected.getLayoutBounds().getHeight() / 2);

	if (lastMouseX < 0) lastMouseX = 0;
	if (lastMouseY < 0) lastMouseY = 0;

	if (event.getX() + (selected.getLayoutBounds().getWidth() / 2) <= canvasPane.getWidth())
		selected.setLayoutX(lastMouseX - selected.getLayoutBounds().getMinX());

	if (event.getY() + (selected.getLayoutBounds().getHeight() / 2) <= canvasPane.getHeight())
		selected.setLayoutY(lastMouseY - selected.getLayoutBounds().getMinY());

	event.consume();
}
 
Example #10
Source File: ModernSkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
public void handleMouseEvent(final MouseEvent EVENT) {
    if (gauge.isDisabled()) return;
    final EventType TYPE = EVENT.getEventType();
    if (MouseEvent.MOUSE_PRESSED.equals(TYPE)) {
        gauge.fireEvent(gauge.BTN_PRESSED_EVENT);
        centerKnob.setFill(new LinearGradient(0.5 * size, 0.2708333333333333 * size,
                                              0.5 * size, 0.7291666666666666 * size,
                                              false, CycleMethod.NO_CYCLE,
                                              new Stop(0.0, Color.rgb(31, 31, 31)),
                                              new Stop(1.0, Color.rgb(69, 70, 73))));
        valueText.setTranslateY(size * 0.501);
        subTitleText.setTranslateY(size * 0.3525);
        unitText.setTranslateY(size * 0.6675);
    } else if (MouseEvent.MOUSE_RELEASED.equals(TYPE)) {
        gauge.fireEvent(gauge.BTN_RELEASED_EVENT);
        centerKnob.setFill(new LinearGradient(0.5 * size, 0.2708333333333333 * size,
                                              0.5 * size, 0.7291666666666666 * size,
                                              false, CycleMethod.NO_CYCLE,
                                              new Stop(0.0, Color.rgb(69, 70, 73)),
                                              new Stop(1.0, Color.rgb(31, 31, 31))));
        valueText.setTranslateY(size * 0.5);
        subTitleText.setTranslateY(size * 0.35);
        unitText.setTranslateY(size * 0.67);
    }
}
 
Example #11
Source File: JointAlignmentManager.java    From graph-editor with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Adds an alignment handler to each of the given joint skins.
 *
 * <p>
 * This is a mouse-pressed handler which checks for appropriate adjacent joints and sets alignment targets in the
 * joint's {@link DraggableBox} root node, so that the joint will align to adjacent joints when dragged near them.
 * </p>
 *
 * @param jointSkins all joint skin instances belonging to a connection
 */
public void addAlignmentHandlers(final List<GJointSkin> jointSkins) {

    final Map<GJointSkin, EventHandler<MouseEvent>> oldAlignmentHandlers = new HashMap<>(alignmentHandlers);
    alignmentHandlers.clear();

    for (final GJointSkin jointSkin : jointSkins) {

        final EventHandler<MouseEvent> oldHandler = oldAlignmentHandlers.get(jointSkin);

        final DraggableBox root = jointSkin.getRoot();

        if (oldHandler != null) {
            root.removeEventHandler(MouseEvent.MOUSE_PRESSED, oldHandler);
        }

        final EventHandler<MouseEvent> newHandler = event -> {
            addHorizontalAlignmentTargets(jointSkin, jointSkins);
            addVerticalAlignmentTargets(jointSkin, jointSkins);
        };

        root.addEventHandler(MouseEvent.MOUSE_PRESSED, newHandler);
        alignmentHandlers.put(jointSkin, newHandler);
    }
}
 
Example #12
Source File: UndecoratorController.java    From DevToolBox with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Based on mouse position returns dock side
 *
 * @param mouseEvent
 * @return DOCK_LEFT,DOCK_RIGHT,DOCK_TOP
 */
int getDockSide(MouseEvent mouseEvent) {
    double minX = Double.POSITIVE_INFINITY;
    double minY = Double.POSITIVE_INFINITY;
    double maxX = 0;
    double maxY = 0;
    // Get "big" screen bounds
    ObservableList<Screen> screens = Screen.getScreens();
    for (Screen screen : screens) {
        Rectangle2D visualBounds = screen.getVisualBounds();
        minX = Math.min(minX, visualBounds.getMinX());
        minY = Math.min(minY, visualBounds.getMinY());
        maxX = Math.max(maxX, visualBounds.getMaxX());
        maxY = Math.max(maxY, visualBounds.getMaxY());
    }
    // Dock Left
    if (mouseEvent.getScreenX() == minX) {
        return DOCK_LEFT;
    } else if (mouseEvent.getScreenX() >= maxX - 1) { // MaxX returns the width? Not width -1 ?!
        return DOCK_RIGHT;
    } else if (mouseEvent.getScreenY() <= minY) {   // Mac menu bar
        return DOCK_TOP;
    }
    return 0;
}
 
Example #13
Source File: MediaTableController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@FXML
public void popMediasLink(MouseEvent event) {
    if (AppVariables.fileRecentNumber <= 0) {
        return;
    }
    RecentVisitMenu menu = new RecentVisitMenu(this, event) {
        @Override
        public List<VisitHistory> recentFiles() {
            List<VisitHistory> recent = VisitHistory.getRecentStreamMedia();
            return recent;
        }

        public List<String> paths() {
            return null;
        }

        @Override
        public List<VisitHistory> recentPaths() {
            return null;
        }

        @Override
        public void handleSelect() {
            addLinkAction();
        }

        @Override
        public void handleFile(String address) {
            addLink(address);
        }

        @Override
        public void handlePath(String fname) {
        }

    };
    menu.setExamples(examples);
    menu.pop();
}
 
Example #14
Source File: DragResizerUtil.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
protected void resetNodeSize(final MouseEvent evt) {
    if (!evt.isPrimaryButtonDown() || evt.getClickCount() < 2) {
        return;
    }

    if (!(node instanceof Region)) {
        return;
    }

    ((Region) node).setPrefWidth(Region.USE_COMPUTED_SIZE);
    ((Region) node).setPrefHeight(Region.USE_COMPUTED_SIZE);
}
 
Example #15
Source File: Zoomer.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
private boolean isMouseEventWithinCanvas(final MouseEvent mouseEvent) {
    final Canvas canvas = getChart().getCanvas();
    // listen to only events within the canvas
    final Point2D mouseLoc = new Point2D(mouseEvent.getScreenX(), mouseEvent.getScreenY());
    final Bounds screenBounds = canvas.localToScreen(canvas.getBoundsInLocal());
    return screenBounds.contains(mouseLoc);
}
 
Example #16
Source File: FriendListWindow.java    From chat-socket with MIT License 5 votes vote down vote up
@FXML
private void onListViewItemClick(MouseEvent event) {
    if (event.getClickCount() == 2) {
        Profile selectedItem = friendListView.getSelectionModel().getSelectedItem();
        if (friendButtonClickListener != null && selectedItem != null)
            friendButtonClickListener.call(selectedItem);
    }
}
 
Example #17
Source File: GoogleMapView.java    From GMapsFX with Apache License 2.0 5 votes vote down vote up
@Override
public Event dispatchEvent(Event event, EventDispatchChain tail) {

    if (event instanceof MouseEvent) {
        MouseEvent mouseEvent = (MouseEvent) event;
        if (mouseEvent.getClickCount() > 1) {
            if (disableDoubleClick) {
                mouseEvent.consume();
            }
        }
    }
    return originalDispatcher.dispatchEvent(event, tail);
}
 
Example #18
Source File: SmoothAreaChartTileSkin.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
@Override public void dispose() {
    tile.getChartData().removeListener(chartDataListener);
    tile.getChartData().forEach(chartData -> chartData.removeChartDataEventListener(chartEventListener));
    fillPath.removeEventHandler(MouseEvent.MOUSE_PRESSED, clickHandler);
    endOfTransformationHandler = null;
    fadeInFadeOut.setOnFinished(null);
    super.dispose();
}
 
Example #19
Source File: ImageMaskController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
protected void doubleClickedCircle(MouseEvent event) {
    if (maskCircleLine == null || !maskCircleLine.isVisible()) {
        return;
    }
    DoublePoint p = getImageXY(event, imageView);
    if (p == null) {
        return;
    }
    double x = p.getX();
    double y = p.getY();
    if (event.getButton() == MouseButton.PRIMARY) {

        maskCircleData.setCenterX(x);
        maskCircleData.setCenterY(y);
        drawMaskCircleLine();

    } else if (event.getButton() == MouseButton.SECONDARY) {

        if (x != maskCircleData.getCenterX() || y != maskCircleData.getCenterY()) {
            double dx = x - maskCircleData.getCenterX();
            double dy = y - maskCircleData.getCenterY();
            maskCircleData.setRadius(Math.sqrt(dx * dx + dy * dy));
            drawMaskCircleLine();
        }

    }
}
 
Example #20
Source File: SwitchSliderTileSkin.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
@Override protected void registerListeners() {
    super.registerListeners();
    thumb.addEventHandler(MouseEvent.MOUSE_PRESSED, mouseEventHandler);
    thumb.addEventHandler(MouseEvent.MOUSE_DRAGGED, mouseEventHandler);
    thumb.addEventHandler(MouseEvent.MOUSE_RELEASED, mouseEventHandler);

    switchBorder.addEventHandler(MouseEvent.MOUSE_PRESSED, mouseEventHandler);
    switchBorder.addEventHandler(MouseEvent.MOUSE_RELEASED, mouseEventHandler);

    tile.activeProperty().addListener(selectedListener);

    tile.valueProperty().addListener(valueListener);
}
 
Example #21
Source File: PopOver.java    From logbook-kai with MIT License 5 votes vote down vote up
/**
 * マウスがこのアンカーノードに入るときに呼び出される関数を定義します。
 *
 * @param event {@link MouseEvent}
 */
protected void setOnMouseEntered(MouseEvent event) {
    Node anchorNode = (Node) event.getSource();
    Popup popup = this.initPopup(anchorNode);
    Bounds screen = anchorNode.localToScreen(anchorNode.getLayoutBounds());
    popup.setAnchorLocation(PopupWindow.AnchorLocation.CONTENT_TOP_LEFT);
    popup.show(anchorNode.getScene().getWindow(), screen.getMinX(), screen.getMaxY());
    this.setLocation(popup, anchorNode, event);
}
 
Example #22
Source File: ChartCanvas.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Handles a mouse released event by passing it on to the registered 
 * handlers.
 * 
 * @param e  the mouse event.
 */
private void handleMouseClicked(MouseEvent e) {
    if (this.liveHandler != null && this.liveHandler.isEnabled()) {
        this.liveHandler.handleMouseClicked(this, e);
    }

    // pass on the event to the auxiliary handlers
    for (MouseHandlerFX handler: this.auxiliaryMouseHandlers) {
        if (handler.isEnabled()) {
            handler.handleMouseClicked(this, e);
        }
    }
}
 
Example #23
Source File: ImagesBlendController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@FXML
private void foreClicked(MouseEvent event) {
    if (foreImage == null || location != ImagesRelativeLocation.Background_In_Foreground) {
        return;
    }
    foreView.setCursor(Cursor.HAND);

    int xv = (int) Math.round(event.getX() * foreImage.getWidth() / foreView.getBoundsInParent().getWidth());
    int yv = (int) Math.round(event.getY() * foreImage.getHeight() / foreView.getBoundsInParent().getHeight());

    pointX.setText(xv + "");
    pointY.setText(yv + "");
}
 
Example #24
Source File: ChartCanvas.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
public void dispatchMouseMovedEvent(Point2D point, MouseEvent e) {
    double x = point.getX();
    double y = point.getY();
    ChartEntity entity = this.info.getEntityCollection().getEntity(x, y);
    ChartMouseEventFX event = new ChartMouseEventFX(this.chart, e, entity);
    for (ChartMouseListenerFX listener : this.chartMouseListeners) {
        listener.chartMouseMoved(event);
    }
}
 
Example #25
Source File: DialogPopup.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
private void installDismissEventHandler(Window window) {
    oldEventDispatcher = window.getEventDispatcher();
    window.setEventDispatcher((event, tail) -> {
        EventType<?> eventType = event.getEventType();
        if (eventType == MouseEvent.MOUSE_PRESSED 
                || eventType == TouchEvent.TOUCH_PRESSED) {
            // Dismiss
            hide();
        } else {
            // Event in the popup window.
            tail.dispatchEvent(event);
        }
        return null;
    });
}
 
Example #26
Source File: PanHandlerFX.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Handles a mouse dragged event by calculating the distance panned and
 * updating the axes accordingly.
 * 
 * @param canvas  the JavaFX canvas (<code>null</code> not permitted).
 * @param e  the mouse event (<code>null</code> not permitted).
 */
public void handleMouseDragged(ChartCanvas canvas, MouseEvent e) {
    if (this.panLast == null) {
        //handle panning if we have a start point else unregister
        canvas.clearLiveHandler();
        return;
    }

    JFreeChart chart = canvas.getChart();
    double dx = e.getX() - this.panLast.getX();
    double dy = e.getY() - this.panLast.getY();
    if (dx == 0.0 && dy == 0.0) {
        return;
    }
    double wPercent = -dx / this.panW;
    double hPercent = dy / this.panH;
    boolean old = chart.getPlot().isNotify();
    chart.getPlot().setNotify(false);
    Pannable p = (Pannable) chart.getPlot();
    PlotRenderingInfo info = canvas.getRenderingInfo().getPlotInfo();
    if (p.getOrientation().isVertical()) {
        p.panDomainAxes(wPercent, info, this.panLast);
        p.panRangeAxes(hPercent, info, this.panLast);
    }
    else {
        p.panDomainAxes(hPercent, info, this.panLast);
        p.panRangeAxes(wPercent, info, this.panLast);
    }
    this.panLast = new Point2D.Double(e.getX(), e.getY());
    chart.getPlot().setNotify(old);
}
 
Example #27
Source File: ChartGestureMouseAdapterFX.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Handles a mouse clicked event. This implementation does nothing, override the method if
 * required.
 * 
 * @param canvas the canvas ({@code null} not permitted).
 * @param e the event ({@code null} not permitted).
 */
@Override
public void handleMouseClicked(ChartCanvas chartPanel, MouseEvent eOrig) {
  if (gestureHandlers == null || gestureHandlers.isEmpty()
      || !(listensFor(Event.CLICK) || listensFor(Event.DOUBLE_CLICK)))
    return;

  MouseEventWrapper e = new MouseEventWrapper(eOrig);
  ChartEntity entity = findChartEntity(e);
  ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
  Button button = Button.getButton(e.getButton());

  if (!e.isConsumed()) {
    // double clicked
    if (e.getClickCount() == 2) {
      // reset click count to handle double clicks quickly
      e.consume();
      // handle event
      handleEvent(new ChartGestureEvent(cw, e, entity,
          new ChartGesture(gestureEntity, Event.DOUBLE_CLICK, button)));
    } else if (e.getClickCount() == 1) {
      // handle event
      handleEvent(new ChartGestureEvent(cw, e, entity,
          new ChartGesture(gestureEntity, Event.CLICK, button)));
    }
  }
}
 
Example #28
Source File: TileSkin.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
protected void registerListeners() {
    tile.widthProperty().addListener(sizeListener);
    tile.heightProperty().addListener(sizeListener);
    tile.setOnTileEvent(tileEventListener);
    tile.currentValueProperty().addListener(currentValueListener);
    if (null != infoRegionHandler) { infoRegion.addEventHandler(MouseEvent.ANY, infoRegionHandler); }
}
 
Example #29
Source File: SelectionCreator.java    From graph-editor with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Handles mouse-released events on the view.
 *
 * @param event a mouse-released event
 */
private void handleViewReleased(final MouseEvent event) {

    if (!event.getButton().equals(MouseButton.PRIMARY)) {
        return;
    }

    selectionBoxStart = null;
    view.hideSelectionBox();
}
 
Example #30
Source File: TextTreeItem.java    From PDF4Teachers with Apache License 2.0 5 votes vote down vote up
public void setup(){

		if(core != null){
			// bindings with the core
			fontProperty().bind(core.fontProperty());
			core.textProperty().addListener(textChangeListener);
			core.fillProperty().addListener(colorChangeListener);
		}

		// Setup les éléments graphiques
		menu = TextTreeView.getNewMenu(this);

		onMouseCLick = (MouseEvent mouseEvent) -> {
			if(mouseEvent.getButton().equals(MouseButton.PRIMARY)){
				addToDocument(false);
				// Update the sorting if is sort by utils
				if(getType() == TextTreeSection.FAVORITE_TYPE){
					if(MainWindow.lbTextTab.treeView.favoritesSection.sortManager.getSelectedButton().getText().equals(TR.tr("Utilisation"))){
						MainWindow.lbTextTab.treeView.favoritesSection.sortManager.simulateCall();
					}
				}else if(getType() == TextTreeSection.LAST_TYPE){
					if(MainWindow.lbTextTab.treeView.lastsSection.sortManager.getSelectedButton().getText().equals(TR.tr("Utilisation"))){
						MainWindow.lbTextTab.treeView.lastsSection.sortManager.simulateCall();
					}
				}
			}
		};
		name.setFill(StyleManager.convertColor(color.get()));
		colorProperty().addListener((observable, oldValue, newValue) -> {
			name.setFill(StyleManager.convertColor(newValue));
		});

		name.fontProperty().bind(Bindings.createObjectBinding(this::getListFont, fontProperty(), Main.settings.smallFontInTextsListProperty()));

		updateIcon();
	}