use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class BoundaryEventPropertyReader method getBounds.
@Override
public Bounds getBounds() {
org.eclipse.dd.dc.Bounds bounds = shape.getBounds();
Point2D docker = getDockerInfo();
return BoundsImpl.build(docker.getX(), docker.getY(), docker.getX() + bounds.getWidth(), docker.getY() + bounds.getHeight());
}
use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class ShapeUtils method updateEdgeConnection.
@SuppressWarnings("unchecked")
public static void updateEdgeConnection(final AbstractCanvasHandler context, final Connection connection, final Node<? extends View<?>, Edge> node) {
if (null != node && null == connection.getLocation() && connection instanceof MagnetConnection) {
final MagnetConnection magnetConnection = (MagnetConnection) connection;
final OptionalInt magnetIndex = magnetConnection.getMagnetIndex();
if (magnetIndex.orElse(-1) == MagnetConnection.MAGNET_CENTER) {
final Shape<ShapeView<?>> nodeShape = context.getCanvas().getShape(node.getUUID());
final BoundingBox boundingBox = nodeShape.getShapeView().getBoundingBox();
magnetConnection.setLocation(new Point2D(boundingBox.getWidth() / 2, boundingBox.getHeight() / 2));
}
}
}
use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class AbstractCanvasControlPointCommandTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
Point2D location1 = new Point2D(0, 0);
controlPoint1 = new ControlPointImpl(location1);
ControlPoint controlPoint2 = new ControlPointImpl(location1, 1);
controlPointList = Arrays.asList(controlPoint1);
when(shape.getShapeView()).thenReturn(shapeView);
when(shape.addControlPoints(controlPoint1)).thenReturn(Arrays.asList(controlPoint2));
when(edge.getUUID()).thenReturn(EDGE_UUID);
when(edge.getContent()).thenReturn(viewConnector);
when(canvasHandler.getCanvas().getShape(EDGE_UUID)).thenReturn(shape);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class CloneNodeCommandTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
when(candidate.getUUID()).thenReturn(NODE_UUID);
when(candidate.getContent()).thenReturn(candidateContent);
when(childrenTraverseProcessorManagedInstance.get()).thenReturn(new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()));
Point2D position = new Point2D(1, 1);
this.cloneNodeCommand = new CloneNodeCommand(candidate, PARENT_UUID, position, null, childrenTraverseProcessorManagedInstance);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class GraphBoundsIndexerImpl method getAt.
@Override
public Node<View<?>, Edge> getAt(final double x, final double y, final double width, final double height, final Element parentNode) {
Point2D parentNodePosition;
double xToCheck = 0;
double yToCheck = 0;
if (parentNode != null) {
parentNodePosition = GraphUtils.getPosition((View) parentNode.asNode().getContent());
xToCheck = x + parentNodePosition.getX();
yToCheck = y + parentNodePosition.getY();
}
Node<View<?>, Edge> element;
Point2D[] pointsToCheck = new Point2D[5];
pointsToCheck[0] = new Point2D(xToCheck, yToCheck);
pointsToCheck[1] = new Point2D(xToCheck + width, yToCheck);
pointsToCheck[2] = new Point2D(xToCheck + (width / 2), yToCheck + (height / 2));
pointsToCheck[3] = new Point2D(xToCheck, yToCheck + height);
pointsToCheck[4] = new Point2D(xToCheck + width, yToCheck + height);
for (Point2D point : pointsToCheck) {
element = findElementAt(point.getX(), point.getY());
if (element != null) {
if (element != parentNode) {
return element;
}
}
}
return null;
}
Aggregations