Overview
User-defined classes are a very useful and flexible feature of eminec MYmap. (If you have ever dealt with object-oriented programming, this concept will be well-known to you.) You can extend eminec MYmap yourself — without doing any programming — using user-defined classes. You can add new properties not provided by eminec to any object in your map.
If you, by example, use a map to make a decision on buying a vehicle, you might add the properties »mileage«, »top speed« and »price«. In project management, you might use »responsible person«, »priority« and »already done (%)«. eminec MYmap makes it possible to create complex class hierarchies using inheritance, which means that only the properties that apply to a certain object are available for that object.
You should have a general knowledge of how to use eminec MYmap before you read this chapter. Background information is provided after a real-life example. If you encounter any problems in following the example, it might be a good idea to read the explanations at the end of this chapter first.
A real-life example
IN THIS SECTION YOU ARE GOING TO UTILIZE USER-DEFINED CLASSES TO CREATE A MODEL REPRESENTING REAL OBJECTS IN A MAP. YOU ARE GOING TO USE EMINEC MYMAP AS A DECISION SUPPORT TOOL. TIME: 30 MINS.
Introduction
In our tutorial, this is your situation:
- Your IT infrastructure is outdated.
- You have created an eminec MYmap document on the subject Computer purchase.
- You want to make a buying decision.
To found your decision, you want to get a deeper market overview first. Therefore, you proceed as follows:
- You add user-defined properties to the objects in your map, such as »processor type«, »main memory« und »battery runtime«.
- You set the property values of the various computer models (i. e. the actual values of the properties previously added).
- Finally, you compare the computers and make the buying decision.
Preparation: Create the map
Before we can begin the exercise, you create the map we are going to work with.
When working with user-defined classes in eminec MYmap, you are mainly going to use the task panes »Outline« and »Class«. The »Outline« task pane gives you an overview of the object hierarchy in your map and is especially useful when you create the branches in your document (i. e. right now). Later, you are going to add the user-defined properties and the property values using the »Class« task pane.
Create an empty map, and open the »Outline« task pane by clicking the corresponding tab at the right end of the window or by pressing the keys Ctrl+5. Change the caption of the map center to Computer purchase. Create two main branches titled Desktops and Notebooks, and add three sub-branches to the branch Desktops named for the computer makers Vale, SpeedSmart Technologies and Mango. Select the Notebooks branch, and add the sub-branches BigBusinessSystems and Mango.
In our example, create the Vale models Accuracy 530 and Accuracy 730 (to do so, insert two sub-branches); add the SpeedSmart Technologies offerings named 3000 and 3400 and the Mango (Desktop) models MangoForce 2000 and MangoForce 2500 dual.
Finally, add the following Notebooks: the BigBusinessSystems models MindPuter N 14 and MindPuter Q 47 as well as the Mango mobile computers MangoForce 15" und MangoForce 17".
You have now inserted all required objects for building your class hierarchy into your map. (As you see, the map is much clearer than this piece of text.)
Declare properties
Select the object you would like to add properties to in your map; in our example, this is first of all the map center (Computer purchase). Switch to the »Class« task pane by clicking the corresponding tab at the right end of the window or by pressing the keys Ctrl+3. The »Class« task pane is divided into the sections »Declare« and »Use«. You are going to work with the »Declare« section first. If it is not currently selected, click it once to show the controls for class declaration.
The »Declare« section toolbar consists of five buttons (from left to right): the commands »New property«, »Delete property«, »Delete all properties«, »Import property template« and »Export property template«.
Click the »New property« button to add a property. In the »Declare« section, the property New #1 appears; it is already selected so that you can replace the default name with the desired name right away. Enter price. When you have finished entering the name of the new property, press Enter to save the new property. Repeat this process until you have added all properties:
- price (already entered)
- processor type
- main memory
eminec MYmap applies these properties to all objects subordinate to the map center — i. e. to all objects in your map. (We will use this to add the actual property values for the various computer models later.) This behavior is called inheritance.
Not all objects should have the same properties. Example: for a Desktop computer, the property battery runtime does not make sense (in contrast to a Notebook computer). If you combine information about Desktops and Notebooks into one map Computer purchase, you declare different sets of properties for these different object classes.
Select the object Notebooks. As you see, the properties previously added now appear in the list »Inherited properties« at the bottom of the »Class« task pane. The top list is empty as you have not yet declared any new properties for the object Notebooks.
Following the same procedure as described above, add the properties battery runtime and screen size. Select the branch MindPuter N 14 (or any other notebook computer) to see for yourself that all properties (price, processor type, main memory, battery runtime and screen size) appear on the »Inherited properties« list for all notebook computers now.
Finally, declare the property Silent (for quiet operation) for the branch Desktop.
You have now declared all properties that are required for this exercise.
Set property values
Now you add the property values — the actual information. The »Use« section of the »Class« task pane is used in this step. Therefore, click the tab »Use« in the task pane. (If the task pane is not visible, select any computer — e. g. the Accuracy 530, as we are going to add its property values first.)
Click a property name in the left column to set the property value. A text box appears, this is where you enter the data. Use the arrow keys UP and DOWN to navigate to the other property values.
Insert the following data into your map by entering the property values of these computers:
| Manufacturer | Model | Proc. type | Main mem. | Price | Silent |
| Vale | Accuracy 530 | P 670 | 512 MB | $900 | no |
| Accuracy 730 | P 690 | 1 GB | $1,400 | yes | |
| SpeedSmart Technologies | 3000 | 3000* | 256 MB | $600 | no |
| 3400 | 3400* | 1 GB | $1,000 | no | |
| Mango | MangoForce 2000 | Q3 2000 | 1 GB | $3,500 | yes |
| MangoForce 2500 dual | Q3 2500 (x2) | 2 GB | $6,000 | yes |
This is the sample data of the notebook computers:
| Manufacturer | Model | Proc. type | Main mem. | Price | B. runtime | Scr. size |
| BigBusinessSystems | N 14 | P-M 830 | 512 MB | 900 € | 2:30 | 14" |
| Q 47 | P-M 850 | 1 GB | 1.400 € | 4:30 | 15" | |
| Mango | MangoForce 15" | Q2 1500 | 256 MB | 2.000 € | 4:00 | 15" |
| MangoForce 17" | Q2 1700 | 1 GB | 3.000 € | 6:00 | 17" |
You have now entered the entire market overview data into your map.
Display and compare property values
In a real application, the data you have just entered would not have been available as a table; you would have done some research, probably on the Internet. More and more pieces of information would have been added into an eminec MYmap document, one after another.
You can now compare the data in eminec MYmap or have the program output a table. (Again, as this is only an exercise, the resulting table is similar to the one that is already provided in this document.)
To compare computer models in eminec MYmap, click the objects in your map. The appropriate property values then appear in the »Class« task pane.
Now select the menu command »File« > »Export« or press the keys Ctrl+E. The window »Export« appears. Choose the entry »Outline, HTML« from the list to the left, and make sure that the checkbox »Add additional information — Class properties« is selected. (This is supported by the »Premium« version only.) Then click »OK« and »Save«.
Your browser opens up and displays an outline with the properties and their values shown as tables for each computer model.
YOU HAVE COLLECTED INFORMATION IN EMINEC MYMAP AND HAVE ANALYZED IT BY VIEWING THE MAP AND EXPORTING A TABLE. THIS CONCLUDES THE TUTORIAL.
Terminology
Now that you know how user-defined classes work in actual use, read more about the background in the following section.
Objects and object types
An eminec MYmap document consists of one or (in most cases) many objects. Each object has a certain object type. In this version, the following object types are available, besides the map center: branch, picture, connection and free text. If you have eminec MYmap show the »Outline« task pane, you can easily see which objects are contained in your map: each line of the outline represents one object. If you map contains, for example, one map center, three branches and six sub-branches, it consists of ten objects (the entire document does not count as a discrete object in the context of user-defined classes).
Properties and property values
Each one of the object types has a number of properties by default — a branch object has the properties »Caption text color« and »Font size«, for example. The editing tools of eminec MYmap allow you to set the property values, i. e. the actual characteristics of a certain object. If you click a branch and then choose a new color from the selection control, you change the property value of the property »Caption text color«. The built-in application logic processes this piece of information correspondingly: for example, eminec MYmap uses the property value »Caption text color« unalterably to determine the text color of the appropriate object when your document is displayed.
Implicitly declared classes and user-defined properties
Besides the properties that are always available for the various object types, you can add your own, additional properties. eminec MYmap uses the structure of your document to generare implicitly declared classes from the existing objects. Therefore, the object model of eminec MYmap is simplified: each object automatically and unalterably declares a class of the same name, and it is the only instance of this class. (In most object-oriented programming languages, declaration of classes is independent of the definition of actual instances. In eminec MYmap, definition and declaration are tantamount.)
User-defined properties are — in contrast to the properties that are unalterably connected to an object type — not connected to the application logic of eminec MYmap and therefore do not influence the display of an object in eminec MYmap in any way.
Class hierarchies and inheritance
Every map in eminec MYmap is stored as a tree structure. (You can see the tree structure clearly by showing the »Outline« task pane.) This constitutes a class hierarchy: a sub-branch that is assigned to a certain branch is in a child-parent relationship with that branch. If you create a branch for a certain manufacturer in a vehicle purchase map, for example, and then add the various models of this manufacturer as sub-branches assigned to the branch, a class hierarchy is created. It expresses that these vehicles are related to this manufacturer.
If you add user-defined properties to the manufacturer class, these properties apply to all vehicle models of this manufacturer by default, because in the class hierarchy, the models are below the object (and the implicitly declared class) of the manufacturer. This behavior of eminec MYmap is called inheritance.
You can set for each object (more correctly: for each class declaration) whether it inherits the properties of its parent or not. If yes, the object has the properties inherited from its parent as well as properties newly added to this object. If inheritance is switched off, the object has the properties directly assigned to it only, properties declared for superordinate objects are discarded.
In this context it is important not to confuse properties and property values: if you add, for example, the property »mileage« to the manufacturer, each vehicle inherits this property; the actual characteristics of the vehicles — the property values — are never inherited, but need to be set for each model separately. Properties that are not user-defined are also never inherited. (Example: A picture subordinate to a branch does not have all properties that are typical of a branch.)
Tips
When you create your own class model, note the implications of the way user-defined classes work in eminec MYmap: if you desire inheritance of certain properties, you must make sure that the objects that shall inherit a certain property are subordinate to the objects that first introduce this property into the class hierarchy of your map.
Properties are never inherited over multiple maps: if you use linked maps, the target map of a link can never inherit properties from the source map. The reason is that every map is saved as an independent file. If inheritance over map boundaries was possible, renaming or moving one file could destroy the entire class hierarchy.
You can change the class declaration even if you have already set property values of the objects. Click a property name in the »Declare« section of the »Class« task pane to change it. You may also remove declarations no longer needed by clicking the »Delete property« and »Delete all properties« buttons.
If you change the name of a property, eminec MYmap will no longer find the property values that have already been set for that property. The property value appears to be empty in this case, but it remains stored in your map. If you rename the property again so that it matches the previous name, or if you create a new property that has the name of the previously existing property, eminec MYmap will automatically assign the property value that had temporarily been invisible to the property. To inhibit storage of invisible property values in your map, you must delete the property value from your map first (i. e. replace it with an empty entry) and then rename or delete the property.
In the context of user-defined classes, the XML export interface of eminec MYmap is very useful. More about this can be found in the chapter Working with XML data.