Search in sources :

Example 1 with IPlot

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

Example 2 with IPlot

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

the class LPlot method duplicate.

@Override
public IPlot duplicate() {
    final IPlot plot = ShapeFactory.INST.createPlot(getPosition(), getPlotMinX(), getPlotMaxX(), getPlotEquation(), isPolar());
    plot.copy(this);
    return plot;
}
Also used : IPlot(net.sf.latexdraw.models.interfaces.shape.IPlot)

Example 3 with IPlot

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

the class TestModifyShapeProperty method configureShapes.

private void configureShapes() {
    final IGrid grid = ShapeFactory.INST.createGrid(ShapeFactory.INST.createPoint());
    final IAxes axes = ShapeFactory.INST.createAxes(ShapeFactory.INST.createPoint());
    final IDot dot = ShapeFactory.INST.createDot(ShapeFactory.INST.createPoint());
    final ICircle circle = ShapeFactory.INST.createCircle();
    final IEllipse ell = ShapeFactory.INST.createEllipse();
    final IText txt = ShapeFactory.INST.createText();
    final IBezierCurve bc = ShapeFactory.INST.createBezierCurve(Collections.emptyList());
    final IPolyline pl = ShapeFactory.INST.createPolyline(Collections.emptyList());
    final IPolygon pg = ShapeFactory.INST.createPolygon(Collections.emptyList());
    final ITriangle tr = ShapeFactory.INST.createTriangle();
    final IRhombus rh = ShapeFactory.INST.createRhombus();
    final IRectangle r1 = ShapeFactory.INST.createRectangle();
    final IPlot plot = ShapeFactory.INST.createPlot(ShapeFactory.INST.createPoint(), 0d, 1d, "x", false);
    final ICircleArc carc = ShapeFactory.INST.createCircleArc();
    final ISquare sq = ShapeFactory.INST.createSquare();
    final IFreehand fh = ShapeFactory.INST.createFreeHand(Collections.emptyList());
    r1.setLineStyle(LineStyle.DASHED);
    r1.setBordersPosition(BorderPos.INTO);
    r1.setFillingStyle(FillingStyle.PLAIN);
    r1.setThickness(2.3);
    r1.setHasDbleBord(true);
    r1.setLineArc(0.2);
    r1.setDbleBordSep(1.3);
    r1.setHatchingsAngle(0.33);
    r1.setHatchingsSep(9.1);
    r1.setHatchingsWidth(12.11);
    r1.setShadowAngle(0.1);
    r1.setGradMidPt(0.66);
    r1.setHatchingsCol(DviPsColors.CYAN);
    r1.setLineColour(DviPsColors.NAVYBLUE);
    r1.setShadowSize(87.2);
    r1.setFillingCol(DviPsColors.CARNATIONPINK);
    r1.setShadowCol(DviPsColors.CORNFLOWERBLUE);
    r1.setDashSepBlack(1.2);
    r1.setDashSepWhite(2.1);
    r1.setDotSep(23.1);
    r1.setGradAngle(1.3);
    r1.setDbleBordCol(DviPsColors.RED);
    r1.setGradColEnd(DviPsColors.BITTERSWEET);
    r1.setGradColStart(DviPsColors.FORESTGREEN);
    r1.setShowPts(true);
    final IRectangle r2 = ShapeFactory.INST.createRectangle();
    r2.setLineStyle(LineStyle.SOLID);
    r2.setBordersPosition(BorderPos.MID);
    r2.setFillingStyle(FillingStyle.HLINES);
    r2.setThickness(6.3);
    r2.setHasShadow(true);
    r2.setLineArc(0.33);
    r2.setDbleBordSep(2.3);
    r2.setHatchingsAngle(-0.53);
    r2.setHatchingsSep(1.1);
    r2.setHatchingsWidth(2.11);
    r2.setShadowAngle(-0.1);
    r2.setGradMidPt(0.31);
    r2.setHatchingsCol(DviPsColors.APRICOT);
    r2.setLineColour(DviPsColors.YELLOW);
    r2.setShadowSize(8.1);
    r2.setFillingCol(DviPsColors.CERULEAN);
    r2.setShadowCol(DviPsColors.DARKORCHID);
    r1.setDashSepBlack(11.2);
    r1.setDashSepWhite(21.1);
    r1.setDotSep(231.1);
    r1.setGradAngle(11.3);
    r1.setDbleBordCol(DviPsColors.ROYALBLUE);
    r1.setGradColEnd(DviPsColors.CADETBLUE);
    r1.setGradColStart(DviPsColors.OLIVE);
    txt.copy(r1);
    ell.copy(r1);
    circle.copy(r2);
    dot.copy(r2);
    bc.copy(r2);
    pl.copy(r1);
    pg.copy(r2);
    tr.copy(r1);
    rh.copy(r2);
    plot.copy(r1);
    carc.copy(r2);
    sq.copy(r1);
    fh.copy(r2);
    group.addShape(r1);
    group.addShape(txt);
    group.addShape(grid);
    group.addShape(pl);
    group.addShape(pg);
    group.addShape(r2);
    group.addShape(axes);
    group.addShape(ell);
    group.addShape(circle);
    group.addShape(tr);
    group.addShape(rh);
    group.addShape(dot);
    group.addShape(bc);
    group.addShape(plot);
    group.addShape(carc);
    group.addShape(sq);
    group.addShape(fh);
}
Also used : IPlot(net.sf.latexdraw.models.interfaces.shape.IPlot) ICircle(net.sf.latexdraw.models.interfaces.shape.ICircle) IDot(net.sf.latexdraw.models.interfaces.shape.IDot) IEllipse(net.sf.latexdraw.models.interfaces.shape.IEllipse) IGrid(net.sf.latexdraw.models.interfaces.shape.IGrid) IAxes(net.sf.latexdraw.models.interfaces.shape.IAxes) IPolygon(net.sf.latexdraw.models.interfaces.shape.IPolygon) IFreehand(net.sf.latexdraw.models.interfaces.shape.IFreehand) IBezierCurve(net.sf.latexdraw.models.interfaces.shape.IBezierCurve) IPolyline(net.sf.latexdraw.models.interfaces.shape.IPolyline) ITriangle(net.sf.latexdraw.models.interfaces.shape.ITriangle) ICircleArc(net.sf.latexdraw.models.interfaces.shape.ICircleArc) IText(net.sf.latexdraw.models.interfaces.shape.IText) ISquare(net.sf.latexdraw.models.interfaces.shape.ISquare) IRhombus(net.sf.latexdraw.models.interfaces.shape.IRhombus) IRectangle(net.sf.latexdraw.models.interfaces.shape.IRectangle)

