use of org.kie.workbench.common.stunner.core.graph.content.view.DiscreteConnection in project kie-wb-common by kiegroup.
the class WiresConnectorView method updateConnection.
private static void updateConnection(final Connection connection, final MagnetManager.Magnets magnets, final com.ait.lienzo.client.core.types.Point2D abeLocation, final Consumer<Boolean> isAutoConnectionConsumer, final Consumer<WiresMagnet> magnetConsumer) {
final WiresMagnet[] magnet = new WiresMagnet[] { null };
final boolean[] auto = new boolean[] { false };
if (null != connection) {
final DiscreteConnection dc = connection instanceof DiscreteConnection ? (DiscreteConnection) connection : null;
if (null != dc) {
// Obtain the magnet index and auto flag, if the connection is a discrete type and it has been already set.
dc.getMagnetIndex().ifPresent(index -> magnet[0] = magnets.getMagnet(index));
auto[0] = dc.isAuto();
}
// If still no magnet found from the connection's cache, figure it out as by the connection's location.
if (null == magnet[0]) {
magnet[0] = getMagnetForConnection(connection, magnets, abeLocation);
// Update the discrete connection magnet cached index, if possible.
if (null != dc) {
dc.setIndex(magnet[0].getIndex());
}
}
}
// Call the magnet and auto connection consumers to assign the new values.
isAutoConnectionConsumer.accept(auto[0]);
magnetConsumer.accept(magnet[0]);
}
Aggregations