use of org.eclipse.draw2d.Connection in project dbeaver by dbeaver.
the class GraphAnimation method recordFinalState.
public static void recordFinalState(IFigure child) {
if (child instanceof Connection) {
recordFinalState((Connection) child);
return;
}
Rectangle rect2 = child.getBounds().getCopy();
Rectangle rect1 = (Rectangle) initialStates.get(child);
if (rect1.isEmpty()) {
rect1.x = rect2.x;
rect1.y = rect2.y;
rect1.width = rect2.width;
}
finalStates.put(child, rect2);
}
use of org.eclipse.draw2d.Connection in project statecharts by Yakindu.
the class EditPartUtils method findEditPartForSemanticElement.
@SuppressWarnings("unchecked")
public static IGraphicalEditPart findEditPartForSemanticElement(EditPart editPart, EObject semanticElement) {
if (semanticElement == null) {
return null;
}
if (editPart instanceof IGraphicalEditPart) {
EObject resolveSemanticElement = ((IGraphicalEditPart) editPart).resolveSemanticElement();
if (resolveSemanticElement != null && EcoreUtil.getURI(resolveSemanticElement).equals(EcoreUtil.getURI(semanticElement))) {
return (IGraphicalEditPart) editPart;
}
}
for (Object child : editPart.getChildren()) {
IGraphicalEditPart recursiveEditPart = findEditPartForSemanticElement((EditPart) child, semanticElement);
if (recursiveEditPart != null) {
return recursiveEditPart;
}
}
if (editPart instanceof NodeEditPart) {
List<Connection> connections = new ArrayList<Connection>();
connections.addAll(((NodeEditPart) editPart).getSourceConnections());
connections.addAll(((NodeEditPart) editPart).getTargetConnections());
for (Object connection : connections) {
EObject resolveSemanticElement = ((IGraphicalEditPart) connection).resolveSemanticElement();
if (EcoreUtil.equals(resolveSemanticElement, semanticElement)) {
return (IGraphicalEditPart) connection;
}
}
}
return null;
}
use of org.eclipse.draw2d.Connection in project statecharts by Yakindu.
the class TreeLayoutUtil method getTreeFigureIncomingConnections.
// private static void setParentAnnotation(IFigure childFigure,
// IFigure parentFigure, EditPartViewer viewer) {
// final IGraphicalEditPart parentEditPart = (IGraphicalEditPart) viewer
// .getVisualPartMap().get(parentFigure);
// final IGraphicalEditPart childEditPart = (IGraphicalEditPart) viewer
// .getVisualPartMap().get(childFigure);
// try {
// CommandUtil
// .executeUndoableOperation(new SetTreeParentAnnotationCommand(
// childEditPart.getNotationView(), parentEditPart
// .getNotationView()));
// } catch (final ExecutionException e) {
// e.printStackTrace();
// }
// }
//
// private static IFigure getAnnotatedParentFigure(IFigure figure,
// EditPartViewer viewer) {
// final IGraphicalEditPart editPart = (IGraphicalEditPart) viewer
// .getVisualPartMap().get(figure);
// final View view = editPart.getNotationView();
//
// final EAnnotation xmiIdAnnotation = view
// .getEAnnotation(TREE_LAYOUT_ANNOTATION);
//
// if (xmiIdAnnotation != null) {
// final String parentURI = xmiIdAnnotation.getDetails().get(
// TREE_NODE_PARENT_URI);
// if (parentURI != null) {
// final EObject object = view.eResource().getEObject(parentURI);
// final IGraphicalEditPart parentEditPart = (IGraphicalEditPart) viewer
// .getEditPartRegistry().get(object);
// return parentEditPart != null ? parentEditPart.getFigure()
// : null;
// }
// }
// return null;
// }
/**
* Returns only elements parent figure is a direct parent. Indirect
* connections are filtered out. Use if children can have many parents.
*
* @param connectionLayer
* @param parentFigure
* @return
*/
public static List<Connection> getTreeFigureIncomingConnections(ConnectionLayer connectionLayer, IFigure parentFigure) {
final List<Connection> connectionList = getIncomingConnections(connectionLayer, parentFigure);
final List<Connection> indirectChildren = new ArrayList<Connection>();
final int parentFigureTreeLevel = getDeepestTreeLevel(connectionLayer, parentFigure);
for (final Connection connection : connectionList) {
final IFigure childFigure = connection.getSourceAnchor().getOwner();
final int childTreeLevel = getDeepestTreeLevel(connectionLayer, childFigure);
if (childTreeLevel == parentFigureTreeLevel + 1) {
// get LayoutConstraint of child Figure;
Object object = parentFigure.getParent().getLayoutManager().getConstraint(childFigure);
if (object instanceof TreeLayoutConstraint) {
TreeLayoutConstraint childConstraint = (TreeLayoutConstraint) object;
final IFigure constrainedParentFig = childConstraint.getTreeParentFigure();
if (constrainedParentFig == null) {
childConstraint.setTreeParentFigure(parentFigure);
} else if (constrainedParentFig != parentFigure) {
indirectChildren.add(connection);
}
}
} else {
indirectChildren.add(connection);
}
}
connectionList.removeAll(indirectChildren);
return connectionList;
}
use of org.eclipse.draw2d.Connection in project archi by archimatetool.
the class ManualBendpointEditPolicy method getCreateBendpointCommand.
@Override
protected Command getCreateBendpointCommand(BendpointRequest request) {
CreateBendpointCommand command = new CreateBendpointCommand();
Point p = request.getLocation();
Connection conn = getConnection();
conn.translateToRelative(p);
command.setLocation(p);
Point ref1 = getConnection().getSourceAnchor().getReferencePoint();
Point ref2 = getConnection().getTargetAnchor().getReferencePoint();
conn.translateToRelative(ref1);
conn.translateToRelative(ref2);
command.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2));
command.setDiagramModelConnection((IDiagramModelConnection) request.getSource().getModel());
command.setIndex(request.getIndex());
return command;
}
use of org.eclipse.draw2d.Connection in project archi by archimatetool.
the class ManualBendpointEditPolicy method getMoveBendpointCommand.
@Override
protected Command getMoveBendpointCommand(BendpointRequest request) {
MoveBendpointCommand command = new MoveBendpointCommand();
Point p = request.getLocation();
Connection conn = getConnection();
conn.translateToRelative(p);
command.setLocation(p);
Point ref1 = getConnection().getSourceAnchor().getReferencePoint();
Point ref2 = getConnection().getTargetAnchor().getReferencePoint();
conn.translateToRelative(ref1);
conn.translateToRelative(ref2);
command.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2));
command.setDiagramModelConnection((IDiagramModelConnection) request.getSource().getModel());
command.setIndex(request.getIndex());
return command;
}
Aggregations