It happens I have quite big UML models generated from QVT transformation. I'd like to automatically get some diagrams for these models (i.e. one class diagram for each package showing the contained class, on diagram for each class depicting the class' relationships, etc.). Is there a way to automatically generate such diagrams (i.e. a QVT transformation from the UML model to the .di model, provided there is a meta-model for the .di file) ?
A QVT transformation from UML to Notation+Di is technically possible, although very (very, very, very) complex to implement.
The best way is to programatically use "DropObjectsRequests" to simulate a drop of a semantic element to a diagram (Which results in displaying the element graphically). There's a tool in the Papyrus extra plug-ins which relies on this strategy to generate diagrams from a predefined template. See "Diagram generation" in the Papyrus additional components, or "extraplugins/diagramtemplate/oep.diagramtemplates.*" on the SVN repository if you're only interested in the implementation.
Here's the basic java code to drop an element in a diagram:
Element elementToShow = getElementToShow(); //The UML Element to drop
EditPart targetEditPart = getTargetEditPart(); //The GMF EditPart which is the drop target (e.g. diagram root)
DropObjectsRequest dropObjectsRequest = new DropObjectsRequest();
ArrayList<Element> list = new ArrayList<Element>();
dropObjectsRequest.setLocation(new Point(20, 100 * position));
Command commandDrop = editPart.getCommand(dropObjectsRequest); //The command is now ready to be executed
thank you for your kind support. I have just installed the Diagram generator additional component and I am trying to use the diagram template. I have created a new template for a chosen model, selected class diagram from the model king box, selected Class and Package from the For box and Operation and Property from the What box (under the Class meta-class). When I execute the template it just creates a diagram for each class and package without actually filling its contents. It seems I am missing something of the diagram generation process. Is there any tutorial for that?