|
GEF (MVC) 3.9.0.201308190730 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.gef.SnapToHelper
org.eclipse.gef.SnapToGeometry
public class SnapToGeometry
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.
Nested Class Summary | |
---|---|
protected static class |
SnapToGeometry.Entry
A vertical or horizontal snapping point. since 3.0 |
Field Summary | |
---|---|
protected SnapToGeometry.Entry[] |
cols
The vertical columnd being snapped to. |
protected GraphicalEditPart |
container
The container editpart providing the coordinates and the children to which snapping occurs. |
static java.lang.String |
KEY_EAST_ANCHOR
The key used to identify the East anchor point in the extended data of a request. |
static java.lang.String |
KEY_NORTH_ANCHOR
The key used to identify the North anchor point in the extended data of a request. |
static java.lang.String |
KEY_SOUTH_ANCHOR
The key used to identify the South anchor point in the extended data of a request. |
static java.lang.String |
KEY_WEST_ANCHOR
The key used to identify the West anchor point in the extended data of a request. |
static java.lang.String |
PROPERTY_SNAP_ENABLED
A property indicating whether this helper should be used. |
protected SnapToGeometry.Entry[] |
rows
The horizontal rows being snapped to. |
protected static double |
THRESHOLD
The sensitivity of the snapping. |
Fields inherited from interface org.eclipse.draw2d.PositionConstants |
---|
ALWAYS_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 Summary | |
---|---|
SnapToGeometry(GraphicalEditPart container)
Constructs a helper that will use the given part as its basis for snapping. |
Method Summary | |
---|---|
protected java.util.List |
generateSnapPartsList(java.util.List exclusions)
Generates a list of parts which should be snapped to. |
protected double |
getCorrectionFor(SnapToGeometry.Entry[] entries,
java.util.Map extendedData,
boolean vert,
double near,
double far)
Returns the correction value for the given entries and sides. |
protected double |
getCorrectionFor(SnapToGeometry.Entry[] entries,
java.util.Map extendedData,
boolean vert,
double value,
int side)
Returns the correction value between +/- getThreshold() , or the
#getThreshold () if no corrections were found. |
protected Rectangle |
getFigureBounds(GraphicalEditPart part)
Returns the rectangular contribution for the given editpart. |
protected double |
getThreshold()
Get the sensitivity of the snapping. |
protected void |
populateRowsAndCols(java.util.List parts)
Updates the cached row and column Entries using the provided parts. |
protected void |
setThreshold(double newThreshold)
Set the sensitivity of the snapping. |
int |
snapRectangle(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.SnapToHelper |
---|
makeAbsolute, makeRelative, snapPoint, snapPoint, snapRectangle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String PROPERTY_SNAP_ENABLED
true
.
EditPartViewer.setProperty(String, Object)
,
Constant Field Valuespublic static final java.lang.String KEY_NORTH_ANCHOR
Integer
value
indicating where the snapping is occurring. This is used for feedback
purposes.
public static final java.lang.String KEY_SOUTH_ANCHOR
Integer
value
indicating where the snapping is occurring. This is used for feedback
purposes.
public static final java.lang.String KEY_WEST_ANCHOR
Integer
value
indicating where the snapping is occurring. This is used for feedback
purposes.
public static final java.lang.String KEY_EAST_ANCHOR
Integer
value
indicating where the snapping is occurring. This is used for feedback
purposes.
protected static final double THRESHOLD
protected SnapToGeometry.Entry[] rows
protected SnapToGeometry.Entry[] cols
protected GraphicalEditPart container
Constructor Detail |
---|
public SnapToGeometry(GraphicalEditPart container)
container
- the container editpartMethod Detail |
---|
protected double getThreshold()
protected void setThreshold(double newThreshold)
newThreshold
- the new snapping thresholdgetThreshold()
protected java.util.List generateSnapPartsList(java.util.List exclusions)
exclusions
- the children to exclude
protected double getCorrectionFor(SnapToGeometry.Entry[] entries, java.util.Map extendedData, boolean vert, double near, double far)
entries
- the entriesextendedData
- the requests extended datavert
- true
if the correction is verticalnear
- the left/top side of the rectanglefar
- the right/bottom side of the rectangle
protected double getCorrectionFor(SnapToGeometry.Entry[] entries, java.util.Map extendedData, boolean vert, double value, int side)
getThreshold()
, or the
#getThreshold () if no corrections were found.
entries
- the entriesextendedData
- the map for setting valuesvert
- true
if verticalvalue
- the value being correctedside
- which sides should be considered
protected Rectangle getFigureBounds(GraphicalEditPart part)
part
- the child
protected void populateRowsAndCols(java.util.List parts)
parts
- a List of EditPartspublic int snapRectangle(Request request, int snapOrientation, PrecisionRectangle baseRect, PrecisionRectangle result)
SnapToHelper
The baseRect is not modified. The correction is applied to the result.
The request's extended data
may contain
additional information about the snapping which was performed.
All coordinate information received and returned by this method should be in absolute coordinates.
snapRectangle
in class SnapToHelper
request
- the request or null
snapOrientation
- the input snap locationsbaseRect
- the input rectangleresult
- the correction is applied to this rectangle
SnapToHelper.snapRectangle(Request, int, PrecisionRectangle,
PrecisionRectangle)
|
GEF (MVC) 3.9.0.201308190730 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |