Package org.eclipse.zest.core.widgets

# Class GraphConnection

java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Item
org.eclipse.zest.core.widgets.GraphItem
org.eclipse.zest.core.widgets.GraphConnection

public class GraphConnection extends GraphItem
This is the graph connection model which stores the source and destination nodes and the properties of this connection (color, line width etc).

## Field Summary

### Fields inherited from class org.eclipse.zest.core.widgets.GraphItem

`CONNECTION, CONTAINER, GRAPH, NODE`

## Constructor Summary

Constructors
Constructor
Description
`GraphConnection(Graph graphModel, int style, GraphNode source, GraphNode destination)`

## Method Summary

Modifier and Type
Method
Description
`protected PolylineConnection`
`cachedOrNewConnectionFigure()`
expose to allow to use custom figures
`void`
`changeLineColor(Color color)`
Sets the connection color.
`protected PolylineConnection`
`createFigure()`
expose to allow to use custom figures
`void`
`dispose()`
`Connection`
`getConnectionFigure()`
`int`
`getConnectionStyle()`
Returns the style of this connection.
`GraphNode`
`getDestination()`
Gets the target node for this relationship
`Object`
`getExternalConnection()`
Deprecated, for removal: This API element is subject to removal in a future version.
Use `Widget.getData()` instead.
`Font`
`getFont()`
Gets the font for the label on this connection
`Graph`
`getGraphModel()`
Gets the graph model that this connection is in
`Color`
`getHighlightColor()`
`int`
`getItemType()`
Gets the graph item type.
`LayoutRelationship`
`getLayoutRelationship()`
Deprecated, for removal: This API element is subject to removal in a future version.
Not used in Zest 2.x.
`Color`
`getLineColor()`
Returns the color of this connection.
`int`
`getLineStyle()`
Returns the connection line style.
`int`
`getLineWidth()`
Returns the connection line width.
`GraphNode`
`getSource()`
Gets the source node for this relationship
`IFigure`
`getTooltip()`
Gets the current tooltip for this node.
`double`
`getWeightInLayout()`
Gets the weight of this connection.
`void`
`highlight()`
Highlights this node.
`boolean`
`isDirected()`
`boolean`
`isDisposed()`
`boolean`
`isHighlighted()`
Returns true if this connection is highlighted, false otherwise
`boolean`
`isVisible()`
Get the visibility of this item.
`void`
`registerConnection(GraphNode source, GraphNode destination)`
`void`
`setConnectionStyle(int style)`
Returns the style of this connection.
`void`
`setCurveDepth(int depth)`
Sets the curve depth of the arc.
`void`
`setDirected(boolean directed)`
`void`
`setFont(Font f)`
Sets the font for the label on this connection.
`void`
`setHighlightColor(Color color)`
Sets the highlight color.
`void`
`setLineColor(Color color)`
Perminently sets the color of this line to the given color.
`void`
`setLineStyle(int lineStyle)`
Sets the connection line style.
`void`
`setLineWidth(int lineWidth)`
Sets the connection line width.
`void`
`setRouter(ConnectionRouter router)`
Sets the connection router of the connection
`void`
`setText(String string)`
`void`
`setTooltip(IFigure tooltip)`
Sets the tooltip on this node.
`void`
`setVisible(boolean visible)`
Set the visibility of this item.
`void`
`setWeight(double weight)`
Sets the weight for this connection.
`String`
`toString()`
Returns a string like 'source -> destination'
`void`
`unhighlight()`
Unhighlights this node.

### Methods inherited from class org.eclipse.zest.core.widgets.GraphItem

`checkStyle`

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

`checkSubclass, getImage, getText, setImage`

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

`addDisposeListener, addListener, addTypedListener, checkWidget, getData, getData, getDisplay, getListeners, getStyle, getTypedListeners, isAutoDirection, isListening, notifyListeners, 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`

## Constructor Details

### GraphConnection

public GraphConnection(Graph graphModel, int style, GraphNode source, GraphNode destination)

## Method Details

### registerConnection

public void registerConnection(GraphNode source, GraphNode destination)

Since:
  1.10

### dispose

public void dispose()

Overrides:
  `dispose` in class `GraphItem`

### isDisposed

public boolean isDisposed()

Overrides:
  `isDisposed` in class `Widget`

### getConnectionFigure

public Connection getConnectionFigure()

### getLayoutRelationship

@Deprecated(since="1.12", forRemoval=true) public LayoutRelationship getLayoutRelationship()
Deprecated, for removal: This API element is subject to removal in a future version.
Not used in Zest 2.x. This class will be removed in a future release in accordance with the two year deprecation policy.
Gets a proxy to this connection that can be used with the Zest layout engine

@nooverride
  This method is not intended to be re-implemented or extended by clients.
@noreference
  This method is not intended to be referenced by clients.

### getExternalConnection

@Deprecated(since="1.12", forRemoval=true) public Object getExternalConnection()
Deprecated, for removal: This API element is subject to removal in a future version.
Use `Widget.getData()` instead. This class will be removed in a future release in accordance with the two year deprecation policy.
Gets the external connection object.

Returns:
  Object
@nooverride
  This method is not intended to be re-implemented or extended by clients.
@noreference
  This method is not intended to be referenced by clients.

### toString

public String toString()
Returns a string like 'source -> destination'

Overrides:
  `toString` in class `Widget`
Returns:
  String

