org.eclipse.gef4.zest.core.viewers

## Class GraphViewer

- java.lang.Object
- - org.eclipse.jface.viewers.Viewer
  - - org.eclipse.jface.viewers.ContentViewer
    - - org.eclipse.jface.viewers.StructuredViewer
      - - org.eclipse.gef4.zest.core.viewers.AbstractZoomableViewer
        - - org.eclipse.gef4.zest.core.viewers.AbstractStructuredGraphViewer
          - - org.eclipse.gef4.zest.core.viewers.GraphViewer

All Implemented Interfaces:
  IInputProvider, IInputSelectionProvider, IPostSelectionProvider, ISelectionProvider

    public class GraphViewer
    extends AbstractStructuredGraphViewer
    implements ISelectionProvider

This view is used to represent a static graph. Static graphs can be layed out, but do not continually update their layout locations.

### Nested Class Summary

### Nested classes/interfaces inherited from class org.eclipse.jface.viewers.StructuredViewer

`StructuredViewer.ColorAndFontCollector, StructuredViewer.ColorAndFontCollectorWithProviders`

### Field Summary

Fields
`protected GraphWidget` `graph`

### Fields inherited from class org.eclipse.jface.viewers.Viewer

`WIDGET_DATA_KEY`

### Constructor Summary

Constructors
Constructor and Description
`GraphViewer(Composite composite, int style)` Initializes the viewer.
`GraphViewer(GraphWidget graph)` Initializes the viewer.

### Method Summary

Methods
`void` `addSelectionChangedListener(ISelectionChangedListener listener)`
`void` `applyLayout()` Applys the current layout to the viewer
`GraphItem` `findGraphItem(java.lang.Object element)` Finds the graph widget item for a given user model item.
`java.lang.Object[]` `getConnectionElements()`
`Control` `getControl()`
`protected org.eclipse.gef4.zest.core.viewers.internal.IStylingGraphModelFactory` `getFactory()` (non-Javadoc)
`GraphWidget` `getGraphControl()`
`protected org.eclipse.gef4.layout.LayoutAlgorithm` `getLayoutAlgorithm()` Gets the current layout algorithm.
`java.lang.Object[]` `getNodeElements()`
`int` `getStyle()` Gets the styles for this structuredViewer
`protected ZoomManager` `getZoomManager()` Returns a ZoomManager that zooming can be done on.
`protected void` `hookControl(Control control)`
`protected void` `inputChanged(java.lang.Object input, java.lang.Object oldInput)`
`void` `refresh(java.lang.Object element)`
`void` `refresh(java.lang.Object element, boolean updateLabels)`
`void` `removeSelectionChangedListener(ISelectionChangedListener listener)`
`void` `reveal(java.lang.Object element)`
`void` `setConnectionStyle(int connectionStyle)` Sets the default style for connections in this graph.
`void` `setContentProvider(IContentProvider contentProvider)`
`void` `setLayoutAlgorithm(org.eclipse.gef4.layout.LayoutAlgorithm algorithm)` Equivalent to setLayoutAlgorithm(algorithm, false).
`void` `setLayoutAlgorithm(org.eclipse.gef4.layout.LayoutAlgorithm algorithm, boolean runLayout)` Sets the layout algorithm to use for this viewer.
`void` `setNodeStyle(int nodeStyle)` Sets the default style for nodes in this graph.
`protected void` `setSelectionToWidget(java.util.List l, boolean reveal)`
`void` `unReveal(java.lang.Object element)`
`void` `update(java.lang.Object[] elements, java.lang.String[] properties)`
`void` `update(java.lang.Object element, java.lang.String[] properties)`

### Methods inherited from class org.eclipse.gef4.zest.core.viewers.AbstractStructuredGraphViewer

`addGraphModelConnection, addGraphModelContainer, addGraphModelNode, addGraphModelNode, addNode, addRelationship, addRelationship, doFindInputItem, doFindItem, doUpdateItem, filterVisuals, findItems, getConnectionsArray, getConnectionStyle, getGraphModelConnection, getGraphModelNode, getGraphStyle, getNodesArray, getNodesMap, getNodeStyle, getRawChildren, getSelectionFromWidget, getWidgetSelection, internalRefresh, removeGraphModelConnection, removeGraphModelNode, removeNode, removeRelationship`

### Methods inherited from class org.eclipse.gef4.zest.core.viewers.AbstractZoomableViewer

