public class LabelSnapContext extends SnapContext
ILabels to their owner during drag operations like movements.
This class provides a set of properties to customize the snapping behavior. IPositionHandler implementations and
similar classes can use the following idiom to get an instance of this class:
| Constructor and Description |
|---|
LabelSnapContext()
Initializes a new instance of the
LabelSnapContext class. |
| Modifier and Type | Method and Description |
|---|---|
void |
addCollectSnapLinesListener(IEventHandler<CollectLabelSnapLineEventArgs> collectSnapLinesEvent)
Adds the given listener for the
CollectSnapLines event that occurs every time this instance has been initialized
to collect SnapLines. |
void |
addSnapLine(SnapLine snapLine)
Adds the given
snapLine to the snap line collection of this context. |
protected void |
cleanUp()
Performs clean up procedures.
|
SnapState |
dragFinished(PointD newLocation,
boolean snappingDisabled)
Called when a drag has been successfully finished.
|
void |
dragInitialized()
Collects a list of snap lines.
|
double |
getSnapLineExtension()
Gets the amount by which snap lines that are induced by existing edge segments are being extended.
|
IEnumerable<SnapLine> |
getSnapLines()
The collection of the
snap lines that have been added to this context. |
SnapState |
handleMove(PointD newLocation,
boolean snappingDisabled)
Handles a move.
|
void |
initializeDrag(IInputModeContext context,
PointD originalLocation)
Called by
IInputMode implementations when an interactive drag is started. |
boolean |
isCollectingAllEdgeDistanceSnapLinesEnabled()
Determines whether this instance should collect snap lines in parallel to the edge path of the label owner at the
distance of other edge labels in the graph.
|
boolean |
isCollectingAllNodeDistanceSnapLinesEnabled()
Determines whether this instance should collect snap lines in parallel to the border of the label owner at the distance
of other node labels in the graph.
|
boolean |
isCollectingEdgePathSnapLinesEnabled()
Determines whether this instance should collect snap lines on the edge path.
|
boolean |
isCollectingInitialLocationSnapLinesEnabled()
Determines whether this instance should collect snap lines for the initial position of a label.
|
boolean |
isCollectingNodeShapeSnapLinesEnabled()
Determines whether this instance should collect six snap lines, two through the center and four through the border sides
of the label owner.
|
boolean |
isCollectingOwnEdgeDistanceSnapLinesEnabled()
Determines whether this instance should collect two snap lines in parallel to the edge path of the label owner at the
initial distance of the edge label.
|
boolean |
isCollectingOwnNodeDistanceSnapLinesEnabled()
Determines whether this instance should collect four snap lines in parallel to the owner's borders at the initial label
distance.
|
boolean |
isCollectingSameOwnerEdgeDistanceSnapLinesEnabled()
Determines whether this instance should collect snap lines in parallel to the edge path of the label owner at the
distances of all edge labels of that owner.
|
boolean |
isCollectingSameOwnerNodeDistanceSnapLinesEnabled()
Determines whether this instance should collect snap lines in parallel to the border of the label owner at the distance
of other node labels of that owner.
|
boolean |
isSnappingEdgeLabelsEnabled()
Specifies whether this context will automatically snap the edge labels to snap lines.
|
boolean |
isSnappingNodeLabelsEnabled()
Specifies whether this context will automatically snap the node labels to snap lines.
|
protected void |
onCollectSnapLines(CollectLabelSnapLineEventArgs args)
Raises the
CollectSnapLines event. |
void |
removeCollectSnapLinesListener(IEventHandler<CollectLabelSnapLineEventArgs> collectSnapLinesEvent)
Removes the given listener for the
CollectSnapLines event that occurs every time this instance has been initialized
to collect SnapLines. |
void |
setCollectingAllEdgeDistanceSnapLinesEnabled(boolean value)
Determines whether this instance should collect snap lines in parallel to the edge path of the label owner at the
distance of other edge labels in the graph.
|
void |
setCollectingAllNodeDistanceSnapLinesEnabled(boolean value)
Determines whether this instance should collect snap lines in parallel to the border of the label owner at the distance
of other node labels in the graph.
|
void |
setCollectingEdgePathSnapLinesEnabled(boolean value)
Determines whether this instance should collect snap lines on the edge path.
|
void |
setCollectingInitialLocationSnapLinesEnabled(boolean value)
Determines whether this instance should collect snap lines for the initial position of a label.
|
void |
setCollectingNodeShapeSnapLinesEnabled(boolean value)
Determines whether this instance should collect six snap lines, two through the center and four through the border sides
of the label owner.
|
void |
setCollectingOwnEdgeDistanceSnapLinesEnabled(boolean value)
Determines whether this instance should collect two snap lines in parallel to the edge path of the label owner at the
initial distance of the edge label.
|
void |
setCollectingOwnNodeDistanceSnapLinesEnabled(boolean value)
Determines whether this instance should collect four snap lines in parallel to the owner's borders at the initial label
distance.
|
void |
setCollectingSameOwnerEdgeDistanceSnapLinesEnabled(boolean value)
Determines whether this instance should collect snap lines in parallel to the edge path of the label owner at the
distances of all edge labels of that owner.
|
void |
setCollectingSameOwnerNodeDistanceSnapLinesEnabled(boolean value)
Determines whether this instance should collect snap lines in parallel to the border of the label owner at the distance
of other node labels of that owner.
|
void |
setSnapLineExtension(double value)
Sets the amount by which snap lines that are induced by existing edge segments are being extended.
|
void |
setSnappingEdgeLabelsEnabled(boolean value)
Specifies whether this context will automatically snap the edge labels to snap lines.
|
void |
setSnappingNodeLabelsEnabled(boolean value)
Specifies whether this context will automatically snap the node labels to snap lines.
|
IInputModeContext |
wrapContext(IInputModeContext context)
Helper method that wraps the given
context so that a ILookup.lookup(Class) query
on the wrapped context for the SnapContext type yields this instance. |
addCleanedUpListener, addCollectSnapResultsListener, addInitializedListener, addInitializingListener, cancelDrag, createSnapResultCanvasObjectDescriptor, createSnapResultsModelManager, dragged, getCurrentInputModeContext, getOriginalLocation, getSnapDistance, getSnapResults, isEnabled, isInitialized, isInitializing, isSnapResultVisualizationEnabled, onCleanUp, onCollectSnapResults, onInitialized, onInitializing, processSnapResults, removeCleanedUpListener, removeCollectSnapResultsListener, removeInitializedListener, removeInitializingListener, setEnabled, setSnapDistance, setSnapResultVisualizationEnabledpublic LabelSnapContext()
LabelSnapContext class.public final void addCollectSnapLinesListener(IEventHandler<CollectLabelSnapLineEventArgs> collectSnapLinesEvent)
CollectSnapLines event that occurs every time this instance has been initialized
to collect SnapLines.
Event handlers should add snap lines to the caller using the methods provided by CollectLabelSnapLineEventArgs.
collectSnapLinesEvent - The listener to add.removeCollectSnapLinesListener(IEventHandler)public final void addSnapLine(SnapLine snapLine)
snapLine to the snap line collection of this context.snapLine - The snap line to add.GraphSnapContext.getAdditionalSnapLines()protected void cleanUp()
SnapContext
This is called in response to SnapContext.cancelDrag() and SnapContext.dragFinished(PointD, boolean) as well as initially
during SnapContext.initializeDrag(IInputModeContext, PointD).
cleanUp in class SnapContextpublic SnapState dragFinished(PointD newLocation, boolean snappingDisabled)
SnapContext
Clears all temporary lists and sets IsInitialized back to false. Also the SnapContext.cleanUp()
method is invoked and the CleanedUp event is triggered.
dragFinished in class SnapContextnewLocation - The current mouse location.snappingDisabled - If set to true snapping is temporarily disabled. This will remove the snap line visualizations and return a SnapState
with the unchanged coordinates and the SnapTypes.NOT_SNAPPED SnapType.SnapState that specifies the adjusted coordinates and how they have been adjusted. The unchanged coordinates
if snapping has been temporarily disabled by setting snappingDisabled to true.public void dragInitialized()
SnapContextSnap lines represent possible horizontal or vertical lines to which a moved item can "snap".
This method is called at the start of MoveInputMode's or
HandleInputMode's gesture after all items to be moved or reshaped have been
added.
dragInitialized in class SnapContextpublic final double getSnapLineExtension()
The default is 40.0d, this value will be used to prolongate the ends of the snap lines.
setSnapLineExtension(double)public final IEnumerable<SnapLine> getSnapLines()
snap lines that have been added to this context.
This collection is only available if IsInitialized is true.
addSnapLine(SnapLine)public SnapState handleMove(PointD newLocation, boolean snappingDisabled)
SnapContext
This method returns the adjusted (mouse) coordinates. It also manages the collection of SnapResults. If snapping
should be temporarily (for a mouse move) disabled, snappingDisabled has to be set to true.
handleMove in class SnapContextnewLocation - The current mouse location.snappingDisabled - If set to true snapping is temporarily disabled. This will remove the snap line visualizations and return a SnapState
with the unchanged coordinates and the SnapType SnapTypes.NOT_SNAPPED.snappingDisabled to true.public void initializeDrag(IInputModeContext context, PointD originalLocation)
SnapContextIInputMode implementations when an interactive drag is started.
Updates IsInitializing, OriginalLocation, and CurrentInputModeContext
and then triggers the Initializing event.
initializeDrag in class SnapContextcontext - The context in which the interactive drag is started.originalLocation - The original location of the mouse.public final boolean isCollectingAllEdgeDistanceSnapLinesEnabled()
The default is false.
true if this instance should collect this kind of snap lines; false otherwise.setCollectingAllEdgeDistanceSnapLinesEnabled(boolean)public final boolean isCollectingAllNodeDistanceSnapLinesEnabled()
Note that the label snaps to these snap lines with the side that is closer to the node's border. That way, snapping to such a snap line preserves the perceived distance from the node border for both labels inside and outside the node bounds.
The default is false.
true if this instance should collect this kind of snap lines; false otherwise.setCollectingAllNodeDistanceSnapLinesEnabled(boolean)public final boolean isCollectingEdgePathSnapLinesEnabled()
The default is true.
true if this instance should collect this kind of snap lines; false otherwise.setCollectingEdgePathSnapLinesEnabled(boolean)public final boolean isCollectingInitialLocationSnapLinesEnabled()
The default is true.
true if this instance should collect snap lines for the initial position of a label; false otherwise.setCollectingInitialLocationSnapLinesEnabled(boolean)public final boolean isCollectingNodeShapeSnapLinesEnabled()
The default is true.
true if this instance should collect snap lines through the border and center of the label owner; otherwise,
false.setCollectingNodeShapeSnapLinesEnabled(boolean)public final boolean isCollectingOwnEdgeDistanceSnapLinesEnabled()
The default is true.
true if this instance should collect this kind of snap lines; false otherwise.setCollectingOwnEdgeDistanceSnapLinesEnabled(boolean)public final boolean isCollectingOwnNodeDistanceSnapLinesEnabled()
Note that the label snaps to these snap lines with the side that is closer to the node's border. That way, snapping to such a snap line preserves the perceived distance from the node border for both labels inside and outside the node bounds.
The default is true.
true if this instance should collect snap lines through the border and center of the label owner; otherwise,
false.setCollectingOwnNodeDistanceSnapLinesEnabled(boolean)public final boolean isCollectingSameOwnerEdgeDistanceSnapLinesEnabled()
The default is true.
true if this instance should collect this kind of snap lines; false otherwise.setCollectingSameOwnerEdgeDistanceSnapLinesEnabled(boolean)public final boolean isCollectingSameOwnerNodeDistanceSnapLinesEnabled()
Note that the label snaps to these snap lines with the side that is closer to the node's border. That way, snapping to such a snap line preserves the perceived distance from the node border for both labels inside and outside the node bounds.
The default is true.
true if this instance should collect this kind of snap lines; false otherwise.setCollectingSameOwnerNodeDistanceSnapLinesEnabled(boolean)public final boolean isSnappingEdgeLabelsEnabled()
The default is true.
true if edge labels will snap to snap lines; false otherwise.setSnappingEdgeLabelsEnabled(boolean)public final boolean isSnappingNodeLabelsEnabled()
The default is true.
true if node labels will snap to snap lines; false otherwise.setSnappingNodeLabelsEnabled(boolean)protected void onCollectSnapLines(CollectLabelSnapLineEventArgs args)
CollectSnapLines event.args - The CollectLabelSnapLineEventArgs instance containing the event data.public final void removeCollectSnapLinesListener(IEventHandler<CollectLabelSnapLineEventArgs> collectSnapLinesEvent)
CollectSnapLines event that occurs every time this instance has been initialized
to collect SnapLines.
Event handlers should add snap lines to the caller using the methods provided by CollectLabelSnapLineEventArgs.
collectSnapLinesEvent - The listener to remove.addCollectSnapLinesListener(IEventHandler)public final void setCollectingAllEdgeDistanceSnapLinesEnabled(boolean value)
The default is false.
value - true if this instance should collect this kind of snap lines; false otherwise.isCollectingAllEdgeDistanceSnapLinesEnabled()public final void setCollectingAllNodeDistanceSnapLinesEnabled(boolean value)
Note that the label snaps to these snap lines with the side that is closer to the node's border. That way, snapping to such a snap line preserves the perceived distance from the node border for both labels inside and outside the node bounds.
The default is false.
value - true if this instance should collect this kind of snap lines; false otherwise.isCollectingAllNodeDistanceSnapLinesEnabled()public final void setCollectingEdgePathSnapLinesEnabled(boolean value)
The default is true.
value - true if this instance should collect this kind of snap lines; false otherwise.isCollectingEdgePathSnapLinesEnabled()public final void setCollectingInitialLocationSnapLinesEnabled(boolean value)
The default is true.
value - true if this instance should collect snap lines for the initial position of a label; false otherwise.isCollectingInitialLocationSnapLinesEnabled()public final void setCollectingNodeShapeSnapLinesEnabled(boolean value)
The default is true.
value - true if this instance should collect snap lines through the border and center of the label owner; otherwise,
false.isCollectingNodeShapeSnapLinesEnabled()public final void setCollectingOwnEdgeDistanceSnapLinesEnabled(boolean value)
The default is true.
value - true if this instance should collect this kind of snap lines; false otherwise.isCollectingOwnEdgeDistanceSnapLinesEnabled()public final void setCollectingOwnNodeDistanceSnapLinesEnabled(boolean value)
Note that the label snaps to these snap lines with the side that is closer to the node's border. That way, snapping to such a snap line preserves the perceived distance from the node border for both labels inside and outside the node bounds.
The default is true.
value - true if this instance should collect snap lines through the border and center of the label owner; otherwise,
false.isCollectingOwnNodeDistanceSnapLinesEnabled()public final void setCollectingSameOwnerEdgeDistanceSnapLinesEnabled(boolean value)
The default is true.
value - true if this instance should collect this kind of snap lines; false otherwise.isCollectingSameOwnerEdgeDistanceSnapLinesEnabled()public final void setCollectingSameOwnerNodeDistanceSnapLinesEnabled(boolean value)
Note that the label snaps to these snap lines with the side that is closer to the node's border. That way, snapping to such a snap line preserves the perceived distance from the node border for both labels inside and outside the node bounds.
The default is true.
value - true if this instance should collect this kind of snap lines; false otherwise.isCollectingSameOwnerNodeDistanceSnapLinesEnabled()public final void setSnapLineExtension(double value)
The default is 40.0d, this value will be used to prolongate the ends of the snap lines.
value - The amount by which snap lines that are induced by existing edge segments are being extended.getSnapLineExtension()public final void setSnappingEdgeLabelsEnabled(boolean value)
The default is true.
value - true if edge labels will snap to snap lines; false otherwise.isSnappingEdgeLabelsEnabled()public final void setSnappingNodeLabelsEnabled(boolean value)
The default is true.
value - true if node labels will snap to snap lines; false otherwise.isSnappingNodeLabelsEnabled()public IInputModeContext wrapContext(IInputModeContext context)
SnapContextcontext so that a ILookup.lookup(Class) query
on the wrapped context for the SnapContext type yields this instance.wrapContext in class SnapContextcontext - The context to wrap and delegate all calls to.SnapContext type.