Creating New Primitive Representations

Created: 10 feb 97
Revised: 20 feb 97
revised: 17 march 97

 

1 What Needs to be Changed

1.1 Preliminaries

Create a new class with an appropriate name. Copy all the methods from RBox into the new class definition.

1.2 Attributes

Modify the initialize method so that your primitive has the attributes you need.

1.3 Displaying

Modify the display and displayScaledBy: methods to draw the required image.

2 Installing the New Primitive

2.1 Install the specification.

Add a specification in the repSpecs directory. This should have the following form:

<name> =

type = representation

endSpecification

description

<some text describing the representation>

endDescription.

 

An example:

box =

type = representation

endSpecification

description

This is a basic box. The size can be changed.

endDescription.

The specification should be saved in a file with the same name as the representation.

2.2 Install new representation in the class REntity.

Modify the REntity class method initializeOptions by adding a line like this:

RepresentationOptions

at: <representation name>

put: [<class name> new].

An example:

RepresentationOptions at: #box put: [RBox new].

The representation name should be the name of the file in the repSpecs directory which holds the representation specification.

2.3 Install the new representation in class RepSpec.

Modify the RepSpec class method initializeRepTypes by adding a line like this:

BasicTypes at: <representation name> put: <class name>.

An example:

BasicTypes at: #box put: RBox.

Accept your change to the method.

Now re-initialize class RepSpec by executing: RepSpec initializeRepTypes

2.4 Modify AttributeDictionary in class RepSpec.

The RepSpec class includes a class variable, AttributeDictionary, which holds the basic attributes belonging to a primitive representation. An entry must be placed in AttributeDictionary for the attributes of the new representation. This is done by modifying class method initializeRepTypes.

An example:

AttributeDictionary at: #box put: Dictionary new.

(AttributeDictionary at: #box) at: #border put: #boolean.

(AttributeDictionary at: #box) at: #colour put: #colour.

(AttributeDictionary at: #box) at: #borderColour put: #colour.

 

Accept your change to the method.

Now re-initialize class RepSpec by executing: RepSpec initializeRepTypes.