use of org.eclipse.draw2d.AnchorListener in project tdi-studio-se by Talend.
the class NodeFigure method setBounds.
@Override
public void setBounds(final Rectangle rect) {
super.setBounds(rect);
Point location = (new Point(rect.getCenter())).translate(new Point(-fig.getSize().width / 2, -(fig.getSize().height / 2)));
Rectangle figBounds = new Rectangle(location, fig.getSize());
this.fig.setBounds(figBounds);
if (dummy) {
if (sourceDummyMap != null) {
if (targetConnection != null && sourceDummyMap.keySet().size() != 0) {
for (final ConnectionFigure curConn : newSourceConnections) {
AnchorListener sourceListener = new AnchorListener() {
@Override
public void anchorMoved(ConnectionAnchor anchor) {
if (curConn != null) {
updateSource(curConn);
}
}
};
if (curConn.getTargetAnchor() != null && curConn.getTargetAnchor().getOwner() != null) {
sourceListeners.put(curConn, sourceListener);
curConn.getTargetAnchor().addAnchorListener(sourceListener);
}
}
newSourceConnections.clear();
updateTarget();
List<ConnectionFigure> toRemove = new ArrayList<ConnectionFigure>();
for (ConnectionFigure curConn : sourceDummyMap.keySet()) {
ConnectionFigure connToRemove = updateSource(curConn);
if (connToRemove != null) {
toRemove.add(connToRemove);
}
}
sourceDummyMap.keySet().removeAll(toRemove);
} else {
INodeConnector mainNodeConnector = node.getConnectorFromType(EConnectionType.FLOW_MAIN);
ConnectionFigure connection = new ConnectionFigure(mainNodeConnector.getConnectionProperty(EConnectionType.FLOW_MAIN), node);
connection.setTargetDecoration(null);
connection.setStart(new Point(figBounds.x, figBounds.y + figBounds.height / 2));
connection.setEnd(new Point(figBounds.x + figBounds.width, figBounds.y + figBounds.height / 2));
}
}
}
if (!rect.getSize().equals(fig.getSize())) {
lineBorder.setUseRectangle(true);
} else {
lineBorder.setUseRectangle(false);
}
}
Aggregations