astah* API User Guide


[Creating/Deleting diagrams]

  1. Creating Diagrams
  2. Deleting Diagrams

Please refer to astah* API JavaDoc for details of each Interface and method.
Creating/editing/Deleting diagrams are supported in astah* UML and professional.

[Transaction operation]

Transaction operation is required when creating/editing/deleting diagrams.
Please refer to Transaction Operations.

[Creating diagrams]


Sample Code: Creating Class Diagram/Object Diagram

public IDiagram createClassDiagram(IModel project, String diagramName) 
        throws InvalidUsingException, ClassNotFoundException {
    ProjectAccessor projectAccessor =  AstahAPI.getAstahAPI().getProjectAccessor();
    ClassDiagramEditor cde = projectAccessor.getDiagramEditorFactory().getClassDiagramEditor();
    try {
        TransactionManager.beginTransaction();
        IDiagram iClassDiagram = cde.createClassDiagram(project, diagramName);
        TransactionManager.endTransaction();
        return iClassDiagram;
    } catch (InvalidEditingException e) {
        e.printStackTrace();
        TransactionManager.abortTransaction();
    }
}

[Deleting diagrams]

Sample Code A: Deleting diagram

public void deleteDiagram(IDiagram diagram) 
        throws ClassNotFoundException, InvalidUsingException {
    ProjectAccessor projectAccessor =  AstahAPI.getAstahAPI().getProjectAccessor();
    ClassDiagramEditor cde = projectAccessor.getDiagramEditorFactory().getClassDiagramEditor();
    try {
        TransactionManager.beginTransaction();
        cde.setDiagram(diagram);
        cde.deleteDiagram();
        TransactionManager.endTransaction();
    } catch (InvalidEditingException e) {
        e.printStackTrace();
        TransactionManager.abortTransaction();
    }
}

Sample Code B: Deleting diagram

public void deleteDiagram(IDiagram diagram) 
        throws ClassNotFoundException, InvalidUsingException {
    ProjectAccessor projectAccessor =  AstahAPI.getAstahAPI().getProjectAccessor();
    ClassDiagramEditor cde = projectAccessor.getDiagramEditorFactory().getClassDiagramEditor();
    try {
        TransactionManager.beginTransaction();
        cde.delete(diagram);
        TransactionManager.endTransaction();
    } catch (InvalidEditingException e) {
        e.printStackTrace();
        TransactionManager.abortTransaction();
    }
}


HOME