Component

See also

Notifications:
The Component object uses notifications to notify observers of changes.

Tasks

Reference Data

Hit Testing

Changed State

Parent

  • getParent()
  • setParent()

Component

class defcon.Component(glyph=None)

This object represents a reference to another glyph.

This object posts the following notifications:

Component.Changed Component.BaseGlyphChanged Component.BaseGlyphDataChanged Component.TransformationChanged Component.IdentifierChanged ===============================

addObserver(observer, methodName, notification)

Add an observer to this object’s notification dispatcher.

  • observer An object that can be referenced with weakref.
  • methodName A string representing the method to be called when the notification is posted.
  • notification The notification that the observer should be notified of.

The method that will be called as a result of the action must accept a single notification argument. This will be a defcon.tools.notifications.Notification object.

This is a convenience method that does the same thing as:

dispatcher = anObject.dispatcher
dispatcher.addObserver(observer=observer, methodName=methodName,
    notification=notification, observable=anObject)
baseGlyph

The glyph that the components references. Setting this will post Component.BaseGlyphChanged and Component.Changed notifications.

bounds

The bounds of the components’s outline expressed as a tuple of form (xMin, yMin, xMax, yMax).

controlPointBounds

The control bounds of all points in the components. This only measures the point positions, it does not measure curves. So, curves without points at the extrema will not be properly measured.

destroyAllRepresentations(notification=None)

Destroy all representations.

destroyRepresentation(name, **kwargs)

Destroy the stored representation for name and **kwargs. If no kwargs are given, any representation with name will be destroyed regardless of the kwargs passed when the representation was created.

dirty

The dirty state of the object. True if the object has been changed. False if not. Setting this to True will cause the base changed notification to be posted. The object will automatically maintain this attribute and update it as you change the object.

disableNotifications(notification=None, observer=None)

Disable this object’s notifications until told to resume them.

  • notification The specific notification to disable. This is optional. If no notification is given, all notifications will be disabled.

This is a convenience method that does the same thing as:

dispatcher = anObject.dispatcher
dispatcher.disableNotifications(
    observable=anObject, notification=notification, observer=observer)
dispatcher

The defcon.tools.notifications.NotificationCenter assigned to the parent of this object.

draw(pen)

Draw the component with pen.

drawPoints(pointPen)

Draw the component with pointPen.

enableNotifications(notification=None, observer=None)

Enable this object’s notifications.

  • notification The specific notification to enable. This is optional.

This is a convenience method that does the same thing as:

dispatcher = anObject.dispatcher
dispatcher.enableNotifications(
    observable=anObject, notification=notification, observer=observer)
font

The Font that this component belongs to.

generateIdentifier()

Create a new, unique identifier for and assign it to the contour. This will post Component.IdentifierChanged and Component.Changed notifications.

getRepresentation(name, **kwargs)

Get a representation. name must be a registered representation name. **kwargs will be passed to the appropriate representation factory.

glyph

The Glyph that this component belongs to. This should not be set externally.

hasCachedRepresentation(name, **kwargs)

Returns a boolean indicating if a representation for name and **kwargs is cached in the object.

hasObserver(observer, notification)

Returns a boolean indicating is the observer is registered for notification.

This is a convenience method that does the same thing as:

dispatcher = anObject.dispatcher
dispatcher.hasObserver(observer=observer,
    notification=notification, observable=anObject)
holdNotifications(notification=None)

Hold this object’s notifications until told to release them.

  • notification The specific notification to hold. This is optional. If no notification is given, all notifications will be held.

This is a convenience method that does the same thing as:

dispatcher = anObject.dispatcher
dispatcher.holdNotifications(
    observable=anObject, notification=notification)
identifier

The identifier. Setting this will post Component.IdentifierChanged and Component.Changed notifications.

identifiers

Set of identifiers for the glyph that this component belongs to. This is primarily for internal use.

layer

The Layer that this component belongs to.

layerSet

The LayerSet that this component belongs to.

move(values)

Move the component by (x, y).

This posts Component.TransformationChanged and Component.Changed notifications.

pointInside(coordinates, evenOdd=False)

Returns a boolean indicating if (x, y) is in the “black” area of the component.

postNotification(notification, data=None)

Post a notification through this object’s notification dispatcher.

  • notification The name of the notification.
  • data Arbitrary data that will be stored in the Notification object.

This is a convenience method that does the same thing as:

dispatcher = anObject.dispatcher
dispatcher.postNotification(
    notification=notification, observable=anObject, data=data)
releaseHeldNotifications(notification=None)

Release this object’s held notifications.

  • notification The specific notification to hold. This is optional.

This is a convenience method that does the same thing as:

dispatcher = anObject.dispatcher
dispatcher.releaseHeldNotifications(
    observable=anObject, notification=notification)
removeObserver(observer, notification)

Remove an observer from this object’s notification dispatcher.

  • observer A registered object.
  • notification The notification that the observer was registered to be notified of.

This is a convenience method that does the same thing as:

dispatcher = anObject.dispatcher
dispatcher.removeObserver(observer=observer,
    notification=notification, observable=anObject)
representationKeys()

Get a list of all representation keys that are currently cached.

transformation

The transformation matrix for the component. Setting this will post Component.TransformationChanged and Component.Changed notifications.

undoManager

The undo manager assigned to this object.