use of net.sf.latexdraw.model.api.shape.Shape in project latexdraw by arnobl.
the class TestPSTShape method testLoadRotationAngleParams.
@Override
@ParameterizedTest
@MethodSource("net.sf.latexdraw.data.ShapeSupplier#getDiversifiedShapes")
public void testLoadRotationAngleParams(final Shape sh) {
assumeFalse(sh instanceof Polygon || sh instanceof BezierCurve);
final Shape s2 = produceOutputShapeFrom(sh);
CompareShapeMatcher.INST.assertEqualShapeRotationAngle(sh, s2);
}
use of net.sf.latexdraw.model.api.shape.Shape in project latexdraw by arnobl.
the class TestPSTShape method testFreeHandPointsCurves.
@Test
public void testFreeHandPointsCurves() {
final Freehand fh = ShapeFactory.INST.createFreeHand(Arrays.asList(ShapeFactory.INST.createPoint(50d, 70d), ShapeFactory.INST.createPoint(100d, 90d), ShapeFactory.INST.createPoint(110d, 100d), ShapeFactory.INST.createPoint(150d, 180d)));
fh.setInterval(1);
fh.setType(FreeHandStyle.CURVES);
final Shape s2 = produceOutputShapeFrom(fh);
assertThat(s2.getPoints()).isEqualTo(Arrays.asList(ShapeFactory.INST.createPoint(50d, 70d), ShapeFactory.INST.createPoint(75d, 80d), ShapeFactory.INST.createPoint(105d, 95d), ShapeFactory.INST.createPoint(130d, 140d)));
}
use of net.sf.latexdraw.model.api.shape.Shape in project latexdraw by arnobl.
the class Canvas method defineShapeListBindingOnAdd.
private void defineShapeListBindingOnAdd(@NotNull final Change<? extends Shape> evt) {
final List<? extends Shape> added = List.copyOf(evt.getAddedSubList());
Platform.runLater(() -> added.forEach(sh -> viewFactory.createView(sh).ifPresent(v -> {
final int index = drawing.getShapes().indexOf(sh);
if (index != -1) {
shapesToViewMap.put(sh, v);
if (index == drawing.size()) {
shapesPane.getChildren().add(v);
} else {
shapesPane.getChildren().add(index, v);
}
}
})));
}
use of net.sf.latexdraw.model.api.shape.Shape in project latexdraw by arnobl.
the class Canvas method updateSelectionBorders.
private void updateSelectionBorders() {
if (selectionBorder.isDisable()) {
return;
}
final List<Shape> selection = List.copyOf(drawing.getSelection().getShapes());
if (selection.isEmpty()) {
selectionBorder.setVisible(false);
} else {
final Rectangle2D rec = selection.stream().map(sh -> shapesToViewMap.get(sh)).filter(vi -> vi != null).map(vi -> {
final Bounds b = vi.getBoundsInParent();
return (Rectangle2D) new Rectangle2D.Double(b.getMinX(), b.getMinY(), b.getWidth(), b.getHeight());
}).reduce(Rectangle2D::createUnion).orElseGet(() -> new Rectangle2D.Double());
setVisibleSelectionBorder(rec.getMinX(), rec.getMinY(), rec.getWidth(), rec.getHeight(), false);
}
}
use of net.sf.latexdraw.model.api.shape.Shape in project latexdraw by arnobl.
the class TestShapePositioner method testOneShapeForeground.
@Test
public void testOneShapeForeground() {
Cmds.of(selectOneShape, selectOneShape).execute();
selectShapeAt.execute(Collections.singletonList(0));
final Shape s1 = drawing.getShapeAt(0).orElseThrow();
final Shape s2 = drawing.getShapeAt(1).orElseThrow();
Cmds.of(() -> clickOn("#foregroundB")).execute();
assertEquals(s2, drawing.getShapeAt(0).orElseThrow());
assertEquals(s1, drawing.getShapeAt(1).orElseThrow());
}
Aggregations