Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Diagram Developer Documentation"
(add a small documentation on snap to grid) |
(→Snap To Grid Enhancement) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
Then you must ovveride the method org.eclipse.gef.EditPart.getDragTracker(Request) in the edit part concerned by your specific SnapToGrid. | 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 | + | 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. |
− | + | *org.eclipse.papyrus.infra.gmfdiag.common.editpart.NodeEditPart.java | |
− | + | *org.eclipse.papyrus.infra.gmfdiag.common.snap.PapyrusDragBorderNodeEditPartTrackerEx.java | |
− | + | *org.eclipse.papyrus.infra.gmfdiag.common.snap.PapyrusDragEditPartsTrackerEx.java | |
− | + | *org.eclipse.papyrus.uml.diagram.common.editparts.BorderNodeEditPart.java | |
− | + | ||
− | + | 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) | ||
+ | |||
+ | |||
+ | =User tricks= | ||
+ | ALT allows to ignore Snap To Grid when your are moving an element |
Revision as of 12:01, 13 December 2013
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 org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx 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.
- org.eclipse.papyrus.infra.gmfdiag.common.editpart.NodeEditPart.java
- org.eclipse.papyrus.infra.gmfdiag.common.snap.PapyrusDragBorderNodeEditPartTrackerEx.java
- org.eclipse.papyrus.infra.gmfdiag.common.snap.PapyrusDragEditPartsTrackerEx.java
- org.eclipse.papyrus.uml.diagram.common.editparts.BorderNodeEditPart.java
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)
User tricks
ALT allows to ignore Snap To Grid when your are moving an element