use of com.ait.lienzo.client.core.shape.wires.IControlHandle in project lienzo-core by ahome-it.
the class WiresConnectorControlImpl method destroyControlPoint.
@Override
public void destroyControlPoint(final IPrimitive<?> control) {
if (m_connector.getPointHandles().size() <= 2) {
m_wiresManager.deregister(m_connector);
return;
}
IControlHandle selected = null;
for (final IControlHandle handle : m_connector.getPointHandles()) {
if (handle.getControl() == control) {
selected = handle;
break;
}
}
if (null == selected) {
return;
}
final Point2DArray oldPoints = m_connector.getLine().getPoint2DArray();
final Point2DArray newPoints = new Point2DArray();
final Point2D selectedPoint2D = selected.getControl().getLocation();
for (int i = 0; i < oldPoints.size(); i++) {
final Point2D current = oldPoints.get(i);
if (!current.equals(selectedPoint2D)) {
newPoints.push(current);
}
}
m_connector.getLine().setPoint2DArray(newPoints);
destroyPointHandles();
showPointHandles();
}
use of com.ait.lienzo.client.core.shape.wires.IControlHandle in project lienzo-core by ahome-it.
the class WiresConnectorControlImpl method showPointHandles.
public void showPointHandles() {
if (m_HandlerRegistrationManager == null) {
m_HandlerRegistrationManager = m_connector.getPointHandles().getHandlerRegistrationManager();
m_connector.getPointHandles().show();
m_headConnectionControl = m_wiresManager.getControlFactory().newConnectionControl(m_connector, true, m_wiresManager);
final ConnectionHandler headConnectionHandler = new ConnectionHandler(m_headConnectionControl);
final Shape<?> head = m_connector.getHeadConnection().getControl().asShape();
head.setDragConstraints(headConnectionHandler);
m_HandlerRegistrationManager.register(head.addNodeDragEndHandler(headConnectionHandler));
m_tailConnectionControl = m_wiresManager.getControlFactory().newConnectionControl(m_connector, false, m_wiresManager);
final ConnectionHandler tailConnectionHandler = new ConnectionHandler(m_tailConnectionControl);
final Shape<?> tail = m_connector.getTailConnection().getControl().asShape();
tail.setDragConstraints(tailConnectionHandler);
m_HandlerRegistrationManager.register(tail.addNodeDragEndHandler(tailConnectionHandler));
final WiresConnectorControlHandler controlPointsHandler = new WiresConnectorControlHandler();
for (final IControlHandle handle : m_connector.getPointHandles()) {
final Shape<?> shape = handle.getControl().asShape();
m_HandlerRegistrationManager.register(shape.addNodeMouseDoubleClickHandler(controlPointsHandler));
}
}
}
use of com.ait.lienzo.client.core.shape.wires.IControlHandle in project lienzo-core by ahome-it.
the class WiresConnectorControlImpl method onMoveStart.
@Override
public void onMoveStart(final double x, final double y) {
final IControlHandleList handles = m_connector.getPointHandles();
m_startPoints = new NFastDoubleArray();
for (int i = 0; i < handles.size(); i++) {
final IControlHandle h = handles.getHandle(i);
final IPrimitive<?> prim = h.getControl();
m_startPoints.push(prim.getX());
m_startPoints.push(prim.getY());
}
}
use of com.ait.lienzo.client.core.shape.wires.IControlHandle in project lienzo-core by ahome-it.
the class WiresConnectorControlImpl method reset.
/*
***************** CONTROL POINTS **********************************
*/
@Override
public void reset() {
if (null != m_startPoints) {
final IControlHandleList handles = m_connector.getPointHandles();
final Point2DArray points = m_connector.getLine().getPoint2DArray();
for (int i = 0, j = 0; i < handles.size(); i++, j += 2) {
final double px = m_startPoints.get(j);
final double py = m_startPoints.get(j + 1);
final IControlHandle h = handles.getHandle(i);
final IPrimitive<?> prim = h.getControl();
prim.setX(px);
prim.setY(py);
final Point2D point = points.get(i);
point.setX(px);
point.setY(py);
}
}
m_connector.getLine().refresh();
m_wiresManager.getLayer().getLayer().batch();
}
use of com.ait.lienzo.client.core.shape.wires.IControlHandle in project lienzo-core by ahome-it.
the class WiresConnectorControlImpl method move.
/**
* See class javadocs to explain why we have these booleans
*/
@Override
public void move(final double dx, final double dy, final boolean midPointsOnly, final boolean moveLinePoints) {
final IControlHandleList handles = m_connector.getPointHandles();
int start = 0;
int end = handles.size();
if (midPointsOnly) {
if (m_connector.getHeadConnection().getMagnet() != null) {
start++;
}
if (m_connector.getTailConnection().getMagnet() != null) {
end--;
}
}
final Point2DArray points = m_connector.getLine().getPoint2DArray();
for (int i = start, j = (start == 0) ? start : 2; i < end; i++, j += 2) {
if (moveLinePoints) {
final Point2D p = points.get(i);
p.setX(m_startPoints.get(j) + dx);
p.setY(m_startPoints.get(j + 1) + dy);
}
final IControlHandle h = handles.getHandle(i);
final IPrimitive<?> prim = h.getControl();
prim.setX(m_startPoints.get(j) + dx);
prim.setY(m_startPoints.get(j + 1) + dy);
}
if (moveLinePoints) {
m_connector.getLine().refresh();
}
m_wiresManager.getLayer().getLayer().batch();
}
Aggregations