Search in sources :

Example 1 with InitTextSetter

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();
}
Also used : ISquaredShape(net.sf.latexdraw.models.interfaces.shape.ISquaredShape) Arrays(java.util.Arrays) MouseButton(javafx.scene.input.MouseButton) IPositionShape(net.sf.latexdraw.models.interfaces.shape.IPositionShape) Point3D(javafx.geometry.Point3D) ShapeFactory(net.sf.latexdraw.models.ShapeFactory) IRectangularShape(net.sf.latexdraw.models.interfaces.shape.IRectangularShape) MathUtils(net.sf.latexdraw.models.MathUtils) AddShape(net.sf.latexdraw.commands.shape.AddShape) Function(java.util.function.Function) BorderPos(net.sf.latexdraw.models.interfaces.shape.BorderPos) Inject(net.sf.latexdraw.util.Inject) IShape(net.sf.latexdraw.models.interfaces.shape.IShape) InsertPicture(net.sf.latexdraw.commands.shape.InsertPicture) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) DnD(org.malai.javafx.interaction.library.DnD) IFreehand(net.sf.latexdraw.models.interfaces.shape.IFreehand) ObjectProperty(javafx.beans.property.ObjectProperty) ViewFactory(net.sf.latexdraw.view.jfx.ViewFactory) IControlPointShape(net.sf.latexdraw.models.interfaces.shape.IControlPointShape) IPolygon(net.sf.latexdraw.models.interfaces.shape.IPolygon) IPolyline(net.sf.latexdraw.models.interfaces.shape.IPolyline) LangTool(net.sf.latexdraw.util.LangTool) IGroup(net.sf.latexdraw.models.interfaces.shape.IGroup) IBezierCurve(net.sf.latexdraw.models.interfaces.shape.IBezierCurve) InitTextSetter(net.sf.latexdraw.commands.shape.InitTextSetter) MultiClick(org.malai.javafx.interaction.library.MultiClick) Platform(javafx.application.Platform) Cursor(javafx.scene.Cursor) FileChooser(javafx.stage.FileChooser) IModifiablePointsShape(net.sf.latexdraw.models.interfaces.shape.IModifiablePointsShape) Press(org.malai.javafx.interaction.library.Press) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Collections(java.util.Collections) InitTextSetter(net.sf.latexdraw.commands.shape.InitTextSetter) InsertPicture(net.sf.latexdraw.commands.shape.InsertPicture) Press(org.malai.javafx.interaction.library.Press)

Example 2 with InitTextSetter

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();
}
Also used : MouseButton(javafx.scene.input.MouseButton) ViewText(net.sf.latexdraw.view.jfx.ViewText) Command(org.malai.command.Command) BoundingBox(javafx.geometry.BoundingBox) ShapeFactory(net.sf.latexdraw.models.ShapeFactory) SelectShapes(net.sf.latexdraw.commands.shape.SelectShapes) JfXWidgetBinding(org.malai.javafx.binding.JfXWidgetBinding) NonInvertibleTransformException(javafx.scene.transform.NonInvertibleTransformException) ArrayList(java.util.ArrayList) ViewShape(net.sf.latexdraw.view.jfx.ViewShape) Inject(net.sf.latexdraw.util.Inject) IShape(net.sf.latexdraw.models.interfaces.shape.IShape) ListChangeListener(javafx.collections.ListChangeListener) Transform(javafx.scene.transform.Transform) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) Canvas(net.sf.latexdraw.view.jfx.Canvas) DnD(org.malai.javafx.interaction.library.DnD) KeyCode(javafx.scene.input.KeyCode) Node(javafx.scene.Node) LSystem(net.sf.latexdraw.util.LSystem) IText(net.sf.latexdraw.models.interfaces.shape.IText) Rectangle(javafx.scene.shape.Rectangle) UpdateToGrid(net.sf.latexdraw.commands.shape.UpdateToGrid) InitTextSetter(net.sf.latexdraw.commands.shape.InitTextSetter) TranslateShapes(net.sf.latexdraw.commands.shape.TranslateShapes) Platform(javafx.application.Platform) Cursor(javafx.scene.Cursor) List(java.util.List) Press(org.malai.javafx.interaction.library.Press) IPlot(net.sf.latexdraw.models.interfaces.shape.IPlot) ViewPlot(net.sf.latexdraw.view.jfx.ViewPlot) Optional(java.util.Optional) DoubleClick(org.malai.javafx.interaction.library.DoubleClick) Collections(java.util.Collections) Shape(javafx.scene.shape.Shape) Bounds(javafx.geometry.Bounds) IPlot(net.sf.latexdraw.models.interfaces.shape.IPlot) ViewText(net.sf.latexdraw.view.jfx.ViewText) InitTextSetter(net.sf.latexdraw.commands.shape.InitTextSetter) DoubleClick(org.malai.javafx.interaction.library.DoubleClick) ViewPlot(net.sf.latexdraw.view.jfx.ViewPlot) IText(net.sf.latexdraw.models.interfaces.shape.IText)

Aggregations

Collections (java.util.Collections)2 Platform (javafx.application.Platform)2 Cursor (javafx.scene.Cursor)2 MouseButton (javafx.scene.input.MouseButton)2 InitTextSetter (net.sf.latexdraw.commands.shape.InitTextSetter)2 ShapeFactory (net.sf.latexdraw.models.ShapeFactory)2 IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)2 IShape (net.sf.latexdraw.models.interfaces.shape.IShape)2 Inject (net.sf.latexdraw.util.Inject)2 DnD (org.malai.javafx.interaction.library.DnD)2 Press (org.malai.javafx.interaction.library.Press)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Optional (java.util.Optional)1 Function (java.util.function.Function)1 ObjectProperty (javafx.beans.property.ObjectProperty)1 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)1 ListChangeListener (javafx.collections.ListChangeListener)1 BoundingBox (javafx.geometry.BoundingBox)1