Search in sources :

Example 1 with Cursor

use of javafx.scene.Cursor in project Malai by arnobl.

the class Pencil method configureBindings.

@Override
protected void configureBindings() {
    // A DnD interaction with the left button of the mouse will produce an AddShape command while interacting on the canvas.
    // A temporary view of the created shape is created and displayed by the canvas.
    // This view is removed at the end of the interaction.
    nodeBinder(AddShape.class, new DnD()).on(canvas).map(i -> new AddShape(drawing, new MyRect(i.getSrcLocalPoint().getX(), i.getSrcLocalPoint().getY()))).first((c, i) -> canvas.setTmpShape(ViewFactory.INSTANCE.createViewShape(c.getShape()))).then((c, i) -> {
        final MyRect sh = (MyRect) c.getShape();
        sh.setWidth(i.getEndLocalPt().getX() - sh.getX());
        sh.setHeight(i.getEndLocalPt().getY() - sh.getY());
    }).when(i -> i.getButton() == MouseButton.PRIMARY).end((c, i) -> canvas.setTmpShape(null)).log(LogLevel.INTERACTION).strictStart().help(new AddRectHelpAnimation(learningPane, canvas)).bind();
    // A DnD interaction with the right button of the mouse moves the targeted shape.
    // To incrementally moves the shape, the DnD interaction has its parameter 'updateSrcOnUpdate' set to true:
    // At each interaction updates, the source point and object take the latest target point and object.
    // The DnD interaction can be stopped (aborted) by pressing the key 'ESC'. This cancels the ongoing command (that thus needs to be undoable).
    nodeBinder(MoveShape.class, new DnD(true, true)).on(canvas.getShapesPane().getChildren()).map(i -> {
        final MyShape sh = i.getSrcObject().map(o -> (MyShape) o.getUserData()).get();
        return new MoveShape(sh, Bindings.createDoubleBinding(() -> sh.getX() + (i.getEndScenePt().getX() - i.getSrcScenePoint().getX()), i.endScenePtProperty(), i.srcScenePointProperty()), Bindings.createDoubleBinding(() -> sh.getY() + (i.getEndScenePt().getY() - i.getSrcScenePoint().getY()), i.endScenePtProperty(), i.srcScenePointProperty()));
    }).when(i -> i.getButton() == MouseButton.SECONDARY).exec().first((c, i) -> {
        // Required to grab the focus to get key events
        Platform.runLater(() -> i.getSrcObject().get().requestFocus());
        i.getSrcObject().get().setEffect(new DropShadow(20d, Color.BLACK));
    }).endOrCancel((c, i) -> i.getSrcObject().get().setEffect(null)).strictStart().help(new MoveRectHelpAnimation(learningPane, canvas)).bind();
    // nodeBinder(MoveShape.class, new CancellableDnD(true)).
    // // The binding dynamically registers elements of the given observable list.
    // // When nodes are added to this list, these nodes register the binding.
    // // When nodes are removed from this list, their binding is cancelled.
    // // This permits to interact on nodes (here, shapes) that are dynamically added to/removed from the canvas.
    // on(canvas.getShapesPane().getChildren()).
    // map(i -> new MoveShape(i.getSrcObject().map(o ->(MyShape) o.getUserData()).orElse(null))).
    // then((a, i) -> a.setCoord(a.getShape().getX() + (i.getEndScenePt().getX() - i.getSrcScenePoint().getX()),
    // a.getShape().getY() + (i.getEndScenePt().getY() - i.getSrcScenePoint().getY()))).
    // when(i -> i.getButton() == MouseButton.SECONDARY).
    // // exec(true): this allows to execute the command each time the interaction updates (and 'when' is true).
    // exec(true).
    // first((a, i) -> {
    // // Required to grab the focus to get key events
    // Platform.runLater(() -> i.getSrcObject().get().requestFocus());
    // i.getSrcObject().get().setEffect(new DropShadow(20d, Color.BLACK));
    // }).
    // end((a, i) -> i.getSrcObject().get().setEffect(null)).
    // strictStart().
    // bind();
    /*
		 * A DnD on the colour picker produces ChangeCol commands when the target of the DnD is a shape
		 * (the shape we want to change the colour). The interim feedback changes the cursor during the DnD to show the dragged colour.
		 * Note that the feedback callback is not optimised here as the colour does not change during the DnD. The cursor
		 * should be changed in 'first'
		 */
    nodeBinder(ChangeColour.class, new DnD()).on(lineCol).map(i -> new ChangeColour(lineCol.getValue(), null)).then((a, i) -> i.getEndObjet().map(view -> (MyShape) view.getUserData()).ifPresent(sh -> a.setShape(sh))).when(i -> i.getEndObjet().orElse(null) instanceof Shape).feedback(() -> lineCol.getScene().setCursor(new ColorCursor(lineCol.getValue()))).endOrCancel((a, i) -> lineCol.getScene().setCursor(Cursor.DEFAULT)).bind();
    /*
		 * A mouse pressure creates an anonymous command that simply shows a message in the console.
		 */
    anonCmdBinder(() -> System.out.println("An example of the anonymous command."), new Press()).on(canvas).bind();
    /*
		 * A widget binding that execute a command asynchronously.
		 * Widgets and properties are provided to the binding to:
		 * show/hide the cancel button, provide widgets with information regarding the progress of the command execution.
		 */
    buttonBinder(Save.class).on(save).async(cancel, progressbar.progressProperty(), textProgress.textProperty()).bind();
}
Also used : Button(javafx.scene.control.Button) AddShape(org.malai.ex.draw.command.AddShape) Initializable(javafx.fxml.Initializable) MouseButton(javafx.scene.input.MouseButton) MyCanvas(org.malai.ex.draw.view.MyCanvas) MyDrawing(org.malai.ex.draw.model.MyDrawing) URL(java.net.URL) Bindings(javafx.beans.binding.Bindings) AddRectHelpAnimation(org.malai.ex.draw.learning.AddRectHelpAnimation) ProgressBar(javafx.scene.control.ProgressBar) MyRect(org.malai.ex.draw.model.MyRect) ResourceBundle(java.util.ResourceBundle) ListChangeListener(javafx.collections.ListChangeListener) MyShape(org.malai.ex.draw.model.MyShape) DnD(org.malai.javafx.interaction.library.DnD) Pane(javafx.scene.layout.Pane) Save(org.malai.ex.draw.command.Save) MoveRectHelpAnimation(org.malai.ex.draw.learning.MoveRectHelpAnimation) ColorPicker(javafx.scene.control.ColorPicker) LogLevel(org.malai.logging.LogLevel) Color(javafx.scene.paint.Color) Label(javafx.scene.control.Label) MoveShape(org.malai.ex.draw.command.MoveShape) ViewFactory(org.malai.ex.draw.view.ViewFactory) ChangeColour(org.malai.ex.draw.command.ChangeColour) JfxInstrument(org.malai.javafx.instrument.JfxInstrument) Group(javafx.scene.Group) Collectors(java.util.stream.Collectors) DropShadow(javafx.scene.effect.DropShadow) Objects(java.util.Objects) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) Cursor(javafx.scene.Cursor) Press(org.malai.javafx.interaction.library.Press) ColorCursor(org.malai.ex.util.ColorCursor) Shape(javafx.scene.shape.Shape) AddShape(org.malai.ex.draw.command.AddShape) MoveShape(org.malai.ex.draw.command.MoveShape) AddShape(org.malai.ex.draw.command.AddShape) MyShape(org.malai.ex.draw.model.MyShape) MoveShape(org.malai.ex.draw.command.MoveShape) Shape(javafx.scene.shape.Shape) MyRect(org.malai.ex.draw.model.MyRect) AddRectHelpAnimation(org.malai.ex.draw.learning.AddRectHelpAnimation) ChangeColour(org.malai.ex.draw.command.ChangeColour) MyShape(org.malai.ex.draw.model.MyShape) ColorCursor(org.malai.ex.util.ColorCursor) DropShadow(javafx.scene.effect.DropShadow) MoveRectHelpAnimation(org.malai.ex.draw.learning.MoveRectHelpAnimation) Save(org.malai.ex.draw.command.Save) DnD(org.malai.javafx.interaction.library.DnD) Press(org.malai.javafx.interaction.library.Press)

