Search in sources :

Example 6 with Bounds

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);
}
Also used : Bounds(org.eclipse.gmf.runtime.notation.Bounds)

Example 7 with 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);
}
Also used : Node(org.eclipse.gmf.runtime.notation.Node) Bounds(org.eclipse.gmf.runtime.notation.Bounds)

Example 8 with Bounds

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;
}
Also used : State(org.yakindu.sct.model.sgraph.State) Node(org.eclipse.gmf.runtime.notation.Node) Bounds(org.eclipse.gmf.runtime.notation.Bounds) Rectangle(org.eclipse.draw2d.geometry.Rectangle) View(org.eclipse.gmf.runtime.notation.View) PreferencesHint(org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint) Diagram(org.eclipse.gmf.runtime.notation.Diagram)

Example 9 with Bounds

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);
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Bounds(org.eclipse.gmf.runtime.notation.Bounds) Rectangle(org.eclipse.draw2d.geometry.Rectangle) GraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)

Aggregations

Bounds (org.eclipse.gmf.runtime.notation.Bounds)9 Node (org.eclipse.gmf.runtime.notation.Node)3 Rectangle (org.eclipse.draw2d.geometry.Rectangle)2 GraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart)2 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)2 Insets (org.eclipse.draw2d.geometry.Insets)1 PreferencesHint (org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint)1 Diagram (org.eclipse.gmf.runtime.notation.Diagram)1 View (org.eclipse.gmf.runtime.notation.View)1 State (org.yakindu.sct.model.sgraph.State)1