use of net.sf.latexdraw.view.jfx.ViewText in project latexdraw by arnobl.
the class TestCanvasSelection method testEditTextDoesNotCreateANewOne.
@Test
public void testEditTextDoesNotCreateANewOne() {
when(pencil.getCurrentChoice()).thenReturn(EditionChoice.TEXT);
when(pencil.createShapeInstance()).thenReturn(ShapeFactory.INST.createText());
new CompositeGUIVoidCommand(addText, waitFXEvents).execute();
final ViewText v = (ViewText) canvas.getViews().getChildren().get(0);
doubleClickOn(v).sleep(10).write("@bar bar").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.ViewText in project latexdraw by arnobl.
the class ShapeTextCustomiser method update.
@Override
protected void update(final IGroup shape) {
if (shape.isTypeOf(ITextProp.class)) {
setActivated(true);
final TextPosition tp = shape.getTextPosition();
bButton.setSelected(tp == TextPosition.BOT);
brButton.setSelected(tp == TextPosition.BOT_RIGHT);
blButton.setSelected(tp == TextPosition.BOT_LEFT);
tButton.setSelected(tp == TextPosition.TOP);
trButton.setSelected(tp == TextPosition.TOP_RIGHT);
tlButton.setSelected(tp == TextPosition.TOP_LEFT);
centreButton.setSelected(tp == TextPosition.CENTER);
lButton.setSelected(tp == TextPosition.LEFT);
rButton.setSelected(tp == TextPosition.RIGHT);
// Otherwise it means that this field is currently being edited and must not be updated.
if (!packagesField.isFocused()) {
packagesField.setText(LaTeXGenerator.getPackages());
}
// Updating the log field.
Platform.runLater(() -> shape.getShapes().stream().filter(sh -> sh instanceof IText && canvas.getViewFromShape(sh).orElse(null) instanceof ViewText && ((ViewText) canvas.getViewFromShape(sh).get()).getCompilationData().isPresent()).findFirst().ifPresent(txt -> {
final ViewText view = (ViewText) canvas.getViewFromShape(txt).get();
final Future<?> currentCompil = view.getCurrentCompilation();
if (currentCompil != null) {
try {
currentCompil.get();
} catch (final InterruptedException | ExecutionException ex) {
BadaboomCollector.INSTANCE.add(ex);
}
}
logField.setText(view.getCompilationData().orElse(""));
}));
} else {
setActivated(false);
}
}
use of net.sf.latexdraw.view.jfx.ViewText 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