Package org.eclipse.gef.editpolicies

# Class GraphicalEditPolicy

java.lang.Object
org.eclipse.gef.editpolicies.AbstractEditPolicy
org.eclipse.gef.editpolicies.GraphicalEditPolicy

All Implemented Interfaces:
  `EditPolicy`, `RequestConstants`

Direct Known Subclasses:
  `DirectEditPolicy`, `GraphicalNodeEditPolicy`, `LayoutEditPolicy`, `SelectionEditPolicy`, `SnapFeedbackPolicy`

public abstract class GraphicalEditPolicy extends AbstractEditPolicy
A `GraphicalEditPolicy` is used with a `GraphicalEditPart`. All GraphicalEditPolicies are involved with the Figure in some way. They might use the Figure to interpret Requests, or they might simply decorate the Figure with graphical Feedback, such as selection handles.

This class provides convenience methods for accessing the host's Figure, and for adding feedback to the GraphicalViewer. This class does not handle any Request types directly.

## Field Summary

### Fields inherited from interface org.eclipse.gef.EditPolicy

`COMPONENT_ROLE, CONNECTION_BENDPOINTS_ROLE, CONNECTION_ENDPOINTS_ROLE, CONNECTION_ROLE, CONTAINER_ROLE, DIRECT_EDIT_ROLE, GRAPHICAL_NODE_ROLE, LAYOUT_ROLE, NODE_ROLE, PRIMARY_DRAG_ROLE, SELECTION_FEEDBACK_ROLE, TREE_CONTAINER_ROLE`

### Fields inherited from interface org.eclipse.gef.RequestConstants

`REQ_ADD, REQ_ALIGN, REQ_ALIGN_CHILDREN, REQ_CLONE, REQ_CONNECTION_END, REQ_CONNECTION_START, REQ_CREATE, REQ_CREATE_BENDPOINT, REQ_DELETE, REQ_DELETE_DEPENDANT, REQ_DIRECT_EDIT, REQ_MOVE, REQ_MOVE_BENDPOINT, REQ_MOVE_CHILDREN, REQ_OPEN, REQ_ORPHAN, REQ_ORPHAN_CHILDREN, REQ_RECONNECT_SOURCE, REQ_RECONNECT_TARGET, REQ_RESIZE, REQ_RESIZE_CHILDREN, REQ_SELECTION, REQ_SELECTION_HOVER`

## Constructor Summary

Constructors
Constructor
Description
`GraphicalEditPolicy()`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`addFeedback(org.eclipse.draw2d.IFigure figure)`
Adds the specified `Figure` to the `LayerConstants.FEEDBACK_LAYER`.
`protected org.eclipse.draw2d.IFigure`
`getFeedbackLayer()`
Returns the layer used for displaying feedback.
`GraphicalEditPart`
`getHost()`
Cast the parent getHost to GraphicalEditPart This reduces the necessary cast operations in this and all child classes as well as in any users of a GraphicalEditPolicy.
`protected org.eclipse.draw2d.IFigure`
`getHostFigure()`
Convenience method to return the host's Figure.
`protected org.eclipse.draw2d.IFigure`
`getLayer(Object layer)`
Obtains the specified layer.
`protected void`
`removeFeedback(org.eclipse.draw2d.IFigure figure)`
Removes the specified `Figure` from the `LayerConstants.FEEDBACK_LAYER`.

### Methods inherited from class org.eclipse.gef.editpolicies.AbstractEditPolicy

`activate, deactivate, debugFeedback, eraseSourceFeedback, eraseTargetFeedback, getCommand, getTargetEditPart, setHost, showSourceFeedback, showTargetFeedback, toString, understandsRequest`

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

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

## Constructor Details

### GraphicalEditPolicy

public GraphicalEditPolicy()

## Method Details

### addFeedback

protected void addFeedback(org.eclipse.draw2d.IFigure figure)
Adds the specified `Figure` to the `LayerConstants.FEEDBACK_LAYER`.

Parameters:
  `figure` - the feedback to add

### getFeedbackLayer

protected org.eclipse.draw2d.IFigure getFeedbackLayer()
Returns the layer used for displaying feedback.

Returns:
  the feedback layer

### getHost

public GraphicalEditPart getHost()
Cast the parent getHost to GraphicalEditPart This reduces the necessary cast operations in this and all child classes as well as in any users of a GraphicalEditPolicy.

Specified by:
  `getHost` in interface `EditPolicy`
Overrides:
  `getHost` in class `AbstractEditPolicy`
Returns:
  the host EditPart on which this policy is installed.
Since:
  3.16
See Also:
  - `EditPolicy.getHost()`

### getHostFigure

protected org.eclipse.draw2d.IFigure getHostFigure()
Convenience method to return the host's Figure.

Returns:
  The host GraphicalEditPart's Figure

### getLayer

protected org.eclipse.draw2d.IFigure getLayer(Object layer)
Obtains the specified layer.

Parameters:
  `layer` - the key identifying the layer
Returns:
  the requested layer

### removeFeedback

protected void removeFeedback(org.eclipse.draw2d.IFigure figure)
Removes the specified `Figure` from the `LayerConstants.FEEDBACK_LAYER`.

Parameters:
  `figure` - the feedback to remove