Search in sources :

Example 71 with IPoint

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

the class LDot method getLazyTopLeftPoint.

@Override
public IPoint getLazyTopLeftPoint() {
    final IPoint centre = getPosition();
    final double diam = getDiametre();
    return ShapeFactory.INST.createPoint(centre.getX() - diam / 2d, centre.getY() - diam / 2d);
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 72 with IPoint

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

the class LDot method getBottomLeftPoint.

@Override
public IPoint getBottomLeftPoint() {
    final IPoint tl = ShapeFactory.INST.createPoint();
    final IPoint br = ShapeFactory.INST.createPoint();
    getTopLeftBottomRightPoints(tl, br);
    return ShapeFactory.INST.createPoint(tl.getX(), br.getY());
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 73 with IPoint

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

the class LEllipse method setCentre.

@Override
public void setCentre(final IPoint centre) {
    if (MathUtils.INST.isValidPt(centre)) {
        final IPoint gc = getGravityCentre();
        translate(centre.getX() - gc.getX(), centre.getY() - gc.getY());
    }
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 74 with IPoint

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

the class LGrid method scaleWithRatio.

@Override
public void scaleWithRatio(final double x, final double y, final Position pos, final Rectangle2D bound) {
    if (pos == null || bound == null)
        return;
    final double sx = x / bound.getWidth();
    final double sy = y / bound.getHeight();
    final double u = getUnit();
    switch(pos) {
        case WEST:
        case SW:
            if (u + sx - 1d >= 0.5) {
                setUnit(u + sx - 1d);
            }
            break;
        case SOUTH:
            if (u + sy - 1d >= 0.5) {
                setUnit(u + sy - 1d);
            }
            break;
        case NORTH:
        case NW:
            if (u + sy - 1d >= 0.5) {
                setUnit(u + sy - 1d);
                translate(0., -getTopRightPoint().getY() + bound.getY());
            }
            break;
        case NE:
            if (u + sy - 1d >= 0.5) {
                setUnit(u + sy - 1d);
                final IPoint tr = getTopRightPoint();
                translate(-tr.getX() + bound.getMaxX(), -tr.getY() + bound.getY());
            }
            break;
        case EAST:
        case SE:
            if (u + sx - 1d >= 0.5) {
                setUnit(u + sx - 1d);
                translate(-getTopRightPoint().getX() + bound.getMaxX(), 0d);
            }
            break;
    }
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 75 with IPoint

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

the class LAbstractCtrlPointShape method balance.

@Override
public void balance() {
    final int size = getNbPoints();
    // Works only with more than 2 points.
    if (size < 3) {
        return;
    }
    IPoint ptPrev;
    IPoint ptNext;
    // Balancing all the points except the first and the last one.
    for (int i = 1; i < size - 1; i++) {
        ptPrev = points.get(i - 1);
        ptNext = points.get(i + 1);
        setControlPoints(i, getBalancedPoints(points.get(i), ptPrev, ptNext));
    }
    // Balancing the first and the last points.
    ptPrev = points.get(size - 1);
    ptNext = points.get(1);
    setControlPoints(0, getBalancedPoints(points.get(0), ptPrev, ptNext));
    ptPrev = points.get(size - 2);
    ptNext = points.get(0);
    setControlPoints(size - 1, getBalancedPoints(points.get(size - 1), ptPrev, ptNext));
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Aggregations

IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)191 Test (org.junit.Test)45 HelperTest (net.sf.latexdraw.HelperTest)25 Theory (org.junit.experimental.theories.Theory)21 IShape (net.sf.latexdraw.models.interfaces.shape.IShape)15 SVGElement (net.sf.latexdraw.parsers.svg.SVGElement)11 SVGGElement (net.sf.latexdraw.parsers.svg.SVGGElement)11 ShapeFactory (net.sf.latexdraw.models.ShapeFactory)10 ILine (net.sf.latexdraw.models.interfaces.shape.ILine)10 IBezierCurve (net.sf.latexdraw.models.interfaces.shape.IBezierCurve)9 IGroup (net.sf.latexdraw.models.interfaces.shape.IGroup)9 ArrayList (java.util.ArrayList)8 MathUtils (net.sf.latexdraw.models.MathUtils)8 Collections (java.util.Collections)7 IPolygon (net.sf.latexdraw.models.interfaces.shape.IPolygon)7 Arrays (java.util.Arrays)6 Cursor (javafx.scene.Cursor)6 BorderPos (net.sf.latexdraw.models.interfaces.shape.BorderPos)6 IModifiablePointsShape (net.sf.latexdraw.models.interfaces.shape.IModifiablePointsShape)6 Inject (net.sf.latexdraw.util.Inject)6