Example 2 with Cursor

use of javafx.scene.Cursor in project Gargoyle by callakrsos.

the class DockNode method handle.

@Override
public void handle(MouseEvent event) {
    //		if(event.getSource() instanceof DockTabPane)
    //			return;
    //		System.err.println(event.getPickResult().getIntersectedNode());
    Cursor cursor = Cursor.DEFAULT;
    // TODO: use escape to cancel resize/drag operation like visual studio
    if (!this.isFloating() || !this.isStageResizable()) {
        return;
    }
    if (event.getEventType() == MouseEvent.MOUSE_PRESSED) {
        sizeLast = new Point2D(event.getScreenX(), event.getScreenY());
    } else if (event.getEventType() == MouseEvent.MOUSE_MOVED) {
        Insets insets = borderPane.getPadding();
        sizeWest = event.getX() < insets.getLeft();
        sizeEast = event.getX() > borderPane.getWidth() - insets.getRight();
        sizeNorth = event.getY() < insets.getTop();
        sizeSouth = event.getY() > borderPane.getHeight() - insets.getBottom();
        if (sizeWest) {
            if (sizeNorth) {
                cursor = Cursor.NW_RESIZE;
            } else if (sizeSouth) {
                cursor = Cursor.SW_RESIZE;
            } else {
                cursor = Cursor.W_RESIZE;
            }
        } else if (sizeEast) {
            if (sizeNorth) {
                cursor = Cursor.NE_RESIZE;
            } else if (sizeSouth) {
                cursor = Cursor.SE_RESIZE;
            } else {
                cursor = Cursor.E_RESIZE;
            }
        } else if (sizeNorth) {
            cursor = Cursor.N_RESIZE;
        } else if (sizeSouth) {
            cursor = Cursor.S_RESIZE;
        }
        this.getScene().setCursor(cursor);
    } else if (event.getEventType() == MouseEvent.MOUSE_DRAGGED && this.isMouseResizeZone()) {
        Point2D sizeCurrent = new Point2D(event.getScreenX(), event.getScreenY());
        Point2D sizeDelta = sizeCurrent.subtract(sizeLast);
        double newX = stage.getX(), newY = stage.getY(), newWidth = stage.getWidth(), newHeight = stage.getHeight();
        if (sizeNorth) {
            newHeight -= sizeDelta.getY();
            newY += sizeDelta.getY();
        } else if (sizeSouth) {
            newHeight += sizeDelta.getY();
        }
        if (sizeWest) {
            newWidth -= sizeDelta.getX();
            newX += sizeDelta.getX();
        } else if (sizeEast) {
            newWidth += sizeDelta.getX();
        }
        // TODO: find a way to do this synchronously and eliminate the flickering of moving the stage
        // around, also file a bug report for this feature if a work around can not be found this
        // primarily occurs when dragging north/west but it also appears in native windows and Visual
        // Studio, so not that big of a concern.
        // Bug report filed:
        // https://bugs.openjdk.java.net/browse/JDK-8133332
        double currentX = sizeLast.getX(), currentY = sizeLast.getY();
        if (newWidth >= stage.getMinWidth()) {
            stage.setX(newX);
            stage.setWidth(newWidth);
            currentX = sizeCurrent.getX();
        }
        if (newHeight >= stage.getMinHeight()) {
            stage.setY(newY);
            stage.setHeight(newHeight);
            currentY = sizeCurrent.getY();
        }
        sizeLast = new Point2D(currentX, currentY);
        // while we are actively resizing
        if (sizeNorth || sizeSouth || sizeWest || sizeEast) {
            event.consume();
        }
    }
}
Also used : Insets(javafx.geometry.Insets) Point2D(javafx.geometry.Point2D) Cursor(javafx.scene.Cursor)

