Skip to main content
Jump to: navigation, search


< GEF‎ | GEF4
Revision as of 01:48, 28 July 2015 by (Talk | contribs) ({Root})

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.


The GEF4 Cloudio component provides support for visualizing tag clouds within a dedicated SWT Canvas or JFace viewer. It is internally decomposed into the single Cloudio.UI module. There are also a couple of undeployed Cloudio UI Examples.


User Documentation

The GEF4 Cloudio component provides a Tag Cloud view that can be used to create word clouds.


The words, which are used to render the word cloud can be loaded from a text file via the 'File -> Load File'. In case the file contains words that should be excluded from the word cloud, a list of stop words (blacklist) can be loaded in addition via 'File -> Load Stopwords'. After having loaded words and/or stop words, the tag cloud is automatically rendered. The rendered tag cloud can be exported to an PNG file via 'File -> Export Image'.

The view delivers various controls to adjust the generation of the word cloud, including background mask (a square PNG image containing black and white pixels only, where black pixels are interpreted as used, such that strings will be drawn on white areas only), font min and max sizes, boost (count) and boost factor, angles, scales, and axis variation. Furthermore, colors and fonts can be specified. After changes to these properties, the tag cloud can be rendered again using 'Re-Position' or 'Re-Layout'.

Below are some examples of tag clouds generated with Cloudio. The images were created with the help of the TagCloud view, modifying different parameters (such as colors, fonts or rotation angles).


Zest cloudio woyzeck.png

Created from Georg Büchner's Woyzeck. The most frequent word was boosted.


Zest cloudio winnetou.png

Karl May's Winnetou III, using two different fonts, 45-degree rotation and a relatively large x-axis variation when placing the words.


Zest cloudio nietzsche.png

'Also sprach Zarathustra', by Nietzsche. 90 degree rotation and a large x-axis variation.

Woyzeck Cluster

Zest cloudio woyzeck cluster.png

Same text as in the first example, but with a modified layout algorithm and label provider: Both labels and initial position are assigned based on the first character of the word (for instance, words starting with a to l are at the bottom left). Doesn't really look good, but shows how to extend the functionality to realize a cluster visualization or else...


  • feature: org.eclipse.gef4.cloudio.ui
  • bundle: org.eclipse.gef4.cloudio.ui

The Cloudio.UI module of GEF4 Cloudio provides SWT- and JFace-based support for rendering tag clouds.


  • package: org.eclipse.gef4.cloudio.ui

The {Root} package provides an SWT widget (TagCloud) and a JFace viewer (TagCloudViewer), which support rendering of word clouds.


TagCloud, Word

A TagCloud is a special org.eclipse.swt.widgets.Canvas, dedicated to display a tag cloud. It expects the to be rendered words and related properties (weight, angle, color, font) to be represented as Word input elements and can be created as follows:

public static void main(String [] args) {
  final Display display = new Display();
  final Shell shell = new Shell(display);
  TagCloud cloud = new TagCloud(shell, SWT.NONE);
  // Generate some dummy words - color, weight and fontdata must
  // always be defined.
  List<Word> words = new ArrayList<Word>();
  Word w = new Word("Hello");
  w.weight = 1;
  w = new Word("Cloudio");
  w.weight = 0.5;
  w.angle = -45;
  shell.setBounds(50,50, 300, 300);
  cloud.setBounds(0,0, shell.getBounds().width, shell.getBounds().height);
  // Assign the list of words to the cloud:
  cloud.setWords(words, null);;
  while (!shell.isDisposed()) {
    if (!display.readAndDispatch()) display.sleep();

The result should look similar to this (String positions are assigned by random):

Zest cloudio snippet1.png

TagCloudViewer, ICloudLabelProvider

A TagCloudViewer is a special org.eclipse.jface.viewers.ContentViewer, that renders a tag cloud. It is internally based on a TagCloud and enhances the functionality of the tag cloud: it is possible to select and deselect elements by mouse click, to zoom in or out using the mouse wheel and to display tool tips on words. The TagCloudViewer expects an org.eclipse.jface.viewers.IStructuredContentProvider and an ICloudLabelProvider. The words that are to be rendered in the TagCloud are inferred by queuing the ICloudLabelProvider for labels of the elements returned by the org.eclipse.jface.viewers.IStructuredContentProvider. The properties of the words (weight, color, font, angle) are retrieved via the ICloudLabelProvider for each word as well.

A TagCloudViewer can be used as follows:

  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.List;
  import org.eclipse.jface.viewers.BaseLabelProvider;
  import org.eclipse.jface.viewers.ISelectionChangedListener;
  import org.eclipse.jface.viewers.IStructuredContentProvider;
  import org.eclipse.jface.viewers.IStructuredSelection;
  import org.eclipse.jface.viewers.SelectionChangedEvent;
  import org.eclipse.jface.viewers.StructuredSelection;
  import org.eclipse.jface.viewers.Viewer;
  import org.eclipse.swt.SWT;
  import org.eclipse.swt.widgets.Display;
  import org.eclipse.swt.widgets.Shell;
  import org.eclipse.zest.cloudio.ICloudLabelProvider;
  import org.eclipse.zest.cloudio.TagCloud;
  import org.eclipse.zest.cloudio.TagCloudViewer;
  public class TagCloudViewerSnippet {
    static class CustomLabelProvider extends BaseLabelProvider implements ICloudLabelProvider {
        private Font font;
        public CustomLabelProvider(Font font) {
            this.font = font;
        public String getLabel(Object element) {
            return element.toString();
        public double getWeight(Object element) {
            return Math.random();
        public Color getColor(Object element) {
            return Display.getDefault().getSystemColor(SWT.COLOR_GREEN);
        public FontData[] getFontData(Object element) {
            return font.getFontData();
        public float getAngle(Object element) {
            return (float) (-90 + Math.random() * 180);
        public String getToolTip(Object element) {
            return element.toString();
    public static void main(String [] args) {
        final Display display = new Display();
        final Shell shell = new Shell(display);
        TagCloud cloud = new TagCloud(shell, SWT.NONE);
        final TagCloudViewer viewer = new TagCloudViewer(cloud);
        // A simple content provider for a list of elements 
        viewer.setContentProvider(new IStructuredContentProvider() {
            public void dispose() { }
            public void inputChanged(Viewer viewer, Object oldInput,
                    Object newInput) {}
            public Object[] getElements(Object inputElement) {
                return ((List<?>)inputElement).toArray();
        // A simple label provider (see above)
        viewer.setLabelProvider(new CustomLabelProvider(cloud.getFont()));
        // Demo of an selection listener
        viewer.addSelectionChangedListener(new ISelectionChangedListener() {
            public void selectionChanged(SelectionChangedEvent event) {
                IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
                System.out.println("Selection: " + selection);
        // Demo data
        List<String> data = new ArrayList<String>();
        data.add("Hello Cloudio");
        shell.setBounds(50,50, 300, 300);
        cloud.setBounds(0,0, shell.getBounds().width, shell.getBounds().height);
        // Set the input of the viewer
        // Set initial selection:
        viewer.setSelection(new StructuredSelection(Arrays.asList("Hello Cloudio")));
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) display.sleep();

The result will look similar to this:

Zest cloudio snippet2.png


  • package: org.eclipse.gef4.cloudio.ui.layout

The Layout package provides the contract (ILayouter) for algorithms that perform placement of words during tag cloud generation, as well as a related default implementation (DefaultLayouter).


ILayouter, DefaultLayouter

An ILayouter is used by a TagCloud to compute the actual placement of words inside a given area. The DefaultLayouter places words similar to the algorithm used by Wordle.


  • package: org.eclipse.gef4.cloudio.ui.util

The Util package provides a two-dimensional tree structure to store non-overlapping rectangles (RectTree), a custom rectangle implementation (SmallRect) with short precision used by it (which will probably be replaced with org.eclipse.gef4.geometry.planar.Rectangle in the future), and a CloudMatrix, which represents a drawable area within a tag cloud through a RectTree.


RectTree, RectNode, SmallRect

A RectTree is a two-dimensional tree structure to store non-overlapping rectangles that are represented through RectNodes, which are internally based on a short-precision rectangle representation (SmallRect).


A CloudMatrix represents the drawable area within a tag cloud (and information about which word is placed at which coordinate), internally based on a RectTree.

Back to the top