Package org.eclipse.gef.editparts

# Class FreeformGraphicalRootEditPart

java.lang.Object
org.eclipse.gef.editparts.AbstractEditPart
org.eclipse.gef.editparts.AbstractGraphicalEditPart
org.eclipse.gef.editparts.SimpleRootEditPart
org.eclipse.gef.editparts.FreeformGraphicalRootEditPart

All Implemented Interfaces:
  `IAdaptable`, `EditPart`, `LayerManager`, `GraphicalEditPart`, `LayerConstants`, `RequestConstants`, `RootEditPart`

Direct Known Subclasses:
  `ScalableFreeformRootEditPart`

public class FreeformGraphicalRootEditPart extends SimpleRootEditPart implements LayerConstants, LayerManager
A graphical root that uses `FreeformFigures` as the layers in the diagram. The `contents` editpart must provide a FreeformFigure as its figure. Freeform figures are special because they can expand in any direction. This allows the user to drag objects or bendpoints into the negative X and Y coordinates of a diagram. If this feature is not being used, clients should use the `FreeformGraphicalRootEditPart` as their viewer's root editpart.

IMPORTANT: The contents editpart that is added to a freeform root should have a `FreeformFigure` (such as FreeformLayer) as its Figure. The primary layer is not using a draw2d LayoutManager, and will not size the contents' figure properly unless it is a freeform figure.

IMPORTANT:The freeform root uses a `FreeformViewport` as its primary figure. This class must be used with the `ScrollingGraphicalViewer`. The viewport gets installed into that viewer's `FigureCanvas`, which provides native scrollbars for scrolling the viewport.

This root serves as the diagram's `LayerManager`, providing the following layer structure, in top-to-bottom order:

Root Freeform Layered Pane
├ | Feedback Layer
├ | Handle Layer
└ | Printable Layers
| ├ Connection Layer
| └ Primary Layer

## Nested Class Summary

## Nested classes/interfaces inherited from class org.eclipse.gef.editparts.AbstractGraphicalEditPart

`AbstractGraphicalEditPart.AccessibleGraphicalEditPart, AbstractGraphicalEditPart.DefaultAccessibleAnchorProvider`

## Nested classes/interfaces inherited from class org.eclipse.gef.editparts.AbstractEditPart

`AbstractEditPart.EditPolicyIterator`

## Nested classes/interfaces inherited from interface org.eclipse.gef.editparts.LayerManager

`LayerManager.Helper`

## Field Summary

### Fields inherited from class org.eclipse.gef.editparts.AbstractGraphicalEditPart

`figure, sourceConnections, targetConnections`

### Fields inherited from class org.eclipse.gef.editparts.AbstractEditPart

`children, FLAG_ACTIVE, FLAG_FOCUS, MAX_FLAG`

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

`SELECTED, SELECTED_NONE, SELECTED_PRIMARY`

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

`CONNECTION_LAYER, FEEDBACK_LAYER, GRID_LAYER, GUIDE_LAYER, HANDLE_LAYER, PRIMARY_LAYER, PRINTABLE_LAYERS, SCALABLE_LAYERS, SCALED_FEEDBACK_LAYER`

### Fields inherited from interface org.eclipse.gef.editparts.LayerManager

`ID`

### 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
`FreeformGraphicalRootEditPart()`

## Method Summary

Modifier and Type
Method
Description
`protected org.eclipse.draw2d.IFigure`
`createFigure()`
The default root figure is a figure with a stack layout.
`protected GridLayer`
`createGridLayer()`
Creates a `grid`.
`protected void`
`createLayers(org.eclipse.draw2d.LayeredPane layeredPane)`
Creates the top-most set of layers on the given layered pane.
`protected org.eclipse.draw2d.LayeredPane`
`createPrintableLayers()`
Creates a layered pane and the layers that should be printed.
`protected org.eclipse.draw2d.FreeformViewport`
`createViewport()`
Create the viewport to be used for this root EditPart.
`<T> T`
`getAdapter(Class<T> adapter)`
Extends `AbstractEditPart.getAdapter(Class)` to handle additional adapter types.
`org.eclipse.draw2d.IFigure`
`getContentPane()`
The contents' Figure will be added to the PRIMARY_LAYER.
`DragTracker`
`getDragTracker(Request req)`
Should not be called, but returns a MarqeeDragTracker for good measure.
`org.eclipse.draw2d.IFigure`
`getLayer(Object key)`
Returns the layer indicated by the key.
`Object`
`getModel()`
The root editpart does not have a real model.
`protected org.eclipse.draw2d.LayeredPane`
`getPrintableLayers()`
Returns the LayeredPane that should be used during printing.
`protected void`
`refreshGridLayer()`
Updates the `grid` based on properties set on the `graphical viewer`: `SnapToGrid.PROPERTY_GRID_VISIBLE`, `SnapToGrid.PROPERTY_GRID_SPACING`, and `SnapToGrid.PROPERTY_GRID_ORIGIN`.
`protected void`
`register()`
Registers itself in the viewer's various registries.
`protected void`
`unregister()`
Undoes any registration performed by `AbstractEditPart.register()`.

