Search in sources :

Example 1 with Handler

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();
}
Also used : Arrays(java.util.Arrays) Initializable(javafx.fxml.Initializable) Command(org.malai.command.Command) MovePtHandler(net.sf.latexdraw.handlers.MovePtHandler) Point3D(javafx.geometry.Point3D) URL(java.net.URL) ShapeFactory(net.sf.latexdraw.models.ShapeFactory) ScaleHandler(net.sf.latexdraw.handlers.ScaleHandler) FXCollections(javafx.collections.FXCollections) MathUtils(net.sf.latexdraw.models.MathUtils) MovePointShape(net.sf.latexdraw.commands.shape.MovePointShape) JfXWidgetBinding(org.malai.javafx.binding.JfXWidgetBinding) Function(java.util.function.Function) IArc(net.sf.latexdraw.models.interfaces.shape.IArc) Position(net.sf.latexdraw.models.interfaces.shape.Position) Inject(net.sf.latexdraw.util.Inject) IShape(net.sf.latexdraw.models.interfaces.shape.IShape) ResourceBundle(java.util.ResourceBundle) ListChangeListener(javafx.collections.ListChangeListener) IDrawing(net.sf.latexdraw.models.interfaces.shape.IDrawing) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) ScaleShapes(net.sf.latexdraw.commands.shape.ScaleShapes) DnD(org.malai.javafx.interaction.library.DnD) ArcAngleHandler(net.sf.latexdraw.handlers.ArcAngleHandler) IControlPointShape(net.sf.latexdraw.models.interfaces.shape.IControlPointShape) Node(javafx.scene.Node) ShapeProperties(net.sf.latexdraw.commands.shape.ShapeProperties) ModifyShapeProperty(net.sf.latexdraw.commands.shape.ModifyShapeProperty) RotationHandler(net.sf.latexdraw.handlers.RotationHandler) IGroup(net.sf.latexdraw.models.interfaces.shape.IGroup) IBezierCurve(net.sf.latexdraw.models.interfaces.shape.IBezierCurve) Collectors(java.util.stream.Collectors) MoveCtrlPoint(net.sf.latexdraw.commands.shape.MoveCtrlPoint) Cursor(javafx.scene.Cursor) List(java.util.List) IModifiablePointsShape(net.sf.latexdraw.models.interfaces.shape.IModifiablePointsShape) CtrlPointHandler(net.sf.latexdraw.handlers.CtrlPointHandler) ObservableList(javafx.collections.ObservableList) Handler(net.sf.latexdraw.handlers.Handler) RotateShapes(net.sf.latexdraw.commands.shape.RotateShapes) IModifiablePointsShape(net.sf.latexdraw.models.interfaces.shape.IModifiablePointsShape) Point3D(javafx.geometry.Point3D) MovePtHandler(net.sf.latexdraw.handlers.MovePtHandler) IGroup(net.sf.latexdraw.models.interfaces.shape.IGroup) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) DnD(org.malai.javafx.interaction.library.DnD)

Aggregations

URL (java.net.URL)1 Arrays (java.util.Arrays)1 List (java.util.List)1 ResourceBundle (java.util.ResourceBundle)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 FXCollections (javafx.collections.FXCollections)1 ListChangeListener (javafx.collections.ListChangeListener)1 ObservableList (javafx.collections.ObservableList)1 Initializable (javafx.fxml.Initializable)1 Point3D (javafx.geometry.Point3D)1 Cursor (javafx.scene.Cursor)1 Node (javafx.scene.Node)1 ModifyShapeProperty (net.sf.latexdraw.commands.shape.ModifyShapeProperty)1 MoveCtrlPoint (net.sf.latexdraw.commands.shape.MoveCtrlPoint)1 MovePointShape (net.sf.latexdraw.commands.shape.MovePointShape)1 RotateShapes (net.sf.latexdraw.commands.shape.RotateShapes)1 ScaleShapes (net.sf.latexdraw.commands.shape.ScaleShapes)1 ShapeProperties (net.sf.latexdraw.commands.shape.ShapeProperties)1 ArcAngleHandler (net.sf.latexdraw.handlers.ArcAngleHandler)1