Package org.eclipse.zest.core.widgets
Class Graph
- All Implemented Interfaces:
Drawable
,IContainer
,IContainer2
Holds the nodes and connections for the graph.
- Since:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
protected List
<GraphConnection> static final int
Fields inherited from class org.eclipse.draw2d.FigureCanvas
ALWAYS, AUTOMATIC, NEVER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConstraintAdapter
(ConstraintAdapter constraintAdapter) Deprecated, for removal: This API element is subject to removal in a future version.No longer used in Zest 2.x.void
addFisheyeListener
(FisheyeListener listener) Adds a listener that will be notified when fisheyed figures change in this graph.void
addLayoutFilter
(LayoutFilter filter) Adds a filter used for hiding elements from layout algorithm.void
void
addSelectionListener
(SelectionListener selectionListener) This adds a listener to the set of listeners that will be called when a selection event occurs.void
addSubgraphFigure
(IFigure figure) void
Runs the layout on this graph.void
Apply this graphs's layout cleanly and display all changes.boolean
canCollapse
(GraphNode node) boolean
void
clear()
Clear the graph of all its content.protected GraphDragSupport
Creator method for DragSupportprotected IFigure
Layer creationprotected org.eclipse.zest.core.widgets.internal.ZestRootLayer
Creator method for ZestRootLayervoid
dispose()
Dispose of the nodes and edges when the graph is disposed.List
<? extends GraphConnection> Gets the list of GraphModelConnection objects.int
Gets the default connection style.getFigureAt
(int x, int y) Finds a figure at the location X, Y in the graph This point should be translated to relative before calling findFigureAtgetGraph()
protected GraphItem
getGraphItem
(IFigure figure) Returns the item for the given figureDeprecated, for removal: This API element is subject to removal in a future version.final int
Gets the default graph style.boolean
getItem()
int
final LayoutContext
getNodes()
Gets a list of the GraphModelNode children objects under the root node in this diagram.int
Gets the default node style.Gets the root layer for this graphGets the list of currently selected graph itemsorg.eclipse.zest.core.viewers.internal.ZoomManager
Returns the ZoomManager component used for scaling the graph widget.boolean
void
notifyListeners
(int eventType, Event event) void
removeFisheyeListener
(FisheyeListener listener) void
removeLayoutFilter
(LayoutFilter filter) Removes given layout filter.void
removeSelectionListener
(SelectionListener selectionListener) void
void
setConnectionStyle
(int connectionStyle) Sets the default connection style.void
setConstraintAdapters
(List<ConstraintAdapter> constraintAdapters) Deprecated, for removal: This API element is subject to removal in a future version.No longer used in Zest 2.x.void
setDynamicLayout
(boolean enabled) Enables or disables dynamic layout (that is layout algorithm performing layout in background or when certain events occur).void
setExpandCollapseManager
(ExpandCollapseManager expandCollapseManager) void
setExpanded
(GraphNode node, boolean expanded) final void
setGraphStyle
(int style) Sets the default graph style.void
setLayoutAlgorithm
(LayoutAlgorithm algorithm, boolean applyLayout) Sets the LayoutAlgorithm for this container and optionally applies it.void
setNodeStyle
(int nodeStyle) Sets the default node style.void
setPreferredSize
(int width, int height) Sets the preferred size of the layout area.void
setRouter
(ConnectionRouter connectionRouter) Updates the connection router and applies to to all existing connections that have no connection routers set to them.void
setSelection
(GraphItem[] items) Changes the selection to the list of itemsvoid
setSubgraphFactory
(SubgraphFactory factory) toString()
Methods inherited from class org.eclipse.draw2d.FigureCanvas
computeSize, getContents, getFont, getHorizontalScrollBarVisibility, getLightweightSystem, getVerticalScrollBarVisibility, getViewport, scrollSmoothTo, scrollTo, scrollToX, scrollToY, setBorder, setContents, setFont, setHorizontalScrollBarVisibility, setScrollBarVisibility, setVerticalScrollBarVisibility, setViewport
Methods inherited from class org.eclipse.swt.widgets.Canvas
drawBackground, getCaret, getIME, scroll, setCaret, setIME
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, redraw, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar, setScrollbarsMode
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, 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, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, 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, addTypedListener, checkWidget, getData, getData, getDisplay, getListeners, getStyle, getTypedListeners, isAutoDirection, isDisposed, isListening, removeDisposeListener, removeListener, removeListener, removeListener, removeTypedListener, reskin, setData, setData
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
-
Field Details
-
ANIMATION_TIME
public static final int ANIMATION_TIME- See Also:
-
FISHEYE_ANIMATION_TIME
public static final int FISHEYE_ANIMATION_TIME- See Also:
-
LIGHT_BLUE
-
LIGHT_BLUE_CYAN
-
GREY_BLUE
-
DARK_BLUE
-
LIGHT_YELLOW
-
HIGHLIGHT_COLOR
-
HIGHLIGHT_ADJACENT_COLOR
-
DEFAULT_NODE_COLOR
-
connections
-
-
Constructor Details
-
Graph
Constructor for a Graph. This widget represents the root of the graph, and can contain graph items such as graph nodes and graph connections.- Parameters:
parent
-style
- The SWT style used for the underlyingFigureCanvas
. SeeFigureCanvas.ACCEPTED_STYLES
for a list of all supported styles. UsesetGraphStyle(int)
to set the Zest-specific styles.
-
Graph
Constructor for a Graph. This widget represents the root of the graph, and can contain graph items such as graph nodes and graph connections.- Parameters:
parent
-style
- The SWT style used for the underlyingFigureCanvas
. SeeFigureCanvas.ACCEPTED_STYLES
for a list of all supported styles. UsesetGraphStyle(int)
to set the Zest-specific styles.enableHideNodes
-- Since:
- 1.8
-
-
Method Details
-
addSelectionListener
This adds a listener to the set of listeners that will be called when a selection event occurs.- Parameters:
selectionListener
-
-
removeSelectionListener
-
getNodes
Gets a list of the GraphModelNode children objects under the root node in this diagram. If the root node is null then all the top level nodes are returned.- Specified by:
getNodes
in interfaceIContainer
- Returns:
- List of GraphModelNode objects
-
addConstraintAdapter
@Deprecated(since="2.0", forRemoval=true) public void addConstraintAdapter(ConstraintAdapter constraintAdapter) Deprecated, for removal: This API element is subject to removal in a future version.No longer used in Zest 2.x. This class will be removed in a future release in accordance with the two year deprecation policy.Adds a new constraint adapter to the list of constraint adapters- Parameters:
constraintAdapter
-
-
setConstraintAdapters
@Deprecated(since="2.0", forRemoval=true) public void setConstraintAdapters(List<ConstraintAdapter> constraintAdapters) Deprecated, for removal: This API element is subject to removal in a future version.No longer used in Zest 2.x. This class will be removed in a future release in accordance with the two year deprecation policy.Sets the constraint adapters on this model- Parameters:
constraintAdapters
-
-
getRootLayer
Gets the root layer for this graph -
setConnectionStyle
public void setConnectionStyle(int connectionStyle) Sets the default connection style.- Parameters:
connectionStyle
- style the connection style to set- See Also:
-
getConnectionStyle
public int getConnectionStyle()Gets the default connection style.- Returns:
- the connection style
- See Also:
-
setNodeStyle
public void setNodeStyle(int nodeStyle) Sets the default node style.- Parameters:
nodeStyle
- the node style to set- See Also:
-
getNodeStyle
public int getNodeStyle()Gets the default node style.- Returns:
- the node style
- See Also:
-
setGraphStyle
public final void setGraphStyle(int style) Sets the default graph style.- Parameters:
style
- the graph style to set.- Since:
- 1.15
- See Also:
-
getGraphStyle
public final int getGraphStyle()Gets the default graph style.- Returns:
- the default graph style
- Since:
- 1.15
-
getConnections
Gets the list of GraphModelConnection objects.- Specified by:
getConnections
in interfaceIContainer2
- Returns:
- list of GraphModelConnection objects
-
setSelection
Changes the selection to the list of items- Parameters:
items
-
-
selectAll
public void selectAll() -
getSelection
Gets the list of currently selected graph items- Returns:
- Currently selected graph items
-
toString
-
getGraphModel
Deprecated, for removal: This API element is subject to removal in a future version. -
dispose
public void dispose()Dispose of the nodes and edges when the graph is disposed. -
applyLayout
public void applyLayout()Runs the layout on this graph. If the view is not visible layout will be deferred until after the view is available.- Specified by:
applyLayout
in interfaceIContainer
-
applyLayoutNow
public void applyLayoutNow()Apply this graphs's layout cleanly and display all changes.- Since:
- 1.14
-
setDynamicLayout
public void setDynamicLayout(boolean enabled) Enables or disables dynamic layout (that is layout algorithm performing layout in background or when certain events occur). Dynamic layout should be disabled before doing a long series of changes in the graph to make sure that layout algorithm won't interfere with these changes. Enabling dynamic layout causes the layout algorithm to be applied even if it's not actually a dynamic algorithm.- Parameters:
enabled
-- Since:
- 1.14
-
isDynamicLayoutEnabled
public boolean isDynamicLayoutEnabled()- Returns:
- true if dynamic layout is enabled (see
setDynamicLayout(boolean)
) - Since:
- 1.14
-
setPreferredSize
public void setPreferredSize(int width, int height) Sets the preferred size of the layout area. Size of ( -1, -1) uses the current canvas size.- Parameters:
width
-height
-
-
getPreferredSize
- Returns:
- the preferred size of the layout area.
- Since:
- 1.14
-
getLayoutContext
- Specified by:
getLayoutContext
in interfaceIContainer2
- @noreference
- This method is not intended to be referenced by clients.
-
setLayoutAlgorithm
Description copied from interface:IContainer
Sets the LayoutAlgorithm for this container and optionally applies it.- Specified by:
setLayoutAlgorithm
in interfaceIContainer
- Parameters:
algorithm
-applyLayout
-
-
setSubgraphFactory
- Since:
- 1.14
-
getSubgraphFactory
- Since:
- 1.14
-
setExpandCollapseManager
- Since:
- 1.14
-
getExpandCollapseManager
- Since:
- 1.14
-
addLayoutFilter
Adds a filter used for hiding elements from layout algorithm. NOTE: If a node or subgraph if filtered out, all connections adjacent to it should also be filtered out. Otherwise layout algorithm may behave in an unexpected way.- Parameters:
filter
- filter to add- Since:
- 1.14
-
getLayoutAlgorithm
-
removeLayoutFilter
Removes given layout filter. If it had not been added to this graph, this method does nothing.- Parameters:
filter
- filter to remove- Since:
- 1.14
-
getFigureAt
Finds a figure at the location X, Y in the graph This point should be translated to relative before calling findFigureAt -
getHideNodesEnabled
public boolean getHideNodesEnabled()- Since:
- 1.8
-
createGraphDragSupport
Creator method for DragSupport- Returns:
- class that implemented GraphDragSupport
- Since:
- 1.9
-
notifyListeners
- Overrides:
notifyListeners
in classWidget
-
clear
public void clear()Clear the graph of all its content.- Since:
- 1.14
-
addNode
- Specified by:
addNode
in interfaceIContainer2
- Parameters:
node
-- @noreference
- This method is not intended to be referenced by clients.
-
addSubgraphFigure
- Specified by:
addSubgraphFigure
in interfaceIContainer2
- Parameters:
figure
-- @noreference
- This method is not intended to be referenced by clients.
-
createLayers
Layer creation- Returns:
- IFigure the rootlayer
- Since:
- 1.9
-
createZestRootLayer
protected org.eclipse.zest.core.widgets.internal.ZestRootLayer createZestRootLayer()Creator method for ZestRootLayer- Returns:
- new ZestRootLayer instance
- Since:
- 1.9
-
getGraph
- Specified by:
getGraph
in interfaceIContainer
-
addFisheyeListener
Adds a listener that will be notified when fisheyed figures change in this graph.- Parameters:
listener
- listener to add- Since:
- 1.14
-
removeFisheyeListener
- Since:
- 1.14
-
getItemType
public int getItemType()- Specified by:
getItemType
in interfaceIContainer
-
getGraphItem
Returns the item for the given figure- Parameters:
figure
-- Returns:
- GraphItem for the given IFigure
- Since:
- 1.9
-
setExpanded
- Since:
- 1.14
-
canExpand
- Since:
- 1.14
-
canCollapse
- Since:
- 1.14
-
getItem
- Specified by:
getItem
in interfaceIContainer2
- Since:
- 1.12
-
getLayoutBounds
- Specified by:
getLayoutBounds
in interfaceIContainer2
- Since:
- 1.12
-
setRouter
Updates the connection router and applies to to all existing connections that have no connection routers set to them.- Parameters:
connectionRouter
-- Since:
- 1.14
-
getZoomManager
public org.eclipse.zest.core.viewers.internal.ZoomManager getZoomManager()Returns the ZoomManager component used for scaling the graph widget.- Returns:
- the ZoomManager component
- Since:
- 1.14
-