### Methods inherited from class org.eclipse.gef.editparts.SimpleRootEditPart

`createEditPolicies, getCommand, getContents, getRoot, getViewer, refreshChildren, setContents, setViewer`

### Methods inherited from class org.eclipse.gef.editparts.AbstractGraphicalEditPart

`activate, addChildVisual, addNodeListener, addNotify, addSourceConnection, addTargetConnection, createConnection, createOrFindConnection, deactivate, fireRemovingSourceConnection, fireRemovingTargetConnection, fireSourceConnectionAdded, fireTargetConnectionAdded, getChildren, getFigure, getModelSourceConnections, getModelTargetConnections, getSourceConnections, getTargetConnections, isSelectable, primAddSourceConnection, primAddTargetConnection, primRemoveSourceConnection, primRemoveTargetConnection, refresh, refreshSourceConnections, refreshTargetConnections, registerVisuals, removeChildVisual, removeNodeListener, removeNotify, removeSourceConnection, removeTargetConnection, reorderChild, reorderSourceConnection, reorderTargetConnection, setFigure, setLayoutConstraint, unregisterVisuals`

### Methods inherited from class org.eclipse.gef.editparts.AbstractEditPart

`activateEditPolicies, addChild, addEditPartListener, createChild, deactivateEditPolicies, debug, debugFeedback, eraseSourceFeedback, eraseTargetFeedback, fireActivated, fireChildAdded, fireDeactivated, fireRemovingChild, fireSelectionChanged, getAccessibleEditPart, getEditPolicy, getEditPolicyIterable, getEditPolicyIterator, getEventListeners, getEventListenersIterable, getFlag, getModelChildren, getParent, getSelected, getTargetEditPart, hasFocus, installEditPolicy, isActive, performRequest, refreshVisuals, registerAccessibility, registerModel, removeChild, removeEditPartListener, removeEditPolicy, setFlag, setFocus, setModel, setParent, setSelected, showSourceFeedback, showTargetFeedback, toString, understandsRequest, unregisterAccessibility, unregisterModel`

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

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

### Methods inherited from interface org.eclipse.gef.EditPart

`activate, addEditPartListener, addNotify, deactivate, eraseSourceFeedback, eraseTargetFeedback, getEditPolicy, getParent, getSelected, getTargetEditPart, hasFocus, installEditPolicy, isActive, isSelectable, performRequest, refresh, removeEditPartListener, removeEditPolicy, removeNotify, setFocus, setModel, setParent, setSelected, showSourceFeedback, showTargetFeedback, understandsRequest`

## Constructor Details

### FreeformGraphicalRootEditPart

public FreeformGraphicalRootEditPart()

## Method Details

### createFigure

protected org.eclipse.draw2d.IFigure createFigure()
Description copied from class: `SimpleRootEditPart`
The default root figure is a figure with a stack layout.

Overrides:
  `createFigure` in class `SimpleRootEditPart`
Returns:
  a Figure
See Also:
  - `AbstractGraphicalEditPart.createFigure()`

### createGridLayer

protected GridLayer createGridLayer()
Creates a `grid`. Sub-classes can override this method to customize the appearance of the grid. The grid layer should be the first layer (i.e., beneath the primary layer) if it is not to cover up parts on the primary layer. In that case, the primary layer should be transparent so that the grid is visible.

Returns:
  the newly created GridLayer

### createLayers

