|
Eclipse GEF 3.0.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.SnapToGuides
A helper used to perform snapping to guides. The guides are obtained from the viewer's
horizontal and vertical RulerProviders
. If snapping is
performed, the request's extended data will contain keyed values indicating which
guides were snapped to, and which side of the part should be attached. Generally
snapping to a guide should attach the part to that guide, but application behavior may
differ.
Snapping (and attaching) to a guide is only possible if a single part is being dragged. The current implementation will not snap if a request contains multiple parts. This may be relaxed in the future to allow snapping, but without setting the attachment extended data.
This helper does not keep up with changes in guides. Clients should instantiate a new helper each time one is requested and not hold onto instances of the helper.
Field Summary | |
protected GraphicalEditPart |
container
The graphical editpart to which guides are relative. |
protected int[] |
horizontalGuides
The locations of the horizontal guides in the container's coordinates. |
static String |
KEY_HORIZONTAL_ANCHOR
The key used to identify the horizontal anchor point. |
static String |
KEY_HORIZONTAL_GUIDE
The key used to identify the Horizontal Guide. |
static String |
KEY_VERTICAL_ANCHOR
The key used to identify the vertical anchor point. |
static String |
KEY_VERTICAL_GUIDE
The key used to identify the Vertical Guide. |
protected static double |
THRESHOLD
The threshold for snapping to guides. |
protected int[] |
verticalGuides
The locations of the vertical guides in the container's coordinates. |
Fields inherited from interface org.eclipse.draw2d.PositionConstants |
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 | |
SnapToGuides(GraphicalEditPart container)
Constructs a new snap-to-guides helper using the given container as the basis. |
Method Summary | |
protected double |
getCorrectionFor(int[] guides,
double near,
double far,
Map extendedData,
boolean isVertical)
Returns the correction for the given near and far sides of a rectangle or THRESHOLD if no correction was found. |
protected double |
getCorrectionFor(int[] guides,
double value,
Map extendedData,
boolean vert,
int side)
Returns the correction for the given location or THRESHOLD if no correction
was found. |
protected int[] |
getHorizontalGuides()
Returns the horizontal guides in the coordinates of the container's contents pane. |
protected int[] |
getVerticalGuides()
Returns the vertical guides in the coordinates of the container's contents pane. |
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 KEY_VERTICAL_GUIDE
public static final String KEY_HORIZONTAL_GUIDE
public static final String KEY_VERTICAL_ANCHOR
-1
indicates the left side should be attached.
0
indicates the center should be attached.
1
indicates the right side should be attached.
public static final String KEY_HORIZONTAL_ANCHOR
-1
indicates the top side should be attached.
0
indicates the middle should be attached.
1
indicates the bottom side should be attached.
protected static final double THRESHOLD
protected GraphicalEditPart container
protected int[] verticalGuides
getVerticalGuides()
.
protected int[] horizontalGuides
getHorizontalGuides()
.
Constructor Detail |
public SnapToGuides(GraphicalEditPart container)
container
- the container editpartMethod Detail |
protected double getCorrectionFor(int[] guides, double near, double far, Map extendedData, boolean isVertical)
THRESHOLD
if no correction was found. The near side represents the top or left side
of a rectangle being snapped. Similar for far. If snapping occurs, the extendedData
will have the guide and attachment point set.
guides
- the location of the guidesnear
- the top or left locationfar
- the bottom or right locationextendedData
- the map for storing snap detailsisVertical
- true
if for vertical guides, false
for horizontal.
protected double getCorrectionFor(int[] guides, double value, Map extendedData, boolean vert, int side)
THRESHOLD
if no correction
was found. If correction occurs, the extendedData will have the guide and attachment
point set. The attachment point is identified by the side
parameter.
The correction's magnitude will be less than THRESHOLD.
guides
- the location of the guidesvalue
- the location being testedextendedData
- the map for storing snap detailsvert
- true
if for vertical guides, false
side
- the integer indicating which side is being snapped
protected int[] getHorizontalGuides()
protected int[] getVerticalGuides()
public 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.0.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |