public interface ILspSnapper
ILspEditor
. Snapping
is performed by allowing the TLspEditOperation
s received by the
editor to be mutated before the editor processes them. For instance, an
ILspSnapper
could detect operations that describe an object translation,
and modify them to make the translation coincide with a particular snap
target (e.g. a vertex of a neighboring polygon).
Edit operations are not modified in place by ILspSnapper
.
Instead this interface takes one operation as input and can produce any number of
new ones as output. This enables complex implementations, such as for
instance performing snapping on individual vertices of a polygon while
dragging the polygon as a whole (i.e. allowing the snapping to change the
shape of the polygon).
Note that the class TLspPointToPointSnapper
implements the most common use
case for snapping, namely snapping of one point onto another.
Snappers can provide visual feedback about their operation by letting the
snap
method create "visual components", which are later painted in the view by the
controller.Modifier and Type | Method and Description |
---|---|
boolean |
canSnap(TLspEditOperation aIncomingOperation,
TLspEditContext aContext)
Returns true if snapping can be performed on the given incoming operation.
|
TLspSnapOperation |
snap(TLspEditOperation aIncomingOperation,
TLspEditContext aContext)
Performs snapping, if possible, based on the incoming edit operation.
|
TLspSnapOperation snap(TLspEditOperation aIncomingOperation, TLspEditContext aContext)
TLspSnapOperation
containing a new list of edit operations. The contents
of this list may be identical to these of aIncomingOperation
.aIncomingOperation
- the incoming edit operation to be processed by the snapperaContext
- provides context information for the edit operationTLspSnapOperation
containing a new list of edit operations.boolean canSnap(TLspEditOperation aIncomingOperation, TLspEditContext aContext)
aIncomingOperation
- the operation that may be processed by the snapperaContext
- provides context information for the edit operation