use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class ConnectorGlyphLienzoRenderer method scaleTo.
private void scaleTo(final Group group, final double width, final double height) {
final BoundingBox bb = group.getBoundingBox();
final double w = bb.getWidth();
final double h = bb.getHeight();
final double sw = w > 0 ? (width / w) : 1;
final double sh = h > 0 ? (height / h) : 1;
group.setScale(sw, sh);
}
use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class LienzoMultipleSelectionControlTest method testOnShapeLocationsChanged.
@Test
public void testOnShapeLocationsChanged() {
// Different canvas
when(shapeLocationsChangedEvent.getCanvasHandler()).thenReturn(mock(CanvasHandler.class));
tested.onShapeLocationsChanged(shapeLocationsChangedEvent);
verify(selectedItems, never()).rebuildBoundingBox();
verify(selectionManager, never()).drawSelectionShape(eq(MIN_WIDTH), eq(MIN_HEIGHT), eq(MAX_WIDTH), eq(MAX_HEIGHT), eq(overLayer));
// Same canvas no selectedItems
when(shapeLocationsChangedEvent.getCanvasHandler()).thenReturn(canvasHandler);
when(shapeLocationsChangedEvent.getUuids()).thenReturn(new ArrayList<>());
tested.onShapeLocationsChanged(shapeLocationsChangedEvent);
verify(selectedItems, never()).rebuildBoundingBox();
verify(selectionManager, never()).drawSelectionShape(eq(MIN_WIDTH), eq(MIN_HEIGHT), eq(MAX_WIDTH), eq(MAX_HEIGHT), eq(overLayer));
// Same canvas with selected items
when(shapeLocationsChangedEvent.getCanvasHandler()).thenReturn(canvasHandler);
List<String> selectedUUIds = new ArrayList<>();
selectedUUIds.add("ELEMENT");
when(shapeLocationsChangedEvent.getUuids()).thenReturn(selectedUUIds);
when(tested.getSelectedItems()).thenReturn(selectedUUIds);
when(delegateShapeProvider.getShape()).thenReturn(mock(com.ait.lienzo.client.core.shape.Shape.class));
when(selectionManager.getSelectedItems()).thenReturn(selectedItems);
when(selectedItems.getBoundingBox()).thenReturn(new BoundingBox(MIN_WIDTH, MIN_HEIGHT, MAX_WIDTH, MAX_HEIGHT));
when(shapeLocationsChangedEvent.getCanvasHandler()).thenReturn(canvasHandler);
tested.onShapeLocationsChanged(shapeLocationsChangedEvent);
verify(selectedItems, times(1)).rebuildBoundingBox();
verify(selectionManager, times(1)).drawSelectionShapeForSelection();
}
use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class EmptyStateLayer method updateCaption.
private void updateCaption() {
BoundingBox captionBB = this.caption.getWrapper().getBoundingBox();
double captionCenterX = captionBB.getWidth() / 2d;
double captionCenterY = captionBB.getHeight() / 2d;
double centerX = getWidth() / 2d;
double centerY = getHeight() / 2d;
caption.setX(centerX - captionCenterX);
caption.setY(centerY + captionCenterY);
}
use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class EmptyStateLayer method updateMessage.
private void updateMessage() {
BoundingBox captionBB = caption.getBoundingBox();
double captionCenterY = captionBB.getHeight() / 2d;
BoundingBox messageBB = message.getBoundingBox();
double messageCenterX = messageBB.getWidth() / 2d;
double centerX = getWidth() / 2d;
double centerY = getHeight() / 2d;
message.setX(centerX - messageCenterX);
message.setY(centerY + captionCenterY + 25 + messageBB.getHeight());
}
use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class LienzoLayerUtils method layerToDataURL.
public static String layerToDataURL(final LienzoLayer lienzoLayer, final DataURLType dataURLType, final int x, final int y, final int width, final int height, final String bgColor) {
final com.ait.lienzo.client.core.shape.Layer layer = lienzoLayer.getLienzoLayer();
final ScratchPad scratchPad = layer.getScratchPad();
scratchPad.setPixelSize(width, height);
if (null != bgColor) {
scratchPad.getContext().setFillColor(bgColor);
scratchPad.getContext().fillRect(0, 0, width, height);
}
layer.drawWithTransforms(scratchPad.getContext(), 1, new BoundingBox(x, y, width, height));
final String data = scratchPad.toDataURL(dataURLType, 1);
scratchPad.clear();
return data;
}
Aggregations