Search in sources :

Example 46 with IText

use of net.sf.latexdraw.models.interfaces.shape.IText 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)

Example 47 with IText

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

the class LText method duplicate.

@Override
public IText duplicate() {
    final IText text = ShapeFactory.INST.createText();
    text.copy(this);
    return text;
}
Also used : IText(net.sf.latexdraw.models.interfaces.shape.IText)

Example 48 with IText

use of net.sf.latexdraw.models.interfaces.shape.IText 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)

Example 49 with IText

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

the class TestParsingPsframebox method testParsepsdiaboxstar.

@Test
public void testParsepsdiaboxstar() {
    parser("\\psdiabox*[doubleline=true]{\\psframe(0,1)}");
    assertEquals(1, listener.getShapes().size());
    final IText text = getShapeAt(0);
    assertEquals("\\psdiabox*[doubleline=true]{\\psframe(0,1)}", text.getText());
}
Also used : IText(net.sf.latexdraw.models.interfaces.shape.IText) Test(org.junit.Test)

Example 50 with IText

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

the class TestParsingPsframebox method testParsepsdiabox.

@Test
public void testParsepsdiabox() {
    parser("\\psdiabox[doubleline=true]{\\psframe(0,1)}");
    assertEquals(1, listener.getShapes().size());
    final IText text = getShapeAt(0);
    assertEquals("\\psdiabox[doubleline=true]{\\psframe(0,1)}", text.getText());
}
Also used : IText(net.sf.latexdraw.models.interfaces.shape.IText) Test(org.junit.Test)

Aggregations

IText (net.sf.latexdraw.models.interfaces.shape.IText)72 Test (org.junit.Test)65 HelperTest (net.sf.latexdraw.HelperTest)6 Platform (javafx.application.Platform)3 URL (java.net.URL)2 Collections (java.util.Collections)2 ResourceBundle (java.util.ResourceBundle)2 Initializable (javafx.fxml.Initializable)2 Point2D (javafx.geometry.Point2D)2 KeyCode (javafx.scene.input.KeyCode)2 ShapeProperties (net.sf.latexdraw.commands.shape.ShapeProperties)2 ShapeFactory (net.sf.latexdraw.models.ShapeFactory)2 IPlot (net.sf.latexdraw.models.interfaces.shape.IPlot)2 TextAreaAutoSize (net.sf.latexdraw.ui.TextAreaAutoSize)2 ViewText (net.sf.latexdraw.view.jfx.ViewText)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1