Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gef-dev] SnapTo API has been changed


The SnapToHelper API has been finalized in the HEAD stream.  It will go into the next build.  There are slight changes in API, including how types of snapping are specified, and how the result is returned.

SnapToHelper is an abstract class.  The abstract method which various implementation implement is:

public abstract int snapRectangle(Request request, int snapOrientation,
                PrecisionRectangle input, PrecisionRectangle result);

The input rectangle indicate what is being snapped.  Whatever correction is needed is applied to the result field, and the input should not be modified.  The orientation is still North, S E W, for resizing and also for sized-creation.  But, for translating a rectangle without changing its size, the new constants HORIZONTAL and VERTICAL are used.

The base class provides a helper method which takes an array of input rectangles instead of just one.  This allows snapping of the primary part which the user is dragging, as well as the union box of all of the parts being dragged together, to be snapped.  One could also include the individual components of the drag to have them snap in cases where the first 2 rectangles did not.

There is also another helper method which takes a point input and result, and converts them to rectangles and calls the snapRectangle method.  This could be used for example when snapping bendpoints.

-Randy

Back to the top