Search in sources :

Example 1 with ModifyShapeProperty

use of net.sf.latexdraw.commands.shape.ModifyShapeProperty in project latexdraw by arnobl.

the class TextSetter method configureBindings.

@Override
protected void configureBindings() {
    // Key Enter to validate the text.
    keyNodeBinder(ModifyShapeProperty.class).on(textField).with(KeyCode.ENTER).map(i -> new ModifyShapeProperty(ShapeProperties.TEXT, ShapeFactory.INST.createGroup(text), textField.getText())).when(i -> !pencil.isActivated() && text != null && !textField.getText().isEmpty()).bind();
    // Key Enter to validate the equation of a plot shape.
    keyNodeBinder(ModifyShapeProperty.class).on(textField).with(KeyCode.ENTER).map(i -> new ModifyShapeProperty(ShapeProperties.PLOT_EQ, ShapeFactory.INST.createGroup(plot), textField.getText())).when(i -> !pencil.isActivated() && plot != null && checkValidPlotFct()).bind();
    // Key Enter to add a text shape.
    keyNodeBinder(AddShape.class).on(textField).with(KeyCode.ENTER).map(i -> {
        text = (IText) pencil.createShapeInstance();
        text.setPosition(ShapeFactory.INST.createPoint(position.getX(), position.getY()));
        text.setText(textField.getText());
        return new AddShape(text, canvas.getDrawing());
    }).when(i -> pencil.isActivated() && pencil.getCurrentChoice() == EditionChoice.TEXT && !textField.getText().isEmpty()).bind();
    // Key Enter to add a plot shape.
    keyNodeBinder(AddShape.class).on(textField).with(KeyCode.ENTER).map(i -> {
        plot = (IPlot) pencil.createShapeInstance();
        plot.setPosition(ShapeFactory.INST.createPoint(position.getX(), position.getY() + textField.getHeight()));
        plot.setPlotEquation(textField.getText());
        return new AddShape(plot, canvas.getDrawing());
    }).when(i -> pencil.isActivated() && pencil.getCurrentChoice() == EditionChoice.PLOT && checkValidPlotFct()).bind();
    keyNodeBinder(ActivateInactivateInstruments.class).on(textField).map(i -> new ActivateInactivateInstruments(null, Collections.singletonList(this), false, false)).with(KeyCode.ENTER).when(i -> textField.isValidText() && !textField.getText().isEmpty()).bind();
    keyNodeBinder(ActivateInactivateInstruments.class).on(textField).map(i -> new ActivateInactivateInstruments(null, Collections.singletonList(this), false, false)).with(KeyCode.ESCAPE).bind();
}
Also used : KeyCode(javafx.scene.input.KeyCode) Initializable(javafx.fxml.Initializable) Command(org.malai.command.Command) ActivateInactivateInstruments(org.malai.javafx.command.ActivateInactivateInstruments) URL(java.net.URL) ShapeFactory(net.sf.latexdraw.models.ShapeFactory) LangTool(net.sf.latexdraw.util.LangTool) ShapeProperties(net.sf.latexdraw.commands.shape.ShapeProperties) IText(net.sf.latexdraw.models.interfaces.shape.IText) PSFunctionParser(net.sf.latexdraw.parsers.ps.PSFunctionParser) ModifyShapeProperty(net.sf.latexdraw.commands.shape.ModifyShapeProperty) AddShape(net.sf.latexdraw.commands.shape.AddShape) TextAreaAutoSize(net.sf.latexdraw.ui.TextAreaAutoSize) Platform(javafx.application.Platform) Tuple(net.sf.latexdraw.util.Tuple) Inject(net.sf.latexdraw.util.Inject) ResourceBundle(java.util.ResourceBundle) IPlot(net.sf.latexdraw.models.interfaces.shape.IPlot) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) Collections(java.util.Collections) AddShape(net.sf.latexdraw.commands.shape.AddShape) ModifyShapeProperty(net.sf.latexdraw.commands.shape.ModifyShapeProperty) ActivateInactivateInstruments(org.malai.javafx.command.ActivateInactivateInstruments)

Aggregations

URL (java.net.URL)1 Collections (java.util.Collections)1 ResourceBundle (java.util.ResourceBundle)1 Platform (javafx.application.Platform)1 Initializable (javafx.fxml.Initializable)1 KeyCode (javafx.scene.input.KeyCode)1 AddShape (net.sf.latexdraw.commands.shape.AddShape)1 ModifyShapeProperty (net.sf.latexdraw.commands.shape.ModifyShapeProperty)1 ShapeProperties (net.sf.latexdraw.commands.shape.ShapeProperties)1 ShapeFactory (net.sf.latexdraw.models.ShapeFactory)1 IPlot (net.sf.latexdraw.models.interfaces.shape.IPlot)1 IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)1 IText (net.sf.latexdraw.models.interfaces.shape.IText)1 PSFunctionParser (net.sf.latexdraw.parsers.ps.PSFunctionParser)1 TextAreaAutoSize (net.sf.latexdraw.ui.TextAreaAutoSize)1 Inject (net.sf.latexdraw.util.Inject)1 LangTool (net.sf.latexdraw.util.LangTool)1 Tuple (net.sf.latexdraw.util.Tuple)1 Command (org.malai.command.Command)1 ActivateInactivateInstruments (org.malai.javafx.command.ActivateInactivateInstruments)1