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);
}
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);
}
}
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);
}
Aggregations