Search in sources :

Example 1 with TextPosition

use of net.sf.latexdraw.models.interfaces.shape.TextPosition in project latexdraw by arnobl.

the class ShapeTextCustomiser method update.

@Override
protected void update(final IGroup shape) {
    if (shape.isTypeOf(ITextProp.class)) {
        setActivated(true);
        final TextPosition tp = shape.getTextPosition();
        bButton.setSelected(tp == TextPosition.BOT);
        brButton.setSelected(tp == TextPosition.BOT_RIGHT);
        blButton.setSelected(tp == TextPosition.BOT_LEFT);
        tButton.setSelected(tp == TextPosition.TOP);
        trButton.setSelected(tp == TextPosition.TOP_RIGHT);
        tlButton.setSelected(tp == TextPosition.TOP_LEFT);
        centreButton.setSelected(tp == TextPosition.CENTER);
        lButton.setSelected(tp == TextPosition.LEFT);
        rButton.setSelected(tp == TextPosition.RIGHT);
        // Otherwise it means that this field is currently being edited and must not be updated.
        if (!packagesField.isFocused()) {
            packagesField.setText(LaTeXGenerator.getPackages());
        }
        // Updating the log field.
        Platform.runLater(() -> shape.getShapes().stream().filter(sh -> sh instanceof IText && canvas.getViewFromShape(sh).orElse(null) instanceof ViewText && ((ViewText) canvas.getViewFromShape(sh).get()).getCompilationData().isPresent()).findFirst().ifPresent(txt -> {
            final ViewText view = (ViewText) canvas.getViewFromShape(txt).get();
            final Future<?> currentCompil = view.getCurrentCompilation();
            if (currentCompil != null) {
                try {
                    currentCompil.get();
                } catch (final InterruptedException | ExecutionException ex) {
                    BadaboomCollector.INSTANCE.add(ex);
                }
            }
            logField.setText(view.getCompilationData().orElse(""));
        }));
    } else {
        setActivated(false);
    }
}
Also used : Initializable(javafx.fxml.Initializable) ViewText(net.sf.latexdraw.view.jfx.ViewText) TitledPane(javafx.scene.control.TitledPane) TextPosition(net.sf.latexdraw.models.interfaces.shape.TextPosition) TextArea(javafx.scene.control.TextArea) URL(java.net.URL) ShapeProperties(net.sf.latexdraw.commands.shape.ShapeProperties) IText(net.sf.latexdraw.models.interfaces.shape.IText) IGroup(net.sf.latexdraw.models.interfaces.shape.IGroup) ModifyLatexProperties(net.sf.latexdraw.commands.ModifyLatexProperties) ITextProp(net.sf.latexdraw.models.interfaces.prop.ITextProp) LaTeXGenerator(net.sf.latexdraw.view.latex.LaTeXGenerator) ExecutionException(java.util.concurrent.ExecutionException) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) Future(java.util.concurrent.Future) ResourceBundle(java.util.ResourceBundle) ToggleButton(javafx.scene.control.ToggleButton) LatexProperties(net.sf.latexdraw.commands.LatexProperties) BadaboomCollector(net.sf.latexdraw.badaboom.BadaboomCollector) ViewText(net.sf.latexdraw.view.jfx.ViewText) TextPosition(net.sf.latexdraw.models.interfaces.shape.TextPosition) Future(java.util.concurrent.Future) IText(net.sf.latexdraw.models.interfaces.shape.IText)

Aggregations

URL (java.net.URL)1 ResourceBundle (java.util.ResourceBundle)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 Platform (javafx.application.Platform)1 FXML (javafx.fxml.FXML)1 Initializable (javafx.fxml.Initializable)1 TextArea (javafx.scene.control.TextArea)1 TitledPane (javafx.scene.control.TitledPane)1 ToggleButton (javafx.scene.control.ToggleButton)1 BadaboomCollector (net.sf.latexdraw.badaboom.BadaboomCollector)1 LatexProperties (net.sf.latexdraw.commands.LatexProperties)1 ModifyLatexProperties (net.sf.latexdraw.commands.ModifyLatexProperties)1 ShapeProperties (net.sf.latexdraw.commands.shape.ShapeProperties)1 ITextProp (net.sf.latexdraw.models.interfaces.prop.ITextProp)1 IGroup (net.sf.latexdraw.models.interfaces.shape.IGroup)1 IText (net.sf.latexdraw.models.interfaces.shape.IText)1 TextPosition (net.sf.latexdraw.models.interfaces.shape.TextPosition)1 ViewText (net.sf.latexdraw.view.jfx.ViewText)1 LaTeXGenerator (net.sf.latexdraw.view.latex.LaTeXGenerator)1