use of net.sf.latexdraw.models.interfaces.shape.IDrawing 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.IDrawing in project latexdraw by arnobl.
the class TestIDrawing method testConstructor.
@Test
public void testConstructor() {
IDrawing d = ShapeFactory.INST.createDrawing();
assertNotNull(d.getSelection());
assertNotNull(d.getShapes());
}
Aggregations