Search in sources :

Example 16 with Grid

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

the class TestParsingPsgrid method testGridUnitin.

@Test
public void testGridUnitin() {
    parser("\\psgrid[unit=20in](0,0)(0,0)(1,1)");
    final Grid grid = getShapeAt(0);
    assertEquals(20d / PSTricksConstants.INCH_VAL_CM, grid.getUnit(), 0.00001);
}
Also used : Grid(net.sf.latexdraw.model.api.shape.Grid) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with Grid

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

the class TestGrid method testCopy.

@Test
public void testCopy() {
    final Grid shape2 = ShapeFactory.INST.createGrid(ShapeFactory.INST.createPoint());
    shape2.setGridDots(45);
    shape2.setSubGridDots(55);
    shape2.setGridLabelsColour(DviPsColors.CYAN);
    shape2.setSubGridColour(DviPsColors.GREEN);
    shape2.setUnit(0.6);
    shape2.setGridWidth(12);
    shape2.setSubGridWidth(24);
    shape2.setSubGridDiv(32);
    shape2.setXLabelSouth(false);
    shape2.setYLabelWest(false);
    shape.copy(shape2);
    assertEquals(shape2.getGridDots(), shape.getGridDots());
    assertEquals(shape2.getSubGridDiv(), shape2.getSubGridDiv());
    assertEquals(shape2.getGridLabelsColour(), shape.getGridLabelsColour());
    assertEquals(shape2.getSubGridColour(), shape.getSubGridColour());
    assertEqualsDouble(shape2.getUnit(), shape.getUnit());
    assertEqualsDouble(shape2.getGridWidth(), shape.getGridWidth());
    assertEqualsDouble(shape2.getSubGridWidth(), shape.getSubGridWidth());
    assertEquals(shape2.getSubGridDiv(), shape.getSubGridDiv());
    assertFalse(shape2.isXLabelSouth());
    assertFalse(shape2.isYLabelWest());
}
Also used : Grid(net.sf.latexdraw.model.api.shape.Grid) StandardGrid(net.sf.latexdraw.model.api.shape.StandardGrid) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 18 with Grid

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

the class TestCanvasCreation method testDrawGrid.

@Test
public void testDrawGrid() {
    final Point2D pos = point(canvas).query();
    Cmds.of(CmdFXVoid.of(() -> editing.setCurrentChoice(EditionChoice.GRID)), () -> moveTo(pos).clickOn(MouseButton.PRIMARY)).execute();
    assertEquals(1, drawing.size());
    assertTrue(drawing.getShapeAt(0).orElseThrow() instanceof Grid);
    final Grid sh = (Grid) drawing.getShapeAt(0).orElseThrow();
    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) Grid(net.sf.latexdraw.model.api.shape.Grid) Test(org.junit.Test)

Example 19 with Grid

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

the class TestHandGridStyle method testPickLineColourHand.

@Test
public void testPickLineColourHand() {
    Cmds.of(activateHand, selectionAddDot, selectionAddGrid, selectionAddGrid, updateIns).execute();
    final Color col = colourSubGrid.getValue();
    Cmds.of(pickcolourSubGrid).execute();
    assertEquals(colourSubGrid.getValue(), ((Grid) drawing.getSelection().getShapeAt(1).orElseThrow()).getSubGridColour().toJFX());
    assertEquals(colourSubGrid.getValue(), ((Grid) drawing.getSelection().getShapeAt(2).orElseThrow()).getSubGridColour().toJFX());
    assertNotEquals(col, colourSubGrid.getValue());
}
Also used : Color(javafx.scene.paint.Color) Grid(net.sf.latexdraw.model.api.shape.Grid) Test(org.junit.Test)

Example 20 with Grid

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

the class TestPencilGridStyle method testPickcolourLabelsColourPencil.

@Test
public void testPickcolourLabelsColourPencil() {
    Cmds.of(activatePencil, pencilCreatesGrid, updateIns).execute();
    final Color col = colourLabels.getValue();
    Cmds.of(pickcolourLabels).execute();
    assertEquals(colourLabels.getValue(), ((Grid) editing.createShapeInstance()).getGridLabelsColour().toJFX());
    assertNotEquals(col, colourLabels.getValue());
}
Also used : Color(javafx.scene.paint.Color) Grid(net.sf.latexdraw.model.api.shape.Grid) Test(org.junit.Test)

Aggregations

Grid (net.sf.latexdraw.model.api.shape.Grid)41 Test (org.junit.jupiter.api.Test)28 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)26 Test (org.junit.Test)8 Rectangle (net.sf.latexdraw.model.api.shape.Rectangle)5 Color (javafx.scene.paint.Color)4 HelperTest (net.sf.latexdraw.HelperTest)3 StandardGrid (net.sf.latexdraw.model.api.shape.StandardGrid)3 ValueSource (org.junit.jupiter.params.provider.ValueSource)3 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 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