use of org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure in project statecharts by Yakindu.
the class StateTextCompartmentEditPart method createFigure.
@Override
protected IFigure createFigure() {
ResizableCompartmentFigure figure = (ResizableCompartmentFigure) super.createFigure();
GridLayout gridLayout = new GridLayout(1, true);
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
figure.getContentPane().setLayoutManager(gridLayout);
figure.setBorder(null);
figure.setToolTip((String) null);
return figure;
}
use of org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure in project elk by eclipse.
the class GmfDiagramLayoutConnector method buildLayoutGraphRecursively.
/**
* Recursively builds a layout graph by analyzing the children of the given edit part.
*
* @param mapping
* the layout mapping
* @param parentEditPart
* the parent edit part of the current elements
* @param parentLayoutNode
* the corresponding KNode
* @param currentEditPart
* the currently analyzed edit part
*/
protected void buildLayoutGraphRecursively(final LayoutMapping mapping, final IGraphicalEditPart parentEditPart, final ElkNode parentLayoutNode, final IGraphicalEditPart currentEditPart) {
Maybe<ElkPadding> kinsets = new Maybe<ElkPadding>();
// iterate through the children of the element
for (Object obj : currentEditPart.getChildren()) {
// check visibility of the child
if (obj instanceof IGraphicalEditPart) {
IFigure figure = ((IGraphicalEditPart) obj).getFigure();
if (!figure.isVisible()) {
continue;
}
}
// process a port (border item)
if (obj instanceof AbstractBorderItemEditPart) {
AbstractBorderItemEditPart borderItem = (AbstractBorderItemEditPart) obj;
if (editPartFilter.filter(borderItem)) {
createPort(mapping, borderItem, parentEditPart, parentLayoutNode);
}
// process a compartment, which may contain other elements
} else if (obj instanceof ResizableCompartmentEditPart && ((CompartmentEditPart) obj).getChildren().size() > 0) {
CompartmentEditPart compartment = (CompartmentEditPart) obj;
if (editPartFilter.filter(compartment)) {
boolean compExp = true;
IFigure compartmentFigure = compartment.getFigure();
if (compartmentFigure instanceof ResizableCompartmentFigure) {
ResizableCompartmentFigure resizCompFigure = (ResizableCompartmentFigure) compartmentFigure;
// check whether the compartment is collapsed
compExp = resizCompFigure.isExpanded();
}
if (compExp) {
buildLayoutGraphRecursively(mapping, parentEditPart, parentLayoutNode, compartment);
}
}
// process a node, which may be a parent of ports, compartments, or other nodes
} else if (obj instanceof ShapeNodeEditPart) {
ShapeNodeEditPart childNodeEditPart = (ShapeNodeEditPart) obj;
if (editPartFilter.filter(childNodeEditPart)) {
ElkNode node = createNode(mapping, childNodeEditPart, parentEditPart, parentLayoutNode, kinsets);
// process the child as new current edit part
buildLayoutGraphRecursively(mapping, childNodeEditPart, node, childNodeEditPart);
}
// process a label of the current node
} else if (obj instanceof IGraphicalEditPart) {
createNodeLabel(mapping, (IGraphicalEditPart) obj, parentEditPart, parentLayoutNode);
}
}
}
Aggregations