Search in sources :

Example 1 with CanvasSettings

use of org.kie.workbench.common.stunner.core.client.canvas.CanvasSettings in project kie-wb-common by kiegroup.

the class AbstractDiagramViewer method open.

@Override
public void open(final D diagram, final int width, final int height, final DiagramViewerCallback<D> callback) {
    final StunnerDiagramEditorPreferences editorPreferences = getPreferences(diagram);
    final boolean isHiDPIEnabled = null != editorPreferences && editorPreferences.isHiDPIEnabled();
    final CanvasSettings settings = new CanvasSettings(width, height, isHiDPIEnabled);
    this.open(diagram, settings, callback);
}
Also used : StunnerDiagramEditorPreferences(org.kie.workbench.common.stunner.core.preferences.StunnerDiagramEditorPreferences) CanvasSettings(org.kie.workbench.common.stunner.core.client.canvas.CanvasSettings)

Example 2 with CanvasSettings

use of org.kie.workbench.common.stunner.core.client.canvas.CanvasSettings in project kie-wb-common by kiegroup.

the class LienzoCanvasTest method testEventHandling.

@Test
public void testEventHandling() {
    CanvasPanel panel = mock(CanvasPanel.class);
    CanvasSettings settings = mock(CanvasSettings.class);
    ViewEventHandlerManager eventHandler = mock(ViewEventHandlerManager.class);
    tested.initialize(panel, settings, eventHandler);
    tested.supports(ViewEventType.DRAG);
    verify(eventHandler, times(1)).supports(eq(ViewEventType.DRAG));
    tested.enableHandlers();
    verify(eventHandler, times(1)).enable();
    tested.disableHandlers();
    verify(eventHandler, times(1)).disable();
    DragHandler dragHandler = mock(DragHandler.class);
    tested.addHandler(ViewEventType.DRAG, dragHandler);
    verify(eventHandler, times(1)).addHandler(eq(ViewEventType.DRAG), eq(dragHandler));
    tested.removeHandler(dragHandler);
    verify(eventHandler, times(1)).removeHandler(eq(dragHandler));
}
Also used : CanvasPanel(org.kie.workbench.common.stunner.core.client.canvas.CanvasPanel) CanvasSettings(org.kie.workbench.common.stunner.core.client.canvas.CanvasSettings) DragHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.DragHandler) ViewEventHandlerManager(org.kie.workbench.common.stunner.client.lienzo.shape.view.ViewEventHandlerManager) Test(org.junit.Test)

Example 3 with CanvasSettings

use of org.kie.workbench.common.stunner.core.client.canvas.CanvasSettings in project kie-wb-common by kiegroup.

the class WiresCanvasTest method testInitialize.

@Test
public void testInitialize() {
    CanvasPanel panel = mock(CanvasPanel.class);
    CanvasSettings settings = mock(CanvasSettings.class);
    assertEquals(tested, tested.initialize(panel, settings));
    verify(wiresManager, times(1)).setSpliceEnabled(eq(false));
    verify(wiresManager, times(1)).setLocationAcceptor(eq(ILocationAcceptor.NONE));
    verify(wiresManager, times(1)).setContainmentAcceptor(eq(IContainmentAcceptor.NONE));
    verify(wiresManager, times(1)).setDockingAcceptor(eq(IDockingAcceptor.NONE));
    verify(wiresManager, times(1)).setConnectionAcceptor(eq(IConnectionAcceptor.NONE));
    verify(wiresManager, times(1)).setControlPointsAcceptor(eq(IControlPointsAcceptor.NONE));
    verify(view, times(1)).use(eq(wiresManager));
    verify(view, times(1)).initialize(eq(panel), eq(settings));
    assertEquals(wiresManager, tested.getWiresManager());
}
Also used : CanvasPanel(org.kie.workbench.common.stunner.core.client.canvas.CanvasPanel) CanvasSettings(org.kie.workbench.common.stunner.core.client.canvas.CanvasSettings) Test(org.junit.Test)

Example 4 with CanvasSettings

use of org.kie.workbench.common.stunner.core.client.canvas.CanvasSettings in project kie-wb-common by kiegroup.

the class AbstractDiagramViewer method open.

@Override
@SuppressWarnings("unchecked")
public void open(final D diagram, final DiagramViewer.DiagramViewerCallback<D> callback) {
    final StunnerDiagramEditorPreferences editorPreferences = getPreferences(diagram);
    final boolean isHiDPIEnabled = null != editorPreferences && editorPreferences.isHiDPIEnabled();
    final CanvasSettings settings = new CanvasSettings(isHiDPIEnabled);
    this.open(diagram, settings, callback);
}
Also used : StunnerDiagramEditorPreferences(org.kie.workbench.common.stunner.core.preferences.StunnerDiagramEditorPreferences) CanvasSettings(org.kie.workbench.common.stunner.core.client.canvas.CanvasSettings)

Example 5 with CanvasSettings

use of org.kie.workbench.common.stunner.core.client.canvas.CanvasSettings in project kie-wb-common by kiegroup.

the class LienzoCanvasTest method testInitialize.

@Test
public void testInitialize() {
    CanvasPanel panel = mock(CanvasPanel.class);
    CanvasSettings settings = mock(CanvasSettings.class);
    when(settings.isHiDPIEnabled()).thenReturn(true);
    assertEquals(tested, tested.initialize(panel, settings));
    assertTrue(LienzoCore.get().isHidpiEnabled());
    assertNotNull(tested.getEventHandlerManager());
    verify(view, times(1)).initialize(eq(panel), eq(settings));
}
Also used : CanvasPanel(org.kie.workbench.common.stunner.core.client.canvas.CanvasPanel) CanvasSettings(org.kie.workbench.common.stunner.core.client.canvas.CanvasSettings) Test(org.junit.Test)

Aggregations

CanvasSettings (org.kie.workbench.common.stunner.core.client.canvas.CanvasSettings)6 Test (org.junit.Test)4 CanvasPanel (org.kie.workbench.common.stunner.core.client.canvas.CanvasPanel)4 ViewEventHandlerManager (org.kie.workbench.common.stunner.client.lienzo.shape.view.ViewEventHandlerManager)2 StunnerDiagramEditorPreferences (org.kie.workbench.common.stunner.core.preferences.StunnerDiagramEditorPreferences)2 DragHandler (org.kie.workbench.common.stunner.core.client.shape.view.event.DragHandler)1