`zoomTo`

### Methods inherited from class org.eclipse.jface.viewers.StructuredViewer

`addDoubleClickListener, addDragSupport, addDropSupport, addFilter, addOpenListener, addPostSelectionChangedListener, assertContentProviderType, assertElementsNotNull, associate, buildLabel, disassociate, equals, filter, findItem, findItems, fireDoubleClick, fireOpen, firePostSelectionChanged, getColorAndFontCollector, getComparator, getComparer, getFilteredChildren, getFilters, getItem, getRoot, getSelection, getSortedChildren, getSorter, handleDispose, handleDoubleSelect, handleInvalidSelection, handleLabelProviderChanged, handleOpen, handlePostSelect, handleSelect, hasFilters, internalRefresh, internalUpdate, mapElement, needsRefilter, preservingSelection, refresh, refresh, refreshItem, removeDoubleClickListener, removeFilter, removeOpenListener, removePostSelectionChangedListener, resetFilters, setComparator, setComparer, setFilters, setInput, setLabelProvider, setSelection, setSelectionToWidget, setSorter, setUseHashlookup, testFindItem, testFindItems, unmapAllElements, unmapElement, unmapElement, updateItem, updateSelection, usingElementMap`

### Methods inherited from class org.eclipse.jface.viewers.ContentViewer

`getContentProvider, getInput, getLabelProvider, labelProviderChanged`

### Methods inherited from class org.eclipse.jface.viewers.Viewer

`addHelpListener, fireHelpRequested, fireSelectionChanged, getData, handleHelpRequest, removeHelpListener, scrollDown, scrollUp, setData, setSelection`

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

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

### Methods inherited from interface org.eclipse.jface.viewers.ISelectionProvider

`getSelection, setSelection`

### Field Detail

#### graph

    protected GraphWidget graph

### Constructor Detail

#### GraphViewer

    public GraphViewer(Composite composite,
               int style)

Initializes the viewer.

Parameters:
  `composite` -
  `style` - the style for the viewer and for the layout algorithm
See Also:
  `ZestStyles#LAYOUT_GRID`, `ZestStyles#LAYOUT_TREE`, `ZestStyles#LAYOUT_RADIAL`, `ZestStyles#LAYOUT_SPRING`, `ZestStyles#NO_OVERLAPPING_NODES`, `ZestStyles#NODES_HIGHLIGHT_ADJACENT`, `ZestStyles.GESTURES_DISABLED`, `ZestStyles#ANIMATION_DISABLED`, `SWT.V_SCROLL`, `SWT.H_SCROLL`

#### GraphViewer

    public GraphViewer(GraphWidget graph)

Initializes the viewer.

Parameters:
  `graph` - The initial graph widget

### Method Detail

#### hookControl

    protected void hookControl(Control control)

Overrides:
  `hookControl` in class `StructuredViewer`

#### inputChanged

    protected void inputChanged(java.lang.Object input,
                    java.lang.Object oldInput)

Overrides:
  `inputChanged` in class `AbstractStructuredGraphViewer`

#### getStyle

    public int getStyle()

Gets the styles for this structuredViewer

Returns:

#### getGraphControl

    public GraphWidget getGraphControl()

Overrides:
  `getGraphControl` in class `AbstractStructuredGraphViewer`

#### setLayoutAlgorithm

    public void setLayoutAlgorithm(org.eclipse.gef4.layout.LayoutAlgorithm algorithm,
                          boolean runLayout)

Sets the layout algorithm to use for this viewer.

Specified by:
  `setLayoutAlgorithm` in class `AbstractStructuredGraphViewer`
Parameters:
  `algorithm` - the algorithm to layout the nodes
  `runLayout` - if the layout should be run

#### setLayoutAlgorithm

    public void setLayoutAlgorithm(org.eclipse.gef4.layout.LayoutAlgorithm algorithm)

Description copied from class: `AbstractStructuredGraphViewer`
Equivalent to setLayoutAlgorithm(algorithm, false).

Overrides:
  `setLayoutAlgorithm` in class `AbstractStructuredGraphViewer`

#### setNodeStyle

    public void setNodeStyle(int nodeStyle)

Description copied from class: `AbstractStructuredGraphViewer`
Sets the default style for nodes in this graph. Note: if an input is set on the viewer, a ZestException will be thrown.

