Mapping Between Business Layer and Presentation Layer

Tips & Tricks

Summary

The yFiles library provides direct support for mapping from nodes and edges to corresponding business objects.
For a better user experience, please go to the integrated documentation viewer to read this article.

Description

When the yFiles graph visualization library is used in an application to present some graph structure to the user, there often is also a business model involved that holds data relating to the objects from the graph structure. The graph structure is simply the application's presentation layer for the data (or part of the data) from the business layer.

When it comes to map between these two layers, the yFiles library provides support for the direction from presentation layer to business layer by means of so-called data accessors, most prominently implementations for interfaces NodeMap and EdgeMap.
The concept of data accessors is explained in the yFiles Developer's Guide in Binding Data to Graph Elements .

Conveniently provided by class Graph are the default implementations of the aforementioned interfaces. These can be created using the Graph.createNodeMap() and Graph.createEdgeMap() methods, respectively.
More information on the default implementations can be found in the yFiles Developer's Guide in the section Default Map Implementations .

Data can also be bound to the graph itself. The map which corresponds to the NodeMap and EdgeMap interface is the more universal DataMap. A default implementation can be created using the Maps.createHashedDataMap() method.

To map from an application's business layer to the presentation layer, i.e., in particular to the nodes and edges of a graph, possible solutions would be to

  • use a field in the business object that holds the corresponding node or edge
  • use a map implementation that does the mapping, e.g., an implementation of interface java.util.Map

Categories this article belongs to:
yFiles for Java > yFiles Basic > Working With the Graph Structure > Binding Data to Graph Elements
yFiles for Java > yFiles Layout
yFiles for Java > yFiles Viewer
yFiles for Java > Other
Applies to:
yFiles for Java 2: 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.10, 2.11, 2.12, 2.13, 2.14, 2.15, 2.16, 2.17, 2.18
Keywords:
business - model - presentation - layer - NodeMap - EdgeMap - map - mapping - node - edge - createNodeMap - default - data - accessor