The angle of a segment

Many applications use orthogonal segments, that is, the angle of a segment can be 0 degrees (horizontal) or 90 degrees (vertical).
IlvSegmentedHyperEdge supports orthogonal segments and also segments with a different fixed angle. It also supports segments with variable angle.

Fixed angle or variable angle

A segment with fixed angle always keeps this angle. When incident segments or end nodes are moved or dragged, a segment will become longer or shorter to stay visually connected, but it will not change its angle. This is shown in figures Orthogonal segments with fixed angle and Segments with fixed angle of 45 degrees.
orthdragnode.gif
Orthogonal segments with fixed angle
In figure Orthogonal segments with fixed angle, when end nodes are dragged, the segments remain orthogonal. They only get longer.
diagdragnode.gif
Segments with fixed angle of 45 degrees
In figure Segments with fixed angle of 45 degrees, when end nodes are dragged, the segments don't change their angle. They only get longer.
A segment with variable angle always adapts the angle to the situation automatically. When incident segments or end nodes are moved or dragged, the segment will change its angle. This is shown in figure Segments with variable angle.
vardragnode.gif
Segments with variable angle
In figure Segments with variable angle, when end nodes are dragged, the segments change the angle.
Whether a segment has a variable angle or a fixed angle depends on how the segment was created. This is described later, in Segment operations.
To test whether a segment has a variable or a fixed angle, call the method:
segment.isVariable()
The angle of a segment is always given in degrees between 0 and 180, where 0 means horizontal and 90 means vertical.
To query the angle of the segment, call the method:
segment.getAngle()

Constraints of variable and fixed angle segments

In the segment tree, segments of fixed or variable angle can be incident, but there are some constraints:
  • A segment with fixed angle can be incident to any number of other segments with fixed or variable angle.
  • A segment with fixed angle cannot be incident to a segment with the same fixed angle. For example, a horizontal segment cannot be incident to another horizontal segment. If the shape of the hyperedge is orthogonal, then horizontal segments will be incident to vertical segments and vertical segments will be incident to horizontal segments. Segments with the same angle are called colinear. See isColinear. For mathematical reasons, it is required that the angle differs at least by 1 degree.
  • A segment with fixed angle can only be connected to at most one hyperedge end ( getEnds() returns an array with at most 1 end).
  • A segment with variable angle can be incident to any number of other segments with variable angle.
  • A segment with variable angle usually starts or ends at a node or at a segment. In the latter case, it is said to be terminated by a segment. The terminating segments of a segment with variable angle can have a fixed angle or a variable angle.
  • A segment with variable angle can only be incident to at most two segments with fixed angle. The two segments with fixed angle must terminate the segment with variable angle. See figure Hyperedge consisting of segments of fixed and variable angle.
  • A segment with variable angle can be connected to 0, 1, or 2 hyperedge ends ( getEnds() returns an array with at most 2 ends).
varfixsegments.gif
Hyperedge consisting of segments of fixed and variable angle
  • Segments with fixed angle are blue.
  • Segments with variable angle are red.
  • The long red segment in the middle of the figure is terminated by segments of fixed angle.