use of org.eclipse.gmf.runtime.notation.Bounds in project statecharts by Yakindu.
the class FactoryUtils method setTextCompartmentLayoutConstraint.
private static void setTextCompartmentLayoutConstraint(Node textCompartment) {
Bounds bounds = NotationFactory.eINSTANCE.createBounds();
bounds.setX(INITIAL_TEXT_COMPARTMENT_X);
bounds.setY(INITIAL_TEXT_COMPARTMENT_Y);
bounds.setHeight(INITIAL_TEXT_COMPARTMENT_HEIGHT);
bounds.setWidth(INITIAL_TEXT_COMPARTMENT_WIDTH);
textCompartment.setLayoutConstraint(bounds);
}
use of org.eclipse.gmf.runtime.notation.Bounds 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.Bounds 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.Bounds in project statecharts by Yakindu.
the class GroupStatesIntoCompositeRefactoring method setCompositeStateLayoutConstraint.
/**
* Iterates through all {@link StateEditPart}s of the current selection and
* computes layout constraints for the composite node.
*
* @param compositeStateNode
* node of the composite state
*/
protected void setCompositeStateLayoutConstraint(Node compositeStateNode) {
Rectangle newbounds = null;
for (GraphicalEditPart editPart : getContextObjects()) {
Rectangle childBounds = editPart.getFigure().getBounds();
if (newbounds == null)
newbounds = childBounds.getCopy();
newbounds.union(childBounds);
}
newbounds.expand(new Insets(PADDING, PADDING, PADDING, PADDING));
Bounds bounds = NotationFactory.eINSTANCE.createBounds();
bounds.setX(newbounds.x);
bounds.setY(newbounds.y);
bounds.setWidth(newbounds.width);
bounds.setHeight(newbounds.height);
compositeStateNode.setLayoutConstraint(bounds);
}
Aggregations