Search in sources :

Example 86 with IPoint

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

the class LRectangularShape method mirrorVertical.

@Override
public void mirrorVertical(final double y) {
    super.mirrorVertical(y);
    if (getHeight() < 0d) {
        final IPoint tmp = ShapeFactory.INST.createPoint(points.get(0));
        points.get(0).setPoint(points.get(3));
        points.get(3).setPoint(tmp);
        tmp.setPoint(points.get(1));
        points.get(1).setPoint(points.get(2));
        points.get(2).setPoint(tmp);
    }
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 87 with IPoint

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

the class LShape method addToRotationAngle.

@Override
public void addToRotationAngle(final IPoint gravCentre, final double angle) {
    if (MathUtils.INST.isValidCoord(angle)) {
        setRotationAngle(getRotationAngle() + angle);
        if (gravCentre != null) {
            final IPoint gravityCentre = getGravityCentre();
            final IPoint rotatedGC = gravityCentre.rotatePoint(gravCentre, angle);
            translate(rotatedGC.getX() - gravityCentre.getX(), rotatedGC.getY() - gravityCentre.getY());
        }
    }
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 88 with IPoint

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

the class LShape method scaleSetPointsWithRatio.

protected void scaleSetPointsWithRatio(final List<IPoint> pts, final double prevWidth, final double prevHeight, final Position pos, final Rectangle2D bound) {
    final double s = Math.max(prevWidth / bound.getWidth(), prevHeight / bound.getHeight());
    final IPoint refPt = pos.getReferencePoint(bound);
    final double refX = refPt.getX();
    final double refY = refPt.getY();
    for (final IPoint pt : pts) {
        if (!MathUtils.INST.equalsDouble(pt.getX(), refX))
            pt.setX(refX + (pt.getX() - refX) * s);
        if (!MathUtils.INST.equalsDouble(pt.getY(), refY))
            pt.setY(refY + (pt.getY() - refY) * s);
    }
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 89 with IPoint

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

the class LShape method scaleSetPoints.

protected void scaleSetPoints(final List<IPoint> pts, final double prevWidth, final double prevHeight, final Position pos, final Rectangle2D bound) {
    final double sx = prevWidth / bound.getWidth();
    final double sy = prevHeight / bound.getHeight();
    final boolean xScale = pos.isEast() || pos.isWest();
    final boolean yScale = pos.isNorth() || pos.isSouth();
    final IPoint refPt = pos.getReferencePoint(bound);
    final double refX = refPt.getX();
    final double refY = refPt.getY();
    pts.forEach(pt -> {
        if (xScale && !MathUtils.INST.equalsDouble(pt.getX(), refX))
            pt.setX(refX + (pt.getX() - refX) * sx);
        if (yScale && !MathUtils.INST.equalsDouble(pt.getY(), refY))
            pt.setY(refY + (pt.getY() - refY) * sy);
    });
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 90 with IPoint

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

the class LShapeFactory method createPolygonFrom.

@Override
public IPolygon createPolygonFrom(final IPolygon 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 IPolygon copy = createPolygon(pts);
    copy.copy(sh);
    return copy;
}
Also used : ArrayList(java.util.ArrayList) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) IPolygon(net.sf.latexdraw.models.interfaces.shape.IPolygon)

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