Search in sources :

Example 11 with DnD

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

the class MoveShape method testCanCancelDnD.

@Test
public void testCanCancelDnD(final FxRobot robot) {
    new NodeBinder<>(new DnD(true, true), i -> new MoveShape(rec), instrument).on(rec).first((i, c) -> rec.requestFocus()).then((i, c) -> c.setCoord(rec.getX() + (i.getTgtScenePoint().getX() - i.getSrcScenePoint().getX()), rec.getY() + (i.getTgtScenePoint().getY() - i.getSrcScenePoint().getY()))).end((i, c) -> fail("")).exec().bind();
    robot.drag(rec).moveBy(100, 100).type(KeyCode.ESCAPE).sleep(50L);
    assertEquals(0, instrument.exec.get());
}
Also used : Assertions.fail(org.junit.jupiter.api.Assertions.fail) KeyCode(javafx.scene.input.KeyCode) NodeBinder(org.malai.javafx.binding.NodeBinder) Undoable(org.malai.undo.Undoable) Rectangle(javafx.scene.shape.Rectangle) DoubleProperty(javafx.beans.property.DoubleProperty) CommandImpl(org.malai.command.CommandImpl) WaitForAsyncUtils(org.testfx.util.WaitForAsyncUtils) Platform(javafx.application.Platform) Test(org.junit.jupiter.api.Test) ResourceBundle(java.util.ResourceBundle) Stage(javafx.stage.Stage) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) FxRobot(org.testfx.api.FxRobot) Start(org.testfx.framework.junit5.Start) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) DnD(org.malai.javafx.interaction.library.DnD) ApplicationExtension(org.testfx.framework.junit5.ApplicationExtension) Pane(javafx.scene.layout.Pane) DnD(org.malai.javafx.interaction.library.DnD) NodeBinder(org.malai.javafx.binding.NodeBinder) Test(org.junit.jupiter.api.Test)

Example 12 with DnD

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

the class TestThrottle method setUp.

@BeforeEach
void setUp() {
    counter = new AtomicInteger();
    binding = new NodeBinder<>(new DnD(), StubCmd::new, instrument).throttle(500L).on(widget1).then((i, c) -> counter.incrementAndGet()).bind();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DnD(org.malai.javafx.interaction.library.DnD) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

DnD (org.malai.javafx.interaction.library.DnD)12 Cursor (javafx.scene.Cursor)8 ResourceBundle (java.util.ResourceBundle)7 Platform (javafx.application.Platform)7 ShapeFactory (net.sf.latexdraw.models.ShapeFactory)6 Inject (net.sf.latexdraw.util.Inject)6 URL (java.net.URL)5 Point3D (javafx.geometry.Point3D)5 MouseButton (javafx.scene.input.MouseButton)5 IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)5 IShape (net.sf.latexdraw.models.interfaces.shape.IShape)5 Arrays (java.util.Arrays)4 Function (java.util.function.Function)4 Initializable (javafx.fxml.Initializable)4 Node (javafx.scene.Node)4 KeyCode (javafx.scene.input.KeyCode)4 Rectangle (javafx.scene.shape.Rectangle)4 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 DoubleProperty (javafx.beans.property.DoubleProperty)3