public class OrthogonalEdgeHelper extends Object implements IOrthogonalEdgeHelper
IOrthogonalEdgeHelper
.
This class inspects the edges in question and infers the
SegmentOrientation
s of the segments from the current geometry of the edge path.
Constructor and Description |
---|
OrthogonalEdgeHelper() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
canRemoveBend(IInputModeContext context,
IBend bend)
Returns whether the given bend can be removed.
|
void |
cleanUpEdge(IInputModeContext context,
IGraph graph,
IEdge edge)
Callback method that is invoked after the provided edge has been edited orthogonally.
|
SegmentOrientation |
getSegmentOrientation(IInputModeContext context,
IEdge edge,
int segmentIndex)
Gets the orientation of the given segment by looking at the geometry of the segment.
|
boolean |
shouldEditOrthogonally(IInputModeContext context,
IEdge edge)
Determines whether the provided edge should be edited orthogonally in the specified input mode context.
|
boolean |
shouldMoveEndImplicitly(IInputModeContext context,
IEdge edge,
boolean sourceEnd)
Determines whether this end of the provided edge can be moved in the input mode context.
|
protected boolean canRemoveBend(IInputModeContext context, IBend bend)
This implementation always returns true
.
context
- The input mode context.bend
- The bend that is designated for removal.public void cleanUpEdge(IInputModeContext context, IGraph graph, IEdge edge)
The default implementation in this class removes duplicate and collinear bends, as well as segments of zero length.
cleanUpEdge
in interface IOrthogonalEdgeHelper
context
- The input mode context which edited the edge.graph
- The graph to use for modifying the edge instance.edge
- The edge to clean up the path.public SegmentOrientation getSegmentOrientation(IInputModeContext context, IEdge edge, int segmentIndex)
If the segment has a zero length, the adjacent segments will be inspected to infer the orientation such that the
orientation toggles between SegmentOrientation.VERTICAL
and SegmentOrientation.HORIZONTAL
.
getSegmentOrientation
in interface IOrthogonalEdgeHelper
context
- The input mode context in which the orientation is needed.edge
- The edge to inspect.segmentIndex
- The index of the segment.public boolean shouldEditOrthogonally(IInputModeContext context, IEdge edge)
If this method returns false
, the other methods will not be queried at all.
The default implementation in this class always returns true
.
shouldEditOrthogonally
in interface IOrthogonalEdgeHelper
context
- The input mode context in which the edge is about to be edited.edge
- The edge to inspect.true
if the edge should be orthogonally edited in the specified input mode context; false
otherwise.public boolean shouldMoveEndImplicitly(IInputModeContext context, IEdge edge, boolean sourceEnd)
This information is required to determine whether an edge's first or last segment needs to be split or the adjacent edge end can be moved along with the other end of the segment.
The default implementation in this class always returns false
.
shouldMoveEndImplicitly
in interface IOrthogonalEdgeHelper
context
- The input mode context in which the segment is edited.edge
- The edge to inspect.sourceEnd
- if set to true
the source end of the edge is queried, otherwise the target end.true
if the end of the edge can be moved for the specified input mode context; false
otherwise, in which
case the corresponding segment needs to be split to keep the segment orientation orthogonal.