### getConnectionStyle

public int getConnectionStyle()
Returns the style of this connection. Valid styles are those that begin with CONNECTION in ZestStyles.

Returns:
  the style of this connection.
See Also:
  - `ZestStyles`

### setConnectionStyle

public void setConnectionStyle(int style)
Returns the style of this connection. Valid styles are those that begin with CONNECTION in ZestStyles.

Parameters:
  `style` - the style of this connection.
See Also:
  - `ZestStyles`

### getWeightInLayout

public double getWeightInLayout()
Gets the weight of this connection. The weight must be in {-1, [0-1]}. A weight of -1 means that there is no force/tension between the nodes. A weight of 0 results in the maximum spring length being used (farthest apart). A weight of 1 results in the minimum spring length being used (closest together).

Returns:
  the weight: {-1, [0 - 1]}.
See Also:
  - `ConnectionLayout.getWeight()`

### getFont

public Font getFont()
Gets the font for the label on this connection

### setFont

public void setFont(Font f)
Sets the font for the label on this connection.

### setWeight

public void setWeight(double weight)
Sets the weight for this connection. The weight must be in {-1, [0-1]}. A weight of -1 means that there is no force/tension between the nodes. A weight of 0 results in the maximum spring length being used (farthest apart). A weight of 1 results in the minimum spring length being used (closest together).

### getLineColor

public Color getLineColor()
Returns the color of this connection.

Returns:
  Color

### setHighlightColor

public void setHighlightColor(Color color)
Sets the highlight color.

Parameters:
  `color` - the color to use for highlighting.

### getHighlightColor

public Color getHighlightColor()

Returns:
  the highlight color

### setLineColor

public void setLineColor(Color color)
Perminently sets the color of this line to the given color. This will become the color of the line when it is not highlighted. If you would like to temporarily change the color of the line, use changeLineColor.

Parameters:
  `color` - the color to be set.
See Also:
  - `changeLineColor(Color color)`

### changeLineColor

public void changeLineColor(Color color)
Sets the connection color.

Parameters:
  `color` -

### setTooltip

public void setTooltip(IFigure tooltip)
Sets the tooltip on this node. This tooltip will display if the mouse hovers over the node. Setting the tooltip has no effect if a custom figure has been set.

### getTooltip

public IFigure getTooltip()
Gets the current tooltip for this node. The tooltip returned is meaningless if a custom figure has been set.

### getLineWidth

public int getLineWidth()
Returns the connection line width.

Returns:
  int

### setLineWidth

public void setLineWidth(int lineWidth)
Sets the connection line width.

Parameters:
  `lineWidth` -

### getLineStyle

public int getLineStyle()
Returns the connection line style.

Returns:
  int

### setLineStyle

public void setLineStyle(int lineStyle)
Sets the connection line style.

Parameters:
  `lineStyle` -

### getSource

public GraphNode getSource()
Gets the source node for this relationship

Returns:
  GraphModelNode

### getDestination

public GraphNode getDestination()
Gets the target node for this relationship

Returns:
  GraphModelNode

### highlight

public void highlight()
Highlights this node. Uses the default highlight color.

Specified by:
  `highlight` in class `GraphItem`

### unhighlight

public void unhighlight()
Unhighlights this node. Uses the default color.

Specified by:
  `unhighlight` in class `GraphItem`

### isHighlighted

public boolean isHighlighted()
Returns true if this connection is highlighted, false otherwise

Overrides:
  `isHighlighted` in class `GraphItem`
Returns:
  boolean state of highlight
Since:
  1.9

### getGraphModel

public Graph getGraphModel()
Gets the graph model that this connection is in

Specified by:
  `getGraphModel` in class `GraphItem`
Returns:
  The graph model that this connection is contained in

### setCurveDepth

public void setCurveDepth(int depth)
Sets the curve depth of the arc. The curve depth is defined as the maximum distance from any point on the chord (i.e. a vector normal to the chord with magnitude d). If 0 is set, a Polyline Connection will be used, otherwise a PolylineArcConnectoin will be used. Negative depths are also supported.

Parameters:
  `depth` - The depth of the curve

### getItemType

public int getItemType()
Description copied from class: `GraphItem`
Gets the graph item type. The item type is one of: GRAPH, NODE or CONNECTION

Specified by:
  `getItemType` in class `GraphItem`

### setVisible

public void setVisible(boolean visible)
Description copied from class: `GraphItem`
Set the visibility of this item.

Specified by:
  `setVisible` in class `GraphItem`
Parameters:
  `visible` - whether or not this item is visible.

### isVisible

public boolean isVisible()
Description copied from class: `GraphItem`
Get the visibility of this item.

Specified by:
  `isVisible` in class `GraphItem`
Returns:
  the visibility of this item.

### setText

public void setText(String string)

Overrides:
  `setText` in class `Item`

### isDirected

public boolean isDirected()

Since:
  1.14

### setDirected

public void setDirected(boolean directed)

Since:
  1.14

### createFigure

protected PolylineConnection createFigure()
expose to allow to use custom figures

Since:
  1.7

### cachedOrNewConnectionFigure

protected PolylineConnection cachedOrNewConnectionFigure()
expose to allow to use custom figures

Since:
  1.7

### setRouter

public void setRouter(ConnectionRouter router)
Sets the connection router of the connection

Parameters:
  `router` -
Since:
  1.14