Skip to main content
Jump to: navigation, search

Diagram Developer Documentation

Snap To Grid Enhancement

By Default Snap To Grid allows to snap on the grid using the top left corner of the figure (in case of Rctangle).

To improve this behavior, you should subclass the GMF Class or one of its superclass. Then you must ovveride the method org.eclipse.gef.EditPart.getDragTracker(Request) in the edit part concerned by your specific SnapToGrid.

In Papyrus we change this class to be able to snap on the 4 corners, the four middle and the center of a rectangle. Have a look to these classes to get examples.


To improve the connection of the endPoint of the link, Papyrus provides its own EditPolicy (in ConnectionEditPart) : org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusConnectionEndEditPolicy.PapyrusConnectionEndEditPolicy, with the role EditPolicy.CONNECTION_ENDPOINTS_ROLE (see this class for details)

Link(s)LF integration

The LinkLF feature (sometimes written LinksLF) has been implemented in GMF Runtime project for Papyrus. LinksLF means Links Look And Feel. This feature concerns several points:

  • snap to grid
  • routers (more particularly Rectilinear Router)
  • managment of floating label
  • bendpoints behavior (and their serialization)
  • management of anchors


  • Moving the source anchor of a link must not move the target anchor
  • Moving the source anchor of a link must not move the target label
  • Snap to grid must be respected for anchors and bendpoints (more prioritary than the serialized values)
  • Increasing the size of a node, must not move the anchors of the links.
  • Snap to grid must be used when the user drop a link for the anchors and the bendpoints

Causes of the problems

  • source and target anchor reference the location where the user clicks to create the link, and not the start and the end of the link shown to the user. (anchor are serialized in percentage of the size of the parent figure)
  • the bendpoints are serialized as a distance in x/y from the source AND from the target
  • moving the source anchor, the target anchor, the source object, the target object and the bendpoints don't update the others values.


This feature is implementing in GMF, with an integration in Papyrus.

  • LinkLFDiagramRootEditPart, provides a specific router
  • SlidableSnapToGridAnchor, a specific anchor, allowing to snap to grid, used by the custom routers., so the figures must support it.
  • LinkLFShapeNodeAnchorDelegate, must be used in EditPart for the method getSourceConnectionAnchor and getTargetConnectionAnchor
  • LinkLFLabelEditPart, for the management of the label for the links
  • LinksLFGraphicalNodeEditPolicy
  • LinkLFNodeFigure
  • some edit policy, others probably exists:
    • AdjustSyntheticBendpointsEditPolicy
    • LinksLFGraphicalNodeEditPolicy
    • AdjustImplicitlyMovedLinksEditPolicy
    • AdjustBorderItemAnchorsEditPolicy


LinkLF is enabled by the plugin org.eclipse.papyrus.uml.diagram.linklf. This plugin provides specific editpolicies for Diagram (UML and SysML) and manage the anchor delegation.

User tricks

ALT allows to ignore Snap To Grid when your are moving an element

Delete Behaviors (added the 19th of May 2016)

  • Define Behavior for DEL and Shift DEL
Delete From Model (DEL) Delete From Diagram (SHIFT+DEL) Example Delete From Model Action (DEL)
View with semantic Delete Hide Class
View with no semantic, but representing a feature Delete: remove the reference from the feature Hide Comment Link, Constraint Links (context and contrainedElement), DurationObservation and TimeObservation Link remove the link and remove the reference from the feature
View with no semantic Hide Hide  ? remove the link
View with semantic Read Only Forbidden Hide PimitivesTypes::Integer
Metaclass All Diagram (Read-Only) Hide Hide Import Metaclass (Profile Diagram) keep the element imported, destroy the view o the metaclass

Display of the stereotypes in the diagram

The framework used to display the stereotypes and their properties has changed between Luna and Mars. A reconciler has been created to migrate the displayed stereotypes (class org.eclipse.papyrus.uml.diagram.common.stereotype.migration.StereotypeDisplayDiagramReconciler. The appearance can changed between the 2 versions. Here, the list of the known changes:

  • the order used to display of the stereotypes (in comment, compartment or braces) was not correctly implemented in Luna, so the order can change in Mars. The problem should be fixed in Neon. This order problem could impact the icon displayed for the element too.
  • in SysML, the Block Figure displayed <<block>> before the name of the class. This feature has been removed.
  • the label provider has changed, so when in Luna you displayed "id=null" in Mars, you now display "id" without value
  • the properties displayed in brace appears now above of the name of the element (Mars). On Luna, they appeared under the name of the element.
  • some stereotype icon disappears in Mars (see Snapshot below)
  • lower case becomes upper case for the name of the stereotype in Mars
  • in Luna,display of a Class stereotyped Block and Requirement in a Block Definition Diagram

Display of a Block in Luna

  • in Mars,display of a Class stereotyped Block and Requirement in a Block Definition Diagram

Display of a Block in Mars

Back to the top