Search in sources :

Example 1 with RotateShapes

use of net.sf.latexdraw.command.shape.RotateShapes in project latexdraw by arnobl.

the class TestCanvas method testSelectionBorderUpdatedOnUndoModifyingCmd.

@Test
public void testSelectionBorderUpdatedOnUndoModifyingCmd() {
    Cmds.of(addRec, selectAllShapes).execute();
    final Bounds borderInitial = canvas.getSelectionBorder().getBoundsInLocal();
    final RotateShapes cmd = new RotateShapes(addedRec.getGravityCentre(), addedRec, Math.PI / 2d);
    cmd.doIt();
    cmd.done();
    CommandsRegistry.getInstance().addCommand(cmd);
    WaitForAsyncUtils.waitForFxEvents();
    final Bounds border = canvas.getSelectionBorder().getBoundsInLocal();
    final Undo undo = new Undo();
    undo.doIt();
    undo.done();
    CommandsRegistry.getInstance().addCommand(undo);
    WaitForAsyncUtils.waitForFxEvents();
    final Bounds border2 = canvas.getSelectionBorder().getBoundsInLocal();
    assertThat(border2).isNotEqualTo(border);
    assertThat(border2).isEqualTo(borderInitial);
}
Also used : RotateShapes(net.sf.latexdraw.command.shape.RotateShapes) Bounds(javafx.geometry.Bounds) Undo(io.github.interacto.command.library.Undo) Test(org.junit.Test)

Example 2 with RotateShapes

use of net.sf.latexdraw.command.shape.RotateShapes in project latexdraw by arnobl.

the class TestCanvas method testSelectionBorderUpdatedOnRedoModifyingCmd.

@Test
public void testSelectionBorderUpdatedOnRedoModifyingCmd() {
    Cmds.of(addRec, selectAllShapes).execute();
    final RotateShapes cmd = new RotateShapes(addedRec.getGravityCentre(), addedRec, Math.PI / 2d);
    cmd.doCmdBody();
    cmd.done();
    CommandsRegistry.getInstance().addCommand(cmd);
    WaitForAsyncUtils.waitForFxEvents();
    final Bounds borderInitial = canvas.getSelectionBorder().getBoundsInLocal();
    final Undo undo = new Undo();
    undo.doIt();
    undo.done();
    CommandsRegistry.getInstance().addCommand(undo);
    WaitForAsyncUtils.waitForFxEvents();
    final Bounds border = canvas.getSelectionBorder().getBoundsInLocal();
    final Redo redo = new Redo();
    redo.doIt();
    redo.done();
    CommandsRegistry.getInstance().addCommand(redo);
    WaitForAsyncUtils.waitForFxEvents();
    final Bounds border2 = canvas.getSelectionBorder().getBoundsInLocal();
    assertThat(border2).isNotEqualTo(border);
    assertThat(border2).isEqualTo(borderInitial);
}
Also used : RotateShapes(net.sf.latexdraw.command.shape.RotateShapes) Bounds(javafx.geometry.Bounds) Redo(io.github.interacto.command.library.Redo) Undo(io.github.interacto.command.library.Undo) Test(org.junit.Test)

Example 3 with RotateShapes

use of net.sf.latexdraw.command.shape.RotateShapes in project latexdraw by arnobl.

the class TestCanvas method testSelectionBorderUpdatedOnModifyingCmd.

@Test
public void testSelectionBorderUpdatedOnModifyingCmd() {
    Cmds.of(addRec, selectAllShapes).execute();
    final Bounds border = canvas.getSelectionBorder().getBoundsInLocal();
    final RotateShapes cmd = new RotateShapes(addedRec.getGravityCentre(), addedRec, Math.PI / 2d);
    cmd.doIt();
    cmd.done();
    CommandsRegistry.getInstance().addCommand(cmd);
    WaitForAsyncUtils.waitForFxEvents();
    final Bounds border2 = canvas.getSelectionBorder().getBoundsInLocal();
    assertThat(border2).isNotEqualTo(border);
}
Also used : RotateShapes(net.sf.latexdraw.command.shape.RotateShapes) Bounds(javafx.geometry.Bounds) Test(org.junit.Test)

Example 4 with RotateShapes

use of net.sf.latexdraw.command.shape.RotateShapes in project latexdraw by arnobl.

the class ShapeRotationCustomiser method configureBindings.

@Override
protected void configureBindings() {
    spinnerBinder().toProduce(() -> new RotateShapes(canvas.getDrawing().getSelection().getGravityCentre(), canvas.getDrawing().getSelection().duplicateDeep(false), Math.toRadians(rotationField.getValue()) - canvas.getDrawing().getSelection().getRotationAngle())).on(rotationField).then(c -> c.setRotationAngle(Math.toRadians(rotationField.getValue()) - canvas.getDrawing().getSelection().getRotationAngle())).continuousExecution().bind();
    buttonBinder().toProduce(() -> new RotateShapes(canvas.getDrawing().getSelection().getGravityCentre(), canvas.getDrawing().getSelection().duplicateDeep(false), Math.PI / 2d)).on(rotate90Button).bind();
    buttonBinder().toProduce(() -> new RotateShapes(canvas.getDrawing().getSelection().getGravityCentre(), canvas.getDrawing().getSelection().duplicateDeep(false), Math.PI)).on(rotate180Button).bind();
    buttonBinder().toProduce(() -> new RotateShapes(canvas.getDrawing().getSelection().getGravityCentre(), canvas.getDrawing().getSelection().duplicateDeep(false), -Math.PI / 2d)).on(rotate270Button).bind();
}
Also used : RotateShapes(net.sf.latexdraw.command.shape.RotateShapes)

Aggregations

RotateShapes (net.sf.latexdraw.command.shape.RotateShapes)4 Bounds (javafx.geometry.Bounds)3 Test (org.junit.Test)3 Undo (io.github.interacto.command.library.Undo)2 Redo (io.github.interacto.command.library.Redo)1