Package org.eclipse.gef
Class SnapToGeometry
java.lang.Object
org.eclipse.gef.SnapToHelper
org.eclipse.gef.SnapToGeometry
- All Implemented Interfaces:
- PositionConstants
A temporary helper used to perform snapping to existing elements. This helper
 can be used in conjunction with the
 
DragEditPartsTracker when
 dragging editparts within a graphical viewer. Snapping is based on the
 existing children of a container. When snapping a rectangle, the edges
 of the rectangle will snap to edges of other rectangles generated from the
 children of the given container. Similarly, the centers and middles of
 rectangles will snap to each other.
 If the snap request is being made during a Move, Reparent or Resize, then the figures of the participants of that request will not be used for snapping. If the request is a Clone, then the figures for the parts being cloned will be used as possible snap locations.
This helper does not keep up with changes made to the container editpart. Clients should instantiate a new helper each time one is requested and not hold on to instances of the helper.
- Since:
- 3.0
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static classA vertical or horizontal snapping point. since 3.0
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected SnapToGeometry.Entry[]The vertical columns being snapped to.protected GraphicalEditPartThe container editpart providing the coordinates and the children to which snapping occurs.static final StringThe key used to identify the East anchor point in the extended data of a request.static final StringThe key used to identify the North anchor point in the extended data of a request.static final StringThe key used to identify the South anchor point in the extended data of a request.static final StringThe key used to identify the West anchor point in the extended data of a request.static final StringA property indicating whether this helper should be used.protected SnapToGeometry.Entry[]The horizontal rows being snapped to.protected static final doubleThe sensitivity of the snapping.Fields inherited from interface org.eclipse.draw2d.PositionConstantsALWAYS_LEFT, ALWAYS_RIGHT, BOTTOM, CENTER, EAST, EAST_WEST, HORIZONTAL, LEFT, LEFT_CENTER_RIGHT, MIDDLE, NONE, NORTH, NORTH_EAST, NORTH_SOUTH, NORTH_WEST, NSEW, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TOP_MIDDLE_BOTTOM, VERTICAL, WEST
- 
Constructor SummaryConstructorsConstructorDescriptionSnapToGeometry(GraphicalEditPart container) Constructs a helper that will use the given part as its basis for snapping.
- 
Method SummaryModifier and TypeMethodDescriptionprotected List<? extends GraphicalEditPart> generateSnapPartsList(List<? extends EditPart> exclusions) Generates a list of parts which should be snapped to.protected doublegetCorrectionFor(SnapToGeometry.Entry[] entries, Map extendedData, boolean vert, double near, double far) Returns the correction value for the given entries and sides.protected doublegetCorrectionFor(SnapToGeometry.Entry[] entries, Map extendedData, boolean vert, double value, int side) Returns the correction value between +/-getThreshold(), or the #getThreshold () if no corrections were found.protected RectangleReturns the rectangular contribution for the given editpart.protected doubleGet the sensitivity of the snapping.protected voidpopulateRowsAndCols(List<? extends GraphicalEditPart> parts) Updates the cached row and column Entries using the provided parts.protected voidsetThreshold(double newThreshold) Set the sensitivity of the snapping.intsnapRectangle(Request request, int snapOrientation, PrecisionRectangle baseRect, PrecisionRectangle result) Applies a snap correction to a Rectangle based on a given Rectangle.Methods inherited from class org.eclipse.gef.SnapToHelpermakeAbsolute, makeRelative, snapPoint, snapPoint, snapRectangle
- 
Field Details- 
PROPERTY_SNAP_ENABLEDA property indicating whether this helper should be used. The value should be an instance of Boolean. Currently, this class does not check to see if the viewer property is set totrue.- See Also:
 
- 
KEY_NORTH_ANCHORThe key used to identify the North anchor point in the extended data of a request. The north anchor may be set to anIntegervalue indicating where the snapping is occurring. This is used for feedback purposes.- See Also:
 
- 
KEY_SOUTH_ANCHORThe key used to identify the South anchor point in the extended data of a request. The south anchor may be set to anIntegervalue indicating where the snapping is occurring. This is used for feedback purposes.- See Also:
 
