Package org.eclipse.zest.core.widgets

# Class GraphNode

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

Direct Known Subclasses:
  `CGraphNode`, `GraphContainer`

public class GraphNode extends GraphItem
Simple node class which has the following properties: color, size, location, and a label. It also has a list of connections and anchors.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected Graph`
`graph`
`static final int`
`HIGHLIGHT_NONE`
`static final int`
`HIGHLIGHT_ON`
`protected int`
`highlighted`
`protected Object`
`internalNode`
The internal node.
`protected org.eclipse.draw2d.IFigure`
`nodeFigure`
`protected IContainer`
`parent`
`protected org.eclipse.draw2d.geometry.Dimension`
`size`

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

`CONNECTION, CONTAINER, GRAPH, NODE`

## Constructor Summary

Constructors
Constructor
Description
`GraphNode(IContainer graphModel, int style)`
`GraphNode(IContainer graphModel, int style, Object data)`
Deprecated, for removal: This API element is subject to removal in a future version.
Since Zest 2.0, use `GraphNode(IContainer, int, IFigure)` instead.
`GraphNode(IContainer graphModel, int style, String text)`
Deprecated, for removal: This API element is subject to removal in a future version.
Since Zest 2.0, use `GraphNode(IContainer, int)` and `setText(String)`
`GraphNode(IContainer graphModel, int style, String text, Object data)`
Deprecated, for removal: This API element is subject to removal in a future version.
Since Zest 2.0, use `GraphNode(IContainer, int, IFigure)` and `setText(String)`
`GraphNode(IContainer graphModel, int style, String text, Image image)`
Deprecated, for removal: This API element is subject to removal in a future version.
Since Zest 2.0, use `GraphNode(IContainer, int)`, `setText(String)`, and `setImage(Image)`
`GraphNode(IContainer graphModel, int style, String text, Image image, Object data)`
Deprecated, for removal: This API element is subject to removal in a future version.
Since Zest 2.0, use `GraphNode(IContainer, int, IFigure)`, `setText(String)` and `setImage(Image)`.
`GraphNode(IContainer graphModel, int style, org.eclipse.draw2d.IFigure data)`

## Method Summary

Modifier and Type
Method
Description
`boolean`
`cacheLabel()`
`protected org.eclipse.draw2d.IFigure`
`createFigureForModel()`
`void`
`dispose()`
`protected org.eclipse.draw2d.IFigure`
`fishEye(boolean enable, boolean animate)`
`Color`
`getBackgroundColor()`
Get the background colour for this node.
`Color`
`getBackgroundHighlightColor()`
Get the highlight background color for this node.
`Color`
`getBorderColor()`
`Color`
`getBorderHighlightColor()`
`int`
`getBorderWidth()`
`Font`
`getFont()`
`Color`
`getForegroundColor()`
Get the foreground colour for this node
`Color`
`getForegroundHighlightColor()`
Get the highlight foreground color for this node.
`Graph`
`getGraphModel()`
Gets the graphModel that this node is contained in
`protected org.eclipse.draw2d.geometry.Rectangle`
`getHideContainerBounds()`
`HideNodeHelper`
`getHideNodeHelper()`
`Color`
`getHighlightColor()`
Deprecated, for removal: This API element is subject to removal in a future version.
Use `getBackgroundHighlightColor()` instead.
`int`
`getItemType()`
Gets the graph item type.
`org.eclipse.zest.core.widgets.InternalNodeLayout`
`getLayout()`
`LayoutEntity`
`getLayoutEntity()`
Deprecated, for removal: This API element is subject to removal in a future version.
Not used in Zest 2.x.
`org.eclipse.draw2d.geometry.Point`
`getLocation()`
Returns a copy of the node's location.
`org.eclipse.draw2d.IFigure`
`getModelFigure()`
`org.eclipse.draw2d.IFigure`
`getNodeFigure()`
Returns the figure of the whole node.
`int`
`getNodeStyle()`
`org.eclipse.draw2d.geometry.Dimension`
`getSize()`
Returns a copy of the node's size.
`List<? extends GraphConnection>`
`getSourceConnections()`
Returns a new list of the source connections (GraphModelConnection objects).
`int`
`getStyle()`
`List<? extends GraphConnection>`
`getTargetConnections()`
Returns a new list of the target connections (GraphModelConnection objects).
`org.eclipse.draw2d.IFigure`
`getTooltip()`
Gets the current tooltip for this node.
`void`
`highlight()`
Highlights the node changing the background color and border color.
`protected void`
`initFigure()`
`protected void`
`initModel(IContainer parent, String text, Image image)`
`boolean`
`isDisposed()`
`boolean`
`isHighlighted()`
returns true if node is highlighted, false otherwise
`boolean`
`isSelected()`
`boolean`
`isSizeFixed()`
Determines if this node has a fixed size or if it is packed to the size of its contents.
`boolean`
`isVisible()`
Get the visibility of this item.
`protected void`
`refreshLocation()`
`void`
`setBackgroundColor(Color c)`
Permanently sets the background color (unhighlighted).
`void`
`setBackgroundHighlightColor(Color c)`
Set the highlight background color for this node.
`void`
`setBorderColor(Color c)`
Sets the border color.
`void`
`setBorderHighlightColor(Color c)`
Sets the highlighted border color.
`void`
`setBorderWidth(int width)`
`void`
`setCacheLabel(boolean cacheLabel)`
`void`
`setFont(Font font)`
`void`
`setForegroundColor(Color c)`
Set the foreground colour for this node
`void`
`setForegroundHighlightColor(Color c)`
Set the highlight foreground color for this node.
`void`
`setHideNodeHelper(HideNodeHelper hideNodeHelper)`
`void`
`setHighlightColor(Color c)`
Deprecated, for removal: This API element is subject to removal in a future version.
Use `setBackgroundHighlightColor(Color)` instead.
`void`
`setImage(Image image)`
`void`
`setLocation(double x, double y)`
Sets the current location for this node.
`void`
`setModelFigure(org.eclipse.draw2d.IFigure figure)`
`void`
`setNodeStyle(int nodeStyle)`
`void`
`setSize(double width, double height)`
`void`
`setText(String string)`
`void`
`setTooltip(org.eclipse.draw2d.IFigure tooltip)`
Sets the tooltip on this node.
`void`
`setVisible(boolean visible)`
Set the visibility of this item.
`String`
`toString()`
A simple toString that we can use for debugging
`void`
`unhighlight()`
Restores the nodes original background color and border width.
`protected void`
`updateFigureForModel(org.eclipse.draw2d.IFigure currentFigure)`

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

`checkStyle`

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

`checkSubclass, getImage, getText`

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

`addDisposeListener, addListener, addTypedListener, checkWidget, getData, getData, getDisplay, getListeners, 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`

## Field Details

### HIGHLIGHT_NONE

public static final int HIGHLIGHT_NONE

See Also:
  - Constant Field Values

### HIGHLIGHT_ON

public static final int HIGHLIGHT_ON

See Also:
  - Constant Field Values

### size

protected org.eclipse.draw2d.geometry.Dimension size

### graph

protected Graph graph

### parent

protected IContainer parent

### internalNode

protected Object internalNode
The internal node.

### highlighted

protected int highlighted

### nodeFigure

protected org.eclipse.draw2d.IFigure nodeFigure

## Constructor Details

### GraphNode

public GraphNode(IContainer graphModel, int style)

### GraphNode

@Deprecated(since="1.12", forRemoval=true) public GraphNode(IContainer graphModel, int style, Object data)
Deprecated, for removal: This API element is subject to removal in a future version.
Since Zest 2.0, use `GraphNode(IContainer, int, IFigure)` instead.

### GraphNode

public GraphNode(IContainer graphModel, int style, org.eclipse.draw2d.IFigure data)

Since:
  1.14

### GraphNode

@Deprecated(since="1.12", forRemoval=true) public GraphNode(IContainer graphModel, int style, String text)
Deprecated, for removal: This API element is subject to removal in a future version.
Since Zest 2.0, use `GraphNode(IContainer, int)` and `setText(String)`

### GraphNode

@Deprecated(since="1.12", forRemoval=true) public GraphNode(IContainer graphModel, int style, String text, Object data)
Deprecated, for removal: This API element is subject to removal in a future version.
Since Zest 2.0, use `GraphNode(IContainer, int, IFigure)` and `setText(String)`

### GraphNode

@Deprecated(since="1.12", forRemoval=true) public GraphNode(IContainer graphModel, int style, String text, Image image)
Deprecated, for removal: This API element is subject to removal in a future version.
Since Zest 2.0, use `GraphNode(IContainer, int)`, `setText(String)`, and `setImage(Image)`

### GraphNode

@Deprecated(since="1.12", forRemoval=true) public GraphNode(IContainer graphModel, int style, String text, Image image, Object data)
Deprecated, for removal: This API element is subject to removal in a future version.
Since Zest 2.0, use `GraphNode(IContainer, int, IFigure)`, `setText(String)` and `setImage(Image)`.

## Method Details

### initFigure

protected void initFigure()

### initModel

protected void initModel(IContainer parent, String text, Image image)

### toString

public String toString()
A simple toString that we can use for debugging

Overrides:
  `toString` in class `Widget`

### getLayoutEntity

@Deprecated(since="1.12", forRemoval=true) public LayoutEntity getLayoutEntity()
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.

@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.

### dispose

public void dispose()

Overrides:
  `dispose` in class `GraphItem`

### isDisposed

public boolean isDisposed()

Overrides:
  `isDisposed` in class `Widget`

### isSizeFixed

public boolean isSizeFixed()
Determines if this node has a fixed size or if it is packed to the size of its contents. To set a node to pack, set its size (-1, -1)

### getSourceConnections

public List<? extends GraphConnection> getSourceConnections()
Returns a new list of the source connections (GraphModelConnection objects).

Returns:
  List a new list of GraphModelConnect objects

### getTargetConnections

public List<? extends GraphConnection> getTargetConnections()
Returns a new list of the target connections (GraphModelConnection objects).

Returns:
  List a new list of GraphModelConnect objects

### getLocation

public org.eclipse.draw2d.geometry.Point getLocation()
Returns a copy of the node's location.

Returns:
  Point

### isSelected

public boolean isSelected()

### setLocation

public void setLocation(double x, double y)
Sets the current location for this node.

### getSize

public org.eclipse.draw2d.geometry.Dimension getSize()
Returns a copy of the node's size.

Returns:
  Dimension

### getForegroundColor

public Color getForegroundColor()
Get the foreground colour for this node

### setForegroundColor

public void setForegroundColor(Color c)
Set the foreground colour for this node

### getBackgroundColor

public Color getBackgroundColor()
Get the background colour for this node. This is the color the node will be if it is not currently highlighted. This color is meaningless if a custom figure has been set.

### setBackgroundColor

public void setBackgroundColor(Color c)
Permanently sets the background color (unhighlighted). This color has no effect if a custom figure has been set.

Parameters:
  `c` -

### setTooltip

public void setTooltip(org.eclipse.draw2d.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 org.eclipse.draw2d.IFigure getTooltip()
Gets the current tooltip for this node. The tooltip returned is meaningless if a custom figure has been set.

### setBorderColor

public void setBorderColor(Color c)
Sets the border color.

Parameters:
  `c` - the border color.

### setBorderHighlightColor

public void setBorderHighlightColor(Color c)
Sets the highlighted border color.

Parameters:
  `c` - the highlighted border color.

### getBackgroundHighlightColor

public Color getBackgroundHighlightColor()
Get the highlight background color for this node.

Since:
  1.19

### setBackgroundHighlightColor

public void setBackgroundHighlightColor(Color c)
Set the highlight background color for this node.

Since:
  1.19

### getForegroundHighlightColor

public Color getForegroundHighlightColor()
Get the highlight foreground color for this node. Returns `getForegroundColor()` if no highlight color is set.

Since:
  1.19

### setForegroundHighlightColor

public void setForegroundHighlightColor(Color c)
Set the highlight foreground color for this node.

Since:
  1.19

### getHighlightColor

@Deprecated(since="2026-09", forRemoval=true) public Color getHighlightColor()
Deprecated, for removal: This API element is subject to removal in a future version.
Use `getBackgroundHighlightColor()` instead. This method will be removed after the 2028-09 release.
Get the highlight colour for this node

### setHighlightColor

@Deprecated(since="2026-09", forRemoval=true) public void setHighlightColor(Color c)
Deprecated, for removal: This API element is subject to removal in a future version.
Use `setBackgroundHighlightColor(Color)` instead. This method will be removed after the 2028-09 release.
Set the highlight colour for this node

### highlight

public void highlight()
Highlights the node changing the background color and border color. The source and destination connections are also highlighted, and the adjacent nodes are highlighted too in a different color.

Specified by:
  `highlight` in class `GraphItem`

### unhighlight

public void unhighlight()
Restores the nodes original background color and border width.

Specified by:
  `unhighlight` in class `GraphItem`

### refreshLocation

protected void refreshLocation()

### getBorderColor

public Color getBorderColor()

### getBorderWidth

public int getBorderWidth()

### setBorderWidth

public void setBorderWidth(int width)

### getFont

public Font getFont()

### setFont

public void setFont(Font font)

### setText

public void setText(String string)

Overrides:
  `setText` in class `Item`

### setImage

public void setImage(Image image)

Overrides:
  `setImage` in class `Item`

### getGraphModel

public Graph getGraphModel()
Gets the graphModel that this node is contained in

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

### getNodeStyle

public int getNodeStyle()

Returns:
  the nodeStyle

### setNodeStyle

public void setNodeStyle(int nodeStyle)

Parameters:
  `nodeStyle` - the nodeStyle to set

### setSize

public void setSize(double width, double height)

### getBorderHighlightColor

public Color getBorderHighlightColor()

### cacheLabel

public boolean cacheLabel()

### setCacheLabel

public void setCacheLabel(boolean cacheLabel)

### getNodeFigure

public org.eclipse.draw2d.IFigure getNodeFigure()
Returns the figure of the whole node.

Returns:
  nodeFigure

### 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.

### setModelFigure

public void setModelFigure(org.eclipse.draw2d.IFigure figure)

Since:
  1.8

### getModelFigure

public org.eclipse.draw2d.IFigure getModelFigure()

Since:
  1.8

### setHideNodeHelper

public void setHideNodeHelper(HideNodeHelper hideNodeHelper)

Since:
  1.8

### getHideNodeHelper

public HideNodeHelper getHideNodeHelper()

Since:
  1.8

### getStyle

public int getStyle()

Overrides:
  `getStyle` in class `Widget`

### getHideContainerBounds

protected org.eclipse.draw2d.geometry.Rectangle getHideContainerBounds()

Since:
  1.8

### fishEye

protected org.eclipse.draw2d.IFigure fishEye(boolean enable, boolean animate)

### isHighlighted

public boolean isHighlighted()
returns true if node is highlighted, false otherwise

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

### updateFigureForModel

protected void updateFigureForModel(org.eclipse.draw2d.IFigure currentFigure)

### createFigureForModel

protected org.eclipse.draw2d.IFigure createFigureForModel()

### 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.

### 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`

### getLayout

public org.eclipse.zest.core.widgets.InternalNodeLayout getLayout()

@noreference
  This method is not intended to be referenced by clients.