use of net.sf.latexdraw.view.jfx.ViewPlot in project latexdraw by arnobl.
the class TestCanvasSelection method testClickPlotSelectsShape.
@Test
public void testClickPlotSelectsShape() {
new CompositeGUIVoidCommand(addPlot, waitFXEvents).execute();
final ViewPlot vplot = (ViewPlot) getPane().getChildren().get(0);
new CompositeGUIVoidCommand(() -> clickOn(vplot), waitFXEvents).execute();
assertEquals(1, canvas.getDrawing().getSelection().size());
assertSame(addedPlot, canvas.getDrawing().getSelection().getShapeAt(0));
}
use of net.sf.latexdraw.view.jfx.ViewPlot in project latexdraw by arnobl.
the class TestCanvasSelection method testEditPlotDoesNotCreateANewOne.
@Test
public void testEditPlotDoesNotCreateANewOne() {
when(pencil.getCurrentChoice()).thenReturn(EditionChoice.PLOT);
when(pencil.createShapeInstance()).thenReturn(ShapeFactory.INST.createPlot(ShapeFactory.INST.createPoint(), 0, 5, "x", false));
ShapePlotCustomiser plot = (ShapePlotCustomiser) injectorFactory.call(ShapePlotCustomiser.class);
plot.maxXSpinner = Mockito.mock(Spinner.class);
plot.minXSpinner = Mockito.mock(Spinner.class);
plot.nbPtsSpinner = Mockito.mock(Spinner.class);
when(plot.maxXSpinner.getValue()).thenReturn(10d);
when(plot.minXSpinner.getValue()).thenReturn(0d);
when(plot.nbPtsSpinner.getValue()).thenReturn(10);
new CompositeGUIVoidCommand(addPlot, waitFXEvents).execute();
final ViewPlot v = (ViewPlot) canvas.getViews().getChildren().get(0);
doubleClickOn(v).sleep(10).type(KeyCode.DELETE).write("x 2 mul").sleep(10).type(KeyCode.ENTER).sleep(SLEEP);
assertEquals(1, canvas.getDrawing().size());
assertEquals(1, canvas.getViews().getChildren().size());
}
use of net.sf.latexdraw.view.jfx.ViewPlot in project latexdraw by arnobl.
the class Hand method dbleClickToInitTextSetter.
/**
* Double click to initialise the text setter to edit plot and text shapes.
*/
private void dbleClickToInitTextSetter() {
// For text shapes.
nodeBinder(InitTextSetter.class, new DoubleClick()).on(canvas.getViews().getChildren()).map(i -> {
final IText text = ((ViewText) i.getClickData().getSrcObject().get().getParent()).getModel();
return new InitTextSetter(textSetter, textSetter, null, ShapeFactory.INST.createPoint(text.getPosition().getX() * canvas.getZoom(), text.getPosition().getY() * canvas.getZoom()), text, null);
}).when(i -> i.getClickData().getSrcObject().isPresent() && i.getClickData().getSrcObject().get().getParent() instanceof ViewText).strictStart().bind();
// For plot shapes.
nodeBinder(InitTextSetter.class, new DoubleClick()).on(canvas.getViews().getChildren()).map(i -> {
final IPlot plot = getViewShape(i.getClickData().getSrcObject()).map(view -> ((ViewPlot) view).getModel()).get();
return new InitTextSetter(textSetter, textSetter, null, ShapeFactory.INST.createPoint(plot.getPosition().getX() * canvas.getZoom(), plot.getPosition().getY() * canvas.getZoom()), null, plot);
}).when(i -> i.getClickData().getSrcObject().isPresent() && i.getClickData().getSrcObject().get().getParent() != null && getViewShape(i.getClickData().getSrcObject()).orElse(null) instanceof ViewPlot).strictStart().bind();
}
Aggregations