Search in sources :

Example 1 with KeysScroll

use of org.malai.javafx.interaction.library.KeysScroll in project Malai by arnobl.

the class BasicZoomer method configureBindings.

@Override
protected void configureBindings() {
    if (withKeys) {
        nodeBinder(Zoom.class, new KeyPressed(false)).on(zoomable).first((c, i) -> {
            final String key = i.getKey();
            c.setZoomable(getZoomable());
            if ("+".equals(key)) {
                c.setZoomLevel(zoomable.getZoom() + zoomable.getZoomIncrement());
            } else {
                c.setZoomLevel(zoomable.getZoom() - zoomable.getZoomIncrement());
            }
            c.setPx(-1d);
            c.setPy(-1d);
        }).when(i -> "+".equals(i.getKey()) || "-".equals(i.getKey())).bind();
    }
    nodeBinder(Zoom.class, new KeysScroll()).on(zoomable).first(c -> c.setZoomable(zoomable)).then((c, i) -> {
        c.setZoomLevel(zoomable.getZoom() + (i.getScrollData().getIncrement() > 0 ? zoomable.getZoomIncrement() : -zoomable.getZoomIncrement()));
        c.setPx(i.getScrollData().getPx());
        c.setPy(i.getScrollData().getPy());
    }).when(i -> i.getKeys().size() == 1 && i.getKeyCodes().get(0) == KeyCode.CONTROL).bind();
}
Also used : KeyCode(javafx.scene.input.KeyCode) KeyPressed(org.malai.javafx.interaction.library.KeyPressed) Node(javafx.scene.Node) Zoom(org.malai.command.library.Zoom) Zoomable(org.malai.properties.Zoomable) KeysScroll(org.malai.javafx.interaction.library.KeysScroll) KeyPressed(org.malai.javafx.interaction.library.KeyPressed) KeysScroll(org.malai.javafx.interaction.library.KeysScroll) Zoom(org.malai.command.library.Zoom)

Aggregations

Node (javafx.scene.Node)1 KeyCode (javafx.scene.input.KeyCode)1 Zoom (org.malai.command.library.Zoom)1 KeyPressed (org.malai.javafx.interaction.library.KeyPressed)1 KeysScroll (org.malai.javafx.interaction.library.KeysScroll)1 Zoomable (org.malai.properties.Zoomable)1