Example 3 with Cursor

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

the class ImagePlot method mouseDown.

/**
 * onMousePressed
 */
private void mouseDown(final MouseEvent e) {
    // Don't start mouse actions when user invokes context menu
    if (!e.isPrimaryButtonDown() || (PlatformInfo.is_mac_os_x && e.isControlDown()))
        return;
    // -> User clicked outside of tracker. Remove it.
    if (roi_tracker != null) {
        removeROITracker();
        // User needs to click again for that.
        return;
    }
    // Select any tracker
    final Point2D current = new Point2D(e.getX(), e.getY());
    for (RegionOfInterest roi : rois) if (roi.isVisible() && roi.isInteractive()) {
        final Rectangle rect = roiToScreen(roi);
        if (rect.contains(current.getX(), current.getY())) {
            // Check if complete ROI is visible,
            // because otherwise tracker would extend beyond the
            // current image viewport
            final Rectangle2D image_rect = GraphicsUtils.convert(image_area);
            if (image_rect.contains(rect.x, rect.y, rect.width, rect.height)) {
                roi_tracker = new Tracker(image_rect);
                roi_tracker.setPosition(rect.x, rect.y, rect.width, rect.height);
                ChildCare.addChild(getParent(), roi_tracker);
                final int index = rois.indexOf(roi);
                roi_tracker.setListener((old_pos, new_pos) -> updateRoiFromScreen(index, new_pos));
                return;
            }
        }
    }
    mouse_start = mouse_current = Optional.of(current);
    final int clicks = e.getClickCount();
    if (mouse_mode == MouseMode.NONE) {
        if (crosshair) {
            updateLocationInfo(e.getX(), e.getY());
            requestRedraw();
        }
    } else if (mouse_mode == MouseMode.PAN) {
        // Determine start of 'pan'
        mouse_start_x_range = x_axis.getValueRange();
        mouse_start_y_range = y_axis.getValueRange();
        mouse_mode = MouseMode.PAN_PLOT;
    } else if (mouse_mode == MouseMode.ZOOM_IN && clicks == 1) {
        // Reset cursor from SIZE* to CROSS.
        if (y_axis.getBounds().contains(current.getX(), current.getY())) {
            mouse_mode = MouseMode.ZOOM_IN_Y;
            PlotCursors.setCursor(this, mouse_mode);
        } else if (image_area.contains(current.getX(), current.getY())) {
            mouse_mode = MouseMode.ZOOM_IN_PLOT;
            PlotCursors.setCursor(this, mouse_mode);
        } else if (x_axis.getBounds().contains(current.getX(), current.getY())) {
            mouse_mode = MouseMode.ZOOM_IN_X;
            PlotCursors.setCursor(this, mouse_mode);
        }
    } else if ((mouse_mode == MouseMode.ZOOM_IN && clicks == 2) || mouse_mode == MouseMode.ZOOM_OUT)
        zoomInOut(current.getX(), current.getY(), ZOOM_FACTOR);
}
Also used : Color(java.awt.Color) Rectangle(java.awt.Rectangle) Interpolation(org.csstudio.javafx.rtplot.Interpolation) ArrayByte(org.diirt.util.array.ArrayByte) ListNumber(org.diirt.util.array.ListNumber) MouseEvent(javafx.scene.input.MouseEvent) IteratorNumber(org.diirt.util.array.IteratorNumber) VImageType(org.diirt.vtype.VImageType) RenderingHints(java.awt.RenderingHints) ChangeImageZoom(org.csstudio.javafx.rtplot.internal.undo.ChangeImageZoom) Level(java.util.logging.Level) RTImagePlotListener(org.csstudio.javafx.rtplot.RTImagePlotListener) DataBufferInt(java.awt.image.DataBufferInt) ChildCare(org.csstudio.javafx.ChildCare) Graphics2D(java.awt.Graphics2D) ArrayInt(org.diirt.util.array.ArrayInt) Point2D(javafx.geometry.Point2D) PlatformInfo(org.csstudio.javafx.PlatformInfo) GraphicsUtils(org.csstudio.javafx.rtplot.internal.util.GraphicsUtils) Rectangle2D(javafx.geometry.Rectangle2D) Messages(org.csstudio.javafx.rtplot.Messages) BufferedImage(java.awt.image.BufferedImage) Activator.logger(org.csstudio.javafx.rtplot.Activator.logger) ToIntFunction(java.util.function.ToIntFunction) Font(javafx.scene.text.Font) RegionOfInterest(org.csstudio.javafx.rtplot.RegionOfInterest) DoubleBuffer(org.csstudio.javafx.DoubleBuffer) ValueRange(org.csstudio.javafx.rtplot.data.ValueRange) ArrayShort(org.diirt.util.array.ArrayShort) Objects(java.util.Objects) Cursor(javafx.scene.Cursor) List(java.util.List) Tracker(org.csstudio.javafx.Tracker) Log10(org.csstudio.javafx.rtplot.internal.util.Log10) ToDoubleFunction(java.util.function.ToDoubleFunction) BufferUtil(org.csstudio.javafx.BufferUtil) SwingFXUtils(javafx.embed.swing.SwingFXUtils) Optional(java.util.Optional) ColorMappingFunction(org.csstudio.javafx.rtplot.ColorMappingFunction) Axis(org.csstudio.javafx.rtplot.Axis) LinearScreenTransform(org.csstudio.javafx.rtplot.internal.util.LinearScreenTransform) AxisRange(org.csstudio.javafx.rtplot.AxisRange) Image(javafx.scene.image.Image) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Tracker(org.csstudio.javafx.Tracker) RegionOfInterest(org.csstudio.javafx.rtplot.RegionOfInterest) Point2D(javafx.geometry.Point2D) Rectangle(java.awt.Rectangle) Rectangle2D(javafx.geometry.Rectangle2D)

