use of org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler in project kie-wb-common by kiegroup.
the class StunnerClientLogger method logSessionInfo.
public static void logSessionInfo(final AbstractClientSession session) {
log("************ Session Info ****************");
if (null != session) {
log("Session = " + session.toString());
log("Canvas = " + session.getCanvas().toString());
if (null != session.getCanvasHandler()) {
final CanvasHandler canvasHandler = session.getCanvasHandler();
log("CanvasHandler = " + canvasHandler.toString());
final Diagram diagram = canvasHandler.getDiagram();
if (null != diagram) {
log("Diagram name = " + diagram.getName());
log("Graph uuid = " + (null != diagram.getGraph() ? diagram.getGraph().getUUID() : "null"));
final Metadata metadata = diagram.getMetadata();
if (null != metadata) {
log("Metadata defSetId = " + metadata.getDefinitionSetId());
log("Metadata shapeSetId = " + metadata.getShapeSetId());
log("Metadata canvas root = " + metadata.getCanvasRootUUID());
log("Metadata title = " + metadata.getTitle());
} else {
log("Metadata = null");
}
} else {
log("Diagram = null");
}
} else {
log("CanvasHandler = null");
}
if (session instanceof ClientFullSession) {
logFullSessionInfo((ClientFullSession) session);
}
} else {
log("Session is null");
}
log("******************************************");
}
use of org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler in project kie-wb-common by kiegroup.
the class ObserverBuilderControl method onBuildCanvasShape.
@SuppressWarnings("unchecked")
void onBuildCanvasShape(@Observes final BuildCanvasShapeEvent buildCanvasShapeEvent) {
checkNotNull("buildCanvasShapeEvent", buildCanvasShapeEvent);
if (null != canvasHandler) {
final CanvasHandler context = buildCanvasShapeEvent.getCanvasHandler();
if (null != context && context.equals(canvasHandler)) {
final Object definition = buildCanvasShapeEvent.getDefinition();
final double x = buildCanvasShapeEvent.getX();
final double y = buildCanvasShapeEvent.getY();
final double _x = x >= 0 ? x - canvasHandler.getAbstractCanvas().getAbsoluteX() : -1;
final double _y = y >= 0 ? y - canvasHandler.getAbstractCanvas().getAbsoluteY() : -1;
final ElementBuildRequest<AbstractCanvasHandler> request = new ElementBuildRequestImpl(_x, _y, definition);
ObserverBuilderControl.this.build(request, new BuildCallback() {
@Override
public void onSuccess(final String uuid) {
canvasHandler.getCanvas().draw();
canvasSelectionEvent.fire(new CanvasSelectionEvent(canvasHandler, uuid));
}
@Override
public void onError(final ClientRuntimeError error) {
LOGGER.log(Level.SEVERE, error.toString());
}
});
}
}
}
use of org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler in project kie-wb-common by kiegroup.
the class CanvasLayoutUtils method getNext.
@SuppressWarnings("unchecked")
public Point2D getNext(final CanvasHandler canvasHandler, final Node<View<?>, Edge> root, final Node<View<?>, Edge> newNode) {
final double[] rootBounds = getBoundCoordinates(root.getContent());
final double[] rootSize = GraphUtils.getNodeSize(root.getContent());
final double[] newNodeSize = GraphUtils.getNodeSize(newNode.getContent());
Point2D[] offset = { new Point2D(PADDING_X, 0) };
Point2D[] parentOffset = { new Point2D(0, 0) };
double[] maxNodeY = { 0 };
if (root.getOutEdges().size() > 0) {
root.getOutEdges().stream().filter(e -> e.getContent() instanceof ViewConnector).filter(e -> null != e.getTargetNode() && !e.getTargetNode().equals(newNode)).forEach(n -> {
final Node<View<?>, Edge> node = n.getTargetNode();
final Point2D nodePos = GraphUtils.getPosition(node.getContent());
final Point2D rootPos = GraphUtils.getPosition(root.getContent());
if (nodePos.getY() > maxNodeY[0]) {
maxNodeY[0] = nodePos.getY();
final double[] nodeSize = GraphUtils.getNodeSize(node.getContent());
offset[0].setY(maxNodeY[0] + nodeSize[1] - rootPos.getY());
}
});
offset[0].setY(offset[0].getY() + parentOffset[0].getY() + PADDING_Y);
} else {
offset[0].setY(parentOffset[0].getY() - (newNodeSize[1] - rootSize[1]) / 2);
}
offset[0].setX(offset[0].getX() + PADDING_X);
final Point2D offsetCoordinates = new Point2D(offset[0].getX(), offset[0].getY());
final Point2D rootNodeCoordinates = new Point2D(rootBounds[0], rootBounds[1]);
return getNext(canvasHandler, root, rootSize[0], rootSize[1], newNodeSize[0], newNodeSize[1], offsetCoordinates, rootNodeCoordinates);
}
use of org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler in project kie-wb-common by kiegroup.
the class ShowcaseDiagramService method save.
public void save(final AbstractClientFullSession session, final ServiceCallback<Diagram<Graph, Metadata>> diagramServiceCallback) {
// Update diagram's image data as thumbnail.
final String thumbData = toImageData(session);
final CanvasHandler canvasHandler = session.getCanvasHandler();
final Diagram diagram = canvasHandler.getDiagram();
diagram.getMetadata().setThumbData(thumbData);
save(diagram, diagramServiceCallback);
}
use of org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler in project kie-wb-common by kiegroup.
the class ShowcaseDiagramService method save.
// TODO: Move this to ClientFactoryServices, so shared for others as well.
public void save(final AbstractClientFullSession session, final ServiceCallback<Diagram<Graph, Metadata>> diagramServiceCallback) {
// Update diagram's image data as thumbnail.
final String thumbData = toImageData(session);
final CanvasHandler canvasHandler = session.getCanvasHandler();
final Diagram diagram = canvasHandler.getDiagram();
diagram.getMetadata().setThumbData(thumbData);
save(diagram, diagramServiceCallback);
}
Aggregations