use of org.malai.javafx.interaction.library.DoubleClick 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