Search in sources :

Example 1 with Text

use of net.sf.latexdraw.model.api.shape.Text in project latexdraw by arnobl.

the class ShapeTextCustomiser method updateOnTextPropShape.

private void updateOnTextPropShape(final Group shape) {
    final TextPosition tp = shape.getTextPosition();
    textPos.getSelectionModel().select(tp);
    // Otherwise it means that this field is currently being edited and must not be updated.
    if (!packagesField.isFocused()) {
        packagesField.setText(latexData.getPackages());
    }
    // Updating the log field.
    shape.getShapes().stream().filter(sh -> sh instanceof Text && canvas.getViewFromShape(sh).orElse(null) instanceof ViewText && ((ViewText) canvas.getViewFromShape(sh).orElseThrow()).getCompilationData().isPresent()).findFirst().ifPresent(txt -> {
        final ViewText view = (ViewText) canvas.getViewFromShape(txt).orElseThrow();
        final Future<?> currentCompil = view.getCurrentCompilation();
        if (currentCompil != null) {
            try {
                currentCompil.get();
            } catch (final InterruptedException ex) {
                Thread.currentThread().interrupt();
                BadaboomCollector.INSTANCE.add(ex);
            } catch (final ExecutionException ex) {
                BadaboomCollector.INSTANCE.add(ex);
            }
        }
        logField.setText(view.getCompilationData().orElse(""));
    });
}
Also used : ViewText(net.sf.latexdraw.view.jfx.ViewText) TextPosition(net.sf.latexdraw.model.api.shape.TextPosition) ViewText(net.sf.latexdraw.view.jfx.ViewText) Text(net.sf.latexdraw.model.api.shape.Text) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with Text

use of net.sf.latexdraw.model.api.shape.Text in project latexdraw by arnobl.

the class TestEditingSelector method testClickTextCreatesText.

@Test
public void testClickTextCreatesText() {
    final TextAreaAutoSize textfield = Mockito.mock(TextAreaAutoSize.class);
    Mockito.when(textSetter.getTextField()).thenReturn(textfield);
    Mockito.when(textSetter.isActivated()).thenReturn(true);
    Mockito.when(textfield.getText()).thenReturn("gridGapProp");
    Cmds.of(clickHand).execute();
    assertEquals(1, drawing.size());
    assertTrue(drawing.getShapeAt(0).orElseThrow() instanceof Text);
    assertEquals("gridGapProp", ((Text) drawing.getShapeAt(0).orElseThrow()).getText());
}
Also used : TextAreaAutoSize(net.sf.latexdraw.ui.TextAreaAutoSize) Text(net.sf.latexdraw.model.api.shape.Text) Test(org.junit.Test)

Example 3 with Text

use of net.sf.latexdraw.model.api.shape.Text in project latexdraw by arnobl.

the class TestTextParsing method testBug7220751.

@Test
public void testBug7220751() {
    // https://bugs.launchpad.net/latexdraw/+bug/722075
    parser("\\color{blue} xyz");
    assertEquals(1, parsedShapes.size());
    final Text text = getShapeAt(0);
    assertEquals("xyz", text.getText());
    assertEquals(DviPsColors.BLUE, text.getLineColour());
}
Also used : Text(net.sf.latexdraw.model.api.shape.Text) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with Text

use of net.sf.latexdraw.model.api.shape.Text in project latexdraw by arnobl.

the class TestParsingRPut method testRPutCoordStarSignedIntText.

@Test
void testRPutCoordStarSignedIntText() {
    parser("\\rput{*-++-90}(1,2){coucou}");
    final Text txt = getShapeAt(0);
    assertEquals("coucou", txt.getText());
    assertEquals(Shape.PPC, txt.getPosition().getX(), 0.001);
    assertEquals(-2d * Shape.PPC, txt.getPosition().getY(), 0.001);
    assertEquals(Math.toRadians(-90d), txt.getRotationAngle(), 0.001);
}
Also used : Text(net.sf.latexdraw.model.api.shape.Text) Test(org.junit.jupiter.api.Test)

Example 5 with Text

use of net.sf.latexdraw.model.api.shape.Text in project latexdraw by arnobl.

the class TestParsingRPut method testRefPointbl.

@Test
void testRefPointbl() {
    parser("\\rput[bl](10,20){coucou}");
    final Text txt = getShapeAt(0);
    assertEquals(TextPosition.BOT_LEFT, txt.getTextPosition());
    assertEquals(10d * Shape.PPC, txt.getPosition().getX(), 0.001);
    assertEquals(-20d * Shape.PPC, txt.getPosition().getY(), 0.001);
}
Also used : Text(net.sf.latexdraw.model.api.shape.Text) Test(org.junit.jupiter.api.Test)

Aggregations

Text (net.sf.latexdraw.model.api.shape.Text)67 Test (org.junit.jupiter.api.Test)53 Test (org.junit.Test)10 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)10 HelperTest (net.sf.latexdraw.HelperTest)6 Rectangle (net.sf.latexdraw.model.api.shape.Rectangle)2 ExecutionException (java.util.concurrent.ExecutionException)1 Point2D (javafx.geometry.Point2D)1 Axes (net.sf.latexdraw.model.api.shape.Axes)1 BezierCurve (net.sf.latexdraw.model.api.shape.BezierCurve)1 Circle (net.sf.latexdraw.model.api.shape.Circle)1 CircleArc (net.sf.latexdraw.model.api.shape.CircleArc)1 Dot (net.sf.latexdraw.model.api.shape.Dot)1 Ellipse (net.sf.latexdraw.model.api.shape.Ellipse)1 Freehand (net.sf.latexdraw.model.api.shape.Freehand)1 Grid (net.sf.latexdraw.model.api.shape.Grid)1 Plot (net.sf.latexdraw.model.api.shape.Plot)1 Polygon (net.sf.latexdraw.model.api.shape.Polygon)1 Polyline (net.sf.latexdraw.model.api.shape.Polyline)1 Rhombus (net.sf.latexdraw.model.api.shape.Rhombus)1