Example 4 with Cursor

use of javafx.scene.Cursor in project jgnash by ccavanaugh.

the class BudgetTableController method initialize.

@FXML
private void initialize() {
    runningTotalsButton.selectedProperty().setValue(preferences.getBoolean(RUNNING_TOTALS, false));
    rateLimitExecutor = new ScheduledThreadPoolExecutor(1, new DefaultDaemonThreadFactory("Budget View Rate Limit Executor"), new ThreadPoolExecutor.DiscardPolicy());
    tableWidthChangeListener = (observable, oldValue, newValue) -> {
        if (newValue != null && !oldValue.equals(newValue)) {
            optimizeColumnWidths();
        }
    };
    handleFontHeightChange();
    yearSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(LocalDate.now().getYear() - YEAR_MARGIN, LocalDate.now().getYear() + YEAR_MARGIN, LocalDate.now().getYear(), 1));
    accountTreeView.getStylesheets().addAll(StyleClass.HIDE_HORIZONTAL_CSS, StyleClass.HIDE_VERTICAL_CSS);
    accountTreeView.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);
    accountTreeView.setShowRoot(false);
    accountTreeView.setEditable(true);
    accountTreeView.fixedCellSizeProperty().bind(rowHeight);
    accountSummaryTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    accountSummaryTable.getStyleClass().addAll(StyleClass.HIDDEN_ROW_FOCUS);
    accountSummaryTable.getStylesheets().addAll(StyleClass.HIDE_HORIZONTAL_CSS, StyleClass.HIDE_VERTICAL_CSS);
    accountSummaryTable.setItems(expandedAccountList);
    accountSummaryTable.fixedCellSizeProperty().bind(rowHeight);
    accountSummaryTable.setSelectionModel(new NullTableViewSelectionModel<>(accountSummaryTable));
    accountTypeTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    accountTypeTable.getStyleClass().addAll(StyleClass.HIDDEN_COLUMN_HEADER, StyleClass.HIDDEN_ROW_FOCUS);
    accountTypeTable.getStylesheets().addAll(StyleClass.HIDE_HORIZONTAL_CSS, StyleClass.HIDE_VERTICAL_CSS);
    accountTypeTable.setItems(accountGroupList);
    accountTypeTable.fixedCellSizeProperty().bind(rowHeight);
    accountTypeTable.prefHeightProperty().bind(rowHeight.multiply(Bindings.size(accountGroupList)).add(BORDER_MARGIN));
    accountTypeTable.setSelectionModel(new NullTableViewSelectionModel<>(accountTypeTable));
    // widths need to be bound to the tree view widths for drag/resizing to work
    accountTypeTable.minWidthProperty().bind(accountTreeView.minWidthProperty());
    accountTypeTable.prefWidthProperty().bind(accountTreeView.prefWidthProperty());
    accountGroupPeriodSummaryTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    accountGroupPeriodSummaryTable.getStyleClass().addAll(StyleClass.HIDDEN_COLUMN_HEADER, StyleClass.HIDDEN_ROW_FOCUS);
    accountGroupPeriodSummaryTable.getStylesheets().addAll(StyleClass.HIDE_HORIZONTAL_CSS, StyleClass.HIDE_VERTICAL_CSS);
    accountGroupPeriodSummaryTable.setItems(accountGroupList);
    accountGroupPeriodSummaryTable.fixedCellSizeProperty().bind(rowHeight);
    accountGroupPeriodSummaryTable.prefHeightProperty().bind(rowHeight.multiply(Bindings.size(accountGroupList)).add(BORDER_MARGIN));
    accountGroupPeriodSummaryTable.setSelectionModel(new NullTableViewSelectionModel<>(accountGroupPeriodSummaryTable));
    buildAccountTreeTable();
    buildAccountTypeTable();
    buildAccountSummaryTable();
    buildAccountGroupSummaryTable();
    accountSummaryTable.maxWidthProperty().bind(minSummaryColumnWidth.multiply(3.0).add(BORDER_MARGIN));
    accountGroupPeriodSummaryTable.maxWidthProperty().bind(minSummaryColumnWidth.multiply(3.0).add(BORDER_MARGIN));
    accountSummaryTable.minWidthProperty().bind(minSummaryColumnWidth.multiply(3.0).add(BORDER_MARGIN));
    accountGroupPeriodSummaryTable.minWidthProperty().bind(minSummaryColumnWidth.multiply(3.0).add(BORDER_MARGIN));
    accountTreeView.expandedItemCountProperty().addListener((observable, oldValue, newValue) -> JavaFXUtils.runLater(this::updateExpandedAccountList));
    // Calling handleBudgetChange which works for most changes, but can trigger an exception.
    // handleBudgetUpdate rate limits and prevents an exception.
    final ChangeListener<Object> budgetChangeListener = (observable, oldValue, newValue) -> handleBudgetUpdate();
    budget.addListener(budgetChangeListener);
    yearSpinner.valueProperty().addListener(budgetChangeListener);
    runningTotalsButton.selectedProperty().addListener(budgetChangeListener);
    visibleColumnCount.addListener(budgetChangeListener);
    runningTotalsButton.selectedProperty().addListener((observable, oldValue, newValue) -> preferences.putBoolean(RUNNING_TOTALS, newValue));
    /* Setting the tables as un-managed effectively removes these tables from the GridPane.  The tables are
           redundant if showing the amounts as running balances. */
    accountSummaryTable.managedProperty().bind(runningTotalsButton.selectedProperty().not());
    accountGroupPeriodSummaryTable.managedProperty().bind(runningTotalsButton.selectedProperty().not());
    horizontalScrollBar.setMin(0);
    horizontalScrollBar.maxProperty().bind(periodCount.subtract(visibleColumnCount));
    horizontalScrollBar.setUnitIncrement(1);
    horizontalScrollBar.disableProperty().bind(periodCount.lessThanOrEqualTo(1));
    // shift the table right and left with the ScrollBar value
    horizontalScrollBar.valueProperty().addListener((observable, oldValue, newValue) -> {
        /* must be synchronized to prevent a race condition from multiple events and an out of
                     * bounds exception */
        synchronized (this) {
            /* don't try unless columns exist.  This can occur if the UI is not large enough to display
                         * a minimum of one period of information.
                         */
            if (periodTable.getColumns().size() > 0) {
                final int newIndex = (int) Math.round(newValue.doubleValue());
                if (newIndex > index) {
                    while (newIndex > index) {
                        handleShiftRight();
                    }
                } else if (newIndex < index) {
                    while (newIndex < index) {
                        handleShiftLeft();
                    }
                }
            }
        }
    });
    // listen for changes in the font scale and update.  Listener needs to be weak to prevent memory leaks
    fontScaleListener = (observable, oldValue, newValue) -> handleFontHeightChange();
    ThemeManager.fontScaleProperty().addListener(new WeakChangeListener<>(fontScaleListener));
    // cursor handler
    accountTreeView.setOnMouseMoved(this::handleMouseMove);
    // drag handler
    accountTreeView.setOnMouseDragged(this::handleDividerDrag);
    // drag handler
    accountTreeView.setOnMousePressed(this::handleMouseClicked);
    // cursor handler
    accountTypeTable.setOnMouseMoved(this::handleMouseMove);
    // drag handler
    accountTypeTable.setOnMouseDragged(this::handleDividerDrag);
    // drag handler
    accountTypeTable.setOnMousePressed(this::handleMouseClicked);
    JavaFXUtils.runLater(() -> accountTreeView.setPrefWidth(preferences.getDouble(ACCOUNT_COLUMN_WIDTH, INITIAL_WIDTH * 2)));
}
Also used : Period(jgnash.time.Period) Pos(javafx.geometry.Pos) Engine(jgnash.engine.Engine) TODAY_BOLD_NEGATIVE_LABEL_ID(jgnash.uifx.skin.StyleClass.TODAY_BOLD_NEGATIVE_LABEL_ID) BigDecimal(java.math.BigDecimal) Budget(jgnash.engine.budget.Budget) MessageProperty(jgnash.engine.message.MessageProperty) DefaultDaemonThreadFactory(jgnash.util.DefaultDaemonThreadFactory) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) TreeTableCell(javafx.scene.control.TreeTableCell) Point2D(javafx.geometry.Point2D) BudgetPeriodDescriptor(jgnash.engine.budget.BudgetPeriodDescriptor) TableView(javafx.scene.control.TableView) NullTableViewSelectionModel(jgnash.uifx.control.NullTableViewSelectionModel) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) MessageListener(jgnash.engine.message.MessageListener) HBox(javafx.scene.layout.HBox) NotNull(jgnash.util.NotNull) NORMAL_CELL_ID(jgnash.uifx.skin.StyleClass.NORMAL_CELL_ID) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) Spinner(javafx.scene.control.Spinner) TODAY_BOLD_LABEL_ID(jgnash.uifx.skin.StyleClass.TODAY_BOLD_LABEL_ID) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) JavaFXUtils(jgnash.uifx.util.JavaFXUtils) AccountGroup(jgnash.engine.AccountGroup) Objects(java.util.Objects) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) BudgetGoal(jgnash.engine.budget.BudgetGoal) TODAY_NORMAL_CELL_ID(jgnash.uifx.skin.StyleClass.TODAY_NORMAL_CELL_ID) List(java.util.List) LocalDate(java.time.LocalDate) Optional(java.util.Optional) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) BOLD_LABEL_ID(jgnash.uifx.skin.StyleClass.BOLD_LABEL_ID) ObservableList(javafx.collections.ObservableList) NumericFormats(jgnash.text.NumericFormats) Message(jgnash.engine.message.Message) WeakChangeListener(javafx.beans.value.WeakChangeListener) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) BudgetPeriodResults(jgnash.engine.budget.BudgetPeriodResults) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) TreeItem(javafx.scene.control.TreeItem) MouseEvent(javafx.scene.input.MouseEvent) EngineFactory(jgnash.engine.EngineFactory) FXCollections(javafx.collections.FXCollections) DoubleProperty(javafx.beans.property.DoubleProperty) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) Bindings(javafx.beans.binding.Bindings) IntegerProperty(javafx.beans.property.IntegerProperty) NumberFormat(java.text.NumberFormat) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) TreeTableView(javafx.scene.control.TreeTableView) ResourceBundle(java.util.ResourceBundle) ThemeManager(jgnash.uifx.skin.ThemeManager) GridPane(javafx.scene.layout.GridPane) BOLD_NEGATIVE_LABEL_ID(jgnash.uifx.skin.StyleClass.BOLD_NEGATIVE_LABEL_ID) Label(javafx.scene.control.Label) Comparators(jgnash.engine.Comparators) FXMLUtils(jgnash.uifx.util.FXMLUtils) BudgetResultsModel(jgnash.engine.budget.BudgetResultsModel) CheckBox(javafx.scene.control.CheckBox) Preferences(java.util.prefs.Preferences) TimeUnit(java.util.concurrent.TimeUnit) Cursor(javafx.scene.Cursor) TreeTableColumn(javafx.scene.control.TreeTableColumn) StageUtils(jgnash.uifx.util.StageUtils) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) StyleClass(jgnash.uifx.skin.StyleClass) SpinnerValueFactory(javafx.scene.control.SpinnerValueFactory) Account(jgnash.engine.Account) TODAY_NORMAL_NEGATIVE_CELL_ID(jgnash.uifx.skin.StyleClass.TODAY_NORMAL_NEGATIVE_CELL_ID) ChangeListener(javafx.beans.value.ChangeListener) NORMAL_NEGATIVE_CELL_ID(jgnash.uifx.skin.StyleClass.NORMAL_NEGATIVE_CELL_ID) ScrollBar(javafx.scene.control.ScrollBar) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) DefaultDaemonThreadFactory(jgnash.util.DefaultDaemonThreadFactory) SpinnerValueFactory(javafx.scene.control.SpinnerValueFactory) FXML(javafx.fxml.FXML)

