Search in sources :

Example 6 with ControlPointImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl in project kie-wb-common by kiegroup.

the class ShapeUtilsTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    final TestingGraphMockHandler graphTestHandler = new TestingGraphMockHandler();
    instance2 = TestingGraphInstanceBuilder.newGraph2(graphTestHandler);
    when(canvasHandler.getCanvas()).thenReturn(canvas);
    when(canvasHandler.getGraphIndex()).thenReturn(graphIndex);
    when(graphIndex.getGraph()).thenReturn(instance2.graph);
    final String e1 = instance2.edge1.getUUID();
    final String e2 = instance2.edge2.getUUID();
    when(canvas.getShape(eq(e1))).thenReturn(edge1Shape);
    when(canvas.getShape(eq(e2))).thenReturn(edge2Shape);
    when(edge1Shape.getShapeView()).thenReturn(edge1ShapeView);
    when(edge2Shape.getShapeView()).thenReturn(edge2ShapeView);
    controlPoint1 = new ControlPointImpl(0, 0);
    controlPointList = Arrays.asList(controlPoint1);
    when(edge1Shape.getControlPoints()).thenReturn(controlPointList);
    when(edge1Shape.addControlPoints(controlPoint1)).thenReturn(controlPointList);
}
Also used : ControlPointImpl(org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl) TestingGraphMockHandler(org.kie.workbench.common.stunner.core.TestingGraphMockHandler) Before(org.junit.Before)

Example 7 with ControlPointImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl in project kie-wb-common by kiegroup.

the class ControlPointControlImpl method registerHandlers.

@SuppressWarnings("unchecked")
private void registerHandlers(final Element element, final Shape<?> shape) {
    if (shape.getShapeView() instanceof HasEventHandlers && element instanceof Edge && element.getContent() instanceof ViewConnector) {
        final HasEventHandlers hasEventHandlers = (HasEventHandlers) shape.getShapeView();
        // Register handler on the Connector to Add a ControlPoint
        MouseDoubleClickHandler eventHandler = new MouseDoubleClickHandler() {

            @Override
            public void handle(MouseDoubleClickEvent event) {
                addControlPoint((Edge) element, new ControlPointImpl(event.getX(), event.getY()));
            }
        };
        hasEventHandlers.addHandler(ViewEventType.MOUSE_DBL_CLICK, eventHandler);
        registerHandler(element.getUUID(), eventHandler);
    }
}
Also used : ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) MouseDoubleClickHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseDoubleClickHandler) ControlPointImpl(org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl) HasEventHandlers(org.kie.workbench.common.stunner.core.client.shape.view.HasEventHandlers) MouseDoubleClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseDoubleClickEvent) Edge(org.kie.workbench.common.stunner.core.graph.Edge)

Example 8 with ControlPointImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl in project kie-wb-common by kiegroup.

the class ControlPointControlImplTest method setUp.

@Before
public void setUp() {
    super.setUp();
    initialControlPointPosition = new Point2D(0, 0);
    newControlPointPosition = new Point2D(10, 10);
    controlPoint1 = new ControlPointImpl(initialControlPointPosition);
    canvasSelectionEvent = new CanvasSelectionEvent(canvasHandler, EDGE_UUID);
    canvasControlPointDragStartEvent = new CanvasControlPointDragStartEvent(initialControlPointPosition);
    canvasControlPointDragEndEvent = new CanvasControlPointDragEndEvent(newControlPointPosition);
    canvasControlPointDoubleClickEvent = new CanvasControlPointDoubleClickEvent(initialControlPointPosition);
    controlPointControl = spy(new ControlPointControlImpl(canvasCommandFactory));
    when(canvas.getShape(EDGE_UUID)).thenReturn(connectorShape);
    when(graphIndex.get(EDGE_UUID)).thenReturn(edge);
    when(graphIndex.getEdge(EDGE_UUID)).thenReturn(edge);
    when(edge.getContent()).thenReturn(viewConnector);
    when(edge.getUUID()).thenReturn(EDGE_UUID);
    when(connectorShape.getShapeView()).thenReturn(shapeView);
    when(viewConnector.getControlPoints()).thenReturn(Arrays.asList(controlPoint1));
    controlPointControl.enable(canvasHandler);
    controlPointControl.setCommandManagerProvider(() -> commandManager);
    controlPointControl.register(edge);
}
Also used : CanvasSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent) Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) CanvasControlPointDragStartEvent(org.kie.workbench.common.stunner.core.client.canvas.event.controlpoint.CanvasControlPointDragStartEvent) CanvasControlPointDragEndEvent(org.kie.workbench.common.stunner.core.client.canvas.event.controlpoint.CanvasControlPointDragEndEvent) ControlPointImpl(org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl) CanvasControlPointDoubleClickEvent(org.kie.workbench.common.stunner.core.client.canvas.event.controlpoint.CanvasControlPointDoubleClickEvent) Before(org.junit.Before)

Aggregations

ControlPointImpl (org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl)8 Before (org.junit.Before)4 ControlPoint (org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint)4 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)4 Edge (org.kie.workbench.common.stunner.core.graph.Edge)2 Point2D (com.ait.lienzo.client.core.types.Point2D)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Test (org.junit.Test)1 Bpmn2OryxManager (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.Bpmn2OryxManager)1 BPMNDefinition (org.kie.workbench.common.stunner.bpmn.definition.BPMNDefinition)1 TestingGraphMockHandler (org.kie.workbench.common.stunner.core.TestingGraphMockHandler)1 FactoryManager (org.kie.workbench.common.stunner.core.api.FactoryManager)1 CanvasControlPointDoubleClickEvent (org.kie.workbench.common.stunner.core.client.canvas.event.controlpoint.CanvasControlPointDoubleClickEvent)1 CanvasControlPointDragEndEvent (org.kie.workbench.common.stunner.core.client.canvas.event.controlpoint.CanvasControlPointDragEndEvent)1 CanvasControlPointDragStartEvent (org.kie.workbench.common.stunner.core.client.canvas.event.controlpoint.CanvasControlPointDragStartEvent)1 CanvasSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent)1 HasEventHandlers (org.kie.workbench.common.stunner.core.client.shape.view.HasEventHandlers)1 MouseDoubleClickEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseDoubleClickEvent)1 MouseDoubleClickHandler (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseDoubleClickHandler)1