use of org.eclipse.draw2d.ConnectionAnchor in project whole by wholeplatform.
the class SimpleEntityTreeFigure method paintConnections.
protected void paintConnections(Graphics graphics) {
if (contents.isVisible()) {
graphics.setForegroundColor(FigureConstants.relationsColor);
int egdeXOffset = DrawUtils.SPACING - DrawUtils.EDGE_SPACING;
ConnectionAnchor[] srcAnchors = getSourceAnchors();
int i;
int prevYSourceLocation = Integer.MAX_VALUE;
for (i = 0; i < srcAnchors.length; i++) {
IFigure contentPane = getContentPane(i);
if (contentPane.isVisible()) {
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 = isRightToLeft() ? targetFigure.getBounds().getRight() : targetFigure.getBounds().getLeft();
targetFigure.translateToAbsolute(targetLocation);
}
translateToRelative(targetLocation);
translateToRelative(sourceLocation);
if (targetLocation.y > sourceLocation.y)
break;
if (prevYSourceLocation >= targetLocation.y - 1)
egdeXOffset += DrawUtils.EDGE_SPACING;
prevYSourceLocation = sourceLocation.y;
DrawUtils.drawHorizontalEdge(graphics, sourceLocation, targetLocation, egdeXOffset);
}
}
egdeXOffset = DrawUtils.SPACING - DrawUtils.EDGE_SPACING;
prevYSourceLocation = Integer.MIN_VALUE;
for (int j = srcAnchors.length - 1; j >= i; j--) {
IFigure contentPane = getContentPane(j);
if (contentPane.isVisible()) {
IFigure targetFigure = (IFigure) contentPane.getChildren().get(0);
Point sourceLocation = srcAnchors[j].getLocation(null);
Point targetLocation = null;
if (targetFigure instanceof INodeFigure)
targetLocation = ((INodeFigure) targetFigure).getTargetAnchor(0).getLocation(null);
else {
targetLocation = isRightToLeft() ? targetFigure.getBounds().getRight() : targetFigure.getBounds().getLeft();
targetFigure.translateToAbsolute(targetLocation);
}
translateToRelative(targetLocation);
translateToRelative(sourceLocation);
if (prevYSourceLocation <= targetLocation.y + 1)
egdeXOffset += DrawUtils.EDGE_SPACING;
prevYSourceLocation = sourceLocation.y;
DrawUtils.drawHorizontalEdge(graphics, sourceLocation, targetLocation, egdeXOffset);
}
}
}
}
use of org.eclipse.draw2d.ConnectionAnchor in project whole by wholeplatform.
the class SimpleTableNodeWithBranchesFigure method paintConnections.
protected void paintConnections(Graphics g) {
g.setForegroundColor(FigureConstants.relationsColor);
int egdeXOffset = DrawUtils.SPACING - DrawUtils.EDGE_SPACING;
ConnectionAnchor[] srcAnchors = getSourceAnchors();
int i, j, pi = 0;
int prevYSourceLocation = Integer.MAX_VALUE;
for (i = 0, pi = 0; i < srcAnchors.length; i++, pi++) {
while (featuresStyling[pi].isEmbedded()) pi++;
IFigure contentPane = getContentPane(typePaneShift + pi);
if (contentPane.isVisible()) {
// TODO test if needed
if (contentPane.getChildren().isEmpty())
return;
Point sourceLocation = srcAnchors[i].getLocation(null);
int yMax = 0;
IFigure targetFigure = (IFigure) contentPane.getChildren().get(0);
List<Point> targetLocations = new ArrayList<>();
if (targetFigure instanceof INodeFigure) {
INodeFigure targetNode = (INodeFigure) targetFigure;
for (int ti = 0; ti < targetNode.getTargetAnchorsSize(); ti++) {
Point t = targetNode.getTargetAnchor(ti).getLocation(sourceLocation);
translateToRelative(t);
targetLocations.add(t);
yMax = Math.max(yMax, t.y);
}
} else {
Point t = targetFigure.getBounds().getLeft();
targetFigure.translateToAbsolute(t);
translateToRelative(t);
targetLocations.add(t);
yMax = Math.max(yMax, t.y);
}
translateToRelative(sourceLocation);
if (yMax > sourceLocation.y)
break;
if (prevYSourceLocation >= yMax - 1)
egdeXOffset += DrawUtils.EDGE_SPACING;
prevYSourceLocation = sourceLocation.y;
DrawUtils.drawHorizontalTree(g, sourceLocation, egdeXOffset, targetLocations.toArray(new Point[targetLocations.size()]));
}
}
egdeXOffset = DrawUtils.SPACING - DrawUtils.EDGE_SPACING;
prevYSourceLocation = Integer.MIN_VALUE;
for (j = srcAnchors.length - 1, pi = featuresStyling.length - 1; j >= i; j--, pi--) {
while (featuresStyling[pi].isEmbedded()) pi--;
IFigure contentPane = getContentPane(typePaneShift + pi);
if (contentPane.isVisible()) {
// TODO test if needed
if (contentPane.getChildren().isEmpty())
return;
Point sourceLocation = srcAnchors[j].getLocation(null);
int yMax = 0;
IFigure targetFigure = (IFigure) contentPane.getChildren().get(0);
List<Point> targetLocations = new ArrayList<>();
if (targetFigure instanceof INodeFigure) {
INodeFigure targetNode = (INodeFigure) targetFigure;
for (int ti = 0; ti < targetNode.getTargetAnchorsSize(); ti++) {
Point t = targetNode.getTargetAnchor(ti).getLocation(sourceLocation);
translateToRelative(t);
targetLocations.add(t);
yMax = Math.max(yMax, t.y);
}
} else {
Point t = targetFigure.getBounds().getLeft();
targetFigure.translateToAbsolute(t);
translateToRelative(t);
targetLocations.add(t);
yMax = Math.max(yMax, t.y);
}
translateToRelative(sourceLocation);
if (prevYSourceLocation <= yMax + 1)
egdeXOffset += DrawUtils.EDGE_SPACING;
prevYSourceLocation = sourceLocation.y;
DrawUtils.drawHorizontalTree(g, sourceLocation, egdeXOffset, targetLocations.toArray(new Point[targetLocations.size()]));
}
}
}
use of org.eclipse.draw2d.ConnectionAnchor in project archi by archimatetool.
the class ConnectionEndpointEditPolicy method showConnectionMoveFeedback.
/**
* Shows or updates connection move feedback. Called whenever a show
* feedback request is received for reconnection.
*
* @param request
* the reconnect request
*/
protected void showConnectionMoveFeedback(ReconnectRequest request) {
NodeEditPart node = null;
if (request.getTarget() instanceof NodeEditPart)
node = (NodeEditPart) request.getTarget();
if (originalAnchor == null) {
if (request.isMovingStartAnchor())
originalAnchor = getConnection().getSourceAnchor();
else
originalAnchor = getConnection().getTargetAnchor();
}
ConnectionAnchor anchor = null;
if (node != null) {
if (request.isMovingStartAnchor())
anchor = node.getSourceConnectionAnchor(request);
else
anchor = node.getTargetConnectionAnchor(request);
}
FeedbackHelper helper = getFeedbackHelper(request);
helper.update(anchor, request.getLocation());
}
use of org.eclipse.draw2d.ConnectionAnchor in project xtext-eclipse by eclipse.
the class Connection method createAnchors.
private void createAnchors(CrossPoint source, CrossPoint target) {
ConnectionAnchor sourceAnchor = new Anchor(source);
ConnectionAnchor targetAnchor = new Anchor(target);
setSourceAnchor(sourceAnchor);
setTargetAnchor(targetAnchor);
}
Aggregations