use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class CanvasLayoutUtils method getNextPositionFromParent.
private Point2D getNextPositionFromParent(final Point2D rootNodeCoordinates, final Point2D offset, final Element parentNode, final double rootNodeHeight, final double rootNodeWidth, final double nodeWidth) {
final Point2D nextPosition = getNextPositionWithOffset(rootNodeCoordinates, offset);
final double[] parentNodeSize = GraphUtils.getNodeSize((View) parentNode.getContent());
final Point2D parentPosition = GraphUtils.getPosition((View) parentNode.getContent());
double newPositionToCheckX = (rootNodeCoordinates.getX() + rootNodeWidth + PADDING_X + nodeWidth);
double parentPositionToCheckX = parentNodeSize[0] + parentPosition.getX();
if (newPositionToCheckX > parentPositionToCheckX) {
nextPosition.setX(parentPosition.getX() + PADDING_X);
nextPosition.setY(rootNodeCoordinates.getY() + rootNodeHeight + PADDING_Y + offset.getY());
}
return nextPosition;
}
use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D 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.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class LienzoTextTooltipTest method testShow.
@Test
public void testShow() {
tested.show("content1", new Point2D(200d, 100d));
final ArgumentCaptor<com.ait.lienzo.client.core.types.Point2D> pointCaptor = ArgumentCaptor.forClass(com.ait.lienzo.client.core.types.Point2D.class);
verify(primitiveTooltip, times(1)).show(eq("content1"), pointCaptor.capture(), eq(PrimitiveTooltip.Direction.WEST));
final com.ait.lienzo.client.core.types.Point2D point = pointCaptor.getValue();
assertEquals(200d, point.getX(), 0);
assertEquals(100d, point.getY(), 0);
verify(primitiveTooltip, never()).hide();
verify(primitiveTooltip, never()).remove();
}
use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class AbstractEdgeBuilder method buildControlPoints.
private void buildControlPoints(BuilderContext context, T edge, GraphCommandFactory commandFactory) {
if (dockers.size() > 2) {
Counter indexCounter = new Counter(0);
ControlPoint[] controlPoints = dockers.subList(1, dockers.size() - 1).stream().sequential().map(docker -> (docker.length == 2 ? new Point2D(docker[0], docker[1]) : null)).filter(Objects::nonNull).map(point -> new ControlPointImpl(point, indexCounter.increment())).toArray(ControlPoint[]::new);
CommandResult<RuleViolation> addControlPointsResult = context.execute(commandFactory.addControlPoint(edge, controlPoints));
if (hasErrors(addControlPointsResult)) {
throw new RuntimeException("Error building BPMN graph. Command 'AddControlPointCommand' execution failed." + addControlPointsResult);
}
}
}
use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class CaseManagementCanvasCommandFactoryTest method checkUpdatePositionCommandType.
@Test
public void checkUpdatePositionCommandType() {
// Checks the command is a specific sub-class for Case Management
final CanvasCommand<AbstractCanvasHandler> command = factory.updatePosition(child, new Point2D(0.0, 0.0));
assertNotNull(command);
assertTrue(command instanceof CaseManagementUpdatePositionCommand);
}
Aggregations