use of com.ait.lienzo.client.core.shape.MultiPath in project kie-wb-common by kiegroup.
the class ConnectorDragProxyImpl method show.
@Override
@SuppressWarnings("unchecked")
public DragProxy<AbstractCanvasHandler, Item, DragProxyCallback> show(final Item item, final int x, final int y, final DragProxyCallback callback) {
// Source connector's shape - Obtain the shape for the source node.
final Node<View<?>, Edge> sourceNode = item.getSourceNode();
final Shape<?> sourceNodeShape = getCanvas().getShape(sourceNode.getUUID());
// Target connector's shape - Create a temporary shape view, that will act as the connector's target node.
final WiresShapeView transientShapeView = new WiresShapeView<>(new MultiPath().rect(0, 0, 1, 1).setFillAlpha(0).setStrokeAlpha(0));
getWiresManager().getMagnetManager().createMagnets(transientShapeView);
// Create the transient connector's shape and view.
final Edge<View<?>, Node> edge = item.getEdge();
final Shape<?> edgeShape = ((ShapeFactory<Object, ?>) item.getShapeFactory()).newShape(edge.getContent().getDefinition());
final EdgeShape connectorShape = (EdgeShape) edgeShape;
this.connectorShapeView = (WiresConnectorView<?>) edgeShape.getShapeView();
// Register and update shape's view as for edge bean's state.
getWiresManager().register(connectorShapeView);
connectorShape.applyProperties(edge, MutationContext.STATIC);
// Apply connector's connections for both source and target shapes.
// Using center connector strategy, so magnet index 0.
final MagnetConnection centerConnection = new MagnetConnection.Builder().atX(0).atY(0).magnet(0).build();
connectorShapeView.connect(sourceNodeShape.getShapeView(), centerConnection, transientShapeView, centerConnection);
// Optimize the index and show the drag proxy for the temporary shape view.
graphBoundsIndexer.build(canvasHandler.getDiagram().getGraph());
shapeViewDragProxyFactory.show(transientShapeView, x, y, new DragProxyCallback() {
@Override
public void onStart(final int x, final int y) {
callback.onStart(x, y);
// As using center magnet, update the connection.
connectorShapeView.updateForCenterConnection();
}
@Override
public void onMove(final int x, final int y) {
callback.onMove(x, y);
// As using center magnet, update the connection.
connectorShapeView.updateForCenterConnection();
}
@Override
public void onComplete(final int x, final int y) {
callback.onComplete(x, y);
deregisterTransientConnector();
getCanvas().draw();
}
});
return this;
}
use of com.ait.lienzo.client.core.shape.MultiPath in project kie-wb-common by kiegroup.
the class CaseManagementColorMapBackedPicker method addDropZone.
void addDropZone(final AbstractCaseManagementShape<?> prim) {
final Optional<MultiPath> optMultiPath = prim.getDropZone();
if (optMultiPath.isPresent()) {
final MultiPath multiPath = optMultiPath.get();
multiPath.getAttributes().setX(prim.getX());
multiPath.getAttributes().setY(prim.getY());
drawShape(m_colorKeyRotor.next(), multiPath.getStrokeWidth(), multiPath, new PickerPart(prim, PickerPart.ShapePart.BODY), true);
}
}
use of com.ait.lienzo.client.core.shape.MultiPath in project kie-wb-common by kiegroup.
the class CaseManagementShapeDefFactoryTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
this.pictureShapeView = new PictureShapeView(new MultiPath().rect(0, 0, 10, 10));
when(stageView.setWidth(anyDouble())).thenReturn(stageView);
when(stageView.setHeight(anyDouble())).thenReturn(stageView);
when(basicShapeViewFactory.pictureFromUri(any(SafeUri.class), anyDouble(), anyDouble())).thenReturn(pictureShapeView);
when(basicShapeViewFactory.connector(anyDouble(), anyDouble(), anyDouble(), anyDouble())).thenReturn(connectorShapeView);
when(cmShapeViewFactory.newNullView()).thenReturn(nullView);
when(cmShapeViewFactory.newStageView(anyDouble(), anyDouble(), anyDouble())).thenReturn(stageView);
when(cmShapeViewFactory.newActivityView(anyDouble(), anyDouble())).thenReturn(activityView);
when(cmShapeViewFactory.newDiagramView(anyDouble(), anyDouble())).thenReturn(diagramView);
this.tested = new CaseManagementShapeDefFactory(cmShapeViewFactory, basicShapeViewFactory, new ShapeDefFunctionalFactory<>());
this.tested.init();
}
use of com.ait.lienzo.client.core.shape.MultiPath in project kie-wb-common by kiegroup.
the class CaseManagementShapeFactoryTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
this.pictureShapeView = new PictureShapeView(new MultiPath().rect(0, 0, 10, 10));
this.cmShapeViewFactory = new CaseManagementShapeViewFactory();
final BasicShapesFactory basicShapesFactory = new BasicShapesFactory(new ShapeDefFunctionalFactory<>(), basicViewFactory);
basicShapesFactory.init();
final CaseManagementShapeDefFactory cmShapeDefFactory = new CaseManagementShapeDefFactory(cmShapeViewFactory, basicViewFactory, new ShapeDefFunctionalFactory<>());
cmShapeDefFactory.init();
this.delegate = spy(new DelegateShapeFactory());
doReturn(glyph).when(delegate).getGlyph(anyString());
this.factory = new CaseManagementShapeFactory(cmShapeDefFactory, basicShapesFactory, delegate);
this.factory.init();
when(basicViewFactory.pictureFromUri(any(SafeUri.class), anyDouble(), anyDouble())).thenReturn(pictureShapeView);
when(basicViewFactory.connector(anyDouble(), anyDouble(), anyDouble(), anyDouble())).thenReturn(connectorShapeView);
when(definitionManager.adapters()).thenReturn(adapterManager);
when(adapterManager.forDefinition()).thenReturn(definitionAdapter);
}
use of com.ait.lienzo.client.core.shape.MultiPath in project kie-wb-common by kiegroup.
the class BaseLayoutManagerTest method setup.
public void setup() {
this.shapes = new ArrayList<>();
this.handler = getLayoutHandler();
this.container = spy(new MockCaseManagementShape());
this.container.setLayoutHandler(handler);
// Shapes are at (0,15), (0,30) and (0,45) by default. Set by LayoutManager.
for (int i = 0; i < 3; i++) {
final int index = i;
final WiresShape shape = new WiresShape(new MultiPath()) {
@Override
public String toString() {
return "WiresShape:" + index;
}
};
container.add(shape);
shapes.add(shape);
}
}
Aggregations