|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.view.AbstractSnapContext y.view.MoveSnapContext
public class MoveSnapContext
A class that provides the context for mouse snapping during move operations.
This class supports the moving of nodes and bends (both single bends, as well as orthogonal segments).
Instances of this class are used in MoveSelectionMode
, OrthogonalMoveBendsMode
, and DropSupport
.
Nested Class Summary | |
---|---|
static class |
MoveSnapContext.MovingBendInfo
Concrete subclass of MoveSnapContext.MovingInfo that
describes the movement of a Bend . |
static class |
MoveSnapContext.MovingInfo
The abstract base class of the classes that describe items that will be moved in the context of the move operation that is described by the MoveSnapContext . |
static class |
MoveSnapContext.MovingPortInfo
Concrete subclass of MoveSnapContext.MovingInfo that
describes the movement of a Port . |
static class |
MoveSnapContext.MovingSegment
A helper class that describes a moving segment. |
Field Summary | |
---|---|
static byte |
FIXED
Constant for use in MoveSnapContext.MovingInfo and its subclasses
that indicates that an item stays fixed at its current location. |
static byte |
MOVE_X
Constant for use in MoveSnapContext.MovingInfo and its subclasses
that indicates that an item is moved in the direction of the x axis according to
the interactive movement. |
static byte |
MOVE_XY
Constant for use in MoveSnapContext.MovingInfo and its subclasses
that indicates that an item is moved according to
the interactive movement. |
static byte |
MOVE_Y
Constant for use in MoveSnapContext.MovingInfo and its subclasses
that indicates that an item is moved in the direction of the y axis according to
the interactive movement. |
Constructor Summary | |
---|---|
MoveSnapContext()
Creates a new instance of this class using no initial view . |
|
MoveSnapContext(Graph2DView view)
Creates a new instance of this class using the provided view for the initial view . |
Method Summary | |
---|---|
protected void |
addFixedSnapLines(Node node,
java.util.Collection snapLines,
java.util.Collection fixedSegmentSnapLines)
Callback method that collects SnapLine s that are induced by a given node. |
protected void |
addNodeSnapLines(Node node,
NodeRealizer realizer,
java.util.Collection nodeSnapLines,
java.util.Collection edgeSnapLines)
Callback method that collects snap lines for fixed nodes that are currently visible. |
MoveSnapContext.MovingSegment |
addSegment(MoveSnapContext.MovingInfo segStart,
MoveSnapContext.MovingInfo segEnd)
Tries to add another segment to this instance based on two MoveSnapContext.MovingInfo s. |
void |
addSegment(MoveSnapContext.MovingSegment segment)
Adds another segment to this instance that should be considered during the adjustMouseCoordinates(y.geom.YPoint)
This method can be used to provide this class with segments that cannot be easily obtained from the graph structure. |
protected void |
addTableGroupNodeSnapLines(Node node,
TableGroupNodeRealizer realizer,
java.util.Collection result,
java.util.Collection edgeSnapLines)
A specialized variant of addNodeSnapLines(y.base.Node, NodeRealizer, java.util.Collection, java.util.Collection)
that will be used if the realizer of the node is a TableGroupNodeRealizer . |
YPoint |
adjustMouseCoordinates(YPoint newMouseCoordinates)
Main method that can be called after initialization
and before cleanUp() that will snap the coordinates and update the Drawable s. |
void |
cleanUp()
Needs to be called after the move operation has been finalized. |
protected void |
collectSnapLines(java.util.Collection fixedNodeSnapLines,
java.util.Collection fixedSegmentSnapLines)
This method will be called to collect all snap lines for the nodes and edges that will be used during the processing of adjustMouseCoordinates(y.geom.YPoint) . |
protected SnapResult |
createGridSnapResult(YPoint initialMouseCoordinates,
java.util.Collection nodesToBeMoved,
java.util.Collection movingBendInfos,
java.util.Collection movingPortInfos,
DataProvider nodeLocations)
Returns a snap result to be used for grid snapping. |
double |
getBendToBendDistance()
Determines the distance for bends to snap to other bends. |
double |
getEdgeToEdgeDistance()
Gets the preferred distance between edges. |
double |
getGridSnapDistance()
Determines the snap distance for grid snapping. |
double |
getNodeToEdgeDistance()
Gets the preferred distance between node borders and edge segments. |
double |
getNodeToNodeDistance()
Gets the preferred distance between node borders. |
double |
getSnapLineExtension()
Yields the amount by which snap lines that are induced by existing edge segments and node borders are being extended. |
void |
initializeMove(YPoint initialMouseCoordinates,
java.util.Collection nodesToBeMoved,
java.util.Collection movingBendInfos,
java.util.Collection movingPortInfos,
DataProvider nodeLocations)
Prepares this instance to perform subsequent adjustments
of the mouse coordinates during a move operation. |
boolean |
isInitialized()
Checks whether this instance has been initializeMove(y.geom.YPoint, java.util.Collection, java.util.Collection, java.util.Collection, y.base.DataProvider)
but not yet cleaned up . |
boolean |
isSnappingBendsToSnapLines()
Whether this context will automatically snap the bends to snap lines. |
boolean |
isSnappingSegmentsToSnapLines()
Determines whether this context will automatically snap orthogonal edge segments to snap lines. |
boolean |
isUsingCenterSnapLines()
Determines whether this instance will try to align the centers of adjacent nodes so that their centers are equally far away from each other. |
boolean |
isUsingEquidistantSnapLines()
Determines whether this instance will try to align moved nodes with adjacent nodes so that there is the same spacing between their borders. |
boolean |
isUsingFixedNodeSnapLines()
Determines whether this context will use snap lines for the sides and centers of the fixed nodes. |
boolean |
isUsingGridSnapping()
Determines whether this instance will try snap the centers of moved graph elements to the grid. |
boolean |
isUsingOrthogonalBendSnapping()
Whether this context will automatically snap the movements of bends so that the two adjacent segments become horizontally or vertically oriented. |
boolean |
isUsingOrthogonalMovementConstraints()
Whether this context will automatically snap the movement in such a way that the overall move gesture is constrained to the horizontal or vertical axis. |
boolean |
isUsingOrthogonalPortSnapping()
Whether this context will automatically snap the movements of bends or nodes so that the first and last segments of edges become orthogonal. |
boolean |
isUsingSegmentSnapLines()
Determines whether this mode should create snap lines for fixed orthogonal edge segments. |
void |
removeSegment(MoveSnapContext.MovingSegment tag)
Removes a previously added segment from this instance. |
void |
setBendToBendDistance(double d)
Specifies the distance for bends to snap to other bends. |
void |
setEdgeToEdgeDistance(double edgeToEdgeDistance)
Sets the preferred distance between edges. |
void |
setGridSnapDistance(double gridSnapDistance)
Sets the snap distance for grid snapping. |
void |
setNodeToEdgeDistance(double nodeToEdgeDistance)
Sets the preferred distance between node borders and edge segments. |
void |
setNodeToNodeDistance(double nodeToNodeDistance)
Sets the preferred distance between node borders. |
void |
setSnapLineExtension(double snapLineExtension)
Sets the amount by which snap lines that are induced by existing edge segments and node borders are being extended. |
void |
setSnappingBendsToSnapLines(boolean snappingBendsToSnapLines)
Determines whether this context will automatically snap the bends to snap lines. |
void |
setSnappingSegmentsToSnapLines(boolean snappingSegmentsToSnapLines)
Determines whether this context will automatically snap orthogonal edge segments to snap lines. |
void |
setUsingCenterSnapLines(boolean usingCenterSnapLines)
Sets whether this instance will try to align the centers of adjacent nodes so that their centers are equally far away from each other. |
void |
setUsingEquidistantSnapLines(boolean usingEquidistantSnapLines)
Sets whether this instance will try to align moved nodes with adjacent nodes so that there is the same spacing between their borders. |
void |
setUsingFixedNodeSnapLines(boolean usingFixedNodeSnapLines)
Sets whether this context will use snap lines for the sides and centers of the fixed nodes. |
void |
setUsingGridSnapping(boolean usingGridSnapping)
Sets whether this instance will try snap the centers of moved graph elements to the grid. |
void |
setUsingOrthogonalBendSnapping(boolean usingOrthogonalBendSnapping)
Determines whether this context will automatically snap the movements of bends so that the two adjacent segments become horizontally or vertically oriented. |
void |
setUsingOrthogonalMovementConstraints(boolean usingOrthogonalMovementConstraints)
Determines whether this context will automatically snap the movement in such a way that the overall move gesture is constrained to the horizontal or vertical axis. |
void |
setUsingOrthogonalPortSnapping(boolean usingOrthogonalPortSnapping)
Determines whether this context will automatically snap the movements of bends or nodes so that the first and last segments of edges become orthogonal. |
void |
setUsingSegmentSnapLines(boolean usingSegmentSnapLines)
Determines whether this mode should create snap lines for fixed orthogonal edge segments. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte FIXED
MoveSnapContext.MovingInfo
and its subclasses
that indicates that an item stays fixed at its current location.
MOVE_X
,
MOVE_Y
,
MOVE_XY
,
Constant Field Valuespublic static final byte MOVE_X
MoveSnapContext.MovingInfo
and its subclasses
that indicates that an item is moved in the direction of the x axis according to
the interactive movement.
This constant can be bitwise combined with MOVE_Y
MOVE_Y
,
MOVE_XY
,
Constant Field Valuespublic static final byte MOVE_Y
MoveSnapContext.MovingInfo
and its subclasses
that indicates that an item is moved in the direction of the y axis according to
the interactive movement.
This constant can be bitwise combined with MOVE_X
MOVE_X
,
MOVE_XY
,
Constant Field Valuespublic static final byte MOVE_XY
MoveSnapContext.MovingInfo
and its subclasses
that indicates that an item is moved according to
the interactive movement.
This constant is a bitwise combination of MOVE_X
and MOVE_Y
.
MOVE_X
,
MOVE_Y
,
Constant Field ValuesConstructor Detail |
---|
public MoveSnapContext()
view
.
The view needs to be set
before this context can
be initialized
.
public MoveSnapContext(Graph2DView view)
view
.
view
- the view to use.initializeMove(y.geom.YPoint, java.util.Collection, java.util.Collection, java.util.Collection, y.base.DataProvider)
Method Detail |
---|
public boolean isInitialized()
initializeMove(y.geom.YPoint, java.util.Collection, java.util.Collection, java.util.Collection, y.base.DataProvider)
but not yet cleaned up
.
Only initialized instances will perform useful tasks in adjustMouseCoordinates(y.geom.YPoint)
public double getSnapLineExtension()
40.0d
public void setSnapLineExtension(double snapLineExtension)
40.0d
snapLineExtension
- The positive amount by which snap lines should be extended into the direction of both ends.public boolean isUsingOrthogonalPortSnapping()
true
.
public void setUsingOrthogonalPortSnapping(boolean usingOrthogonalPortSnapping)
true
.
public boolean isSnappingSegmentsToSnapLines()
false
.
public void setSnappingSegmentsToSnapLines(boolean snappingSegmentsToSnapLines)
false
.
public boolean isUsingOrthogonalBendSnapping()
true
.
public void setUsingOrthogonalBendSnapping(boolean usingOrthogonalBendSnapping)
true
.
public double getBendToBendDistance()
The default is 0.0d
which disables bend-to-bend snapping.
setBendToBendDistance(double)
public void setBendToBendDistance(double d)
The default is 0.0d
which disables bend-to-bend snapping.
d
- the distance for bends to snap to other bends.getBendToBendDistance()
public boolean isSnappingBendsToSnapLines()
false
.
public void setSnappingBendsToSnapLines(boolean snappingBendsToSnapLines)
false
.
public boolean isUsingOrthogonalMovementConstraints()
false
.
public void setUsingOrthogonalMovementConstraints(boolean usingOrthogonalMovementConstraints)
false
.
public boolean isUsingFixedNodeSnapLines()
true
.
addFixedSnapLines(y.base.Node, java.util.Collection, java.util.Collection)
public void setUsingFixedNodeSnapLines(boolean usingFixedNodeSnapLines)
true
.
addFixedSnapLines(y.base.Node, java.util.Collection, java.util.Collection)
public boolean isUsingSegmentSnapLines()
false
.
public void setUsingSegmentSnapLines(boolean usingSegmentSnapLines)
false
.
public double getEdgeToEdgeDistance()
0.0d
which disables parallel snap lines.
public void setEdgeToEdgeDistance(double edgeToEdgeDistance)
public double getNodeToNodeDistance()
0.0d
which disables distant snap lines around the nodes.
public void setNodeToNodeDistance(double nodeToNodeDistance)
0.0d
which disables distant snap lines around the nodes.
public double getNodeToEdgeDistance()
0.0d
which disables distant snap lines around the nodes for edge segments.
public void setNodeToEdgeDistance(double nodeToEdgeDistance)
-1.0d
which disables distant snap lines around the nodes for edge segments.
public boolean isUsingCenterSnapLines()
another setting
for distributing nodes evenly, so that there
is the same spacing between their borders, not between their centers. This only makes a difference, if the
nodes are not equally sized.
public void setUsingCenterSnapLines(boolean usingCenterSnapLines)
another setting
for distributing nodes evenly, so that there
is the same spacing between their borders, not between their centers. This only makes a difference, if the
nodes are not equally sized.
public boolean isUsingEquidistantSnapLines()
another setting
for distributing nodes evenly, so that there
is the same spacing between their centers, not between their borders. This only makes a difference, if the
nodes are not equally sized.
public void setUsingEquidistantSnapLines(boolean usingEquidistantSnapLines)
another setting
for distributing nodes evenly, so that there
is the same spacing between their centers, not between their borders. This only makes a difference, if the
nodes are not equally sized.
public boolean isUsingGridSnapping()
view
. The default is false
.
getGridSnapDistance()
public void setUsingGridSnapping(boolean usingGridSnapping)
view
. The default is false
.
setGridSnapDistance(double)
public double getGridSnapDistance()
10.0d
. Note: this is not the
grid width, but a separate snap distance
for grid snapping.
isUsingGridSnapping()
public void setGridSnapDistance(double gridSnapDistance)
10.0d
. Note: this is not the
grid width, but a separate snap distance
for grid snapping.
setUsingGridSnapping(boolean)
public void initializeMove(YPoint initialMouseCoordinates, java.util.Collection nodesToBeMoved, java.util.Collection movingBendInfos, java.util.Collection movingPortInfos, DataProvider nodeLocations)
adjustments
of the mouse coordinates during a move operation.
initialMouseCoordinates
- The mouse coordinates at the beginning of the operation.nodesToBeMoved
- The nodes that will be moved during the operation according to the movement of the mouse.movingBendInfos
- A collection of MoveSnapContext.MovingBendInfo
instances that describe the movement of the bends that will be moved.movingPortInfos
- A collection of MoveSnapContext.MovingPortInfo
instances that describe the movement of the ports that will be moved.nodeLocations
- The original location of the nodes in nodesToBeMoved
. This DataProvider
needs to yield
for each node in the collection a Rectangle2D
that describes the initial bounds of the node.public void cleanUp()
initializeMove(y.geom.YPoint, java.util.Collection, java.util.Collection, java.util.Collection, y.base.DataProvider)
.
cleanUp
in class AbstractSnapContext
protected SnapResult createGridSnapResult(YPoint initialMouseCoordinates, java.util.Collection nodesToBeMoved, java.util.Collection movingBendInfos, java.util.Collection movingPortInfos, DataProvider nodeLocations)
initialization
for a move, if
this snap context uses
the grid. If the result is not null
it is
added
to the list of snap results to be considered subsequently during the move.
This method can be customized in subclasses.
initialMouseCoordinates
- The mouse coordinates at the beginning of the operation.nodesToBeMoved
- The nodes that will be moved during the operation according to the movement of the mouse.movingBendInfos
- A collection of MoveSnapContext.MovingBendInfo
instances that describe the movement of the bends that will be moved.movingPortInfos
- A collection of MoveSnapContext.MovingPortInfo
instances that describe the movement of the ports that will be moved.nodeLocations
- The original location of the nodes in nodesToBeMoved
. This DataProvider
needs to yield
for each node in the collection a Rectangle2D
that describes the initial bounds of the node.
null
initializeMove(YPoint, Collection, Collection, Collection, DataProvider)
,
isUsingGridSnapping()
public void addSegment(MoveSnapContext.MovingSegment segment)
adjustMouseCoordinates(y.geom.YPoint)
This method can be used to provide this class with segments that cannot be easily obtained from the graph structure.
This method therefor will only be used for special purposes.
segment
- a segment that will be moved by this instance.public MoveSnapContext.MovingSegment addSegment(MoveSnapContext.MovingInfo segStart, MoveSnapContext.MovingInfo segEnd)
MoveSnapContext.MovingInfo
s.
addSegment(y.view.MoveSnapContext.MovingSegment)
public void removeSegment(MoveSnapContext.MovingSegment tag)
tag
- a segment that has been added using addSegment(y.view.MoveSnapContext.MovingSegment)
or addSegment(y.view.MoveSnapContext.MovingInfo, y.view.MoveSnapContext.MovingInfo)
, previously.protected void addNodeSnapLines(Node node, NodeRealizer realizer, java.util.Collection nodeSnapLines, java.util.Collection edgeSnapLines)
node
- The node which will stay at its position during the move operation and for which snap lines
shall be calculated.realizer
- The realizer of the node.nodeSnapLines
- The collection to which SnapLine
instances should be added that will be used
to test moving nodes against.edgeSnapLines
- The collection to which SnapLine
instances should be added that will be used to test moving
orthogonal segments against.protected void addTableGroupNodeSnapLines(Node node, TableGroupNodeRealizer realizer, java.util.Collection result, java.util.Collection edgeSnapLines)
addNodeSnapLines(y.base.Node, NodeRealizer, java.util.Collection, java.util.Collection)
that will be used if the realizer of the node is a TableGroupNodeRealizer
.
protected void collectSnapLines(java.util.Collection fixedNodeSnapLines, java.util.Collection fixedSegmentSnapLines)
adjustMouseCoordinates(y.geom.YPoint)
. This method is called by initializeMove(y.geom.YPoint, java.util.Collection, java.util.Collection, java.util.Collection, y.base.DataProvider)
during initialization.
fixedNodeSnapLines
- The collection to add all SnapLine
instances to,
that will be used by the moving nodes to snap to.fixedSegmentSnapLines
- The collection to add all SnapLine
instances to,
that will be used by the moving orthogonal edge segments to snap to.public YPoint adjustMouseCoordinates(YPoint newMouseCoordinates)
initialization
and before cleanUp()
that will snap the coordinates and update the Drawable
s.
This method should be called for each update in the mouse coordinates to determine the new coordinates.
If snapping is temporarily disabled, AbstractSnapContext.resetResults()
should be called, instead.
newMouseCoordinates
- The coordinates of the mouse
AbstractSnapContext.resetResults()
protected void addFixedSnapLines(Node node, java.util.Collection snapLines, java.util.Collection fixedSegmentSnapLines)
SnapLine
s that are induced by a given node.
This method delegates to addNodeSnapLines(y.base.Node, NodeRealizer, java.util.Collection, java.util.Collection)
if the corresponding node realizer intersects with the current view
.
node
- The node to collect snaplines for. This node will not be moved for the current context.snapLines
- The collection to add SnapLine
instances to that will be
used to snap other node borders against.fixedSegmentSnapLines
- The collection to add SnapLine
instances to that will be used
to snap orthogonal edge segments to.
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |