Skip to content
Patrick Ziegler edited this page Sep 19, 2024 · 7 revisions

Zest: The Eclipse Visualization Toolkit, is a set of visualization components built for Eclipse. The entire Zest library has been developed in SWT / Draw2D and integrates seamlessly within Eclipse because of its recognized design.

zest_screenshot

Overview

Zest has been modeled after JFace, and all the Zest views conform to the same standards and conventions as existing Eclipse views. This means that the providers, actions and listeners used within existing applications can be leveraged within Zest.

The Zest project also contains a graph layout package which can be used independently. The graph layout package can be used within existing Java applications (SWT or AWT) to provide layout locations for a set of entities and relationships.

Features

Zest is a visualization toolkit with a growing number of viewers (Static Graph Viewer), all of which aim to be easy to program against. We are actively looking for new visualizations to include in the toolkit.

zest_screen1

The Zest graph layout package provides the following layout algorithms:

  • Spring Layout Algorithm
  • Tree Layout Algorithm
  • Radial Layout Algorithm
  • Grid Layout Algorithm

Zest 2.x

New subgraph rendering

In Zest 2, subgraphs can hide their contained nodes or add different types of additional information about pruned elements:

LabelSubgraph

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.

150px

TriangleSubgraph

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).

Zest-tree-subgraph-triangle.png

PrunedSuccessorsSubgraph

Each subgraph is represented as a little label showing how many direct successors are pruned.

Zest-tree-subgraph-successors.png

New layout algorithms

SpaceTreeLayoutAlgorithm

SpaceTreeLayoutAlgorithm keeps track of node positions all the time, always trying to form a nice tree structure. This means movement of nodes with the mouse is somehow restricted (you can move a node within its current layer, but only if it doesn't cause nodes to be pushed out of the graph area. When an expand operation is requested on a node, the node is centered and its subtree is shown, as long as there's enough space (other parts of the tree can be collapsed to extend available space).

Zest-tree-layout-spacetree.png

DirectedGraphLayoutAlgorithm

DirectedGraphLayoutAlgorithm was designed with the PDE Dependency Visualization in mind and is based on its layout algorithm. Initially only nodes without predecessors are expanded. Other nodes become visible if they have at least one direct predecessor which is visible and expanded. Collapsed nodes can have outcoming connections if the target node is visible because of a predecessor. There's an option to hide such connections.

Zest-tree-layout-dag.pmg

Migration from Zest 1.x to Zest 2.x

In Zest 2, the layout API has been reworked. Most code should keep working just fine. See the Javadoc of the deprecated API for documentation on migrating to the new API. In a few cases however, code changes are required.

Layout Filters

Instead of org.eclipse.zest.layouts.Filter use org.eclipse.zest.core.widgets.LayoutFilter (see example below and full code in GraphSnippet8.java in the examples bundle).

LayoutFilter filter = new LayoutFilter() {
  public boolean isObjectFiltered(GraphItem item) {
    if (item instanceof GraphConnection) {
      GraphConnection connection = (GraphConnection) item;
      Object data = connection.getData();
      if (data != null && data instanceof Boolean) {
        return ((Boolean) data).booleanValue();
      }
      return true;
    }
    return false;
  }
};

Custom Layouts

The AbstractLayoutAlgorithm class which was previously used to implement Zest 1.x layout algorithms is now used to implement Zest 2.x layout algorithms. (see example below and full code in CustomLayout.java in the examples bundle).

LayoutAlgorithm layoutAlgorithm = new AbstractLayoutAlgorithm() {
  public void applyLayout(boolean clean) {
    EntityLayout[] entitiesToLayout = context.getEntities();
    int totalSteps = entitiesToLayout.length;
    double distance = context.getBounds().width / totalSteps;
    int xLocation = 0;
    for (int currentStep = 0; currentStep < entitiesToLayout.length; currentStep++) {
      EntityLayout layoutEntity = entitiesToLayout[currentStep];
      layoutEntity.setLocation(xLocation, layoutEntity.getLocation().y);
      xLocation += distance;
    }
  }
};

The layout algorithm no longer receives the current nodes and connections as arguments and instead has to get them from the layout context. This variable is automatically set for the AbstractLayoutAlgorithm and can be accessed via the protected context field.

Instead of the LayoutEntity and LayoutRelationship, one now has to use the EntityLayout and ConnectionLayout, respectively.

By default, the layout algorithm will be called for (almost) every event. The user can decide whether the layout needs to be re-calculated by checking the clean flag or alternatively disable it via setDynamicLayout() in the Zest Graph.

Compatibility Mode

In order to ease the transition from Zest 1.x based layout algorithms to Zest 2.x, Zest comes with a "legacy" mode that also supports the use of previously implemented algorithms. To use them, the layout algorithms need to be adapted to extend AbstractLayoutAlgorithm.Zest1 instead of AbstractLayoutAlgorithm. Similar subclasses exist for common algorithms (GridLayoutAlgorithm, SpringLayoutAlgorithm, etc...). Note that this mode will be removed in a future release.

Connection Style Providers

The IConnectionStyleProvider and IEntityConnectionStyleProvider interfaces now contain getRouter methods returning an org.eclipse.draw2d.ConnectionRouter. Return null for the default router. See ManhattanLayoutJFaceSnippet.java in the examples bundle.