use of org.eclipse.gmf.runtime.notation.Node in project statecharts by Yakindu.
the class ExtractSubdiagramRefactoring method setPreferredSize.
protected void setPreferredSize() {
Node node = (Node) getContextObject();
Bounds bounds = (Bounds) node.getLayoutConstraint();
bounds.setWidth(-1);
bounds.setHeight(-1);
}
use of org.eclipse.gmf.runtime.notation.Node in project statecharts by Yakindu.
the class ExtractSubdiagramRefactoring method createSubdiagram.
/**
* Creates a new {@link Diagram} and copies child elements
*/
protected Diagram createSubdiagram() {
View contextView = getContextObject();
State contextElement = (State) contextView.getElement();
Diagram subdiagram = ViewService.createDiagram(contextElement, StatechartDiagramEditor.ID, preferencesHint);
View figureCompartment = ViewUtil.getChildBySemanticHint(contextView, SemanticHints.STATE_FIGURE_COMPARTMENT);
getResource().getContents().add(subdiagram);
boolean isHorizontal = isHorizontal(figureCompartment);
int offset = 0;
int subregions = figureCompartment.getChildren().size();
while (figureCompartment.getChildren().size() > 0) {
Node child = (Node) figureCompartment.getChildren().get(0);
if (subregions > 1) {
Rectangle actualBounds = getActualBounds(child);
if (actualBounds != Rectangle.SINGLETON) {
Bounds modelBounds = (Bounds) child.getLayoutConstraint();
modelBounds.setWidth(actualBounds.width());
modelBounds.setHeight(actualBounds.height());
if (isHorizontal) {
modelBounds.setX(offset);
offset += actualBounds.width();
} else {
modelBounds.setY(offset);
offset += actualBounds.height();
}
}
}
subdiagram.insertChild(child);
}
return subdiagram;
}
use of org.eclipse.gmf.runtime.notation.Node in project statecharts by Yakindu.
the class ExtractSubdiagramRefactoring method createExitPoint.
protected void createExitPoint(Edge edge, Diagram subdiagram) {
Transition transition = (Transition) edge.getElement();
// create semantic exit point
Region exitPointContainer = getExitPointContainer(transition);
Exit exitPoint = createSemanticExitPoint(transition);
// create node for exit point
View exitPointContainerView = helper.getViewForSemanticElement(exitPointContainer, subdiagram);
View exitPointRegionCompartment = ViewUtil.getChildBySemanticHint(exitPointContainerView, SemanticHints.REGION_COMPARTMENT);
Node exitNode = ViewService.createNode(exitPointRegionCompartment, exitPoint, SemanticHints.EXIT, preferencesHint);
// re-wire existing transition to new exit point
Vertex oldTransitionTarget = transition.getTarget();
transition.setTarget(exitPoint);
View oldEdgeTarget = edge.getTarget();
edge.setTarget(exitNode);
// create transition from selected state to former transition target
Transition exitPointTransition = SGraphFactory.eINSTANCE.createTransition();
exitPointTransition.setSource((State) subdiagram.getElement());
exitPointTransition.setTarget(oldTransitionTarget);
ViewService.createEdge(getContextObject(), oldEdgeTarget, exitPointTransition, SemanticHints.TRANSITION, preferencesHint);
addExitPointSpec(exitPointTransition, exitPoint);
}
use of org.eclipse.gmf.runtime.notation.Node in project statecharts by Yakindu.
the class GroupStatesIntoCompositeRefactoring method createNodeForCompositeState.
protected Node createNodeForCompositeState(State compositeState) {
Node compositeStateNode = ViewService.createNode(parentRegionView, compositeState, SemanticHints.STATE, preferencesHint);
setCompositeStateLayoutConstraint(compositeStateNode);
return compositeStateNode;
}
Aggregations