Example 5 with Cursor

use of javafx.scene.Cursor in project processing by processing.

the class PSurfaceFX method setCursor.

public void setCursor(int kind) {
    Cursor c;
    switch(kind) {
        case PConstants.ARROW:
            c = Cursor.DEFAULT;
            break;
        case PConstants.CROSS:
            c = Cursor.CROSSHAIR;
            break;
        case PConstants.HAND:
            c = Cursor.HAND;
            break;
        case PConstants.MOVE:
            c = Cursor.MOVE;
            break;
        case PConstants.TEXT:
            c = Cursor.TEXT;
            break;
        case PConstants.WAIT:
            c = Cursor.WAIT;
            break;
        default:
            c = Cursor.DEFAULT;
            break;
    }
    lastCursor = c;
    canvas.getScene().setCursor(c);
}
Also used : ImageCursor(javafx.scene.ImageCursor) Cursor(javafx.scene.Cursor)

Aggregations

Cursor (javafx.scene.Cursor)9 Objects (java.util.Objects)3 Point2D (javafx.geometry.Point2D)3 List (java.util.List)2 Optional (java.util.Optional)2 ResourceBundle (java.util.ResourceBundle)2 Level (java.util.logging.Level)2 Collectors (java.util.stream.Collectors)2 Platform (javafx.application.Platform)2 Bindings (javafx.beans.binding.Bindings)2 FXML (javafx.fxml.FXML)2 ImageCursor (javafx.scene.ImageCursor)2 Label (javafx.scene.control.Label)2 MouseEvent (javafx.scene.input.MouseEvent)2 Entity (com.almasb.fxgl.entity.Entity)1 SelectableComponent (com.almasb.fxgl.entity.component.SelectableComponent)1 ColoredTexture (com.almasb.fxgl.texture.ColoredTexture)1 Color (java.awt.Color)1 Graphics2D (java.awt.Graphics2D)1 Rectangle (java.awt.Rectangle)1