use of org.uberfire.ext.wires.core.trees.client.canvas.WiresTreeNodeConnector in project drools-wb by kiegroup.
the class GuidedDecisionTreeWidget method onDragPreviewHandler.
public void onDragPreviewHandler(@Observes ShapeDragPreviewEvent shapeDragPreviewEvent) {
// We can only connect WiresTreeNodes to each other
if (!(shapeDragPreviewEvent.getShape() instanceof BaseGuidedDecisionTreeShape)) {
dropContext.setContext(null);
return;
}
// Find a Parent Node to attach the Shape to
final double cx = getX(shapeDragPreviewEvent.getX());
final double cy = getY(shapeDragPreviewEvent.getY());
final BaseGuidedDecisionTreeShape uiChild = (BaseGuidedDecisionTreeShape) shapeDragPreviewEvent.getShape();
final BaseGuidedDecisionTreeShape uiProspectiveParent = getParentNode(uiChild, cx, cy);
// If there is a prospective parent show the line between child and parent
if (uiProspectiveParent != null) {
if (connector == null) {
connector = new WiresTreeNodeConnector();
canvasLayer.add(connector);
connector.moveToBottom();
}
connector.getPoints().get(0).set(uiProspectiveParent.getLocation());
connector.getPoints().get(1).set(new Point2D(cx, cy));
} else if (connector != null) {
canvasLayer.remove(connector);
connector = null;
}
dropContext.setContext(uiProspectiveParent);
canvasLayer.batch();
}
Aggregations