use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.
the class Border method configureMovePointBinding.
private void configureMovePointBinding() {
nodeBinder(MovePointShape.class, new DnD()).on(mvPtHandlers).first((c, i) -> i.getSrcObject().filter(o -> o instanceof MovePtHandler).map(o -> (MovePtHandler) o).ifPresent(handler -> {
final IGroup group = canvas.getDrawing().getSelection();
if (group.size() == 1 && group.getShapeAt(0) instanceof IModifiablePointsShape) {
c.setPoint(handler.getPoint());
c.setShape((IModifiablePointsShape) group.getShapeAt(0));
}
})).then((c, i) -> i.getSrcObject().ifPresent(node -> {
final Point3D startPt = node.localToParent(i.getSrcLocalPoint());
final Point3D endPt = node.localToParent(i.getEndLocalPt());
final IPoint ptToMove = ((MovePtHandler) node).getPoint();
final double x = ptToMove.getX() + endPt.getX() - startPt.getX();
final double y = ptToMove.getY() + endPt.getY() - startPt.getY();
c.setNewCoord(grid.getTransformedPointToGrid(new Point3D(x, y, 0d)));
})).exec().when(i -> i.getSrcLocalPoint() != null && i.getEndLocalPt() != null && i.getSrcObject().orElse(null) instanceof MovePtHandler).bind();
}
use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.
the class Border method configureBindings.
@Override
protected void configureBindings() {
addBinding(new DnD2Scale(this));
configureMovePointBinding();
nodeBinder(MoveCtrlPoint.class, new DnD()).on(ctrlPt1Handlers).on(ctrlPt2Handlers).first((c, i) -> {
final IGroup group = canvas.getDrawing().getSelection();
if (group.size() == 1 && group.getShapeAt(0) instanceof IControlPointShape) {
c.setPoint(i.getSrcObject().map(h -> ((CtrlPointHandler) h).getPoint()).orElse(null));
c.setShape((IControlPointShape) group.getShapeAt(0));
c.setIsFirstCtrlPt(ctrlPt1Handlers.contains(i.getSrcObject().orElse(null)));
}
}).then((c, i) -> {
final Point3D startPt = i.getSrcObject().map(n -> n.localToParent(i.getSrcLocalPoint())).orElse(new Point3D(0d, 0d, 0d));
final Point3D endPt = i.getSrcObject().map(n -> n.localToParent(i.getEndLocalPt())).orElse(new Point3D(0d, 0d, 0d));
final IPoint ptToMove = i.getSrcObject().map(n -> ((CtrlPointHandler) n).getPoint()).orElse(ShapeFactory.INST.createPoint());
final double x = ptToMove.getX() + endPt.getX() - startPt.getX();
final double y = ptToMove.getY() + endPt.getY() - startPt.getY();
c.setNewCoord(grid.getTransformedPointToGrid(new Point3D(x, y, 0d)));
}).exec().bind();
nodeBinder(RotateShapes.class, new DnD()).on(rotHandler).first((c, i) -> {
final IDrawing drawing = canvas.getDrawing();
c.setGravityCentre(drawing.getSelection().getGravityCentre());
c.getGc().translate(canvas.getOrigin().getX(), canvas.getOrigin().getY());
c.setShape(drawing.getSelection().duplicateDeep(false));
}).then((c, i) -> c.setRotationAngle(c.getGc().computeRotationAngle(ShapeFactory.INST.createPoint(canvas.sceneToLocal(i.getSrcScenePoint())), ShapeFactory.INST.createPoint(canvas.sceneToLocal(i.getEndScenePt()))))).exec().bind();
addBinding(new DnD2ArcAngle(this));
}
use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.
the class MoveCtrlPoint method move.
private void move(final IPoint firstPt, final IPoint sndPt) {
final int indexPt = getIndexCtrlPt();
shape.setXFirstCtrlPt(firstPt.getX(), indexPt);
shape.setYFirstCtrlPt(firstPt.getY(), indexPt);
shape.setXSecondCtrlPt(sndPt.getX(), indexPt);
shape.setYSecondCtrlPt(sndPt.getY(), indexPt);
shape.setModified(true);
}
use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.
the class TestIGroup method testGetAxesDistLabelsOk.
@Test
public void testGetAxesDistLabelsOk() {
IPoint pt = ShapeFactory.INST.createPoint(10d, 11d);
init4getAxes().setDistLabels(pt);
assertEquals(pt, shape.getDistLabels());
}
use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.
the class TestIGroup method testSetAxesIncrement.
@Test
public void testSetAxesIncrement() {
init4setAxes();
IPoint pt = ShapeFactory.INST.createPoint(13d, 14d);
shape.setIncrement(pt);
shape.getShapes().stream().filter(sh -> sh instanceof IAxes).map(sh -> (IAxes) sh).forEach(sh -> assertEquals(pt, sh.getIncrement()));
}
Aggregations