org.eclipse.gef.cloudio.internal.ui

## Class TagCloud

- java.lang.Object
- - org.eclipse.swt.widgets.Widget
  - - org.eclipse.swt.widgets.Control
    - - org.eclipse.swt.widgets.Scrollable
      - - org.eclipse.swt.widgets.Composite
        - - org.eclipse.swt.widgets.Canvas
          - - org.eclipse.gef.cloudio.internal.ui.TagCloud

All Implemented Interfaces:
  org.eclipse.swt.graphics.Drawable

    public class TagCloud
    extends org.eclipse.swt.widgets.Canvas

### Field Summary

### Fields inherited from class org.eclipse.swt.widgets.Control

`view`

### Constructor Summary

Constructors
Constructor and Description
`TagCloud(org.eclipse.swt.widgets.Composite parent, int style)` Creates a new Tag cloud on the given parent.
`TagCloud(org.eclipse.swt.widgets.Composite parent, int style, int accuracy, int maxSize)` Creates a new Tag cloud on the given parent.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addMouseListener(org.eclipse.swt.events.MouseListener listener)`
`void` `addMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener)`
`void` `addMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener)`
`void` `addMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)`
`void` `addSelectionListener(org.eclipse.swt.events.SelectionListener listener)`
`protected void` `calcExtents(org.eclipse.core.runtime.IProgressMonitor monitor)` Calculates the bounds of each word, by determining the `Rectangle` a path would require to render an element.
`int` `getBoost()`
`float` `getBoostFactor()`
`protected org.eclipse.swt.graphics.Rectangle` `getCloudArea()` Returns the maximum cloud area.
`org.eclipse.swt.graphics.ImageData` `getImageData()` Returns the `ImageData` of the text layer image (all rendered elements, unscaled, without highlighted selection).
`ILayouter` `getLayouter()`
`int` `getMaxFontSize()`
`int` `getMinFontSize()`
`java.util.Set<Word>` `getSelection()` Returns the set of selected elements.
`org.eclipse.swt.graphics.Color` `getSelectionColor()`
`java.util.List<Word>` `getWords()`
`double` `getZoom()`
`int` `layoutCloud(org.eclipse.core.runtime.IProgressMonitor monitor, boolean recalc)` Does a full relayout of all displayed elements.
`protected int` `layoutWords(java.util.Collection<Word> wordsToUse, org.eclipse.core.runtime.IProgressMonitor monitor)` Generates the layout of the given words.
`void` `redrawTextLayerImage()`
`void` `removeMouseListener(org.eclipse.swt.events.MouseListener listener)`
`void` `removeMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener)`
`void` `removeMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener)`
`void` `removeMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)`
`void` `removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)`
`void` `setAntiAlias(boolean enabled)` Enable or disable antialiasing.
`void` `setBackground(org.eclipse.swt.graphics.Color color)`
`void` `setBackgroundMask(org.eclipse.swt.graphics.ImageData bgData)` Set a background mask to define the drawable area of the cloud.
`void` `setBoost(int boost)` Enable boosting for the first `boost` elements.
`void` `setBoostFactor(float boostFactor)`
`void` `setLayouter(ILayouter layouter)`
`void` `setMaxFontSize(int maxSize)` Sets the maximum font size (which must be a value greater 0).
`void` `setMinFontSize(int size)` Sets the minimum font size.
`void` `setOpacity(int opacity)` Sets the opacity of the words, which must be a value between 0 and 255 (inclusive).
`void` `setSelection(java.util.Set<Word> words)` Marks the set of elements as selected.
`void` `setSelectionColor(org.eclipse.swt.graphics.Color color)` Sets the highlight color of the cloud.
`int` `setWords(java.util.List<Word> values, org.eclipse.core.runtime.IProgressMonitor monitor)` Sets the given list as input of the tag cloud, replacing any previous content.
`void` `zoomFit()` Resets the zoom such that the generated cloud will fit exactly into the available space (unless the zoom factor is too small or too large).
`void` `zoomIn()` Zooms in, by the factor of 10 percent.
`void` `zoomOut()` Zooms out, by the factor of 10 percent.
`void` `zoomReset()` Resets the zoom to 100 % (original size)

### Methods inherited from class org.eclipse.swt.widgets.Canvas

`drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIME`

### Methods inherited from class org.eclipse.swt.widgets.Composite

`changed, checkSubclass, computeSize, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList`

### Methods inherited from class org.eclipse.swt.widgets.Scrollable

`computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar`

### Methods inherited from class org.eclipse.swt.widgets.Control

`addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update`

### Methods inherited from class org.eclipse.swt.widgets.Widget

`addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.eclipse.swt.graphics.Drawable

