use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class AutoGridTest method testGrid2.
@Test
public void testGrid2() {
final double size = 2.5;
final double padding = 0.5;
final Direction direction = Direction.SOUTH;
final BoundingBox boundingBox = new BoundingBox(0d, 0d, 100d, 100d);
tested = new AutoGrid.Builder().forBoundingBox(boundingBox).withIconSize(size).withPadding(padding).towards(direction).build();
assertEquals(size, tested.getIconSize(), 0);
assertEquals(padding, tested.getPadding(), 0);
assertEquals(direction, tested.getDirection());
assertEquals(100, tested.getMaxSize(), 0);
assertEquals((size + padding) / 2, tested.getMargin(), 0);
final List<Point2D> expectedPoints = new ArrayList<>();
final Iterator<Point2D> points = tested.iterator();
int count = 5;
for (int i = 0; i < count; i++) {
final Point2D point = points.next();
expectedPoints.add(point);
}
assertEquals(5, expectedPoints.size());
assertEquals(new Point2D(0d, 0d), expectedPoints.get(0));
assertEquals(new Point2D(0d, 3d), expectedPoints.get(1));
assertEquals(new Point2D(0d, 6d), expectedPoints.get(2));
assertEquals(new Point2D(0d, 9d), expectedPoints.get(3));
assertEquals(new Point2D(0d, 12d), expectedPoints.get(4));
}
use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class ItemGridImplTest method testInit.
@Test
public void testInit() {
assertEquals(group, tested.asPrimitive());
assertEquals(group, tested.getPrimitive());
assertEquals(groupItem, tested.getWrapped());
assertFalse(tested.isVisible());
assertEquals(2, tested.size());
assertTrue(tested.iterator().hasNext());
verify(button1, times(1)).hide();
verify(button1, never()).show();
verify(button2, times(1)).hide();
verify(button2, never()).show();
verify(groupItemWrap, times(1)).add(button1Prim);
verify(groupItemWrap, times(1)).add(button2Prim);
final BoundingBox boundingBox = tested.getBoundingBox().get();
assertEquals(0, boundingBox.getX(), 0);
assertEquals(0, boundingBox.getY(), 0);
assertEquals(11, boundingBox.getWidth(), 0);
assertEquals(11, boundingBox.getHeight(), 0);
}
use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class LienzoCanvasExport method layerToDataURL.
private static String layerToDataURL(final com.ait.lienzo.client.core.shape.Layer layer, final DataURLType dataURLType, final int x, final int y, final int width, final int height, final String bgColor) {
ScratchPad scratchPad = layer.getScratchPad();
if (null != bgColor) {
scratchPad.getContext().setFillColor(bgColor);
scratchPad.getContext().fillRect(x, y, width, height);
}
layer.drawWithTransforms(scratchPad.getContext(), 1, new BoundingBox(x, y, width, height));
final String data = scratchPad.toDataURL(dataURLType, 1);
scratchPad.clear();
return data;
}
use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class LocationControlImpl method ensureDragConstraints.
@SuppressWarnings("unchecked")
private void ensureDragConstraints(final HasDragBounds<?> shapeView) {
if (null == boundsConstraint) {
boundsConstraint = getLocationBounds();
// Selection multiple bounding constraints.
getWiresManager().getSelectionManager().getControl().setBoundsConstraint(new BoundingBox(boundsConstraint[0], boundsConstraint[1], boundsConstraint[2], boundsConstraint[3]));
}
// Shape drag bounds.
shapeView.setDragBounds(boundsConstraint[0], boundsConstraint[1], boundsConstraint[2], boundsConstraint[3]);
}
use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class LocationControlImplTest method testRegisterAndSetBounds.
@Test
public void testRegisterAndSetBounds() {
tested.enable(canvasHandler);
assertFalse(tested.isRegistered(element));
tested.register(element);
assertTrue(tested.isRegistered(element));
verify(shapeView, times(1)).setDragEnabled(eq(true));
ArgumentCaptor<BoundingBox> bbCaptor = ArgumentCaptor.forClass(BoundingBox.class);
verify(wiresCompositeControl, times(1)).setBoundsConstraint(bbCaptor.capture());
BoundingBox bb = bbCaptor.getValue();
assertEquals(1.0d, bb.getMinX(), 0d);
assertEquals(2.0d, bb.getMinY(), 0d);
assertEquals(3000.0d, bb.getMaxX(), 0d);
assertEquals(4000.0d, bb.getMaxY(), 0d);
verify(shapeView, times(1)).setDragBounds(1.0d, 2.0d, 3000d, 4000d);
verify(shapeEventHandler, times(1)).supports(eq(ViewEventType.MOUSE_ENTER));
verify(shapeEventHandler, times(1)).addHandler(eq(ViewEventType.MOUSE_ENTER), any(MouseEnterHandler.class));
verify(shapeEventHandler, times(1)).supports(eq(ViewEventType.MOUSE_EXIT));
verify(shapeEventHandler, times(1)).addHandler(eq(ViewEventType.MOUSE_EXIT), any(MouseEnterHandler.class));
}
Aggregations