Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "GEF/GEF4/Zest"

< GEF‎ | GEF4
(Remove section about Zest 1.x and clear migration section, which is no longer accurate.)
(Zest.FX.UI)
(25 intermediate revisions by 2 users not shown)
Line 1: Line 1:
TODO: Create a stand-alone documentation of the GEF4 Zest component here. Up to now, some documentation can already be found under [[Zest]]
+
''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 [http://wiki.eclipse.org/GEF/GEF4/Zest the original wiki page]''.
  
''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 [http://wiki.eclipse.org/Zest the original wiki page]''.
+
__NOTOC__
  
== GEF4 Zest ==
+
== Introduction ==
  
This is a collection of documentation on Zest 2.0, the latest development version of Zest. Zest 2 is part of [[GEF/GEF4|GEF4]] and can be installed from the [[GEF/GEF4#Update_Sites|GEF4 Update Sites]]. Additional information can also be found here:
+
The [[GEF/GEF4/Zest|<span style="color:#206FAD">GEF4 Zest</span>]] component provides support for visualizing [[GEF/GEF4/Graph|GEF4 Graph]]-based graph models, applying automatic layout as provided by [[GEF/GEF4/Layout|GEF4 Layout]]. It is internally decomposed into the [[#Zest.FX|Zest.FX]] and [[#Zest.FX.UI|Zest.FX.UI]] modules. In addition, there is a deployed [[GEF/GEF4/Zest/Examples#Graph Example (Standalone, Eclipse UI)|Zest Graph Example]] as well as some undeployed [[GEF/GEF4/Zest/Examples#JFace-API Examples (undeployed)|JFace-API examples]].
  
* [[Tree_Views_for_Zest | Zest 2.0 Layout API]]
+
[[Image:GEF4-Components-Zest.png|600px]]
* [[Zest/DOT | Graphviz DOT support]]
+
  
Currently, an alternative Zest.Core implementation using GEF4 MVC and JavaFX, called [[GEF/GEF4/Zest/FX|Zest.FX]], is under development.
+
== Zest.FX ==
  
== Contribute ==
+
*'''feature: org.eclipse.gef4.zest.fx'''
 +
*'''bundle: org.eclipse.gef4.zest.fx'''
  
The Zest 2 source code is available from the [http://git.eclipse.org/c/gef/org.eclipse.gef4.git/ GEF4 Git repository]. It is also [https://github.com/eclipse/gef4 mirrored on GitHub]. There are example snippets in ''org.eclipse.gef4.zest.examples'' and tests in ''org.eclipse.gef4.zest.tests''. For instructions on contributing, see the [[GEF/Contributor Guide | GEF Contributor Guide]]. You can search for [https://bugs.eclipse.org/bugs/buglist.cgi?list_id=4722702&classification=Tools&query_format=advanced&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&component=Zest&product=GEF existing bugs], or [https://bugs.eclipse.org/bugs/enter_bug.cgi?product=GEF&component=Zest file a new one].
+
The [[#Zest.FX|Zest.FX]] module provides a graph viewer and implements all functionality therefor. It uses JavaFX and [[GEF/GEF4/FX|GEF4 FX]] for visualization purposes and is internally based on [[GEF/GEF4/MVC|GEF4 MVC]], can thus also be used standalone. Integrating with the Eclipse UI is realized by the [[#Zest.FX.UI|Zest.FX.UI]] module.
  
== New subgraph rendering ==
+
[[Image:GEF4Zest.FX-GraphExample.png|319px|GEF4 Zest stand-alone Graph example]]
  
In GEF4 Zest, subgraphs can hide their contained nodes or add different types of additional information about ''pruned'' elements:
+
=== Visualization ===
  
=== LabelSubgraph ===
+
The [[GEF/GEF4/MVC|GEF4 MVC]] component is used as the framework for the viewer. It is extended by implementing content parts for the [[GEF/GEF4/Graph|GEF4 Graph]] data model (GraphContentPart, NodeContentPart, and EdgeContentPart) and binding a separate content part factory for it, integrating the [[GEF/GEF4/Layout|GEF4 Layout]] component ([[GEF/GEF4/Zest#Layout_Integration|see below]]), and implementing hiding of nodes by providing a HidingModel and corresponding policies and behaviors.
  
Each subgraph is represented as a separate graph item: a label showing the number of nodes contained within it. It can be subclassed to show other kinds of information.
+
The [[GEF/GEF4/Graph|GEF4 Graph]] data model consists of 3 classes: Graph, Node, and Edge. A Graph serves as a container for Nodes and Edges. Additionally, a Graph can be ''nested'' inside a so called ''nesting'' Node. Moreover, arbitrary attributes can be set on Graphs, Nodes, and Edges, which the visualization is based on ([[GEF/GEF4/Zest#Visualization_Properties|Visualization Properties]]). GEF4 Zest expects a Graph as its input, which is stored in the ContentModel provided by [[GEF/GEF4/MVC|GEF4 MVC]]. A separate content part is created for every Graph, Node, or Edge in the ContentModel and the content parts are automatically synchronized with the ContentModel, i.e. content parts are removed, created, or refreshed according to ContentModel changes. The content parts are utilized for the synchronization and are also responsible for the visualization of their corresponding content objects.
  
[[Image:Zest-tree-subgraph-label.png|150px‎]]
+
[[Image:GEF4Zest-visuals.png|GEF4 Zest default visuals]]
  
=== TriangleSubgraph ===
+
The default visualization for nodes consists of a JavaFX Rectangle for background and border, a Text for the label, and an ImageView for the icon. The default visualization for edges consists of an FXGeometryNode<ICurve> for the connection line, and a JavaFX Text for the label.
  
Each subgraph is represented as a triangle. It's designed specifically to work with ''SpaceTreeLayoutAlgorithm'' (see below) and assumes that nodes ''pruned'' inside it form a tree structure. Properties of this structure are visualized by properties of the triangle. The height of the triangle corresponds to the height of the tree, the length of the triangle's base corresponds to the total number of leaves in the tree and the luminance of the triangle's color corresponds to the average number of children for each node in the tree (which can be understood as the density).
+
==== Visualization Properties ====
  
[[Image:Zest-tree-subgraph-triangle.png|150px‎]]
+
The visualization is based on the attributes that are associated with graphs, nodes, or edges.
  
=== PrunedSuccessorsSubgraph ===
+
The following attributes are evaluated for graphs:
 +
* "type": Stores a String specifying whether the graph is "directed" or "undirected". In a directed graph, every edge represents a unidirectional connection between its source and target nodes, whereas in an undirected graph, every edge represents a bidirectional connection between its source and target nodes.
  
Each subgraph is represented as a little label showing how many direct successors are ''pruned''.
+
The following attributes are evaluated for nodes and edges (referred to as elements):
 +
* "css-class": Stores the CSS class (String) that is assigned to this element.
 +
* "css-id": Stores the CSS id (String) that is assigned to this element.
 +
* "label": Stores the label (String) for this element.
  
[[Image:Zest-tree-subgraph-successors.png|150px‎]]
+
The following attributes are evaluated for nodes:
 +
* "node-rect-css-style": Stores the CSS style (String) that is assigned to the JavaFX Rectangle which displays the border and background of this node.
 +
* "node-label-css-style": Stores the CSS style (String) that is assigned to the JavaFX Text which displays the label of this node.
 +
* "icon": JavaFX Image which is displayed next to the node's label.
 +
* "tooltip": Text (String) which is shown as a tooltip, i.e. when the mouse hover the node and does not move for a short time.
 +
* "fisheye": If set to True (Boolean), the node's visualization is reduced to a minimum and only expands when the mouse is over the node.
  
 +
The following attributes are evaluated for edges:
 +
* "edge-curve-css-style": Stores the CSS style (String) that is assigned to the FXGeometryNode<ICurve> ([[GEF/GEF4/FX|GEF4 FX]]) which displays this edge.
 +
* "edge-label-css-style": Stores the CSS style (String) that is assigned to the JavaFX Text which displays the label of this edge.
 +
* "edge-router": Stores an IFXConnectionRouter ([[GEF/GEF4/FX|GEF4 FX]]) that is used to compute the ICurve ([[GEF/GEF4/Geometry|GEF4 Geometry]]) which is used as the basis for the visualization of this edge.
 +
* "style": Stores a String specifying the dash pattern of the edge, which can be "solid", "dashed", "dotted", "dashdot", or "dashdotdot".
 +
 +
=== Layout Integration ===
 +
 +
The [[GEF/GEF4/Layout|GEF4 Layout]] interfaces are adopted to the [[GEF/GEF4/Graph|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. A GraphLayoutContext combines all layout information for one Graph. Therefore, one GraphLayoutContext is maintained per GraphContentPart via the adapter mechanism.
 +
 +
You can access the GraphLayoutContext for a specific Graph as follows:
 +
<source lang="java">
 +
GraphLayoutContext layoutContext = viewer.getContentPartMap().get(graph).getAdapter(LayoutModel.class);
 +
</source>
 +
 +
==== Layout Properties ====
 +
 +
The following attributes are evaluated for graphs:
 +
* "layout": Stores the ILayoutAlgorithm (see [[GEF/GEF4/Layout|GEF4 Layout]]) that will be used to layout the nodes and edges of this graph.
 +
 +
The following attributes are evaluated for nodes and edges (referred to as elements):
 +
* "layout-irrelevant": If set to True (Boolean), this element will not get layed out.
 +
 +
=== Hiding of nodes ===
 +
 +
[[Image:GEF4Zest-HidingHoverHandles.png|Hover handles for hide/show]]
 +
 +
A HidingModel stores which nodes are currently hidden. Every visible node shows a small marker indicating how many of its neighbors are hidden. You can hide/show nodes using the hover handles, respectively. The visualization is automatically synchronized with the HidingModel.
 +
 +
== Zest.FX.UI ==
 +
 +
*'''feature: org.eclipse.gef4.zest.fx.ui'''
 +
*'''bundle: org.eclipse.gef4.zest.fx.ui'''
 +
 +
The Zest.FX.UI module contains all Eclipse Workbench UI integration aspects.
 +
 +
=== Eclipse Integration ===
 +
 +
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.
 +
 +
[[Image:GEF4Zest.FX.UI-GraphExample.png|318px|GEF4 Zest in Eclipse]]
 +
 +
----
  
 
== Migration from Zest 1.x to GEF4 Zest ==
 
== Migration from Zest 1.x to GEF4 Zest ==
  
TODO: Provide detailed information on how to migrate from Zest 1.x to GEF4 Zest, as indicated within bugzilla  [https://bugs.eclipse.org/bugs/show_bug.cgi?id=441131 #441131].
+
[[GEF/GEF4/Zest|GEF4 Zest]] was mostly written from scratch, replacing the Zest 1.x API as well as the provisional Zest 2.x API ([[Tree_Views_for_Zest | 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 [[GEF/GEF4/MVC|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 [[GEF/GEF4/Graph|GEF4 Graph]] where previously Zest 1.x Graph, GraphNode, and GraphConnection were created/modified.
 +
 
 +
Since GEF4 Zest is based on [[GEF/GEF4/MVC|GEF4 MVC]], you should be familiar with the mechanisms and concepts of [[GEF/GEF4/MVC|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 [[GEF/GEF4/Layout|GEF4 Layout]] into GEF4 Zest.
 +
 
 +
The GEF4 Git repository contains an [http://git.eclipse.org/c/gef/org.eclipse.gef4.git/tree/org.eclipse.gef4.zest.examples.graph/src/org/eclipse/gef4/zest/examples/graph/ZestGraphExample.java 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 ([[GEF/GEF4/Zest#Visualization_Properties | Visualization Properties]]).
 +
 
 +
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 [http://git.eclipse.org/c/gef/org.eclipse.gef4.git/tree/org.eclipse.gef4.layout.examples/src/org/eclipse/gef4/layout/examples/CustomNodeLayoutExample.java 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.
 +
 
 +
==== Modifying graphs ====
 +
 
 +
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 [http://git.eclipse.org/c/gef/org.eclipse.gef4.git/tree/org.eclipse.gef4.layout.examples/src/org/eclipse/gef4/layout/examples/FullyMeshedLayoutExample.java example] of this scenario.
 +
 
 +
==== Layout filter ====
 +
 
 +
Nodes and edges can be marked as layout-irrelevant, meaning they will not get reported to layout algorithms. The GEF4 Git repository contains an [http://git.eclipse.org/c/gef/org.eclipse.gef4.git/tree/org.eclipse.gef4.layout.examples/src/org/eclipse/gef4/layout/examples/FilterLayoutExample.java 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 <code>#getConnectedTo(Object)</code> 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 [http://git.eclipse.org/c/gef/org.eclipse.gef4.git/tree/org.eclipse.gef4.zest.examples.ui/src/org/eclipse/gef4/zest/examples/ui/JFaceCustomNodeExample.java 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:
 +
* [http://git.eclipse.org/c/gef/org.eclipse.gef4.git/tree/org.eclipse.gef4.zest.examples.ui/src/org/eclipse/gef4/zest/examples/ui/JFaceColorsExample.java JFaceColorsExample]
 +
* [http://git.eclipse.org/c/gef/org.eclipse.gef4.git/tree/org.eclipse.gef4.zest.examples.ui/src/org/eclipse/gef4/zest/examples/ui/JFaceFontsExample.java JFaceFontsExample]
 +
* [http://git.eclipse.org/c/gef/org.eclipse.gef4.git/tree/org.eclipse.gef4.zest.examples.ui/src/org/eclipse/gef4/zest/examples/ui/JFaceTooltipExample.java JFaceTooltipExample]
 +
* [http://git.eclipse.org/c/gef/org.eclipse.gef4.git/tree/org.eclipse.gef4.zest.examples.ui/src/org/eclipse/gef4/zest/examples/ui/JFaceEdgeDecorationExample.java JFaceEdgeDecorationExample]
 +
* [http://git.eclipse.org/c/gef/org.eclipse.gef4.git/tree/org.eclipse.gef4.zest.examples.ui/src/org/eclipse/gef4/zest/examples/ui/JFaceEdgeRouterExample.java JFaceEdgeRouterExample]
 +
* [http://git.eclipse.org/c/gef/org.eclipse.gef4.git/tree/org.eclipse.gef4.zest.examples.ui/src/org/eclipse/gef4/zest/examples/ui/JFaceNestingExample.java JFaceNestingExample]
 +
 
 +
==== Colors, sizes, borders, styles ====
 +
 
 +
Many visual features can be specified via JavaFX CSS within GEF4 Zest which would have required either a style provider or a custom figure in previous versions. The CSS styles can be applied to individual elements, or entire classes of elements. There are four parts of the visualization which can be styled individually:
 +
* "node-rect-css-style": Styles the JavaFX Rectangle which renders the border and background of a node.
 +
* "node-label-css-style": Styles the JavaFX Text which renders the label of a node.
 +
* "edge-curve-css-style": Styles the FXGeometryNode which renders an edge.
 +
* "edge-label-css-style": Styles the JavaFX Text which renders the label of an edge.
 +
 
 +
The values returned by a provider for the font, foreground, and background color are transferred into equivalent CSS styles which can be overwritten by an IGraphNodeLabelProvider or INestedGraphLabelProvider.
 +
 
 +
==== Zooming ====
 +
 
 +
Within [[GEF/GEF4/MVC|GEF4 MVC]], a ViewportModel maintains a content transformation which can be modified to zoom in/out of a visualization. GEF4 Zest uses zooming to switch between nested graphs, i.e. when zooming into a nesting node, it will eventually be replaced by its nested graph.
 +
 
 +
==== Custom visualization ====
 +
 
 +
You can change the content parts for nodes and edges, and therefore their visualizations. This is done by binding your own content part factory within the application's module (Guice). The content part factory is responsible for creating the controller objects (content parts) for respective content objects (Node, Edge, Graph). Therefore, you can create your own content parts instead of the content parts provided by GEF4 Zest.
 +
 
 +
The GEF4 Git repository contains an [http://git.eclipse.org/c/gef/org.eclipse.gef4.git/tree/org.eclipse.gef4.zest.examples.ui/src/org/eclipse/gef4/zest/examples/ui/JFaceCustomNodeExample.java example] of this scenario.
 +
 
 
[[Category: GEF]]
 
[[Category: GEF]]

Revision as of 06:10, 25 May 2015

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.


Introduction

The GEF4 Zest component provides support for visualizing GEF4 Graph-based graph models, applying automatic layout as provided by GEF4 Layout. It is internally decomposed into the Zest.FX and Zest.FX.UI modules. In addition, there is a deployed Zest Graph Example as well as some undeployed JFace-API examples.

GEF4-Components-Zest.png

Zest.FX

  • feature: org.eclipse.gef4.zest.fx
  • bundle: org.eclipse.gef4.zest.fx

The Zest.FX module provides a graph viewer and implements all functionality therefor. It uses JavaFX and GEF4 FX for visualization purposes and is internally based on GEF4 MVC, can thus also be used standalone. Integrating with the Eclipse UI is realized by the Zest.FX.UI module.

GEF4 Zest stand-alone Graph example

Visualization

The GEF4 MVC component is used as the framework for the viewer. It is extended by implementing content parts for the GEF4 Graph data model (GraphContentPart, NodeContentPart, and EdgeContentPart) and binding a separate content part factory for it, integrating the GEF4 Layout component (see below), and implementing hiding of nodes by providing a HidingModel and corresponding policies and behaviors.

The GEF4 Graph data model consists of 3 classes: Graph, Node, and Edge. A Graph serves as a container for Nodes and Edges. Additionally, a Graph can be nested inside a so called nesting Node. Moreover, arbitrary attributes can be set on Graphs, Nodes, and Edges, which the visualization is based on (Visualization Properties). GEF4 Zest expects a Graph as its input, which is stored in the ContentModel provided by GEF4 MVC. A separate content part is created for every Graph, Node, or Edge in the ContentModel and the content parts are automatically synchronized with the ContentModel, i.e. content parts are removed, created, or refreshed according to ContentModel changes. The content parts are utilized for the synchronization and are also responsible for the visualization of their corresponding content objects.

GEF4 Zest default visuals

The default visualization for nodes consists of a JavaFX Rectangle for background and border, a Text for the label, and an ImageView for the icon. The default visualization for edges consists of an FXGeometryNode<ICurve> for the connection line, and a JavaFX Text for the label.

Visualization Properties

The visualization is based on the attributes that are associated with graphs, nodes, or edges.

The following attributes are evaluated for graphs:

  • "type": Stores a String specifying whether the graph is "directed" or "undirected". In a directed graph, every edge represents a unidirectional connection between its source and target nodes, whereas in an undirected graph, every edge represents a bidirectional connection between its source and target nodes.

The following attributes are evaluated for nodes and edges (referred to as elements):

  • "css-class": Stores the CSS class (String) that is assigned to this element.
  • "css-id": Stores the CSS id (String) that is assigned to this element.
  • "label": Stores the label (String) for this element.

The following attributes are evaluated for nodes:

  • "node-rect-css-style": Stores the CSS style (String) that is assigned to the JavaFX Rectangle which displays the border and background of this node.
  • "node-label-css-style": Stores the CSS style (String) that is assigned to the JavaFX Text which displays the label of this node.
  • "icon": JavaFX Image which is displayed next to the node's label.
  • "tooltip": Text (String) which is shown as a tooltip, i.e. when the mouse hover the node and does not move for a short time.
  • "fisheye": If set to True (Boolean), the node's visualization is reduced to a minimum and only expands when the mouse is over the node.

The following attributes are evaluated for edges:

  • "edge-curve-css-style": Stores the CSS style (String) that is assigned to the FXGeometryNode<ICurve> (GEF4 FX) which displays this edge.
  • "edge-label-css-style": Stores the CSS style (String) that is assigned to the JavaFX Text which displays the label of this edge.
  • "edge-router": Stores an IFXConnectionRouter (GEF4 FX) that is used to compute the ICurve (GEF4 Geometry) which is used as the basis for the visualization of this edge.
  • "style": Stores a String specifying the dash pattern of the edge, which can be "solid", "dashed", "dotted", "dashdot", or "dashdotdot".

Layout Integration

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. A GraphLayoutContext combines all layout information for one Graph. Therefore, one GraphLayoutContext is maintained per GraphContentPart via the adapter mechanism.

You can access the GraphLayoutContext for a specific Graph as follows:

GraphLayoutContext layoutContext = viewer.getContentPartMap().get(graph).getAdapter(LayoutModel.class);

Layout Properties

The following attributes are evaluated for graphs:

  • "layout": Stores the ILayoutAlgorithm (see GEF4 Layout) that will be used to layout the nodes and edges of this graph.

The following attributes are evaluated for nodes and edges (referred to as elements):

  • "layout-irrelevant": If set to True (Boolean), this element will not get layed out.

Hiding of nodes

Hover handles for hide/show

A HidingModel stores which nodes are currently hidden. Every visible node shows a small marker indicating how many of its neighbors are hidden. You can hide/show nodes using the hover handles, respectively. The visualization is automatically synchronized with the HidingModel.

Zest.FX.UI

  • feature: org.eclipse.gef4.zest.fx.ui
  • bundle: org.eclipse.gef4.zest.fx.ui

The Zest.FX.UI module contains all Eclipse Workbench UI integration aspects.

Eclipse Integration

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.

GEF4 Zest in Eclipse


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 ( Visualization Properties).

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.

Modifying graphs

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.

Layout filter

Nodes and edges can be marked as layout-irrelevant, meaning they will not get reported to layout algorithms. 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:

Colors, sizes, borders, styles

Many visual features can be specified via JavaFX CSS within GEF4 Zest which would have required either a style provider or a custom figure in previous versions. The CSS styles can be applied to individual elements, or entire classes of elements. There are four parts of the visualization which can be styled individually:

  • "node-rect-css-style": Styles the JavaFX Rectangle which renders the border and background of a node.
  • "node-label-css-style": Styles the JavaFX Text which renders the label of a node.
  • "edge-curve-css-style": Styles the FXGeometryNode which renders an edge.
  • "edge-label-css-style": Styles the JavaFX Text which renders the label of an edge.

The values returned by a provider for the font, foreground, and background color are transferred into equivalent CSS styles which can be overwritten by an IGraphNodeLabelProvider or INestedGraphLabelProvider.

Zooming

Within GEF4 MVC, a ViewportModel maintains a content transformation which can be modified to zoom in/out of a visualization. GEF4 Zest uses zooming to switch between nested graphs, i.e. when zooming into a nesting node, it will eventually be replaced by its nested graph.

Custom visualization

You can change the content parts for nodes and edges, and therefore their visualizations. This is done by binding your own content part factory within the application's module (Guice). The content part factory is responsible for creating the controller objects (content parts) for respective content objects (Node, Edge, Graph). Therefore, you can create your own content parts instead of the content parts provided by GEF4 Zest.

The GEF4 Git repository contains an example of this scenario.

Back to the top