Search in sources :

Example 1 with ExternalXtextLabelEditPart

use of org.yakindu.base.xtext.utils.gmf.directedit.ExternalXtextLabelEditPart 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));
                }
            }
        }
    }
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Connection(org.eclipse.draw2d.Connection) ExternalXtextLabelEditPart(org.yakindu.base.xtext.utils.gmf.directedit.ExternalXtextLabelEditPart) Vector(org.eclipse.draw2d.geometry.Vector) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

Connection (org.eclipse.draw2d.Connection)1 IFigure (org.eclipse.draw2d.IFigure)1 PointList (org.eclipse.draw2d.geometry.PointList)1 Vector (org.eclipse.draw2d.geometry.Vector)1 ExternalXtextLabelEditPart (org.yakindu.base.xtext.utils.gmf.directedit.ExternalXtextLabelEditPart)1