use of net.sf.latexdraw.view.jfx.Canvas in project latexdraw by arnobl.
the class Hand method bindPressureToSelectShape.
/**
* Pressure to select shapes
*/
private void bindPressureToSelectShape() {
nodeBinder(SelectShapes.class, new Press()).on(canvas.getViews().getChildren()).first((c, i) -> {
c.setDrawing(canvas.getDrawing());
getViewShape(i.getSrcObject()).map(src -> src.getModel()).ifPresent(targetSh -> {
if (i.isShiftPressed()) {
canvas.getDrawing().getSelection().getShapes().stream().filter(sh -> sh != targetSh).forEach(sh -> c.addShape(sh));
return;
}
if (i.isCtrlPressed()) {
canvas.getDrawing().getSelection().getShapes().forEach(sh -> c.addShape(sh));
c.addShape(targetSh);
return;
}
c.setShape(targetSh);
});
}).bind();
// A simple pressure on the canvas deselects the shapes
nodeBinder(SelectShapes.class, new Press()).on(canvas).first((c, i) -> c.setDrawing(canvas.getDrawing())).when(i -> i.getSrcObject().orElse(null) instanceof Canvas).bind();
}
use of net.sf.latexdraw.view.jfx.Canvas in project latexdraw by arnobl.
the class TestModifyMagneticGrid method setUp.
@Override
@Before
public void setUp() {
super.setUp();
grid = new MagneticGridImpl(new Canvas());
// Cannot have two runners so cannot use mock to mock Canvas:
CommandsRegistry.INSTANCE.removeAllHandlers();
switch(property) {
case STYLE:
mementoCmd = () -> grid.getGridStyle();
value = GridStyle.STANDARD;
break;
case MAGNETIC:
mementoCmd = () -> grid.isMagnetic();
value = true;
break;
case GRID_SPACING:
mementoCmd = () -> grid.getGridSpacing();
value = 11;
break;
}
memento = mementoCmd.get();
}
use of net.sf.latexdraw.view.jfx.Canvas in project latexdraw by arnobl.
the class TestTabSelector method start.
@Override
public void start(final Stage aStage) {
super.start(aStage);
tabPane = find("#tabPane");
final int width = 800;
final int height = 600;
stage.minHeightProperty().unbind();
stage.minWidthProperty().unbind();
final Canvas canvas = injector.getInstance(Canvas.class);
canvas.setMaxWidth(width);
canvas.setMaxHeight(height);
canvas.getScene().getWindow().setWidth(width);
canvas.getScene().getWindow().setHeight(height);
stage.setMaxWidth(width);
stage.setMaxHeight(height);
stage.setMinWidth(width);
stage.setMinHeight(height);
stage.centerOnScreen();
stage.toFront();
}
use of net.sf.latexdraw.view.jfx.Canvas in project latexdraw by arnobl.
the class TestTabSelector method testClickCanvasActivationsOnSelectedShape.
@Test
public void testClickCanvasActivationsOnSelectedShape() {
final IRectangle rectangle = ShapeFactory.INST.createRectangle(ShapeFactory.INST.createPoint(), 100, 50);
final Canvas canvas = injector.getInstance(Canvas.class);
Platform.runLater(() -> {
canvas.getDrawing().addShape(rectangle);
canvas.getDrawing().getSelection().addShape(rectangle);
});
WaitForAsyncUtils.waitForFxEvents();
clickOn(tabPane.lookup("#tabPST"));
clickOn(tabPane.lookup("#canvasTab"));
WaitForAsyncUtils.waitForFxEvents();
sleep(100L);
Mockito.verify(deleter, Mockito.times(1)).setActivated(true);
}
use of net.sf.latexdraw.view.jfx.Canvas in project latexdraw by arnobl.
the class TestAlignShape method setUp.
@Override
@Before
public void setUp() {
super.setUp();
canvas = Mockito.mock(Canvas.class);
final IShapeFactory fac = ShapeFactory.INST;
shapes = fac.createGroup();
shapes.addShape(fac.createRectangle(fac.createPoint(10d, -2d), 6d, 6d));
shapes.addShape(fac.createRectangle(fac.createPoint(-5d, 20d), 12d, 15d));
shapes.addShape(fac.createRectangle(fac.createPoint(14d, 60d), 20d, 16d));
views = new Group();
IntStream.range(0, shapes.size()).forEach(i -> {
views.getChildren().add(ViewFactory.INSTANCE.createView(shapes.getShapeAt(i)).get());
Mockito.when(canvas.getViewFromShape(shapes.getShapeAt(i))).thenReturn(Optional.of((ViewShape<?>) views.getChildren().get(i)));
});
}
Aggregations