public class NodeReshapeSnapResultProvider extends Object implements INodeReshapeSnapResultProvider
INodeReshapeSnapResultProvider
interface.Modifier and Type | Field and Description |
---|---|
static INodeReshapeSnapResultProvider |
INSTANCE
A shared singleton instance of this type.
|
Constructor and Description |
---|
NodeReshapeSnapResultProvider() |
Modifier and Type | Method and Description |
---|---|
protected void |
addGridLineSnapResult(GraphSnapContext context,
CollectSnapResultsEventArgs args,
INode node,
SnapLineSnapTypes snapLineType,
IPoint snapLineLocation,
double delta,
PointD snappedLocation,
double from,
double to,
PointD snapLinePoint)
Adds a snap result for a location that snaps to a grid line.
|
protected void |
addGridSnapResult(GraphSnapContext context,
CollectSnapResultsEventArgs args,
INode node,
IGridConstraintProvider<INode> provider,
PointD gridSnappedPoint,
PointD snappedLocation)
Adds a snap result for a location that snaps to the grid.
|
protected void |
addSameSizeSnapResult(GraphSnapContext context,
CollectSnapResultsEventArgs args,
INode node,
SnapLineOrientation orientation,
Iterable<RectD> rectangles,
double finalSize,
double snapDelta)
Adds a snap result for "same size" to the collect event argument.
|
protected void |
addSnaplineSnapResult(GraphSnapContext context,
CollectSnapResultsEventArgs args,
INode node,
OrthogonalSnapLine snapLine,
double delta,
PointD snapPoint)
Adds a snap result for a location that snaps the node's bounds to a snap line.
|
protected void |
collectGridSnapResults(GraphSnapContext context,
CollectSnapResultsEventArgs args,
INode node,
ReshapeRectangleContext reshapeContext,
RectD suggestedLayout)
Collects the snap results for the grid.
|
protected void |
collectSameSizeSnapResults(GraphSnapContext context,
CollectSnapResultsEventArgs args,
INode node,
ReshapeRectangleContext reshapeContext,
RectD suggestedLayout)
Collects the snap results that make the node the same size as other elements.
|
protected void |
collectSnapLineResults(GraphSnapContext context,
CollectSnapResultsEventArgs args,
INode node,
ReshapeRectangleContext reshapeContext,
RectD suggestedLayout)
Collects the snap results that makes the node's bounds snap to the
fixed node snap lines . |
void |
collectSnapResults(GraphSnapContext context,
CollectSnapResultsEventArgs args,
INode node,
ReshapeRectangleContext reshapeContext)
Called when a node is
dragged
to add SnapResult s for
OrthogonalSnapLine s or sizes to which this node can potentially snap during resizing. |
protected IEnumerable<SnapLine> |
getSnapLines(GraphSnapContext context,
INode node,
ReshapeRectangleContext reshapeContext,
RectD suggestedLayout)
Helper method for method
collectSnapLineResults(GraphSnapContext, CollectSnapResultsEventArgs, INode, ReshapeRectangleContext, RectD)
that gets all the SnapLine that should be checked for the currently moved node. |
public static final INodeReshapeSnapResultProvider INSTANCE
Since this type does not carry state this instance can be used in multi-threaded contexts without synchronization.
protected void addGridLineSnapResult(GraphSnapContext context, CollectSnapResultsEventArgs args, INode node, SnapLineSnapTypes snapLineType, IPoint snapLineLocation, double delta, PointD snappedLocation, double from, double to, PointD snapLinePoint)
This method is called by collectGridSnapResults(GraphSnapContext, CollectSnapResultsEventArgs, INode, ReshapeRectangleContext, RectD)
for each grid line snap.
context
- The context in which the snapping is performed.args
- The CollectSnapResultsEventArgs
instance containing the event data.node
- The node that is being reshaped.delta
- The amount the mouse needs to be moved in order to get to the snapping location.snappedLocation
- The location of the mouse that is associated with the grid point.snapLineType
- The type of snap line.snapLineLocation
- The point at which the snap line is anchored.from
- Where the snap line starts.to
- Where the snap line ends.snapLinePoint
- A point of interest on the snap line that can be highlighted.protected void addGridSnapResult(GraphSnapContext context, CollectSnapResultsEventArgs args, INode node, IGridConstraintProvider<INode> provider, PointD gridSnappedPoint, PointD snappedLocation)
This method is called by collectGridSnapResults(GraphSnapContext, CollectSnapResultsEventArgs, INode, ReshapeRectangleContext, RectD)
for each grid snap.
context
- The context in which the snapping is performed.args
- The CollectSnapResultsEventArgs
instance containing the event data.node
- The node that is being reshaped.provider
- The provider that is associated with the grid snapping.gridSnappedPoint
- The point on the grid that should be highlighted.snappedLocation
- The location of the mouse that is associated with the grid point.protected void addSameSizeSnapResult(GraphSnapContext context, CollectSnapResultsEventArgs args, INode node, SnapLineOrientation orientation, Iterable<RectD> rectangles, double finalSize, double snapDelta)
This method is called by collectSameSizeSnapResults(GraphSnapContext, CollectSnapResultsEventArgs, INode, ReshapeRectangleContext, RectD)
for each result found.
context
- The context in which the snapping is performed.args
- The CollectSnapResultsEventArgs
instance containing the event data. This will be used to add
the result to.node
- The node that is being reshaped.orientation
- The orientation of the result - indicates whether width or height have been snapped.rectangles
- The rectangles that have the same width or height as the node will - this does not yet includes the rectangle of the
node being reshaped.finalSize
- The target size to which the node will snap.snapDelta
- The snap delta that the mouse needs to be moved in order to snap.protected void addSnaplineSnapResult(GraphSnapContext context, CollectSnapResultsEventArgs args, INode node, OrthogonalSnapLine snapLine, double delta, PointD snapPoint)
This method is called by collectSnapLineResults(GraphSnapContext, CollectSnapResultsEventArgs, INode, ReshapeRectangleContext, RectD)
for each snap line snap.
context
- The context in which the snapping is performed.args
- The CollectSnapResultsEventArgs
instance containing the event data.node
- The node that is being reshaped.snapLine
- The snap line to which the node can be snappeddelta
- The amount the mouse needs to be moved in order to get to the snapping location.snapPoint
- The point of interest that can be highlighted on the snap line.protected void collectGridSnapResults(GraphSnapContext context, CollectSnapResultsEventArgs args, INode node, ReshapeRectangleContext reshapeContext, RectD suggestedLayout)
context
- The context in which the snapping is performed.args
- The CollectSnapResultsEventArgs
instance containing the event data.node
- The node that is being reshaped.reshapeContext
- The reshape context that describes how the node's layout is reshaped.suggestedLayout
- The suggested layout of the node.protected void collectSameSizeSnapResults(GraphSnapContext context, CollectSnapResultsEventArgs args, INode node, ReshapeRectangleContext reshapeContext, RectD suggestedLayout)
This method ultimately delegates to addSameSizeSnapResult(GraphSnapContext, CollectSnapResultsEventArgs, INode, SnapLineOrientation, Iterable, double, double)
to add the results to the event argument.
context
- The context in which the snapping is performed.args
- The CollectSnapResultsEventArgs
instance containing the event data.node
- The node that is being reshaped.reshapeContext
- The reshape context that contains information about the nature of the resize.suggestedLayout
- The layout of the node as it would be if the mouse location would not be snapped.protected void collectSnapLineResults(GraphSnapContext context, CollectSnapResultsEventArgs args, INode node, ReshapeRectangleContext reshapeContext, RectD suggestedLayout)
fixed node snap lines
.
This method ultimately delegates to addSnaplineSnapResult(GraphSnapContext, CollectSnapResultsEventArgs, INode, OrthogonalSnapLine, double, PointD)
to add the results to the event argument. Method getSnapLines(GraphSnapContext, INode, ReshapeRectangleContext, RectD)
is used to query the snap lines that will be checked by this method.
context
- The context in which the snapping is performed.args
- The CollectSnapResultsEventArgs
instance containing the event data.node
- The node that is being reshaped.reshapeContext
- The reshape context that contains information about the nature of the resize.suggestedLayout
- The layout of the node as it would be if the mouse location would not be snapped.public void collectSnapResults(GraphSnapContext context, CollectSnapResultsEventArgs args, INode node, ReshapeRectangleContext reshapeContext)
dragged
to add SnapResult
s for
OrthogonalSnapLine
s or sizes to which this node can potentially snap during resizing.
This implementation delegates to the following methods in order:
collectGridSnapResults(GraphSnapContext, CollectSnapResultsEventArgs, INode, ReshapeRectangleContext, RectD)
collectSameSizeSnapResults(GraphSnapContext, CollectSnapResultsEventArgs, INode, ReshapeRectangleContext, RectD)
collectSnapLineResults(GraphSnapContext, CollectSnapResultsEventArgs, INode, ReshapeRectangleContext, RectD)
collectSnapResults
in interface INodeReshapeSnapResultProvider
context
- The snap context which manages the snap lines and the settings.args
- The event argument to obtain the context from and add the results to.node
- The node that is being reshaped.reshapeContext
- Carries information about the reshape process.protected IEnumerable<SnapLine> getSnapLines(GraphSnapContext context, INode node, ReshapeRectangleContext reshapeContext, RectD suggestedLayout)
collectSnapLineResults(GraphSnapContext, CollectSnapResultsEventArgs, INode, ReshapeRectangleContext, RectD)
that gets all the SnapLine
that should be checked for the currently moved node.
This method aggregates the fixed nodes' snaplines
and the additional snap lines
that are relevant to the node.
context
- The context in which the snapping is performed.node
- The node that is being reshaped.reshapeContext
- The reshape context that contains information about the nature of the resize.suggestedLayout
- The layout of the node as it would be if the mouse location would not be snapped.