Example 4 with IPlot

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

the class TestTextSetter method testTypeEqFieldOKAddShape.

@Test
public void testTypeEqFieldOKAddShape() {
    pencil.setCurrentChoice(EditionChoice.PLOT);
    final Point2D pos = point(canvas).query();
    moveTo(pos).sleep(SLEEP).clickOn(MouseButton.PRIMARY).sleep(10).write("x 2 mul").type(KeyCode.ENTER).sleep(SLEEP);
    assertEquals(1, canvas.getDrawing().size());
    assertTrue(canvas.getDrawing().getShapeAt(0) instanceof IPlot);
    final IPlot sh = (IPlot) canvas.getDrawing().getShapeAt(0);
    assertEquals("x 2 mul", sh.getPlotEquation());
    assertEquals(-Canvas.getMargins() + canvas.screenToLocal(pos).getX(), sh.getPosition().getX(), 1d);
    assertEquals(-Canvas.getMargins() + canvas.screenToLocal(pos).getY() + setter.getTextField().getPrefHeight(), sh.getPosition().getY(), 1d);
}
Also used : IPlot(net.sf.latexdraw.models.interfaces.shape.IPlot) Point2D(javafx.geometry.Point2D) Test(org.junit.Test)

Example 5 with IPlot

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

the class TestIPlot method testDuplicate.

@Test
public void testDuplicate() {
    shape.setPlotEquation("2 x mul");
    shape.setPolar(true);
    shape.setNbPlottedPoints(73);
    shape.setPlotStyle(PlotStyle.ECURVE);
    shape.setPlotMinX(-234.0);
    shape.setPlotMaxX(123.0);
    shape.setDotStyle(DotStyle.BAR);
    shape.setDiametre(23.0);
    shape.setDotFillingCol(DviPsColors.YELLOW);
    shape.setPlotEquation("x");
    final IPlot plot = shape.duplicate();
    assertEquals("x", plot.getPlotEquation());
    assertTrue(plot.isPolar());
    assertEquals(DviPsColors.YELLOW, plot.getDotFillingCol());
    assertEquals(23.0, plot.getDiametre(), 0.0001);
    assertEquals(DotStyle.BAR, plot.getDotStyle());
    assertEquals(123.0, plot.getPlotMaxX(), 0.0001);
    assertEquals(-234.0, plot.getPlotMinX(), 0.0001);
    assertEquals(PlotStyle.ECURVE, plot.getPlotStyle());
    assertEquals(73, plot.getNbPlottedPoints());
}
Also used : IPlot(net.sf.latexdraw.models.interfaces.shape.IPlot) HelperTest(net.sf.latexdraw.HelperTest) Test(org.junit.Test)

Aggregations

IPlot (net.sf.latexdraw.models.interfaces.shape.IPlot)19 Test (org.junit.Test)9 Theory (org.junit.experimental.theories.Theory)5 IText (net.sf.latexdraw.models.interfaces.shape.IText)4 Collections (java.util.Collections)3 ShapeFactory (net.sf.latexdraw.models.ShapeFactory)3 IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)3 List (java.util.List)2 Platform (javafx.application.Platform)2 Point2D (javafx.geometry.Point2D)2 KeyCode (javafx.scene.input.KeyCode)2 HelperTest (net.sf.latexdraw.HelperTest)2 IShape (net.sf.latexdraw.models.interfaces.shape.IShape)2 URL (java.net.URL)1 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Deque (java.util.Deque)1 Optional (java.util.Optional)1 ResourceBundle (java.util.ResourceBundle)1