C

BorderLine

This class can be used to easily model an orthogonal borderline or sky-line.
Inheritance Hierarchy

Remarks

It provides methods for measuring the distance between different BorderLine instances, merging multiple instances, modifying, and efficiently moving them around.

See Also

Developer's Guide

Members

No filters for this type

Constructors

Initializes a new instance of the BorderLine class, representing a single segment that extends from the lowest possible position (-Number.MAX_VALUE) to the highest possible position (+ Number.MAX_VALUE) with a constant value.

Parameters

value: number
the value of the segment
Initializes a new instance of the BorderLine class, representing a single segment that extends from the specified min position to the specified max position with a constant value.

Parameters

min: number
The starting position of the BorderLine
max: number
The ending position of the BorderLine
value: number
The value of the segment
Initializes a new instance of the BorderLine class, representing a single segment that extends from the specified min position to the specified max position.

Parameters

min: number
The starting position of the BorderLine
max: number
The ending position of the BorderLine
valueAtMin: number
The value at the starting position of the segment
valueAtMax: number
The value at the ending position of the segment

Properties

Returns the first segment or null if there is no such segment.
readonlyfinal
Returns the last segment or null if there is no such segment.
readonlyfinal
Gets the highest position of this border line
readonlyfinal
Gets the highest value that is set on this borderline
readonlyfinal

Property Value

the value
Gets the lowest position of this borderline
readonlyfinal
Gets the lowest value that is set on this borderline
readonlyfinal

Property Value

the value

Methods

Adds the given offset to the segments' positions.
This method has complexity O(1).
final

Parameters

delta: number
the delta to add to the positions
Adds the given offset to the current values of the whole borderline.
This method has complexity O(1).
final

Parameters

delta: number
The delta to add to the values
Creates a copy of this borderline, optionally negating the values or offsets
final

Parameters

negateValues?: boolean
whether the values are negated
negateOffsets?: boolean
whether the offsets are negated

Return Value

BorderLine
the copy of the borderline
Merges this borderline with the given borderline using the "maximum" policy.
That means the resulting borderline will have a greater value of both borderlines on each position. If you imagine each borderline as the upper border of a plane, the resulting borderline will be the upper border of the merged planes.
final

Parameters

other: BorderLine
the other borderline

Return Value

BorderLine
a new borderline that is the result of the merge
Merges this borderline with the given borderline using the "minimum" policy.
That means the resulting borderline will have a smaller value of both borderlines on each position. If you imagine each borderline as the lower border of a plane, the resulting borderline will be the lower border of the merged planes.
final

Parameters

other: BorderLine
the other borderline

Return Value

BorderLine
a new borderline that is the result of the merge
Enlarges this borderline horizontally, so that the values of the borderline stay the same however their starting and ending positions are moved in the direction of toMin and toMax.

This is useful for scenarios where a borderline is needed that consists of an enlarged border.

Note that this method normalizes the segments, i.e., it transforms each segment with slope != 0 to a segment with slope == 0.

final

Parameters

toMin: number
the delta by which the border should be extended towards -Infinity
toMax: number
the delta by which the border should be extended towards +Infinity
positive: boolean
whether the borderline should be interpreted to point in positive direction. This influences the direction into which a segment's border is extended.
Calculates the minimum distance between this borderline and the other one.
The other one is treated as if the values were all greater.
final

Parameters

greater: BorderLine
The other borderline to which the distance is calculated.

Return Value

number
The minimum distance between this borderline and the other one.
Returns the highest position of the given segment.
final

Parameters

segment: BorderLineSegment
The segment

Return Value

number
The highest position of the given segment.
Calculates the maximum value in the interval specified by position from and position to.
If the from value is larger or equal to the to value, the algorithm always returns -Number.MAX_VALUE.
final

Parameters

from: number
The starting position of the interval.
to: number
The ending position of the interval.

Return Value

number
The maximum value in the interval specified by position from and position to.
Returns the lowest position of the given segment.
final

Parameters

segment: BorderLineSegment
The segment

Return Value

number
The lowest position of the given segment.
Calculates the minimum value in the interval specified by position from and position to.
If the from value is larger or equal to the to value, the algorithm always returns Number.MAX_VALUE.
final

Parameters

from: number
The starting position of the interval.
to: number
The ending position of the interval.

Return Value

number
The minimum value in the interval specified by position from and position to.
Returns the segment at the given position.
final

Parameters

position: number
The position

Return Value

BorderLineSegment
The segment at the given position.
Returns the slope of the given segment.
final

Parameters

segment: BorderLineSegment
The segment

Return Value

number
The slope of the given segment.
Returns the value at the lowest position of the given segment.
If the segment's slope is 0, it is the value of the whole segment. In case the slope differs from 0, it is the value of the start of the slope.
final

Parameters

segment: BorderLineSegment
The segment

Return Value

number
The value at the lowest position of the given segment.
Returns the value that is set on this borderline at the specified position.
final

Parameters

position: number
The position for which the value is to be returned

Return Value

number
The value

Throws

Exception ({ name: 'IndexOutOfRangeError' })
If the position is outside the borderline.
Returns the value that is set on this borderline at the specified position.
The position must lie within the range of the segment.
final

Parameters

segment: BorderLineSegment
The segment for which the value is to be returned
position: number
The position for which the value is to be returned

Return Value

number
The value

Throws

Exception ({ name: 'ArgumentError' })
if position is outside the segment's range.
Merges this borderline with the given borderline using the "maximum" policy.
final

Parameters

other: BorderLine
the other borderline
Merges this borderline with the given borderline using the "minimum" policy.
final

Parameters

other: BorderLine
the other borderline
Assures that all values in the given interval are greater than or equal to the given value.
final

Parameters

min: number
the lower position of the interval
max: number
the upper position of the interval
value: number
the smallest possible value for the interval
Assures that all values in the given interval are less than or equal to the given value.
final

Parameters

min: number
the lower position of the interval
max: number
the upper position of the interval
value: number
the greatest possible value for the interval
Sets a specific interval specified by position min and position max to a slope starting at a given value.
final

Parameters

min: number
The lower position of the interval.
max: number
The upper position of the interval.
value: number
The value at min where the slope starts.
slope: number
The slope of the segment in the given interval.

Throws

Exception ({ name: 'ArgumentError' })
If min is greater than max.
Sets a specific interval specified by position min and position max to a given value.
final

Parameters

min: number
The lower position of the interval.
max: number
The upper position of the interval.
value: number
The value for the whole interval.
Returns a lengthy string representation of this borderline.
final

Return Value

string
A lengthy string representation of this borderline.