Hi,
I implemented such a behavior. You will need a custom Feature for this. Decide of a default collapsed size. First you will remember the initial size in properties of your pictogram-element
PictogramElement pe = moduleShape;
int width = pe.getGraphicsAlgorithm().getWidth();
int height = pe.getGraphicsAlgorithm().getHeight();
Graphiti.getPeService().setPropertyValue(pe, "initial_width", String.valueOf(width));
Graphiti.getPeService().setPropertyValue(pe, "initial_height", String.valueOf(height));
Graphiti.getPeService().setPropertyValue(pe, "isCollapsed", "true");
then resize it
ResizeShapeContext context1 = new ResizeShapeContext(moduleShape);
context1.setSize(100, 100);
context1.setLocation(moduleShape.getGraphicsAlgorithm().getX(), moduleShape.getGraphicsAlgorithm().getY());
IResizeShapeFeature rsf = getFeatureProvider().getResizeShapeFeature(context1);
if (rsf.canExecute(context1)) {
rsf.execute(context1);
}
addConnectionOccurences(moduleShape);
and set its children invisible if you need to. Good Luck