Search in sources :

Example 61 with Point

use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.

the class PlotViewComputation method fillPoints.

default List<Point> fillPoints(final Plot shape, final double posX, final double posY, final double minX, final double maxX, final double step) {
    final double xs = shape.getXScale();
    final double ys = shape.getYScale();
    double x = minX;
    final List<Point> pts = new ArrayList<>();
    if (shape.isPolar()) {
        for (int i = 0; i < shape.getNbPlottedPoints(); i++, x += step) {
            pts.add(getPolarPoint(shape, x, xs, ys, posX, posY));
        }
    } else {
        for (int i = 0; i < shape.getNbPlottedPoints(); i++, x += step) {
            pts.add(ShapeFactory.INST.createPoint(x * Shape.PPC * xs + posX, -shape.getY(x) * Shape.PPC * ys + posY));
        }
    }
    return pts;
}
Also used : ArrayList(java.util.ArrayList) Point(net.sf.latexdraw.model.api.shape.Point) Point(net.sf.latexdraw.model.api.shape.Point)

Example 62 with Point

use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.

the class Canvas method convertToOrigin.

/**
 * Converts the given point in the coordinate system based on the canvas' origin. The given
 * point must be in the coordinate system of a container widget (the top-left point is the origin).
 * @param pt The point to convert.
 * @return The converted point or null if the given point is null.
 */
public Point convertToOrigin(final Point pt) {
    final Point convertion;
    if (pt == null) {
        convertion = null;
    } else {
        convertion = ShapeFactory.INST.createPoint(pt);
        convertion.translate(-ORIGIN.getX(), -ORIGIN.getY());
    }
    return convertion;
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point)

Example 63 with Point

use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.

the class LineImpl method getBottomRightPoint.

@Override
@NotNull
public Point getBottomRightPoint() {
    final Point pt1 = getPoint1();
    final Point pt2 = getPoint2();
    return ShapeFactory.INST.createPoint(Math.max(pt1.getX(), pt2.getX()), Math.max(pt1.getY(), pt2.getY()));
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) NotNull(org.jetbrains.annotations.NotNull)

Example 64 with Point

use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.

the class LineImpl method getTopLeftPoint.

@Override
@NotNull
public Point getTopLeftPoint() {
    final Point pt1 = getPoint1();
    final Point pt2 = getPoint2();
    return ShapeFactory.INST.createPoint(Math.min(pt1.getX(), pt2.getX()), Math.min(pt1.getY(), pt2.getY()));
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) NotNull(org.jetbrains.annotations.NotNull)

Example 65 with Point

use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.

the class LineImpl method getPerpendicularLine.

@Override
public Line getPerpendicularLine(final Point pt) {
    if (!MathUtils.INST.isValidPt(pt)) {
        return null;
    }
    if (isVerticalLine()) {
        return MathUtils.INST.equalsDouble(pt.getX(), x1) ? ShapeFactory.INST.createLine(pt.getY(), ShapeFactory.INST.createPoint(pt)) : null;
    }
    if (MathUtils.INST.equalsDouble(pt.getX(), 0.0)) {
        final Point pt3 = ShapeFactory.INST.createPoint(getPoint2());
        final Point pt2 = pt3.rotatePoint(pt, Math.PI / 2.0);
        return ShapeFactory.INST.createLine(pt2, pt);
    }
    if (MathUtils.INST.equalsDouble(a, 0.0)) {
        return ShapeFactory.INST.createLine(pt.getX(), pt.getY(), pt.getX(), pt.getY() - 10.0);
    }
    final double a2 = -1.0 / a;
    return ShapeFactory.INST.createLine(pt.getY() - a2 * pt.getX(), pt);
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point)

Aggregations

Point (net.sf.latexdraw.model.api.shape.Point)139 Test (org.junit.Test)52 HelperTest (net.sf.latexdraw.HelperTest)27 Theory (org.junit.experimental.theories.Theory)23 NotNull (org.jetbrains.annotations.NotNull)19 Line (net.sf.latexdraw.model.api.shape.Line)10 Shape (net.sf.latexdraw.model.api.shape.Shape)9 SVGElement (net.sf.latexdraw.parser.svg.SVGElement)9 SVGGElement (net.sf.latexdraw.parser.svg.SVGGElement)9 Test (org.junit.jupiter.api.Test)8 ArrayList (java.util.ArrayList)7 Polyline (net.sf.latexdraw.model.api.shape.Polyline)5 Color (javafx.scene.paint.Color)4 MathUtils (net.sf.latexdraw.model.MathUtils)4 ShapeFactory (net.sf.latexdraw.model.ShapeFactory)4 BezierCurve (net.sf.latexdraw.model.api.shape.BezierCurve)4 Canvas (net.sf.latexdraw.view.jfx.Canvas)4 Point2D (java.awt.geom.Point2D)3 List (java.util.List)3 ShapeData (net.sf.latexdraw.data.ShapeData)3