Overrides:
  `setNodeStyle` in class `AbstractStructuredGraphViewer`
Parameters:
  `nodeStyle` - the style for the nodes.
See Also:
  `#ZestStyles`

#### setContentProvider

    public void setContentProvider(IContentProvider contentProvider)

Overrides:
  `setContentProvider` in class `StructuredViewer`

#### findGraphItem

    public GraphItem findGraphItem(java.lang.Object element)

Finds the graph widget item for a given user model item. Note: This method returns an internal interface (GraphItem). You should be able to cast this to either a IGraphModelNode or IGraphModelConnection (which are also internal). These are internal because this API is not stable. If use this method (to access internal nodes and edges), your code may not compile between versions.

Parameters:
  `The` - user model node.
Returns:
  An IGraphItem. This should be either a IGraphModelNode or IGraphModelConnection

#### applyLayout

    public void applyLayout()

Applys the current layout to the viewer

Specified by:
  `applyLayout` in class `AbstractStructuredGraphViewer`

#### setSelectionToWidget

    protected void setSelectionToWidget(java.util.List l,
                            boolean reveal)

Overrides:
  `setSelectionToWidget` in class `AbstractStructuredGraphViewer`

#### getControl

    public Control getControl()

Specified by:
  `getControl` in class `Viewer`

#### getNodeElements

    public java.lang.Object[] getNodeElements()

Overrides:
  `getNodeElements` in class `AbstractStructuredGraphViewer`

#### getConnectionElements

    public java.lang.Object[] getConnectionElements()

Overrides:
  `getConnectionElements` in class `AbstractStructuredGraphViewer`

#### reveal

    public void reveal(java.lang.Object element)

Overrides:
  `reveal` in class `AbstractStructuredGraphViewer`

#### setConnectionStyle

    public void setConnectionStyle(int connectionStyle)

Description copied from class: `AbstractStructuredGraphViewer`
Sets the default style for connections in this graph. Note: if an input is set on the viewer, a ZestException will be thrown.

Overrides:
  `setConnectionStyle` in class `AbstractStructuredGraphViewer`
Parameters:
  `connectionStyle` - the style for the connections.
See Also:
  `#ZestStyles`

#### unReveal

    public void unReveal(java.lang.Object element)

Overrides:
  `unReveal` in class `AbstractStructuredGraphViewer`

#### addSelectionChangedListener

    public void addSelectionChangedListener(ISelectionChangedListener listener)

Specified by:
  `addSelectionChangedListener` in interface `ISelectionProvider`
Overrides:
  `addSelectionChangedListener` in class `Viewer`

#### removeSelectionChangedListener

    public void removeSelectionChangedListener(ISelectionChangedListener listener)

Specified by:
  `removeSelectionChangedListener` in interface `ISelectionProvider`
Overrides:
  `removeSelectionChangedListener` in class `Viewer`

#### refresh

    public void refresh(java.lang.Object element)

Overrides:
  `refresh` in class `StructuredViewer`

#### refresh

    public void refresh(java.lang.Object element,
               boolean updateLabels)

Overrides:
  `refresh` in class `StructuredViewer`

#### update

    public void update(java.lang.Object element,
              java.lang.String[] properties)

Overrides:
  `update` in class `StructuredViewer`

#### update

    public void update(java.lang.Object[] elements,
              java.lang.String[] properties)

Overrides:
  `update` in class `StructuredViewer`

#### getZoomManager

    protected ZoomManager getZoomManager()

Description copied from class: `AbstractZoomableViewer`
Returns a ZoomManager that zooming can be done on. May return null if none is available.

Specified by:
  `getZoomManager` in class `AbstractZoomableViewer`
Returns:
  a ZoomManager that zooming can be done on.

#### getFactory

    protected org.eclipse.gef4.zest.core.viewers.internal.IStylingGraphModelFactory getFactory()

(non-Javadoc)

Specified by:
  `getFactory` in class `AbstractStructuredGraphViewer`
Returns:
See Also:
  `AbstractStructuredGraphViewer.getFactory()`

#### getLayoutAlgorithm

    protected org.eclipse.gef4.layout.LayoutAlgorithm getLayoutAlgorithm()

Description copied from class: `AbstractStructuredGraphViewer`
Gets the current layout algorithm.

Specified by:
  `getLayoutAlgorithm` in class `AbstractStructuredGraphViewer`
Returns:
  the current layout algorithm.