use of com.ait.lienzo.client.core.shape.wires.WiresShape in project lienzo-core by ahome-it.
the class WiresConnectionControlImpl method allowedMagnetAndUpdateAutoConnections.
public static boolean allowedMagnetAndUpdateAutoConnections(final WiresConnection connection, final boolean isHead, final WiresShape shape, final WiresMagnet currentMagnet, final boolean applyAccept) {
final WiresConnector connector = connection.getConnector();
// shape can be null, to see if a connection can be unconnected to a magnet
boolean accept;
WiresShape headS;
WiresShape tailS;
if (isHead) {
accept = connector.getConnectionAcceptor().headConnectionAllowed(connection, shape);
headS = shape;
tailS = (connector.getTailConnection().getMagnet() != null) ? connector.getTailConnection().getMagnet().getMagnets().getWiresShape() : null;
} else {
accept = connector.getConnectionAcceptor().tailConnectionAllowed(connection, shape);
headS = (connector.getHeadConnection().getMagnet() != null) ? connector.getHeadConnection().getMagnet().getMagnets().getWiresShape() : null;
tailS = shape;
}
if (applyAccept && accept) {
accept = accept && acceptMagnetAndUpdateAutoConnection(connection, isHead, headS, tailS, currentMagnet);
if (!accept) {
throw new RuntimeException("This should never happen, acceptors should not fail if the alled passed. Added for defensive programming checking");
}
}
return accept;
}
use of com.ait.lienzo.client.core.shape.wires.WiresShape in project lienzo-core by ahome-it.
the class WiresConnectionControlImpl method makeAndUpdateSpecialConnections.
private boolean makeAndUpdateSpecialConnections() {
final WiresConnection connection = getConnection();
WiresShape shape = null;
if (m_current_magnet != null) {
shape = m_current_magnet.getMagnets().getWiresShape();
connection.setAutoConnection(false);
} else {
if (m_colorKey != null) {
shape = m_shape_color_map.get(m_colorKey);
if ((shape != null) && (shape.getMagnets() != null)) {
// no magnet is selected, but if we are over a shape, then auto connect
connection.setAutoConnection(true);
} else {
connection.setAutoConnection(false);
}
} else {
connection.setAutoConnection(false);
}
}
return allowedMagnetAndUpdateAutoConnections(connection, m_head, shape, m_current_magnet, true);
}
use of com.ait.lienzo.client.core.shape.wires.WiresShape in project lienzo-core by ahome-it.
the class WiresDockingControlImpl method afterMoveStart.
@Override
protected void afterMoveStart(final double x, final double y) {
super.afterMoveStart(x, y);
final WiresShape shape = getShape();
if (null != shape.getDockedTo()) {
shape.setDockedTo(null);
}
}
use of com.ait.lienzo.client.core.shape.wires.WiresShape in project lienzo-core by ahome-it.
the class WiresDockingControlImpl method getAdjust.
@Override
public Point2D getAdjust() {
if (isEnabled() && (intersection != null)) {
final WiresShape shape = getShape();
final BoundingBox box = shape.getPath().getBoundingBox();
// convert to local xy of the path
final Point2D absLoc = getParent().getComputedLocation();
final double newX = (absLoc.getX() + intersection.getX()) - (box.getWidth() / 2);
final double newY = (absLoc.getY() + intersection.getY()) - (box.getHeight() / 2);
return new Point2D(newX - initialPathLocation.getX(), newY - initialPathLocation.getY());
}
return new Point2D(0, 0);
}
use of com.ait.lienzo.client.core.shape.wires.WiresShape in project lienzo-core by ahome-it.
the class WiresDockingControlImpl method afterMove.
@Override
protected boolean afterMove(final double dx, final double dy) {
super.afterMove(dx, dy);
intersection = null;
if (isAllow()) {
final Point2D location = getParentPickerControl().getCurrentLocation();
// convert to local xy of the path
final Point2D absLoc = getParent().getComputedLocation();
intersection = Geometry.findIntersection((int) (location.getX() - absLoc.getX()), (int) (location.getY() - absLoc.getY()), ((WiresShape) getParent()).getPath());
}
return null != intersection;
}
Aggregations