IN OMEElementClass, OMEInstantiableClass # (2,3)
ISA OMEElement # (4)
WITH name
: "Element"
# (5)
defaultname
# (6)
: "An Element"
imagename
# (7)
: "Graphic1.gif"
imagesize
# (8)
width : 80;
height : 50
autogui : 1 # (9)
END
In this example, we defined a class of an element type, whose name is MyFirstElement. Traditionally, a type class in a framework is defined as a SimpleClass.
Rule (2): All element types must be IN (an instance of) OMEElementClass.
In the example, MyFirstElement is an instance of OMEElementClass.
Rule (3): All object types that can occur in the model (i.e. can be instantiated) must be an instance of OMEInstantiableClass.
In the example, MyFirstElement is an instance of OMEInstantiableClass.
Rule (4): All element types be a specialization (a.k.a. subclass) of OMEElement.
In the example, MyFirstElement is a specialization
(a.k.a. subclass) of OMEElement. OMEElementClass, OMEInstantiableClass
and OMEElement are defined in OME Meta Framework (see ome.tel).
Rule (5): In Attribute Category: "name", OME expects one unlabeled attribute, which should be the name of the type, as experienced by the user. Any user interface dialogues that refer the type will use this value.
In the example, the name of the element type Myfirstement
refers to is "Element".
Rule (6): Attribute Category: "defaultname" is optional. If an attribute category "defaultname" exists, the tool expects one unlabeled attribute, which is the default name for instances of this type (the user can always change the name of any instance). If omitted, the default name will be the name of the type, followed by the internal unique integer id assigned to the object.
In the example, the default name for the objects of type MyFirstElement is "An Element".
Rule (7): In Attribute Category: "imagename", the tool expects one unlabeled, which should be the name of a .gif file to be used to represent objects of this type. The image that is used should reside in ome/program/images/, otherwise an exception will be thrown.
In the example, the name of the image file which is used
to represent an element is "Graphic1.gif".
Rule (8): Attribute Category: "imagesize" is optional. If present, OME expects two attributes labeled "width" and "height". The integer values specify the default dimensions (in pixels) of the graphical representation of objects of this type. If omitted, the default dimensions will be those of the image specified under imagename.
In the example, the width of the image used to represent
an element is 80 pixels, while the height is 50 pixels.
Rule (9): Attribute Category: "autogui" is optional. If an attribute category "autogui" is presented, one unlabeled integer attribute is expected. If the value of the attribute is non-zero, the tool will automatically produce items in the graphical user interface to allow users to instantiate objects of this type. If omitted, or given a value of zero, no user interface items for this object will produced (automatically).
In the example, there will be a toolbar button created automatically in the GUI to allow users to create a new object of type MyFirstElement.
IN OMELinkClass, OMEInstantiableClass # (10)
ISA OMELink
WITH
attribute
# (11)
to : OMEObject;
from : MyFirstElement
name
: "Link"
imagename
# (12)
: "Arrow.gif"
imagesize
width : 20;
height : 20
stroke
: "dashed"
# (13)
autogui
: 1
END
Here, we defined a type of link named MyLink.
Rule (11): Links must have attributes labelled "to" and "from" under the attribute category "attribute". These attributes specify what kinds of objects will be valid sources and destinations for this link. This feature can be used to place constraints in your framework!
* Notice how we can use non-instantiable objects (OMEObject) in our constraints. This is a very powerful mechanism. Framework developers can create Object classes that are never meant to be instantiated but can be used to set up a hierarchy that may be utilized in establishing the proper constraints.
In this example, a MyLink can only have a MyFirstElement as its source, but any type of object (including another link) as a destination, since all instantiated objects are specialization of OMEObject (via OMEElement or OMELink).
Rule (12): Similar to an element, a link must provide an image. This image however, is used only for the "head" of the link (typically an arrow head).
Rule (13): The tool expects one unlabelled
attribute under the category of "stroke". The value of the attribute must
be one of the supported stroke types. If omitted, the default value for
this attribute is "solid". Currently, the two supported stroke types are:
"solid" - a solid line; "dashed" - a dashed line.
In the future, more stroke types can be still defined
if necessary.
SimpleClass ChildA
IN OMEElementClass, OMEInstantiableClass
ISA OMEElement, ValidChild
# (15)
WITH
name
: "Child A"
imagename
: "Resource.gif"
imagesize
width : 80;
height : 50
autogui
: 1
END
SimpleClass ChildB
IN OMEElementClass, OMEInstantiableClass
ISA OMEElement, ValidChild
# (15)
WITH
name
: "Child B"
imagename
: "Task.gif"
imagesize
width : 80;
height : 50
autogui
: 1
END
SimpleClass MyExpandableElement
IN OMEElementClass, OMEInstantiableClass
ISA OMEElement, OMEGrowableElement
# (16)
WITH
attribute
children : ValidChild
# (17)
name
: "Expandable"
imagename
: "Actor.gif"
imagesize
width : 80;
height : 80
autogui
: 1
END
In the example, a non-instantiable class named ValidChild is defined. We will make use of the this class in the following.
Rule (15): A user can bring together previously unrelated classes by declaring them as the subclasses of a same non-instantiable class.
The declarations of types ChildA and ChildB are standard element type declarations (instances of OMEElement, OMEInstantiableClass, subclass of OMEElement), but are also subclasses of ValidChild. Thus, these two class must have some common features described by ValidChild.
Rule (16): To declare an element to be expandable, we can simply make it a subclass of OMEGrowableElement.
Here we defined an expandable element named as MyExpandableElement.
Rule (17): All expandable element types should have an attribute labeled "children" under the attribute category "attribute". The value of this attribute should be some element type.
In a very loosely constrained example, we could use OMEElement. Here, we have used ValidChild to demonstrate using non-instantiable classes for constraining relationships. In this framework, ChildA and ChildB can be children (or "within the bounds") of a MyExpandableElement, but a MyFirstElement cannot.