Search in sources :

Example 91 with IPoint

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

the class LShapeFactory method createBezierCurveFrom.

@Override
public IBezierCurve createBezierCurveFrom(final IBezierCurve bc, final IPoint pointToAdd) {
    if (bc == null || !MathUtils.INST.isValidPt(pointToAdd))
        return null;
    final List<IPoint> pts = new ArrayList<>(bc.getPoints());
    final List<IPoint> ptsCtrl = new ArrayList<>(bc.getFirstCtrlPts());
    pts.add(pointToAdd);
    ptsCtrl.add(createPoint(pointToAdd.getX(), pointToAdd.getY() + IBezierCurve.DEFAULT_POSITION_CTRL));
    final IBezierCurve copy = new LBezierCurve(pts, ptsCtrl);
    copy.copy(bc);
    return copy;
}
Also used : IBezierCurve(net.sf.latexdraw.models.interfaces.shape.IBezierCurve) ArrayList(java.util.ArrayList) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 92 with IPoint

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

the class LShapeFactory method createFreeHandFrom.

@Override
public IFreehand createFreeHandFrom(final IFreehand sh, final IPoint pointToAdd) {
    if (sh == null || !MathUtils.INST.isValidPt(pointToAdd))
        return null;
    final List<IPoint> pts = new ArrayList<>(sh.getPoints());
    pts.add(pointToAdd);
    final IFreehand copy = createFreeHand(pts);
    copy.copy(sh);
    return copy;
}
Also used : IFreehand(net.sf.latexdraw.models.interfaces.shape.IFreehand) ArrayList(java.util.ArrayList) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 93 with IPoint

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

the class LSquaredShape method setWidth.

@Override
public void setWidth(final double width) {
    if (MathUtils.INST.isValidCoord(width) && width > 0) {
        final IPoint pt = points.get(points.size() - 1);
        final double xPos = pt.getX() + width;
        final double yPos = pt.getY() - width;
        points.get(1).setX(xPos);
        points.get(2).setX(xPos);
        points.get(0).setY(yPos);
        points.get(1).setY(yPos);
    }
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 94 with IPoint

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

the class ShapeCoordDimCustomiser method update.

@Override
protected void update(final IGroup shape) {
    if (shape.isEmpty() || !hand.isActivated()) {
        setActivated(false);
    } else {
        setActivated(true);
        final IPoint tl = shape.getTopLeftPoint();
        tlxS.getValueFactory().setValue(tl.getX());
        tlyS.getValueFactory().setValue(tl.getY());
    }
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 95 with IPoint

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

the class LGroup method setGridStartList.

@Override
public void setGridStartList(final List<IPoint> values) {
    if (values != null && values.size() == shapes.size()) {
        IntStream.range(0, values.size()).forEach(i -> {
            final IShape sh = shapes.get(i);
            final IPoint pt = values.get(i);
            if (pt != null && sh instanceof IStdGridProp) {
                ((IStdGridProp) sh).setGridStart(pt.getX(), pt.getY());
            }
        });
    }
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) IShape(net.sf.latexdraw.models.interfaces.shape.IShape) IStdGridProp(net.sf.latexdraw.models.interfaces.prop.IStdGridProp)

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