Non-Editable Graphs
Not every application needs to be a full-blown graph editor. Your application might only need to explore static graphs or graphs that are not created and modified interactively, but are instead created or modified via code. GraphViewerInputMode is an easy way to view a graph without allowing changes to it.
graphComponent.inputMode = new GraphViewerInputMode()
A GraphViewerInputMode is already set as the default input mode, so a new instance only has to be set if the default has been changed before.
GraphViewerInputMode can be useful in various circumstances:
- You have a static graph that is generated from external data, but it is large enough to require navigation features like zooming and panning.
- Your graph is not static but is created and updated through code, for example, in response to external events or as a result of a layout algorithm.
- Your graph can be edited only through a number of special features, like toolbar buttons or context menus, but not via the default gestures provided by GraphEditorInputMode (which would necessitate turning off most of GraphEditorInputMode’s functionality).
In principle GraphViewerInputMode is very similar to GraphEditorInputMode, but it lacks the functionality to change the structure of the graph interactively. By default, it is configured with gestures that allow easy exploration of static graphs. However, core interaction features of GraphEditorInputMode that do not change the graph — such as selection, the ability to react to clicks on items, have context menus, or tooltips — are exactly the same in GraphViewerInputMode.