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