Search in sources :

Example 36 with Text

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

the class TestText method testConstructorsOK4.

@Test
public void testConstructorsOK4() {
    final Text txt = ShapeFactory.INST.createText(ShapeFactory.INST.createPoint(0, Double.NEGATIVE_INFINITY), "aa");
    assertEquals(ShapeFactory.INST.createPoint(), txt.getPosition());
}
Also used : Text(net.sf.latexdraw.model.api.shape.Text) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 37 with Text

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

the class TestText method testCopy.

@Test
public void testCopy() {
    final Text s2 = ShapeFactory.INST.createText();
    shape.setText("foo");
    shape.setTextPosition(TextPosition.BOT_RIGHT);
    s2.copy(shape);
    assertEquals(shape.getText(), s2.getText());
    assertEquals(shape.getTextPosition(), s2.getTextPosition());
}
Also used : Text(net.sf.latexdraw.model.api.shape.Text) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 38 with Text

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

the class TestText method testConstructorsOK2.

@Test
public void testConstructorsOK2() {
    final Text txt = ShapeFactory.INST.createText(ShapeFactory.INST.createPoint(), "coucou");
    assertNotNull(txt.getText());
    assertFalse(txt.getText().isEmpty());
}
Also used : Text(net.sf.latexdraw.model.api.shape.Text) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 39 with Text

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

the class PolymorphTextTest method testTextPosition.

@ParameterizedTest
@MethodSource("net.sf.latexdraw.data.ShapeSupplier#createDiversifiedText")
default void testTextPosition(final Text sh) {
    final Text s2 = produceOutputShapeFrom(sh);
    CompareShapeMatcher.INST.assertEqualsText(sh, s2);
}
Also used : Text(net.sf.latexdraw.model.api.shape.Text) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 40 with Text

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

the class TestCanvasCreation method testDrawText.

@Test
public void testDrawText() {
    final Point2D pos = point(canvas).query();
    when(setter.isActivated()).thenReturn(true);
    when(setter.getPosition()).thenReturn(ShapeFactory.INST.createPoint(-Canvas.getMargins() + canvas.screenToLocal(pos).getX(), -Canvas.getMargins() + canvas.screenToLocal(pos).getY()));
    Cmds.of(CmdFXVoid.of(() -> {
        editing.setCurrentChoice(EditionChoice.TEXT);
        textAutoSize.setText("gridGapProp");
    }), () -> moveTo(pos).clickOn(MouseButton.PRIMARY)).execute();
    assertEquals(1, drawing.size());
    assertTrue(drawing.getShapeAt(0).orElseThrow() instanceof Text);
    final Text sh = (Text) drawing.getShapeAt(0).orElseThrow();
    assertEquals("gridGapProp", sh.getText());
    assertEquals(-Canvas.getMargins() + canvas.screenToLocal(pos).getX(), sh.getPosition().getX(), 1d);
    assertEquals(-Canvas.getMargins() + canvas.screenToLocal(pos).getY(), sh.getPosition().getY(), 1d);
}
Also used : Point2D(javafx.geometry.Point2D) Text(net.sf.latexdraw.model.api.shape.Text) Test(org.junit.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