Eclipse GEF
3.0

org.eclipse.gef
Class SnapToHelper

java.lang.Object
  extended byorg.eclipse.gef.SnapToHelper
Direct Known Subclasses:
CompoundSnapToHelper, SnapToGeometry, SnapToGrid, SnapToGuides

public abstract class SnapToHelper
extends Object

A helper used temporarily by Tools for snapping certain mouse interactions. SnapToHelpers should not be reused by tools or by the editparts which provide them to the tools. For example, for a move operation, the life-cycle of a SnapToHelper begins when a drag is initiated, and ends when the drag is over. If another drag is initiated right after the first one is completed, new SnapToHelpers are employed. This means that helpers can assume that everything else is static, and there is no need to track changes outside of the helper.

Since:
3.0

Constructor Summary
SnapToHelper()
           
 
Method Summary
protected  void makeAbsolute(IFigure figure, Translatable t)
          Translates from a given figure to absolute coordinates.
protected  void makeRelative(IFigure figure, Translatable t)
          Translates from absolute to coordinates relative to the given figure.
 int snapPoint(Request request, int snapDirections, PrecisionPoint where, PrecisionPoint result)
          Applies a snapping correction to the given result.
 int snapRectangle(Request request, int snapOrientation, PrecisionRectangle[] baseRects, PrecisionRectangle result)
          A convenience method for snapping a Rectangle based on one or more rectangles.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SnapToHelper

public SnapToHelper()
Method Detail

makeAbsolute

protected void makeAbsolute(IFigure figure,
                            Translatable t)
Translates from a given figure to absolute coordinates.

Parameters:
figure - the reference figure
t - the object to translate

makeRelative

protected void makeRelative(IFigure figure,
                            Translatable t)
Translates from absolute to coordinates relative to the given figure.

Parameters:
figure - the reference figure
t - the object to translate

snapPoint

public int snapPoint(Request request,
                     int snapDirections,
                     PrecisionPoint where,
                     PrecisionPoint result)
Applies a snapping correction to the given result. Snapping can occur in the four primary directions: NORTH, SOUTH, EAST, WEST, as defined on PositionConstants. By default a Point is treated as an empty Rectangle. Only NORTH and WEST should be used in general. But SOUTH and EAST may also be used. Similarly, VERTICAL and HORIZONTAL may be used to allow a point to snap to the "center" or "middle" as defined by the concrete subclass.

The returned value should be a subset of the given snapDirections based on what correction was applied to the result. e.g., if the x value was adjusted, the returned value should not contain WEST, EAST, or HORIZONTAL.

All coordinate information received and returned by this method should be in absolute coordinates.

Parameters:
request - a request or null
snapDirections - the directions in which snapping should occur.
where - the rectangle used to determine snapping
result - the result
Returns:
the remaining snap locations

snapRectangle

public int snapRectangle(Request request,
                         int snapOrientation,
                         PrecisionRectangle[] baseRects,
                         PrecisionRectangle result)
A convenience method for snapping a Rectangle based on one or more rectangles. This method will call #snapRectangle(Request, int, PrecisionRectangle, PrecisionRectangle) for each rectangle in the array or until no more snap locations remain.

All coordinate information received and returned by this method should be in absolute coordinates.

Parameters:
request - the request or null
baseRects - the prioritized rectangles to snap to
result - the output
snapOrientation - the input snap locations
Returns:
the remaining snap locations

Eclipse GEF
3.0

Copyright (c) IBM Corp. and others 2000, 2004. All Rights Reserved.