use of net.sf.latexdraw.commands.shape.InitTextSetter in project latexdraw by arnobl.
the class Pencil method configureBindings.
@Override
protected void configureBindings() {
bindPressToAddShape();
// Binds a pressure to insert a picture
nodeBinder(InsertPicture.class, new Press()).on(canvas).map(i -> new InsertPicture(ShapeFactory.INST.createPicture(getAdaptedPoint(i.getSrcLocalPoint())), canvas.getDrawing(), getPictureFileChooser())).when(i -> currentChoice.get() == EditionChoice.PICTURE && i.getButton() == MouseButton.PRIMARY).bind();
bindDnDToDrawRectangularShape();
bindDnDToDrawSquaredShape();
bindDnDToDrawFreeHandShape();
bindMultiClic2AddShape();
// Binds a pressure to show the text setter
nodeBinder(InitTextSetter.class, new Press()).on(canvas).map(i -> new InitTextSetter(textSetter, textSetter, "", getAdaptedPoint(i.getSrcLocalPoint()), null, null)).when(i -> (currentChoice.get() == EditionChoice.TEXT || currentChoice.get() == EditionChoice.PLOT) && i.getButton() == MouseButton.PRIMARY).bind();
}
use of net.sf.latexdraw.commands.shape.InitTextSetter 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