Search in sources :

Example 81 with IPoint

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

the class LModifiablePointsShape method setPoint.

@Override
public boolean setPoint(final double x, final double y, final int position) {
    if (!MathUtils.INST.isValidPt(x, y) || position < -1 || position > points.size() || points.isEmpty())
        return false;
    final IPoint p = position == -1 ? points.get(points.size() - 1) : points.get(position);
    p.setPoint(x, y);
    return true;
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 82 with IPoint

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

the class LPlot method getBottomRightPoint.

@Override
public IPoint getBottomRightPoint() {
    final double step = getPlottingStep();
    final IPoint pos = getPosition();
    final double plotMinX = getPlotMinX();
    final double yMin = IntStream.range(0, getNbPlottedPoints()).mapToDouble(x -> getY(plotMinX + x * step)).min().orElse(0.0);
    return ShapeFactory.INST.createPoint(pos.getX() + getPlotMaxX() * IShape.PPC * getXScale(), pos.getY() - yMin * IShape.PPC * getYScale());
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 83 with IPoint

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

the class LPlot method getTopRightPoint.

@Override
public IPoint getTopRightPoint() {
    final double step = getPlottingStep();
    final IPoint pos = getPosition();
    final double plotMinX = getPlotMinX();
    final double maxY = IntStream.range(0, getNbPlottedPoints()).mapToDouble(x -> getY(plotMinX + x * step)).max().orElse(0.0);
    return ShapeFactory.INST.createPoint(pos.getX() + getPlotMaxX() * IShape.PPC * getXScale(), pos.getY() - maxY * IShape.PPC * getYScale());
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 84 with IPoint

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

the class LPlot method getTopLeftPoint.

@Override
public IPoint getTopLeftPoint() {
    final double step = getPlottingStep();
    final IPoint pos = getPosition();
    final double plotMinX = getPlotMinX();
    final double yMax = IntStream.range(0, getNbPlottedPoints()).mapToDouble(x -> getY(plotMinX + x * step)).max().orElse(0.0);
    return ShapeFactory.INST.createPoint(pos.getX() + plotMinX * IShape.PPC * getXScale(), pos.getY() - yMax * IShape.PPC * getYScale());
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 85 with IPoint

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

the class LPositionShape method setPosition.

@Override
public void setPosition(final double x, final double y) {
    if (MathUtils.INST.isValidPt(x, y)) {
        final IPoint pos = getPosition();
        translate(x - pos.getX(), y - pos.getY());
    }
}
Also used : 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