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;
}
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;
}
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()));
}
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()));
}
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);
}
Aggregations