Understanding the role of data model

When using libraries or nodeRendererFunction in Diagrammer, the data property on each item (node, group or link) provides mainly the rendering information and optionally the required information that should be edited or displayed. First, the data is used to specify the item renderer via rendering options and then to get consumed in that renderer for displaying the required information and for edition purposes. When editing, the data property will be updated will be updated whether in the default case or the custom rendering case. This process is suitable for Visualizer as the main need is visualizing and navigating through data. But in Diagrammer, such a process can be insufficient and not suitable for some enterprise applications where a data model is maintained in the back end.


We can imagine an application where node symbols are dragged from a given drag source and where each item should acquire a predefined information from the application presentation model and a pre-computed unique id. The data acquired for each dragged item presents the drag symbol data and the unique identifier is automatically generated. Thus, differentiating between nodes should be performed at a second step by updating the data with the required information. Proceeding is known as a source of bugs in the application and it is a not a recommended architectural choice. Even though we are perfectly able to use the data value for each item for extracting rendering information and performing edition directives, in several cases, this process leads to several problems in some integration scenarios:

Decoupling rendering options from displayed and edited information relies on user/developer choice. As a solution, the dataModel property have been added on each item (node, group, table, link and their decorators) to allow developers inject information while letting the data property value deal with rendering specifications. In this recommended configuration, the data value will be used with all the rendering options to determine the renderer while still being injected in any generated item renderer: If the dataModel value is not null, its value will be used by all display properties of all item instead of using the default data value: If the renderer implements the IEditable interface, the value is also injected in the item renderer of each item (and its decorator) to: Note : The dataModel can be used in some implementations to control a renderer aspect (color, shape...) according to the value of a given property in the data model.