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(""));
});
}
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());
}
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());
}
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);
}
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);
}
Aggregations