TwoColoredArrayRange

open class TwoColoredArrayRange<BoundType : Comparable<BoundType>, LengthType : Comparable<LengthType>, ColorType : Enum<ColorType>> @JvmOverloads constructor(val range: ClosedRange<BoundType>, val step: LengthType, val math: BoundMath<BoundType, LengthType>, val defaultColor: ColorType, val otherColor: ColorType, val rangeFactory: RangeFactory<BoundType> = ClosedRangeFactory()) : MutableTwoColoredRange<BoundType, LengthType, ColorType>

TwoColoredRange implementation using ArrayList. It keeps list of subranges painted with defaultColor and calculates subranges of otherColor when required so requests related to defaultColor are more efficient than ones related to otherColor.

Inheritors

Constructors

Link copied to clipboard
constructor(range: ClosedRange<BoundType>, step: LengthType, math: BoundMath<BoundType, LengthType>, defaultColor: ColorType, otherColor: ColorType, rangeFactory: RangeFactory<BoundType> = ClosedRangeFactory())

Properties

Link copied to clipboard
override val defaultColor: ColorType

the default color, a colored range is supposed to be fully colored with it right after constructor call.

Link copied to clipboard
open override val length: LengthType

the length of colored range.

Link copied to clipboard

the math used for calculating lengths and distances of subranges.

Link copied to clipboard
override val otherColor: ColorType

the second color.

Link copied to clipboard
override val range: ClosedRange<BoundType>

a regular range marking bounds of colored range.

Link copied to clipboard

the factory for ranges, it is used for custom ranges type. For example IntRange is more convenient than ClosedRange<BoundType> for equality checks outside the interface or class.

Link copied to clipboard
override val step: LengthType

the minimal non-zero length of a subrange and distance between two neighbour subranges. Usually it has a value of 1 for integer types of BoundType.

Functions

Link copied to clipboard
open override fun getColor(bound: BoundType): ColorType

Looks for a subrange containing bound and returns its color.

Link copied to clipboard
open override fun getSubrangeOfColor(color: ColorType): ClosedRange<BoundType>?

getSubrangeOfColor called with maxLength = step and limitByRange = range.

open override fun getSubrangeOfColor(color: ColorType, maxLength: LengthType): ClosedRange<BoundType>?

getSubrangeOfColor called with limitByRange = range.

open override fun getSubrangeOfColor(color: ColorType, limitByRange: ClosedRange<BoundType>): ClosedRange<BoundType>?

getSubrangeOfColor called with maxLength = step.

open override fun getSubrangeOfColor(color: ColorType, maxLength: LengthType, limitByRange: ClosedRange<BoundType>): ClosedRange<BoundType>?

Performs a search for a subrange with color color limited by limitByRange. If a subrange with length >= maxLength was found then returns a subrange from foundSubrange.start to foundSubrange.start + maxLength (involving math and rangeFactory). Otherwise returns first non-empty subrange with color color inside limitByRange or null.

Link copied to clipboard

Returns list of subranges colored with color.

Link copied to clipboard

Returns list of subranges colored with defaultColor.

Link copied to clipboard

Returns list of subranges colored with otherColor.

Link copied to clipboard
open operator override fun iterator(): Iterator<Pair<ClosedRange<BoundType>, ColorType>>
Link copied to clipboard
open override fun setSubrangeColor(subrange: ClosedRange<BoundType>, color: ColorType)

Paints subrange with color overriding any previous colors the subrange contained.

Link copied to clipboard
open override fun setSubrangeDefaultColor(subrange: ClosedRange<BoundType>)

Paints subrange with defaultColor overriding any previous colors the subrange contained.

Link copied to clipboard
open override fun setSubrangeOtherColor(subrange: ClosedRange<BoundType>)

Paints subrange with otherColor overriding any previous colors the subrange contained.

Link copied to clipboard

Iterator limited by limitByRange.