|
Eclipse GEF 3.1 |
||||||||||
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
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. |
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 String |
KEY_EAST_ANCHOR
The key used to identify the East anchor point in the extended data of a request. |
static String |
KEY_NORTH_ANCHOR
The key used to identify the North anchor point in the extended data of a request. |
static String |
KEY_SOUTH_ANCHOR
The key used to identify the South anchor point in the extended data of a request. |
static String |
KEY_WEST_ANCHOR
The key used to identify the West anchor point in the extended data of a request. |
static 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 List |
generateSnapPartsList(List exclusions)
Generates a list of parts which should be snapped to. |
protected double |
getCorrectionFor(SnapToGeometry.Entry[] entries,
Map extendedData,
boolean vert,
double near,
double far)
Returns the correction value for the given entries and sides. |
protected double |
getCorrectionFor(SnapToGeometry.Entry[] entries,
Map extendedData,
boolean vert,
double value,
int side)
Returns the correction value between ± THRESHOLD , or the THRESHOLD if no
corrections were found. |
protected Rectangle |
getFigureBounds(GraphicalEditPart part)
Returns the rectangular contribution for the given editpart. |
protected void |
populateRowsAndCols(List parts)
Updates the cached row and column Entries using the provided parts. |
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 String PROPERTY_SNAP_ENABLED
true
.
EditPartViewer.setProperty(String, Object)
,
Constant Field Valuespublic static final String KEY_NORTH_ANCHOR
Integer
value indicating where the snapping is
occurring. This is used for feedback purposes.
public static final String KEY_SOUTH_ANCHOR
Integer
value indicating where the snapping is
occurring. This is used for feedback purposes.
public static final String KEY_WEST_ANCHOR
Integer
value indicating where the snapping is
occurring. This is used for feedback purposes.
public static final 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 List generateSnapPartsList(List exclusions)
exclusions
- the children to exclude
protected double getCorrectionFor(SnapToGeometry.Entry[] entries, 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, Map extendedData, boolean vert, double value, int side)
THRESHOLD
, or the THRESHOLD 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(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
baseRect
- the input rectangleresult
- the correction is applied to this rectanglesnapOrientation
- the input snap locations
SnapToHelper.snapRectangle(Request, int, PrecisionRectangle, PrecisionRectangle)
|
Eclipse GEF 3.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |