Package org.fxmisc.richtext.model
Class TwoLevelNavigator
- java.lang.Object
-
- org.fxmisc.richtext.model.TwoLevelNavigator
-
- All Implemented Interfaces:
TwoDimensional
public class TwoLevelNavigator extends Object implements TwoDimensional
Default implementation ofTwoDimensional
that makes it trivial to calculate a position within a two dimensional object.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.fxmisc.richtext.model.TwoDimensional
TwoDimensional.Bias, TwoDimensional.Position
-
-
Constructor Summary
Constructors Constructor Description TwoLevelNavigator(IntSupplier elemCount, IntUnaryOperator elemLength)
Creates a navigator that can be used to find aTwoDimensional.Position
within a two dimensional object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TwoDimensional.Position
offsetToPosition(int offset, TwoDimensional.Bias bias)
Creates a two dimensional position in some entity (e.g.TwoDimensional.Position
position(int major, int minor)
Creates a two dimensional position in some entity (e.g.
-
-
-
Constructor Detail
-
TwoLevelNavigator
public TwoLevelNavigator(IntSupplier elemCount, IntUnaryOperator elemLength)
Creates a navigator that can be used to find aTwoDimensional.Position
within a two dimensional object.- Parameters:
elemCount
- a supplier that returns the number of "inner lists" within an "outer list" (seeTwoDimensional
for clarification). For example,List::size
elemLength
- a function that, given the index of an "inner list," returns either the size of that "inner list" of the length of that inner object.
-
-
Method Detail
-
position
public TwoDimensional.Position position(int major, int minor)
Description copied from interface:TwoDimensional
Creates a two dimensional position in some entity (e.g. area, list of lists, list of some object with length) where themajor
value is the index within the outer list) and theminor
value is either the index within the inner list or some amount of length in a list of objects that have length.- Specified by:
position
in interfaceTwoDimensional
-
offsetToPosition
public TwoDimensional.Position offsetToPosition(int offset, TwoDimensional.Bias bias)
Description copied from interface:TwoDimensional
Creates a two dimensional position in some entity (e.g. area, list of lists, list of some object with length) where theoffset
value is an absolute position in that entity.- Specified by:
offsetToPosition
in interfaceTwoDimensional
-
-