use of com.ait.lienzo.client.core.shape.Group in project kie-wb-common by kiegroup.
the class GroupItemTest method testHide.
@Test
public void testHide() {
when(group.getAlpha()).thenReturn(1d);
final Command before = mock(Command.class);
final Command after = mock(Command.class);
tested.hide(before, after);
verify(before, times(1)).execute();
verify(hideExecutor, times(1)).accept(eq(group), eq(after));
verify(showExecutor, never()).accept(any(Group.class), any(Command.class));
}
use of com.ait.lienzo.client.core.shape.Group in project kie-wb-common by kiegroup.
the class ButtonGridItemImplTest method setUp.
@Before
@SuppressWarnings("unchecked")
public void setUp() {
buttonGroup = spy(new Group().setAlpha(0d));
toolboxGroup = spy(new Group());
when(buttonGroup.getComputedBoundingPoints()).thenReturn(buttonBoundingPoints);
when(buttonGroup.getBoundingBox()).thenReturn(buttonBoundingBox);
when(buttonBoundingPoints.getBoundingBox()).thenReturn(buttonBoundingBox);
when(toolboxGroup.getComputedBoundingPoints()).thenReturn(toolboxBoundingPoints);
when(toolboxGroup.getBoundingBox()).thenReturn(toolboxBoundingBox);
when(toolboxBoundingPoints.getBoundingBox()).thenReturn(toolboxBoundingBox);
when(button.getBoundingBox()).thenReturn(() -> buttonBoundingBox);
when(button.asPrimitive()).thenReturn(buttonGroup);
when(button.getPrimitive()).thenReturn(mock(IPrimitive.class));
when(button.getWrapped()).thenReturn(buttonWrap);
when(buttonWrap.registrations()).thenReturn(registrations);
when(buttonWrap.asPrimitive()).thenReturn(buttonGroup);
when(buttonWrap.getBoundingBox()).thenReturn(() -> buttonBoundingBox);
when(toolbox.getBoundingBox()).thenReturn(() -> toolboxBoundingBox);
when(toolbox.asPrimitive()).thenReturn(toolboxGroup);
when(toolbox.getPrimitive()).thenReturn(mock(IPrimitive.class));
when(toolbox.getAt()).thenReturn(Direction.SOUTH_EAST);
when(toolbox.getWrapped()).thenReturn(toolboxWrap);
when(toolboxWrap.asPrimitive()).thenReturn(toolboxGroup);
when(toolboxWrap.getBoundingBox()).thenReturn(() -> toolboxBoundingBox);
when(button1.getPrimitive()).thenReturn(button1Prim);
doAnswer(invocationOnMock -> {
((Command) invocationOnMock.getArguments()[0]).execute();
((Command) invocationOnMock.getArguments()[1]).execute();
return button;
}).when(button).show(any(Command.class), any(Command.class));
doAnswer(invocationOnMock -> {
((Command) invocationOnMock.getArguments()[0]).execute();
((Command) invocationOnMock.getArguments()[1]).execute();
return button;
}).when(button).hide(any(Command.class), any(Command.class));
doAnswer(invocationOnMock -> {
((Command) invocationOnMock.getArguments()[0]).execute();
((Command) invocationOnMock.getArguments()[1]).execute();
return toolbox;
}).when(toolbox).show(any(Command.class), any(Command.class));
doAnswer(invocationOnMock -> {
((Command) invocationOnMock.getArguments()[0]).execute();
((Command) invocationOnMock.getArguments()[1]).execute();
return toolbox;
}).when(toolbox).hide(any(Command.class), any(Command.class));
tested = new ButtonGridItemImpl(button, toolbox).useHideExecutor(hideExecutor).useShowExecutor(showExecutor);
}
use of com.ait.lienzo.client.core.shape.Group in project kie-wb-common by kiegroup.
the class ItemImplTest method testFocusExecutorDoingUnFocus.
@Test
public void testFocusExecutorDoingUnFocus() {
final AbstractDecoratorItem decorator = mock(AbstractDecoratorItem.class);
final Group decPrimitive = mock(Group.class);
when(decorator.asPrimitive()).thenReturn(decPrimitive);
final TooltipItem<?> tooltip = mock(TooltipItem.class);
tested = new ItemImpl(groupItem, shape).setFocusDelay(0).setUnFocusDelay(0).decorate(decorator).tooltip(tooltip);
final AbstractFocusableGroupItem<ItemImpl>.FocusGroupExecutor focusExecutor = spy(tested.getFocusGroupExecutor());
doAnswer(invocationOnMock -> {
((Command) invocationOnMock.getArguments()[1]).execute();
return null;
}).when(focusExecutor).accept(any(Group.class), any(Command.class));
focusExecutor.unFocus();
verify(focusExecutor, times(1)).setAlpha(AbstractFocusableGroupItem.ALPHA_UNFOCUSED);
verify(decorator, times(3)).hide();
verify(tooltip, times(2)).hide();
}
use of com.ait.lienzo.client.core.shape.Group in project kie-wb-common by kiegroup.
the class LienzoSvgDataUriGlyphRendererTest method testRender.
@Test
@SuppressWarnings("unchecked")
public void testRender() {
final Group glyphView = tested.render(glyph, 100, 200);
assertEquals(group, glyphView);
final ArgumentCaptor<String> imageGlyphCaptor = ArgumentCaptor.forClass(String.class);
verify(lienzoPictureGlyphRenderer, times(1)).render(imageGlyphCaptor.capture(), eq(100d), eq(200d));
assertEquals(URI_B64, imageGlyphCaptor.getValue());
}
use of com.ait.lienzo.client.core.shape.Group in project kie-wb-common by kiegroup.
the class BaseExpressionGrid method executeRenderQueueCommands.
@Override
protected void executeRenderQueueCommands(final boolean isSelectionLayer) {
final List<Pair<Group, GridRenderer.RendererCommand>> gridLineCommands = new ArrayList<>();
final List<Pair<Group, GridRenderer.RendererCommand>> allOtherCommands = new ArrayList<>();
final List<Pair<Group, GridRenderer.RendererCommand>> selectedCellsCommands = new ArrayList<>();
for (Pair<Group, List<GridRenderer.RendererCommand>> p : renderQueue) {
final Group parent = p.getK1();
final List<GridRenderer.RendererCommand> commands = p.getK2();
for (GridRenderer.RendererCommand command : commands) {
if (command instanceof GridRenderer.RenderSelectedCellsCommand) {
selectedCellsCommands.add(new Pair<>(parent, command));
} else if (command instanceof GridRenderer.RenderHeaderGridLinesCommand) {
gridLineCommands.add(new Pair<>(parent, command));
} else if (command instanceof GridRenderer.RenderBodyGridLinesCommand) {
gridLineCommands.add(new Pair<>(parent, command));
} else {
allOtherCommands.add(new Pair<>(parent, command));
}
}
}
final Predicate<Pair<Group, GridRenderer.RendererCommand>> renderHeader = (p) -> {
final GridRenderer.RendererCommand command = p.getK2();
if (isHeaderHidden()) {
return !(command instanceof GridRenderer.RendererHeaderCommand);
}
return true;
};
renderQueue.clear();
allOtherCommands.stream().filter(renderHeader).forEach(p -> addCommandToRenderQueue(p.getK1(), p.getK2()));
gridLineCommands.stream().filter(renderHeader).forEach(p -> addCommandToRenderQueue(p.getK1(), p.getK2()));
selectedCellsCommands.stream().filter(renderHeader).forEach(p -> addCommandToRenderQueue(p.getK1(), p.getK2()));
super.executeRenderQueueCommands(isSelectionLayer);
}
Aggregations