use of net.sf.latexdraw.commands.shape.TranslateShapes in project latexdraw by arnobl.
the class Hand method bindDnDTranslate.
/**
* A DnD on a shape view allows to translate the underlying shape.
*/
private void bindDnDTranslate() {
nodeBinder(TranslateShapes.class, new DnD(true, true)).on(canvas.getViews().getChildren()).on(canvas.getSelectionBorder()).map(i -> new TranslateShapes(canvas.getDrawing(), canvas.getDrawing().getSelection().duplicateDeep(false))).then((c, i) -> {
final IPoint startPt = grid.getTransformedPointToGrid(i.getSrcScenePoint());
final IPoint endPt = grid.getTransformedPointToGrid(i.getEndScenePt());
c.setT(endPt.getX() - startPt.getX(), endPt.getY() - startPt.getY());
}).when(i -> i.getButton() == MouseButton.PRIMARY && !canvas.getDrawing().getSelection().isEmpty()).exec().first((c, i) -> {
i.getSrcObject().ifPresent(node -> Platform.runLater(() -> node.requestFocus()));
canvas.setCursor(Cursor.MOVE);
}).cancel((c, i) -> canvas.update()).strictStart().bind();
}
Aggregations