Note to non-wiki readers: This documentation is generated from the Eclipse wiki - if you have corrections or additions it would be awesome if you added them in the original wiki page.
- 1 Introduction
- 2 MVC
- 3 Visualization Properties
- 4 Layout Integration
- 5 Eclipse Integration
- 6 Migration from Zest 1.x to GEF4 Zest
- 6.1 Migration from Zest 1.x Core to GEF4 Zest.FX
- 6.2 Migration from Zest 1.x JFace to GEF4 Zest.FX.UI
GEF4 Zest is a graph visualization component that can be used to visualize GEF4 Graph-based graph models, applying automatic layout as provided by GEF4 Layout. It uses JavaFX and GEF4 FX for visualization purposes and is internally based on GEF4 MVC.
The GEF4 MVC component is used as the framework for the viewer.
The ContentParts are implemented for the GEF4 Graph data model:
The visualization is based on the attributes that are associated with graphs, nodes, or edges. The following attributes are supported:
- For graphs: type, layout.
- For nodes/edges: css-class, css-id, label, layout-irrelevant.
- For nodes: node-rect-css-style, node-label-css-style, icon, tooltip, fisheye, hidden.
- For edges: edge-curve-css-style, edge-label-css-style, edge-router, style.
The GEF4 Layout interfaces are adopted to the GEF4 Graph data model. The layout objects are constructed from a given Graph object.
The layout objects support a general property mechanism to exchange layout information. GEF4 Zest transfers visualization attributes (locations and sizes) to layout properties and vice versa.
The LayoutContext for a graph is stored in the LayoutModel that is associated with the corresponding GraphContentPart.
GEF4 Zest provides an Eclipse ViewPart (o.e.g4.zest.fx.ui.parts.ZestFxUiView) for visualizing graph models, so that you can integrate it into the Eclipse workbench.
Migration from Zest 1.x to GEF4 Zest
GEF4 Zest was mostly written from scratch, replacing the Zest 1.x API as well as the provisional Zest 2.x API ( Zest 2.0 Layout API) that was developed as an intermediate step.
The Zest 1.x API consists of two parts: 1) a core API for the visualization of graphs, and 2) an on-top JFace API with specific content and label providers and a viewer dedicated to displaying Zest graphs. The former has been replaced by GEF4 Zest.FX and the latter by GEF4 Zest.FX.UI.
Migration from Zest 1.x Core to GEF4 Zest.FX
In comparison to the Zest 1.x Core API, which is based on SWT/Draw2d visualization-wise, and interweaves graph data, layout data, and visuals, the new GEF4 Zest API, on the other hand, is based on GEF4 MVC and maintains distinct object hierarchies for the graph data (content model), the layout data (layout model), and the visuals. This decouples the code, which is one of the design goals of GEF4 in general. As a result, you cannot directly affect the visualization as in Zest 1.x Core, but instead modify the underlying graph model which will effect a content synchronization, i.e. update the visualization based on the content changes. Therefore, to transition from Zest 1.x Core to GEF4 Zest.FX, you have to create/modify a GEF4 Graph where previously Zest 1.x Graph, GraphNode, and GraphConnection were created/modified.
Since GEF4 Zest is based on GEF4 MVC, you should be familiar with the mechanisms and concepts of GEF4 MVC, which are employed as follows:
- A ContentModel stores the Graph that is currently rendered.
- A ContentPartFactory constructs controller objects (content parts) for graphs, nodes, and edges. These are responsible for the visualization, content synchronization, and layout integration.
- All content parts support an adapter mechanism where you can set/query adapters for distinct keys. Functionality can be added to a content part by setting a corresponding adapter on it. For example, you can enable different interactions (moving nodes via drag, etc.) by setting the corresponding policies as adapters on the content parts.
- A Module defines (Guice) bindings for the context of an application. Using this mechanism, you can specify which adapters should be set on the different content parts. For example, the adapter mechanism is used to integrate GEF4 Layout into GEF4 Zest.
The GEF4 Git repository contains an example on how to use the new API. The example is very simple as the rendered graph is not modified later on. However, it contains everything that is needed for a fully functional example. As you can see when taking a look into the source code, attributes are set on the graph model to specify certain visualization features such as label, tooltip, CSS id, etc.. Actually, the whole visualization results from those attributes. You can find a list of all available attributes GEF/GEF4/Zest#Attributes here.
Some specific Zest 1.x Core functionalities are implemented differently within GEF4 Zest.FX. The corresponding use case scenerios are as follows.
Custom node/edge visualization
As the content parts are responsible for the visualization, you have to create a custom content part in order to exchange the visualization of certain graph elements. GEF4 Zest.FX uses a ContentPartFactory to create content parts for graph elements. Therefore, you have to exchange the ContentPartFactory to be able to create custom content parts. The ZestFxModule contains a binding for the ContentPartFactory, i.e. you have to override the corresponding ContentPartFactory#bindIContentPartFactory() method in your module to bind a CustomContentPartFactory instead. Within the CustomContentPartFactory, you can construct custom content parts, for example, for graph elements with specific attributes.
The GEF4 Git repository contains an example of this scenario. However, note that colors, fonts, borders, and sizes can be configured via JavaFX CSS and do not need a custom visualization.
Since you cannot modify the visualization directly, you have to adjust the underlying graph model instead. The visualization is then updated automatically. The GEF4 Git repository contains an example of this scenario.
Migration from Zest 1.x JFace to GEF4 Zest.FX.UI
GEF4 Zest.FX.UI consists of a ZestContentViewer and five zest-specific content and label providers. In comparison to the Zest 1.x JFace API, the ZestContentViewer is not a StructuredViewer anymore, but just a ContentViewer. Zooming is part of the Zest 1.x GraphViewer, but this is already covered within GEF4 MVC.FX. Moreover, the functionality of some of the Zest 1.x JFace providers is covered by standard JFace providers, and is therefore replaced by them:
- The old IEntityStyleProvider provides tooltip, fisheye, border, and color information. These are now provided via standard JFace IToolTipProvider, JFace IColorProvider, and GEF4 IGraphNodeLabelProvider (which provides arbitrary attributes for nodes, edges, and graphs). Additionally, the JFace IFontProvider is supported, which provides a Font for a node.
- The old IConnectionStyleProvider (and IEntityConnectionStyleProvider) provide style, color, tooltip, connection router, and connection decorator. These are now provided via GEF4 IEdgeDecorationProvider and GEF4 IGraphNodeLabelProvider, except for the tooltip, which is currently not supported for edges within GEF4 Zest.FX.
Probably, the biggest difference between the Zest 1.x JFace API and GEF4 Zest.FX.UI are the content providers. Zest.FX.UI defines two content providers:
- The IGraphNodeContentProvider provides all content elements that represent nodes for a flat graph. The edges are inferred via a
#getConnectedTo(Object)method. This is the equivalent of the Zest 1.x IGraphEntityContentProvider.
- The INestedGraphContentProvider extends the IGraphNodeContentProvider by two methods to provide nested graphs. This is the equivalence of the Zest 1.x INestedContentProvider.
So, both new content providers are node-oriented, i.e. they provide content elements which represent nodes, not edges. The Zest 1.x API additionally defines an IGraphEntityRelationshipContentProvider which provides content elements that represent edges, which is not covered by Zest.FX.UI.
Besides, the following providers have not been migrated, because their corresponding functionality is implemented by means of another mechanism:
- The Zest 1.x IFigureProvider provides a custom visualization for a node. This is now done by creating a different content part for nodes with a custom visualization, as can be seen in this example.
- The Zest 1.x ISelfStyleProvider provides a custom styling for a node or an edge. This is now done by creating a custom content part and/or using CSS to style the node/edge.
You can find examples on how to use the different providers in the GEF4 Git repository: