# eric6.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

None

### 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.
buildItemDataString | Public method to build a string to persist the specific item data.
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.

### Static Methods

None

#### ClassItem (Constructor)

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

Constructor

model
  class model containing the class data (ClassModel)
external
  flag indicating a class defined outside our scope (boolean)
x
  x-coordinate (integer)
y
  y-coordinate (integer)
rounded=
  flag indicating a rounded corner (boolean)
noAttrs=
  flag indicating, that no attributes should be shown (boolean)
parent=
  reference to the parent object (QGraphicsItem)
scene=
  reference to the scene object (QGraphicsScene)

#### 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.buildItemDataString

buildItemDataString()

Public method to build a string to persist the specific item data.

This string must start with ", " and should be built like "attribute=value" with pairs separated by ", ". value must not contain ", " or newlines.

Returns:
  persistence data (string)

#### ClassItem.isExternal

isExternal()

Public method returning the external state.

Returns:
  external state (boolean)

#### ClassItem.paint

paint(painter, option, widget=None)

Public method to paint the item in local coordinates.

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

#### ClassItem.parseItemDataString

parseItemDataString(version, data)

Public method to parse the given persistence data.

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

Returns:
  flag indicating success (boolean)

#### ClassItem.setModel

setModel(model)

Public method to set the class model.

model
  class model containing the class data (ClassModel)

Up

## ClassModel

Class implementing the class model.

### Derived from

UMLModel

### Class Attributes

None

### Class Methods

None

### Methods

ClassModel | Constructor
addAttribute | Public method to add an attribute to the class model.
addMethod | Public method to add a method to the class model.
getAttributes | 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, attributes=None)

Constructor

name
  the class name (string)
methods
  list of method names of the class (list of strings)
attributes
  list of attribute names of the class (list of strings)

#### ClassModel.addAttribute

addAttribute(attribute)

Public method to add an attribute to the class model.

attribute
  attribute name to be added (string)

#### ClassModel.addMethod

addMethod(method)

Public method to add a method to the class model.

method
  method name to be added (string)

#### ClassModel.getAttributes

getAttributes()

Public method to retrieve the attributes of the class.

Returns:
  list of class attributes (list of strings)

#### ClassModel.getMethods

getMethods()

Public method to retrieve the methods of the class.

Returns:
  list of class methods (list of strings)

Up