Programming

<<[Constraints and Actions]  :::  [AToM3 Types]>>

4. AToM3 Graphics

In AToM3 there are two kinds of graphics the user can assign to an AToM3 object: icons and links. The first ones inherit from graphEntity while the second ones inherit from graphLink. Both graphEntity and graphLink classes inherit from VisualObj.

4.1 VisualObj

The important attributes and methods from VisualObj are the following:


Figure 1: Structure of class VisualObj, base class of all graphical objects.

The attributes have the following meaning: The methods have the following meaning:

4.2 graphEntity

This is the base class of all icon-like graphical objects. This objects are created at the meta-level, using a graphical editor (class appearanceEditor in file appearanceDialog.py).


Figure 2: Structure of class graphEntity, base class of all icon-like graphical objects.

The attributes have the following meaning:

The methods have the following meaning: At the meta-level, you can assign a graphEntity to an AToM3 object by declaring an attribute of type ATOM3Appearance.

4.3 GraphicalForm

Each object you draw in the graphical editor (except connectors) is indeed a GraphicalForm object. The following figure shows its main attributes and methods:


Figure 3: Structure of class GraphicalForm, wrapper for all Tkinter canvas objects in AToM3.

The meaning of the attributes is the following:

The meaning of the methods is the following: These objects are widely used if you want to change the object's graphical appearance at run time (in the code of some Constraint or Action). All you have to do is to access the graphical object's attribute associated with the graphical form and call some of the previous methods. An example of this is given in section 4.5 , although of course, you can also change the appearance of a graphical form in semantic constraints.

4.4 graphLink

This is the base class for all link-type graphical objects, which usually are meant to connect two other graphical objects. The objects they connect can be icon-like or link-like objects. Visually a graphLink is compose of incoming links, a center (of type graphEntity, which may be None), and outgoing links. Links can have several points and may be smoothed. Links can have an arrow or graphEntity object at the end, and also in the middle. The structure of the graphLink class is shown in the following picture:


Figure 4: Structure of class graphLink.

The meaning of the attributes is as follows: The meaning of the methods is the following: At the meta-level, you can assign a graphLink to an AToM3 object by declaring an attribute of type ATOM3Link

4.5 Example

Following with the previous example, suppose you assign the following appearance to the entity you have just created:


Figure 5: Creating an appearance icon

Suppose you have set the following Python action (by clicking on Set Constraint|new):

number=self.semanticObject.aNumber.getValue()    # get the aNumber attribute value from the semantic object
if number > 500:
  self.gf0.setFill("red")                        # set the rectangle's inside to red if value's greater than 500
else:
  self.gf0.setFill("green")                      # set the rectangle's inside to green if value's less than 500
and that you have named this action as changeColor. This code is an action because we are not returning any value. As we intend to change the rectangle's inside from red to green depending on the value of aNumber, we have to evaluate the code after the entity has been edited or created, so we set this code as a POSTCondition on EDIT and CREATE.

When clicking in the OK button, a class named graph_aTest.py is generated. As in the Entity Relationship Meta-Model, the Entity objects have an ATOM3Appearance attribute, the graph_aTest class inherits from graphEntity. Note how a method called DrawObject is created which contains the necessary Python code to draw the object in the canvas and a method called changeColor has been created for the action we have defined. Methods postCondition and preCondition have also been created, but as in our case, we only have post-conditions, only the first method has some code.


<<[Constraints and Actions]  :::  [AToM3 Types]>>



Maintained by Juan de Lara. Last modified 22 July 2002.