Search in sources :

Example 11 with IAxes

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

the class TestParsingPsaxes method testParamDx.

@Theory
public void testParamDx(@DoubleData(vals = { 2d, 3.5 }) final double dx) {
    parser("\\psaxes[Dx=" + dx + "](0,0)(0,0)(2,2)");
    final IAxes axes = getShapeAt(0);
    assertEquals(dx, axes.getIncrementX(), 0.00001);
}
Also used : IAxes(net.sf.latexdraw.models.interfaces.shape.IAxes) Theory(org.junit.experimental.theories.Theory)

Example 12 with IAxes

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

the class TestParsingPsaxes method testLabelsStyle.

@Theory
public void testLabelsStyle(final PlottingStyle style) {
    parser("\\psaxes[labels=" + style.getPSTToken() + "](0,0)(0,0)(2,2)");
    final IAxes axes = getShapeAt(0);
    assertEquals(style, axes.getLabelsDisplayed());
}
Also used : IAxes(net.sf.latexdraw.models.interfaces.shape.IAxes) Theory(org.junit.experimental.theories.Theory)

Example 13 with IAxes

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

the class TestIAxes method testDuplicate.

@Test
public void testDuplicate() {
    shape.setIncrementX(24);
    shape.setIncrementY(28);
    shape.setAxesStyle(AxesStyle.FRAME);
    shape.setTicksStyle(TicksStyle.BOTTOM);
    shape.setDistLabelsX(12);
    shape.setDistLabelsY(112);
    shape.setShowOrigin(false);
    shape.setTicksDisplayed(PlottingStyle.NONE);
    shape.setTicksSize(34);
    IAxes s2 = shape.duplicate();
    assertNotNull(s2);
    assertEqualsDouble(s2.getIncrementX(), shape.getIncrementX());
    assertEqualsDouble(s2.getIncrementY(), shape.getIncrementY());
    assertEquals(s2.getAxesStyle(), shape.getAxesStyle());
    assertEqualsDouble(s2.getTicksSize(), shape.getTicksSize());
    assertEquals(s2.getTicksDisplayed(), shape.getTicksDisplayed());
    assertEquals(s2.getTicksStyle(), shape.getTicksStyle());
    assertEqualsDouble(s2.getDistLabelsX(), shape.getDistLabelsX());
    assertEqualsDouble(s2.getDistLabelsY(), shape.getDistLabelsY());
    assertEquals(s2.isShowOrigin(), shape.isShowOrigin());
}
Also used : IAxes(net.sf.latexdraw.models.interfaces.shape.IAxes) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 14 with IAxes

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

the class TestIAxes method testConstructor3OK.

@Test
public void testConstructor3OK() {
    IAxes axes = ShapeFactory.INST.createAxes(ShapeFactory.INST.createPoint(10, -20));
    assertNotNull(axes.getPtAt(0));
    assertEqualsDouble(10d, axes.getPtAt(0).getX());
    assertEqualsDouble(-20d, axes.getPtAt(0).getY());
}
Also used : IAxes(net.sf.latexdraw.models.interfaces.shape.IAxes) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 15 with IAxes

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

the class GenericAxes method updatePathTicksX.

default void updatePathTicksX(final double gapx, final TicksStyle ticksStyle, final double tickLgth) {
    final IAxes model = getModel();
    final boolean noArrowLeftX = model.getArrowStyle(1) == ArrowStyle.NONE || model.getGridMinX() == model.getOriginX();
    final boolean noArrowRightX = model.getArrowStyle(3) == ArrowStyle.NONE || model.getGridMaxX() == model.getOriginX();
    final double distX = model.getDistLabelsX();
    final double y;
    switch(ticksStyle) {
        case FULL:
            y = tickLgth / 2d;
            break;
        case TOP:
            y = 0d;
            break;
        default:
            y = tickLgth;
    }
    for (double incrx = model.getIncrementX(), maxx = model.getGridMaxX() / distX, minx = model.getGridMinX() / distX, i = minx * incrx; i <= maxx * incrx; i += incrx * distX) {
        final int inti = (int) i;
        if (isElementPaintable(noArrowLeftX, noArrowRightX, minx, maxx, inti)) {
            final double x = inti * gapx;
            createPathTicksMoveTo(x, y);
            createPathTicksLineTo(x, y - tickLgth);
        }
    }
}
Also used : IAxes(net.sf.latexdraw.models.interfaces.shape.IAxes)

Aggregations

IAxes (net.sf.latexdraw.models.interfaces.shape.IAxes)50 Theory (org.junit.experimental.theories.Theory)28 Test (org.junit.Test)12 IArrowableSingleShape (net.sf.latexdraw.models.interfaces.shape.IArrowableSingleShape)10 HelperTest (net.sf.latexdraw.HelperTest)7 IShape (net.sf.latexdraw.models.interfaces.shape.IShape)5 PlottingStyle (net.sf.latexdraw.models.interfaces.shape.PlottingStyle)4 TicksStyle (net.sf.latexdraw.models.interfaces.shape.TicksStyle)4 IDot (net.sf.latexdraw.models.interfaces.shape.IDot)3 IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)3 IRectangle (net.sf.latexdraw.models.interfaces.shape.IRectangle)3 Collections (java.util.Collections)2 ShapeData (net.sf.latexdraw.data.ShapeData)2 ShapeFactory (net.sf.latexdraw.models.ShapeFactory)2 ArrowStyle (net.sf.latexdraw.models.interfaces.shape.ArrowStyle)2 AxesStyle (net.sf.latexdraw.models.interfaces.shape.AxesStyle)2 BorderPos (net.sf.latexdraw.models.interfaces.shape.BorderPos)2 DotStyle (net.sf.latexdraw.models.interfaces.shape.DotStyle)2 FillingStyle (net.sf.latexdraw.models.interfaces.shape.FillingStyle)2 IGroup (net.sf.latexdraw.models.interfaces.shape.IGroup)2