`isAutoScalable`

### Constructor Detail

#### TagCloud

    public TagCloud(org.eclipse.swt.widgets.Composite parent,
                    int style,
                    int accuracy,
                    int maxSize)

Creates a new Tag cloud on the given parent. When using this constructor, please read the following carefully:
Parameter `accuracy` defines the size of the raster used when placing strings, and must be a value greater than `0`. An accuracy of `1` will theoretically give best results, as the drawable area is analyzed most detailed, but this will also be very slow.
Parameter `maxSize` defines the maximum size of the drawable area and must be a power of `accuracy`, such that `accuracy^n=maxSize` holds.
To add scroll bars to the cloud, use `SWT.HORIZONTAL` and `SWT.VERTICAL`.

Parameters:
  `accuracy` -
  `maxSize` -
  `parent` -
  `style` -

#### TagCloud

    public TagCloud(org.eclipse.swt.widgets.Composite parent,
                    int style)

Creates a new Tag cloud on the given parent. To add scroll bars to the cloud, use `SWT.HORIZONTAL` and `SWT.VERTICAL`. This is a shortcut to `TagCloud(Composite, int, int, int)`, which sets the accuracy to `5` and the maximum size of the drawable area to `5120`.

Parameters:
  `parent` -
  `style` -

### Method Detail

#### zoomReset

    public void zoomReset()

Resets the zoom to 100 % (original size)

#### getZoom

    public double getZoom()

#### zoomFit

    public void zoomFit()

Resets the zoom such that the generated cloud will fit exactly into the available space (unless the zoom factor is too small or too large).

#### zoomIn

    public void zoomIn()

Zooms in, by the factor of 10 percent.

#### zoomOut

    public void zoomOut()

Zooms out, by the factor of 10 percent.

#### getCloudArea

    protected org.eclipse.swt.graphics.Rectangle getCloudArea()

Returns the maximum cloud area.

Returns:
  the maximum cloud area

#### calcExtents

    protected void calcExtents(org.eclipse.core.runtime.IProgressMonitor monitor)

Calculates the bounds of each word, by determining the `Rectangle` a path would require to render an element.

Parameters:
  `monitor` -

#### layoutWords

    protected int layoutWords(java.util.Collection<Word> wordsToUse,
                              org.eclipse.core.runtime.IProgressMonitor monitor)

Generates the layout of the given words.

Parameters:
  `wordsToUse` -
  `monitor` - may be `null`.
Returns:
  the number of words which could be placed

#### setWords

    public int setWords(java.util.List<Word> values,
                        org.eclipse.core.runtime.IProgressMonitor monitor)

Sets the given list as input of the tag cloud, replacing any previous content. By default, available word positions will be determined in-order, starting with the element at position 0.

Parameters:
  `values` -
  `monitor` -

#### setBackgroundMask

    public void setBackgroundMask(org.eclipse.swt.graphics.ImageData bgData)

Set a background mask to define the drawable area of the cloud. The image must be a square containing black and white pixels only. It is scaled to the full size of the drawable region. Black pixels are interpreted as used, such that strings will be drawn on white areas only. If parameter `bgData` is `null`, the old mask will be removed.

Parameters:
  `bgData` - a square containing black and white pixels only

#### addMouseListener

    public void addMouseListener(org.eclipse.swt.events.MouseListener listener)

Overrides:
  `addMouseListener` in class `org.eclipse.swt.widgets.Control`

