Search in sources :

Example 36 with IText

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

the class TestParsingRPut method testRPutCoordRotationLText.

@Test
public void testRPutCoordRotationLText() {
    parser("\\rput{L}(1,2){coucou}");
    final IText txt = getShapeAt(0);
    assertEquals("coucou", txt.getText());
    assertEquals(IShape.PPC, txt.getPosition().getX(), 0.001);
    assertEquals(-2d * IShape.PPC, txt.getPosition().getY(), 0.001);
    assertEquals(Math.toRadians(-90d), txt.getRotationAngle(), 0.001);
}
Also used : IText(net.sf.latexdraw.models.interfaces.shape.IText) Test(org.junit.Test)

Example 37 with IText

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

the class TestTextParsing method testBracket.

@Test
public void testBracket() {
    parser("{( )}");
    final IText txt = getShapeAt(0);
    assertEquals("( )", txt.getText());
}
Also used : IText(net.sf.latexdraw.models.interfaces.shape.IText) Test(org.junit.Test)

Example 38 with IText

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

the class TestTextParsing method testBug7220753.

@Test
public void testBug7220753() {
    // https://bugs.launchpad.net/latexdraw/+bug/722075
    parser("\\textcolor{blue}{xyz} foobar");
    assertEquals(2, listener.getShapes().size());
    IText text = getShapeAt(1);
    assertEquals("foobar", text.getText());
    assertEquals(DviPsColors.BLACK, text.getLineColour());
}
Also used : IText(net.sf.latexdraw.models.interfaces.shape.IText) Test(org.junit.Test)

Example 39 with IText

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

the class TestTextParsing method testParseTextfootnotesize.

@Test
public void testParseTextfootnotesize() {
    parser("\\rput(1,2){\\footnotesize coucou}");
    assertEquals(1, listener.getShapes().size());
    IText text = getShapeAt(0);
    assertEquals("\\footnotesize coucou", text.getText());
}
Also used : IText(net.sf.latexdraw.models.interfaces.shape.IText) Test(org.junit.Test)

Example 40 with IText

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

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