# eric7.Graphics.UMLClassDiagramBuilder

Module implementing a dialog showing a UML like class diagram.

### Global Attributes

None

### Classes

UMLClassDiagramBuilder | Class implementing a builder for UML like class diagrams.

### Functions

None

## UMLClassDiagramBuilder

Class implementing a builder for UML like class diagrams.

### Derived from

UMLDiagramBuilder

### Class Attributes

None

### Class Methods

None

### Methods

UMLClassDiagramBuilder | Constructor
__addExternalClass | Private method to add a class defined outside the module.
__addLocalClass | Private method to add a class defined in the module.
__arrangeClasses | Private method to arrange the shapes on the canvas.
__createAssociations | Private method to generate the associations between the class shapes.
__getCurrentShape | Private method to get the named shape.
buildDiagram | Public method to build the class shapes of the class diagram.
fromDict | Public method to populate the class with data persisted by 'toDict()'.
initialize | Public method to initialize the object.
parsePersistenceData | Public method to parse persisted data.
toDict | Public method to collect data to be persisted.

### Static Methods

None

#### UMLClassDiagramBuilder (Constructor)

UMLClassDiagramBuilder(dialog, view, project, file, noAttrs=False)

Constructor

dialog (UMLDialog)
  reference to the UML dialog
view (UMLGraphicsView)
  reference to the view object
project (Project)
  reference to the project object
file (str)
  file name of a python module to be shown
noAttrs (bool)
  flag indicating, that no attributes should be shown

#### UMLClassDiagramBuilder.__addExternalClass

__addExternalClass(_class, x, y)

Private method to add a class defined outside the module.

If the canvas is too small to take the shape, it is enlarged.

_class (ModuleParser.Class)
  class to be shown
x (float)
  x-coordinate
y (float)
  y-coordinate

#### UMLClassDiagramBuilder.__addLocalClass

__addLocalClass(className, _class, x, y, isRbModule=False)

Private method to add a class defined in the module.

className (str)
  name of the class to be as a dictionary key
_class (ModuleParser.Class)
  class to be shown
x (float)
  x-coordinate
y (float)
  y-coordinate
isRbModule (bool)
  flag indicating a Ruby module

#### UMLClassDiagramBuilder.__arrangeClasses

__arrangeClasses(nodes, routes, whiteSpaceFactor=1.2)

Private method to arrange the shapes on the canvas.

The algorithm is borrowed from Boa Constructor.

nodes (list of str)
  list of nodes to arrange
routes (list of tuple of (str, str))
  list of routes
whiteSpaceFactor (float)
  factor to increase whitespace between items

#### UMLClassDiagramBuilder.__createAssociations

__createAssociations(routes)

Private method to generate the associations between the class shapes.

routes (list of tuple of (str, str))
  list of relationsships

#### UMLClassDiagramBuilder.__getCurrentShape

__getCurrentShape(name)

Private method to get the named shape.

name (str)
  name of the shape

Return:
  shape

Return Type:
  QGraphicsItem

#### UMLClassDiagramBuilder.buildDiagram

buildDiagram()

Public method to build the class shapes of the class diagram.

The algorithm is borrowed from Boa Constructor.

#### UMLClassDiagramBuilder.fromDict

fromDict(_version, data)

Public method to populate the class with data persisted by 'toDict()'.

_version (str)
  version of the data (unused)
data (dict)
  dictionary containing the persisted data

Return:
  tuple containing a flag indicating success and an info message in case the diagram belongs to a different project

Return Type:
  tuple of (bool, str)

#### UMLClassDiagramBuilder.initialize

initialize()

Public method to initialize the object.

#### UMLClassDiagramBuilder.parsePersistenceData

parsePersistenceData(_version, data)

Public method to parse persisted data.

_version (str)
  version of the data (unused)
data (str)
  persisted data to be parsed

Return:
  flag indicating success

Return Type:
  bool

#### UMLClassDiagramBuilder.toDict

toDict()

Public method to collect data to be persisted.

Return:
  dictionary containing data to be persisted

Return Type:
  dict

Up