#### addMouseMoveListener

    public void addMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener)

Overrides:
  `addMouseMoveListener` in class `org.eclipse.swt.widgets.Control`

#### addMouseTrackListener

    public void addMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener)

Overrides:
  `addMouseTrackListener` in class `org.eclipse.swt.widgets.Control`

#### addMouseWheelListener

    public void addMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)

Overrides:
  `addMouseWheelListener` in class `org.eclipse.swt.widgets.Control`

#### addSelectionListener

    public void addSelectionListener(org.eclipse.swt.events.SelectionListener listener)

#### removeMouseListener

    public void removeMouseListener(org.eclipse.swt.events.MouseListener listener)

Overrides:
  `removeMouseListener` in class `org.eclipse.swt.widgets.Control`

#### removeMouseMoveListener

    public void removeMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener)

Overrides:
  `removeMouseMoveListener` in class `org.eclipse.swt.widgets.Control`

#### removeMouseTrackListener

    public void removeMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener)

Overrides:
  `removeMouseTrackListener` in class `org.eclipse.swt.widgets.Control`

#### removeMouseWheelListener

    public void removeMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)

Overrides:
  `removeMouseWheelListener` in class `org.eclipse.swt.widgets.Control`

#### removeSelectionListener

    public void removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)

#### setSelection

    public void setSelection(java.util.Set<Word> words)

Marks the set of elements as selected.

Parameters:
  `words` - must not be `null`.

#### redrawTextLayerImage

    public void redrawTextLayerImage()

#### getSelection

    public java.util.Set<Word> getSelection()

Returns the set of selected elements. Never returns `null`.

Returns:
  the set of selected words

#### setSelectionColor

    public void setSelectionColor(org.eclipse.swt.graphics.Color color)

Sets the highlight color of the cloud. Default color is red.

Parameters:
  `color` -

#### setBackground

    public void setBackground(org.eclipse.swt.graphics.Color color)

Overrides:
  `setBackground` in class `org.eclipse.swt.widgets.Control`

#### layoutCloud

    public int layoutCloud(org.eclipse.core.runtime.IProgressMonitor monitor,
                           boolean recalc)

Does a full relayout of all displayed elements.

Parameters:
  `monitor` -
Returns:
  the number of words that could be placed

#### setMaxFontSize

    public void setMaxFontSize(int maxSize)

Sets the maximum font size (which must be a value greater 0). Note that strings which are too large to fit into the cloud region will be skipped. By default, this value is 500.

Parameters:
  `maxSize` -

#### setOpacity

    public void setOpacity(int opacity)

Sets the opacity of the words, which must be a value between 0 and 255 (inclusive). Currently not very useful...

Parameters:
  `opacity` -

#### setMinFontSize

    public void setMinFontSize(int size)

Sets the minimum font size. Should be a reasonable value > 0 (twice of `accuracy` is recommended). By default, this value is 12.

Parameters:
  `size` -

#### getImageData

    public org.eclipse.swt.graphics.ImageData getImageData()

Returns the `ImageData` of the text layer image (all rendered elements, unscaled, without highlighted selection). Can be used to print or export the cloud.

Returns:
  the image data of the text layer image

#### setBoost

    public void setBoost(int boost)

Enable boosting for the first `boost` elements. By default, no elements are boosted.

Parameters:
  `boost` -

#### setAntiAlias

    public void setAntiAlias(boolean enabled)

Enable or disable antialiasing. Enabled by default.

Parameters:
  `enabled` -

#### setBoostFactor

    public void setBoostFactor(float boostFactor)

#### getSelectionColor

    public org.eclipse.swt.graphics.Color getSelectionColor()

#### setLayouter

    public void setLayouter(ILayouter layouter)

#### getMaxFontSize

    public int getMaxFontSize()

#### getMinFontSize

    public int getMinFontSize()

#### getBoost

    public int getBoost()

#### getBoostFactor

    public float getBoostFactor()

#### getWords

    public java.util.List<Word> getWords()

#### getLayouter

    public ILayouter getLayouter()