# eric7.Graphics.ClassItem

Module implementing an UML like class item.

### Global Attributes

None

### Classes

ClassItem | Class implementing an UML like class item.
ClassModel | Class implementing the class model.

### Functions

None

## ClassItem

Class implementing an UML like class item.

### Derived from

UMLItem

### Class Attributes

ItemType

### Class Methods

fromDict | Class method to create a class item from persisted data.

### Methods

ClassItem | Constructor
__calculateSize | Private method to calculate the size of the class item.
__createTexts | Private method to create the text items of the class item.
isExternal | Public method returning the external state.
paint | Public method to paint the item in local coordinates.
parseItemDataString | Public method to parse the given persistence data.
setModel | Public method to set the class model.
toDict | Public method to collect data to be persisted.

### Static Methods

None

#### ClassItem.fromDict (class method)

fromDict(data, colors=None)

Class method to create a class item from persisted data.

data (dict)
  dictionary containing the persisted data as generated by toDict()
colors (tuple of (QColor, QColor))
  tuple containing the foreground and background colors

Return:
  created class item

Return Type:
  ClassItem

#### ClassItem (Constructor)

ClassItem(model=None, external=False, x=0, y=0, rounded=False, noAttrs=False, colors=None, parent=None, scene=None, )

Constructor

model (ClassModel)
  class model containing the class data
external (boolean)
  flag indicating a class defined outside our scope
x (int)
  x-coordinate
y (int)
  y-coordinate
rounded (bool)
  flag indicating a rounded corner
noAttrs (bool)
  flag indicating, that no attributes should be shown
colors (tuple of (QColor, QColor))
  tuple containing the foreground and background colors
parent (QGraphicsItem)
  reference to the parent object
scene (QGraphicsScene)
  reference to the scene object

#### ClassItem.__calculateSize

__calculateSize()

Private method to calculate the size of the class item.

#### ClassItem.__createTexts

__createTexts()

Private method to create the text items of the class item.

#### ClassItem.isExternal

isExternal()

Public method returning the external state.

Return:
  external state

Return Type:
  bool

#### ClassItem.paint

paint(painter, option, _widget=None)

Public method to paint the item in local coordinates.

painter (QPainter)
  reference to the painter object
option (QStyleOptionGraphicsItem)
  style options
_widget (QWidget)
  optional reference to the widget painted on (unused)

#### ClassItem.parseItemDataString

parseItemDataString(_version, data)

Public method to parse the given persistence data.

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

Return:
  flag indicating success

Return Type:
  bool

#### ClassItem.setModel

setModel(model)

Public method to set the class model.

model (ClassModel)
  class model containing the class data

#### ClassItem.toDict

toDict()

Public method to collect data to be persisted.

Return:
  dictionary containing data to be persisted

Return Type:
  dict

Up

## ClassModel

Class implementing the class model.

### Derived from

UMLModel

### Class Attributes

None

### Class Methods

None

### Methods

ClassModel | Constructor
addClassAttribute | Public method to add a class attribute to the class model.
addInstanceAttribute | Public method to add an instance attribute to the class model.
addMethod | Public method to add a method to the class model.
getClassAttributes | Public method to retrieve the global attributes of the class.
getInstanceAttributes | Public method to retrieve the attributes of the class.
getMethods | Public method to retrieve the methods of the class.

### Static Methods

None

#### ClassModel (Constructor)

ClassModel(name, methods=None, instanceAttributes=None, classAttributes=None)

Constructor

name (str)
  the class name
methods (list of str)
  list of method names of the class
instanceAttributes (list of str)
  list of instance attribute names of the class
classAttributes (list of str)
  list of class attribute names of the class

#### ClassModel.addClassAttribute

addClassAttribute(attribute)

Public method to add a class attribute to the class model.

attribute (str)
  class attribute name to be added

#### ClassModel.addInstanceAttribute

addInstanceAttribute(attribute)

Public method to add an instance attribute to the class model.

attribute (str)
  instance attribute name to be added

#### ClassModel.addMethod

addMethod(method)

Public method to add a method to the class model.

method (str)
  method name to be added

#### ClassModel.getClassAttributes

getClassAttributes()

Public method to retrieve the global attributes of the class.

Return:
  list of class attributes

Return Type:
  list of str

#### ClassModel.getInstanceAttributes

getInstanceAttributes()

Public method to retrieve the attributes of the class.

Return:
  list of instance attributes

Return Type:
  list of str

#### ClassModel.getMethods

getMethods()

Public method to retrieve the methods of the class.

Return:
  list of class methods

Return Type:
  list of str

Up