use of org.eclipse.draw2d.ConnectionAnchor in project whole by wholeplatform.
the class RBNodeFigure method paintConnections.
protected void paintConnections(Graphics graphics) {
graphics.setForegroundColor(ColorConstants.black);
ConnectionAnchor[] srcAnchors = getSourceAnchors();
for (int i = 0; i < srcAnchors.length; i++) {
IFigure contentPane = getContentPane(i + 1);
IFigure targetFigure = (IFigure) contentPane.getChildren().get(0);
Point sourceLocation = srcAnchors[i].getLocation(null);
Point targetLocation = null;
if (targetFigure instanceof INodeFigure)
targetLocation = ((INodeFigure) targetFigure).getTargetAnchor(0).getLocation(null);
else {
targetLocation = targetFigure.getBounds().getTop();
targetFigure.translateToAbsolute(targetLocation);
}
translateToRelative(targetLocation);
translateToRelative(sourceLocation);
graphics.drawLine(sourceLocation, targetLocation);
}
}
use of org.eclipse.draw2d.ConnectionAnchor in project webtools.sourceediting by eclipse.
the class XSDModelGroupRouter method getEndDirection.
protected Ray getEndDirection(Connection conn) {
ConnectionAnchor anchor = conn.getTargetAnchor();
Point p = getEndPoint(conn);
Rectangle rect;
if (anchor.getOwner() == null)
rect = new Rectangle(p.x - 1, p.y - 1, 2, 2);
else {
rect = conn.getTargetAnchor().getOwner().getBounds().getCopy();
conn.getTargetAnchor().getOwner().translateToAbsolute(rect);
}
return getDirection(rect, p);
}
use of org.eclipse.draw2d.ConnectionAnchor in project yamcs-studio by yamcs.
the class AbstractBaseEditPart method getClosestAnchorAt.
/**
* Get the closest anchor to point p.
*
* @param p
* the reference point
* @return the closest anchor to point p
*/
protected ConnectionAnchor getClosestAnchorAt(Point p) {
if (anchorMap == null) {
fillAnchorMap();
}
ConnectionAnchor closest = null;
double min = Long.MAX_VALUE;
for (var anchor : anchorMap.values()) {
var p2 = anchor.getLocation(null);
var d = p.getDistance(p2);
if (d < min) {
min = d;
closest = anchor;
}
}
return closest;
}
use of org.eclipse.draw2d.ConnectionAnchor 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);
}
}
use of org.eclipse.draw2d.ConnectionAnchor in project yamcs-studio by yamcs.
the class WidgetNodeEditPolicy method getConnectionCompleteCommand.
@Override
protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
ConnectionCreateCommand cmd = (ConnectionCreateCommand) request.getStartCommand();
cmd.setTarget(getWidgetEditPart().getWidgetModel());
ConnectionAnchor anchor = getWidgetEditPart().getTargetConnectionAnchor(request);
if (anchor == null)
return null;
cmd.setTargetTerminal(getWidgetEditPart().getTerminalNameFromAnchor(anchor));
return cmd;
}
Aggregations