public class NodeSnapResultProvider extends Object implements INodeSnapResultProvider
INodeSnapResultProvider
interface.Modifier and Type | Field and Description |
---|---|
static INodeSnapResultProvider |
INSTANCE
Yields the static shared instance of this class.
|
Constructor and Description |
---|
NodeSnapResultProvider() |
Modifier and Type | Method and Description |
---|---|
protected void |
addGridSnapResult(GraphSnapContext context,
CollectSnapResultsEventArgs args,
PointD location,
INode node)
Calculates a
SnapResult and adds it to the
argument. |
protected void |
addGridSnapResultCore(GraphSnapContext context,
CollectSnapResultsEventArgs args,
PointD location,
INode node,
GridSnapTypes gridSnapType,
SnapPolicy xSnapPolicy,
SnapPolicy ySnapPolicy)
Calculates a
SnapResult and adds it to the
argument. |
protected void |
collectGridSnapResults(GraphSnapContext context,
CollectSnapResultsEventArgs args,
RectD suggestedLayout,
INode node)
Collects snap results that snap the node to a grid and
adds them
to the argument. |
protected void |
collectSnapLineSnapResults(GraphSnapContext context,
CollectSnapResultsEventArgs args,
RectD suggestedLayout,
INode node)
Collects the results for the given layout for all snap lines in question.
|
protected void |
collectSnapResults(CollectSnapResultsEventArgs args,
OrthogonalSnapLine snapLine,
RectD suggestedLayout,
INode node)
Verifies whether the node will snap to the given snap line.
|
void |
collectSnapResults(GraphSnapContext context,
CollectSnapResultsEventArgs args,
RectD suggestedLayout,
INode node)
Called when a node is
dragged
to add SnapResult s for
OrthogonalSnapLine s to which this node can potentially snap. |
public static final INodeSnapResultProvider INSTANCE
Since this implementation does not carry any state, this instance can safely be used even in multi-threaded environments.
protected void addGridSnapResult(GraphSnapContext context, CollectSnapResultsEventArgs args, PointD location, INode node)
SnapResult
and adds it
to the
argument.
This method delegates to addGridSnapResultCore(GraphSnapContext, CollectSnapResultsEventArgs, PointD, INode, GridSnapTypes, SnapPolicy, SnapPolicy)
using GridSnapType
and SnapPolicy.TO_NEAREST
as the additional
arguments. This method snaps the location
to the next grid point or grid lines that are determined by NodeGridConstraintProvider
or obtained from the Context
.
context
- The context in which the snapping is performed.args
- The arguments to add the results to.location
- A location in the layout of the suggested layout of the node that will be snapped to a grid point location.node
- The node that is currently being processed.protected void addGridSnapResultCore(GraphSnapContext context, CollectSnapResultsEventArgs args, PointD location, INode node, GridSnapTypes gridSnapType, SnapPolicy xSnapPolicy, SnapPolicy ySnapPolicy)
SnapResult
and adds it
to the
argument.
This method snaps the location
to the next grid point or grid lines that are determined by NodeGridConstraintProvider
or obtained from the Context
.
context
- The context in which the snapping is performed.args
- The arguments to add the results to.location
- A location in the layout of the suggested layout of the node that will be snapped to a grid point location.node
- The node that is currently being processed.gridSnapType
- The type of snapping that should be performed.xSnapPolicy
- How to snap the x coordinate.ySnapPolicy
- How to snap the y coordinate.protected void collectGridSnapResults(GraphSnapContext context, CollectSnapResultsEventArgs args, RectD suggestedLayout, INode node)
adds them
to the argument.
This implementation simply delegates to addGridSnapResult(GraphSnapContext, CollectSnapResultsEventArgs, PointD, INode)
using the center of the suggestedLayout
.
context
- The context in which the snapping is performed.args
- The arguments to add the results to.suggestedLayout
- The layout of the node if it would move without snapping.node
- The node that is currently being processed.protected void collectSnapLineSnapResults(GraphSnapContext context, CollectSnapResultsEventArgs args, RectD suggestedLayout, INode node)
For each snap line that could be snapped to, this method calls
collectSnapResults(CollectSnapResultsEventArgs, OrthogonalSnapLine, RectD, INode)
.
context
- The context for which the results are being queried.args
- The CollectSnapResultsEventArgs
instance to which the results should be
added
.suggestedLayout
- The suggested layout of the node.node
- The node that is being dragged.protected void collectSnapResults(CollectSnapResultsEventArgs args, OrthogonalSnapLine snapLine, RectD suggestedLayout, INode node)
If the node will snap, a SnapResult
for a SnapLine
will be created and added to the event argument.
args
- The arguments to add the results to.snapLine
- The snap line to test snapping for.suggestedLayout
- The layout of the node if it would move without snapping.node
- The node that is currently being processed.public void collectSnapResults(GraphSnapContext context, CollectSnapResultsEventArgs args, RectD suggestedLayout, INode node)
INodeSnapResultProvider
dragged
to add SnapResult
s for
OrthogonalSnapLine
s to which this node can potentially snap.collectSnapResults
in interface INodeSnapResultProvider
context
- The snap context which manages the snap lines and the settings.args
- The event argument to obtain the necessary information from and
add results to
.suggestedLayout
- The layout
of the node if the node would not snap.node
- The node that is being moved.