use of org.eclipse.draw2d.ConnectionAnchor in project tdi-studio-se by Talend.
the class LookupConnectionRouter method getEndDirection.
protected Vector 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 PatchedConnectionLayerClippingStrategy method getEdgeClippingRectangle.
@Override
protected Rectangle[] getEdgeClippingRectangle(Connection connection) {
// start with clipping the connection at its original bounds
Rectangle clipRect = getAbsoluteBoundsAsCopy(connection);
// in case we cannot infer source and target of the connection (e.g.
// if XYAnchors are used), returning the bounds is all we can do
ConnectionAnchor sourceAnchor = connection.getSourceAnchor();
ConnectionAnchor targetAnchor = connection.getTargetAnchor();
if (sourceAnchor == null || sourceAnchor.getOwner() == null || targetAnchor == null || targetAnchor.getOwner() == null) {
return new Rectangle[] { clipRect };
}
// source and target figure are known, see if there is common
// viewport
// the connection has to be clipped at.
IFigure sourceFigure = sourceAnchor.getOwner();
IFigure targetFigure = targetAnchor.getOwner();
if (!sourceFigure.isShowing() || !targetFigure.isShowing())
return new Rectangle[] {};
return super.getEdgeClippingRectangle(connection);
}
use of org.eclipse.draw2d.ConnectionAnchor in project yamcs-studio by yamcs.
the class WidgetNodeEditPolicy method getConnectionCreateCommand.
@Override
protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
AbstractWidgetModel source = getWidgetEditPart().getWidgetModel();
ConnectionAnchor anchor = getWidgetEditPart().getSourceConnectionAnchor(request);
String sourceTerminal = getWidgetEditPart().getTerminalNameFromAnchor(anchor);
ConnectionCreateCommand cmd = new ConnectionCreateCommand(source, sourceTerminal);
request.setStartCommand(cmd);
return cmd;
}
use of org.eclipse.draw2d.ConnectionAnchor in project whole by wholeplatform.
the class ChildrenBranchesFigure method createTargetAnchors.
@Override
protected ConnectionAnchor[] createTargetAnchors() {
@SuppressWarnings("unchecked") List<IFigure> children = getContentPane(0).getChildren();
int childrenSize = children.size();
if (childrenSize == 0)
return NO_ANCHORS;
else {
ConnectionAnchor[] anchors = new ConnectionAnchor[childrenSize];
for (int i = 0; i < childrenSize; i++) {
IFigure child = children.get(i);
if (child instanceof INodeFigure) {
// TODO x size
anchors[i] = ((INodeFigure) child).getTargetAnchor(0);
} else
anchors[i] = AnchorFactory.createLeftMiddleAnchor(child);
}
return anchors;
}
}
use of org.eclipse.draw2d.ConnectionAnchor in project whole by wholeplatform.
the class AbstractStyledLayout method getChildPoint.
protected Point getChildPoint(int index, IFigure childFigure) {
if (childFigure instanceof INodeFigure) {
Point absoluteRootPoint = new Point(getRootPoint());
childFigure.translateToAbsolute(absoluteRootPoint);
ConnectionAnchor targetAnchor = ((INodeFigure) childFigure).getClosestTargetAnchor(absoluteRootPoint, getDistanceMetric());
if (targetAnchor != null) {
Point childPoint = targetAnchor.getLocation(absoluteRootPoint);
childFigure.translateToRelative(childPoint);
return childPoint;
}
}
return getChildPoint2(index, childFigure);
}
Aggregations