use of net.sf.latexdraw.handlers.Handler in project latexdraw by arnobl.
the class Border method configureMovePointBinding.
private void configureMovePointBinding() {
nodeBinder(MovePointShape.class, new DnD()).on(mvPtHandlers).first((c, i) -> i.getSrcObject().filter(o -> o instanceof MovePtHandler).map(o -> (MovePtHandler) o).ifPresent(handler -> {
final IGroup group = canvas.getDrawing().getSelection();
if (group.size() == 1 && group.getShapeAt(0) instanceof IModifiablePointsShape) {
c.setPoint(handler.getPoint());
c.setShape((IModifiablePointsShape) group.getShapeAt(0));
}
})).then((c, i) -> i.getSrcObject().ifPresent(node -> {
final Point3D startPt = node.localToParent(i.getSrcLocalPoint());
final Point3D endPt = node.localToParent(i.getEndLocalPt());
final IPoint ptToMove = ((MovePtHandler) node).getPoint();
final double x = ptToMove.getX() + endPt.getX() - startPt.getX();
final double y = ptToMove.getY() + endPt.getY() - startPt.getY();
c.setNewCoord(grid.getTransformedPointToGrid(new Point3D(x, y, 0d)));
})).exec().when(i -> i.getSrcLocalPoint() != null && i.getEndLocalPt() != null && i.getSrcObject().orElse(null) instanceof MovePtHandler).bind();
}
Aggregations