protected void createLayers(org.eclipse.draw2d.LayeredPane layeredPane)
Creates the top-most set of layers on the given layered pane.

Parameters:
  `layeredPane` - the parent for the created layers

### createPrintableLayers

protected org.eclipse.draw2d.LayeredPane createPrintableLayers()
Creates a layered pane and the layers that should be printed.

Returns:
  a new LayeredPane containing the printable layers
See Also:
  - `PrintGraphicalViewerOperation`

### createViewport

protected org.eclipse.draw2d.FreeformViewport createViewport()
Create the viewport to be used for this root EditPart. Subclasses can override this method to customize the viewport for their needs.

Since:
  3.24

### getAdapter

public <T> T getAdapter(Class<T> adapter)
Description copied from class: `AbstractGraphicalEditPart`
Extends `AbstractEditPart.getAdapter(Class)` to handle additional adapter types. Currently, these types include `AccessibleHandleProvider` and `AccessibleAnchorProvider`. Subclasses should extend this method to support additional adapter types, or to replace the default provided adapters.

Specified by:
  `getAdapter` in interface `IAdaptable`
Overrides:
  `getAdapter` in class `AbstractGraphicalEditPart`
See Also:
  - `IAdaptable.getAdapter(java.lang.Class)`

### getContentPane

public org.eclipse.draw2d.IFigure getContentPane()
The contents' Figure will be added to the PRIMARY_LAYER.

Specified by:
  `getContentPane` in interface `GraphicalEditPart`
Overrides:
  `getContentPane` in class `AbstractGraphicalEditPart`
Returns:
  the content pane Figure
See Also:
  - `GraphicalEditPart.getContentPane()`

### getDragTracker

public DragTracker getDragTracker(Request req)
Should not be called, but returns a MarqeeDragTracker for good measure.

Specified by:
  `getDragTracker` in interface `EditPart`
Overrides:
  `getDragTracker` in class `AbstractGraphicalEditPart`
Parameters:
  `req` - a `Request` indicating the context of the drag
Returns:
  `null` or a DragTracker
See Also:
  - `EditPart.getDragTracker(org.eclipse.gef.Request)`

### getLayer

public org.eclipse.draw2d.IFigure getLayer(Object key)
Returns the layer indicated by the key. Searches all layered panes.

Specified by:
  `getLayer` in interface `LayerManager`
Overrides:
  `getLayer` in class `AbstractGraphicalEditPart`
Parameters:
  `key` - ID of the Layer
Returns:
  The requested layer or `null` if it doesn't exist
See Also:
  - `LayerManager.getLayer(Object)`

### getModel

public Object getModel()
The root editpart does not have a real model. The LayerManager ID is returned so that this editpart gets registered using that key.

Specified by:
  `getModel` in interface `EditPart`
Overrides:
  `getModel` in class `AbstractEditPart`
Returns:
  `null` or the primary model object
See Also:
  - `EditPart.getModel()`

### getPrintableLayers

protected org.eclipse.draw2d.LayeredPane getPrintableLayers()
Returns the LayeredPane that should be used during printing. This layer will be identified using `LayerConstants.PRINTABLE_LAYERS`.

Returns:
  the layered pane containing all printable content

### refreshGridLayer

protected void refreshGridLayer()
Updates the `grid` based on properties set on the `graphical viewer`: `SnapToGrid.PROPERTY_GRID_VISIBLE`, `SnapToGrid.PROPERTY_GRID_SPACING`, and `SnapToGrid.PROPERTY_GRID_ORIGIN`.

This method is invoked initially when the GridLayer is created, and when any of the above-mentioned properties are changed on the viewer.

### register

protected void register()
Description copied from class: `AbstractEditPart`
Registers itself in the viewer's various registries. If your EditPart has a 1-to-1 relationship with a visual object and a 1-to-1 relationship with a model object, the default implementation should be sufficient.

Overrides:
  `register` in class `AbstractEditPart`
See Also:
  - `AbstractEditPart.register()`

### unregister

protected void unregister()
Description copied from class: `AbstractEditPart`
Undoes any registration performed by `AbstractEditPart.register()`. The provided base classes will correctly unregister their visuals.

Overrides:
  `unregister` in class `AbstractEditPart`
See Also:
  - `AbstractEditPart.unregister()`