use of org.eclipse.draw2d.Connection in project statecharts by Yakindu.
the class TreeLayoutUtil method getDeepestTreeLevel.
private static int getDeepestTreeLevel(ConnectionLayer connectionLayer, IFigure figure) {
final List<Connection> connectionList = getOutgoingConnections(connectionLayer, figure);
if (connectionList.size() > 0) {
final int[] ret = new int[connectionList.size()];
for (int i = 0; i < connectionList.size(); i++) {
ret[i] = 1 + getDeepestTreeLevel(connectionLayer, connectionList.get(i).getTargetAnchor().getOwner());
}
int maxLevel = ret[0];
if (ret.length > 1) {
for (int i = 1; i < ret.length; i++) {
if (ret[i] > maxLevel) {
maxLevel = ret[i];
}
}
}
return maxLevel;
}
return 0;
}
use of org.eclipse.draw2d.Connection in project statecharts by Yakindu.
the class InitialPointsOfRequestDataManager method storeInitialPointsInRequest.
/**
* Store the initial points of the edge in the request (before feedback
* drawing). This data can be used later for computing the location of the
* labels of this edge in the command construction.<BR>
* This method also set the feedback data of the {@link EdgeLabelLocator} of the
* labels of the current connection to correctly draw the label feedback during
* the label move.
*
* @param request
* the request in which to store the original points of the edge.
* @param connectionEditPart
* the editPart of the edge
*/
@SuppressWarnings("unchecked")
public void storeInitialPointsInRequest(LocationRequest request, ConnectionEditPart connectionEditPart) {
if (initialPoints == null) {
initialPoints = new PointList();
Connection connection = (Connection) connectionEditPart.getFigure();
for (int i = 0; i < connection.getPoints().size(); i++) {
initialPoints.addPoint(connection.getPoints().getPoint(i).getCopy());
}
request.getExtendedData().put(INITIAL_POINTS_KEY, initialPoints);
List<?> children = connectionEditPart.getChildren();
for (Object child : children) {
if (child instanceof ExternalXtextLabelEditPart) {
IFigure figure = ((ExternalXtextLabelEditPart) child).getFigure();
Object currentConstraint = connection.getLayoutManager().getConstraint(figure);
if (currentConstraint instanceof EdgeLabelLocator) {
EdgeLabelLocator edgeLabelLocator = (EdgeLabelLocator) currentConstraint;
edgeLabelLocator.setFeedbackData(initialPoints, new Vector(edgeLabelLocator.getOffset().x, edgeLabelLocator.getOffset().y), SetLabelsOffsetOperation.isEdgeWithObliqueRoutingStyle(connectionEditPart));
}
}
}
}
}
use of org.eclipse.draw2d.Connection in project archi by archimatetool.
the class ArchiConnectionEndpointLocator method relocate.
/**
* Relocates the given IFigure at either the source or target end of the
* Connection, based on the <code>boolean</code> given in the constructor
* {@link #ConnectionEndpointLocator(Connection, boolean)}.
*
* @param figure
* The figure to relocate
*/
@Override
public void relocate(IFigure figure) {
Connection conn = getConnection();
Point startPoint = Point.SINGLETON;
Point endPoint = new Point();
int startPointPosition = 0;
int endPointPosition = 1;
if (isEnd()) {
startPointPosition = conn.getPoints().size() - 1;
endPointPosition = startPointPosition - 1;
}
conn.getPoints().getPoint(startPoint, startPointPosition);
conn.getPoints().getPoint(endPoint, endPointPosition);
int quadrant;
quadrant = calculateConnectionLocation(startPoint, endPoint);
int cos = 1;
transposer.setEnabled(false);
/*
* Label placement calculations are done as if the connection point is
* along the left or right side of the figure. If the connection point
* is along the top or bottom, values are transposed.
*/
if (quadrant == 1 || quadrant == 3)
transposer.setEnabled(true);
if (quadrant == 3 || quadrant == 4)
cos = -1;
Dimension figureSize = transposer.t(figure.getPreferredSize());
startPoint = transposer.t(startPoint);
endPoint = transposer.t(endPoint);
double tan = calculateTan(startPoint, endPoint);
int figureWidth = figureSize.width;
int figureHeight = figureSize.height;
int yShift = calculateYShift(figureWidth, figureHeight);
Point figurePoint = new Point(startPoint.x + (uDistance * cos) + figureWidth * ((cos - 1) / 2), (int) (startPoint.y + cos * uDistance * tan + vDistance + yShift));
figureBounds.setSize(transposer.t(figureSize));
figureBounds.setLocation(transposer.t(figurePoint));
figure.setBounds(figureBounds);
}
use of org.eclipse.draw2d.Connection in project archi by archimatetool.
the class MarqueeSelectionTool method isPrimaryMarqueeSelectedEditPart.
/**
* Determines which edit parts are directly affected by the current marquee
* selection. Calculation is performed by regarding the current marquee
* selection rectangle ( {@link #getCurrentMarqueeSelectionRectangle()}),
* taking into consideration the current marquee behavior (contained vs.
* touched) that was provided ( {@link #setMarqueeBehavior(int)} ).
*
* @param editPart
* the {@link EditPart} whose state is to be determined
* @return <code>true</code> if the {@link EditPart} should be regarded as
* being included in the current marquee selection,
* <code>false</code> otherwise.
* @since 3.7
*/
private boolean isPrimaryMarqueeSelectedEditPart(GraphicalEditPart editPart) {
// figure bounds are used to determine if edit part is included in
// selection
IFigure figure = editPart.getFigure();
Rectangle r = figure.getBounds().getCopy();
figure.translateToAbsolute(r);
boolean included = false;
Rectangle marqueeSelectionRectangle = getCurrentMarqueeSelectionRectangle();
if (editPart instanceof ConnectionEditPart) {
if (marqueeBehavior == BEHAVIOR_CONNECTIONS_TOUCHED || marqueeBehavior == BEHAVIOR_CONNECTIONS_CONTAINED) {
if (marqueeSelectionRectangle.intersects(r)) {
// children will contain ConnectionEditParts only in case
// behavior is BEHAVIOR_CONNECTIONS_TOUCHED or
// BEHAVIOR_CONNECTIONS_CONTAINED
Rectangle relMarqueeRect = Rectangle.SINGLETON;
figure.translateToRelative(relMarqueeRect.setBounds(marqueeSelectionRectangle));
if (marqueeBehavior == BEHAVIOR_CONNECTIONS_TOUCHED) {
included = ((Connection) figure).getPoints().intersects(relMarqueeRect);
} else if (marqueeBehavior == BEHAVIOR_CONNECTIONS_CONTAINED) {
included = relMarqueeRect.contains(((Connection) figure).getPoints().getBounds());
}
}
}
} else {
// otherwise children will only be 'node' edit parts
if (marqueeBehavior == BEHAVIOR_NODES_TOUCHED || marqueeBehavior == BEHAVIOR_NODES_TOUCHED_AND_RELATED_CONNECTIONS) {
included = marqueeSelectionRectangle.intersects(r);
} else if (marqueeBehavior == BEHAVIOR_NODES_CONTAINED || marqueeBehavior == BEHAVIOR_NODES_CONTAINED_AND_RELATED_CONNECTIONS) {
included = marqueeSelectionRectangle.contains(r);
}
}
return included;
}
use of org.eclipse.draw2d.Connection in project tdi-studio-se by Talend.
the class ParallelLocator method getReferencePoint.
@Override
protected Point getReferencePoint() {
Connection conn = getConnection();
Point p = Point.SINGLETON;
Point p1 = conn.getPoints().getPoint(getIndex());
Point p2 = conn.getPoints().getPoint(getIndex() + 1);
conn.translateToAbsolute(p1);
conn.translateToAbsolute(p2);
p.x = ((p2.x - p1.x) / 9) * 1 + p1.x;
p.y = ((p2.y - p1.y) / 9) * 1 + p1.y;
return p;
}
Aggregations