- 
KEY_WEST_ANCHORThe key used to identify the West anchor point in the extended data of a request. The west anchor may be set to anIntegervalue indicating where the snapping is occurring. This is used for feedback purposes.- See Also:
 
- 
KEY_EAST_ANCHORThe key used to identify the East anchor point in the extended data of a request. The east anchor may be set to anIntegervalue indicating where the snapping is occurring. This is used for feedback purposes.- See Also:
 
- 
THRESHOLDprotected static final double THRESHOLDThe sensitivity of the snapping. Corrections greater than this value will not occur.- See Also:
 
- 
rowsThe horizontal rows being snapped to.
- 
colsThe vertical columns being snapped to.
- 
containerThe container editpart providing the coordinates and the children to which snapping occurs.
 
- 
- 
Constructor Details- 
SnapToGeometryConstructs a helper that will use the given part as its basis for snapping. The part's contents pane will provide the coordinate system and its children determine the existing elements.- Parameters:
- container- the container editpart
- Since:
- 3.0
 
 
- 
- 
Method Details- 
getThresholdprotected double getThreshold()Get the sensitivity of the snapping. Corrections greater than this value will not occur.- Returns:
- the snapping threshold
- Since:
- 3.4
 
- 
setThresholdprotected void setThreshold(double newThreshold) Set the sensitivity of the snapping.- Parameters:
- newThreshold- the new snapping threshold
- Since:
- 3.4
- See Also:
 
- 
generateSnapPartsListprotected List<? extends GraphicalEditPart> generateSnapPartsList(List<? extends EditPart> exclusions) Generates a list of parts which should be snapped to. The list is the original children, minus the given exclusions, minus and children whose figures are not visible.- Parameters:
- exclusions- the children to exclude
- Returns:
- a list of parts which should be snapped to
- Since:
- 3.0
 
- 
getCorrectionForprotected double getCorrectionFor(SnapToGeometry.Entry[] entries, Map extendedData, boolean vert, double near, double far) Returns the correction value for the given entries and sides. During a move, the left, right, or center is free to snap to a location.- Parameters:
- entries- the entries
- extendedData- the requests extended data
- vert-- trueif the correction is vertical
- near- the left/top side of the rectangle
- far- the right/bottom side of the rectangle
- Returns:
- the correction amount or #getThreshold () if no correction was made
 
- 
getCorrectionForprotected double getCorrectionFor(SnapToGeometry.Entry[] entries, Map extendedData, boolean vert, double value, int side) Returns the correction value between +/-getThreshold(), or the #getThreshold () if no corrections were found.- Parameters:
- entries- the entries
- extendedData- the map for setting values
- vert-- trueif vertical
- value- the value being corrected
- side- which sides should be considered
- Returns:
- the correction or #getThreshold () if no correction was made
 
- 
getFigureBoundsReturns the rectangular contribution for the given editpart. This is the rectangle with which snapping is performed.- Parameters:
- part- the child
- Returns:
- the rectangular guide for that part
- Since:
- 3.0
 
- 
populateRowsAndColsUpdates the cached row and column Entries using the provided parts.- Parameters:
- parts- a List of EditParts
- Since:
- 3.0
 
- 
snapRectanglepublic int snapRectangle(Request request, int snapOrientation, PrecisionRectangle baseRect, PrecisionRectangle result) Description copied from class:SnapToHelperApplies a snap correction to a Rectangle based on a given Rectangle. The provided baseRect will be used as a reference for snapping. The types of snapping to be performed are indicated by the snapOrientation parameter. The correction is applied to the result field.The baseRect is not modified. The correction is applied to the result. The request's extended datamay contain additional information about the snapping which was performed.All coordinate information received and returned by this method should be in absolute coordinates. - Specified by:
- snapRectanglein class- SnapToHelper
- Parameters:
- request- the request or- null
- snapOrientation- the input snap locations
- baseRect- the input rectangle
- result- the correction is applied to this rectangle
- Returns:
- the remaining snap locations
- See Also:
 
 
-