# eric6.Graphics.PackageDiagramBuilder

Module implementing a dialog showing a UML like class diagram of a package.

### Global Attributes

None

### Classes

PackageDiagramBuilder | Class implementing a builder for UML like class diagrams of a package.

### Functions

None

## PackageDiagramBuilder

Class implementing a builder for UML like class diagrams of a package.

### Derived from

UMLDiagramBuilder

### Class Attributes

None

### Class Methods

None

### Methods

PackageDiagramBuilder | Constructor
__addExternalClass | Private method to add a class defined outside the module.
__addLocalClass | Private method to add a class defined in the module.
__addPackage | Private method to add a package to the diagram.
__arrangeClasses | Private method to arrange the shapes on the canvas.
__buildModulesDict | Private method to build a dictionary of modules contained in the package.
__buildSubpackagesDict | Private method to build a dictionary of sub-packages contained in this package.
__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 package diagram.
getPersistenceData | Public method to get a string for data to be persisted.
initialize | Public method to initialize the object.
parsePersistenceData | Public method to parse persisted data.

### Static Methods

None

#### PackageDiagramBuilder (Constructor)

PackageDiagramBuilder(dialog, view, project, package, noAttrs=False)

Constructor

dialog
  reference to the UML dialog (UMLDialog)
view
  reference to the view object (UMLGraphicsView)
project
  reference to the project object (Project)
package
  name of a python package to be shown (string)
noAttrs=
  flag indicating, that no attributes should be shown (boolean)

#### PackageDiagramBuilder.__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
  class to be shown (string)
x
  x-coordinate (float)
y
  y-coordinate (float)

#### PackageDiagramBuilder.__addLocalClass

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

Private method to add a class defined in the module.

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

#### PackageDiagramBuilder.__addPackage

__addPackage(name, modules, x, y)

Private method to add a package to the diagram.

name
  package name to be shown (string)
modules
  list of module names contained in the package (list of strings)
x
  x-coordinate (float)
y
  y-coordinate (float)

#### PackageDiagramBuilder.__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 nodes to arrange
routes
  list of routes
whiteSpaceFactor
  factor to increase whitespace between items (float)

#### PackageDiagramBuilder.__buildModulesDict

__buildModulesDict()

Private method to build a dictionary of modules contained in the package.

Returns:
  dictionary of modules contained in the package.

#### PackageDiagramBuilder.__buildSubpackagesDict

__buildSubpackagesDict()

Private method to build a dictionary of sub-packages contained in this package.

Returns:
  dictionary of sub-packages contained in this package

#### PackageDiagramBuilder.__createAssociations

__createAssociations(routes)

Private method to generate the associations between the class shapes.

routes
  list of relationsships

#### PackageDiagramBuilder.__getCurrentShape

__getCurrentShape(name)

Private method to get the named shape.

name
  name of the shape (string)

Returns:
  shape (QCanvasItem)

#### PackageDiagramBuilder.buildDiagram

buildDiagram()

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

The algorithm is borrowed from Boa Constructor.

#### PackageDiagramBuilder.getPersistenceData

getPersistenceData()

Public method to get a string for data to be persisted.

Returns:
  persisted data string (string)

#### PackageDiagramBuilder.initialize

initialize()

Public method to initialize the object.

#### PackageDiagramBuilder.parsePersistenceData

parsePersistenceData(version, data)

Public method to parse persisted data.

version
  version of the data (string)
data
  persisted data to be parsed (string)

Returns:
  flag indicating success (boolean)

Up