use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class LineImpl method getIntersectionSegment.
@Override
public Point getIntersectionSegment(final Line l) {
final Point p = getIntersection(l);
if (p == null) {
return null;
}
final double px = p.getX();
final double py = p.getY();
final Point tl = getTopLeftPoint();
final Point br = getBottomRightPoint();
final Point tl2 = l.getTopLeftPoint();
final Point br2 = l.getBottomRightPoint();
if (px >= tl.getX() && px <= br.getX() && py >= tl.getY() && py <= br.getY() && px >= tl2.getX() && px <= br2.getX() && py >= tl2.getY() && py <= br2.getY()) {
return p;
}
return null;
}
use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class ShapeFactoryImpl method createPolygonFrom.
@Override
@NotNull
public Polygon createPolygonFrom(final Polygon sh, final Point pointToAdd) {
if (sh == null || !MathUtils.INST.isValidPt(pointToAdd)) {
throw new IllegalArgumentException();
}
final List<Point> pts = new ArrayList<>(sh.getPoints());
pts.add(pointToAdd);
final Polygon copy = createPolygon(pts);
copy.copy(sh);
return copy;
}
use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class ShapeFactoryImpl method createFreeHandFrom.
@Override
@NotNull
public Freehand createFreeHandFrom(final Freehand sh, final Point pointToAdd) {
if (sh == null || !MathUtils.INST.isValidPt(pointToAdd)) {
throw new IllegalArgumentException();
}
final List<Point> pts = new ArrayList<>(sh.getPoints());
pts.add(pointToAdd);
final Freehand copy = createFreeHand(pts);
copy.copy(sh);
return copy;
}
use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class ShapeFactoryImpl method createPolylineFrom.
@Override
@NotNull
public Polyline createPolylineFrom(final Polyline sh, final Point pointToAdd) {
if (sh == null || !MathUtils.INST.isValidPt(pointToAdd)) {
throw new IllegalArgumentException();
}
final List<Point> pts = new ArrayList<>(sh.getPoints());
pts.add(pointToAdd);
final Polyline copy = createPolyline(pts);
copy.copy(sh);
return copy;
}
use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class TestCanvasTranslation method testTranslateOnSelectionRectangle.
@Test
public void testTranslateOnSelectionRectangle() {
Cmds.of(addRec).execute();
final Point tl = canvas.getDrawing().getShapeAt(0).orElseThrow().getTopLeftPoint();
Cmds.of(() -> clickOn(canvas.getViews().getChildren().get(0))).execute();
final Point2D bounds = canvas.localToScreen(canvas.getSelectionBorder().getLayoutX() + Canvas.getMargins(), canvas.getSelectionBorder().getLayoutY() + Canvas.getMargins());
Cmds.of(() -> drag(bounds.getX() + 150, bounds.getY()), () -> dropBy(100d, 200d)).execute();
assertEquals(tl.getX() + 100d, canvas.getDrawing().getShapeAt(0).orElseThrow().getTopLeftPoint().getX(), 1d);
assertEquals(tl.getY() + 200d, canvas.getDrawing().getShapeAt(0).orElseThrow().getTopLeftPoint().getY(), 1d);
}
Aggregations