Top Description Inners Fields Constructors Methods
org.fxmisc.richtext.model

public Class TwoLevelNavigator

extends Object
implements TwoDimensional
Class Inheritance
All Implemented Interfaces
org.fxmisc.richtext.model.TwoDimensional
Static Imports
org.fxmisc.richtext.model.TwoDimensional.Bias.*

Default implementation of TwoDimensional that makes it trivial to calculate a position within a two dimensional object.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final IntSupplier
private final IntUnaryOperator

Constructor Summary

AccessConstructor and Description
public
TwoLevelNavigator(IntSupplier
a supplier that returns the number of "inner lists" within an "outer list" (see TwoDimensional for clarification). For example, List::size
elemCount
,
IntUnaryOperator
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.
elemLength
)

Creates a navigator that can be used to find a TwoDimensional.Position within a two dimensional object.

Method Summary

Modifier and TypeMethod and Description
public TwoDimensional.Position
offsetToPosition(int offset, TwoDimensional.Bias bias)

Implements org.fxmisc.richtext.model.TwoDimensional.offsetToPosition.

Creates a two dimensional position in some entity (e.g. area, list of lists, list of some object with length) where the offset value is an absolute position in that entity.

public TwoDimensional.Position
position(int major, int minor)

Implements org.fxmisc.richtext.model.TwoDimensional.position.

Creates a two dimensional position in some entity (e.g. area, list of lists, list of some object with length) where the major value is the index within the outer list) and the minor value is either the index within the inner list or some amount of length in a list of objects that have length.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

elemCountback to summary
private final IntSupplier elemCount
elemLengthback to summary
private final IntUnaryOperator elemLength

Constructor Detail

TwoLevelNavigatorback to summary
public TwoLevelNavigator(IntSupplier elemCount, IntUnaryOperator elemLength)

Creates a navigator that can be used to find a TwoDimensional.Position within a two dimensional object.

Parameters
elemCount:IntSupplier

a supplier that returns the number of "inner lists" within an "outer list" (see TwoDimensional for clarification). For example, List::size

elemLength:IntUnaryOperator

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

offsetToPositionback to summary
public TwoDimensional.Position offsetToPosition(int offset, TwoDimensional.Bias bias)

Implements org.fxmisc.richtext.model.TwoDimensional.offsetToPosition.

Doc from org.fxmisc.richtext.model.TwoDimensional.offsetToPosition.

Creates a two dimensional position in some entity (e.g. area, list of lists, list of some object with length) where the offset value is an absolute position in that entity.

Annotations
@Override
positionback to summary
public TwoDimensional.Position position(int major, int minor)

Implements org.fxmisc.richtext.model.TwoDimensional.position.

Doc from org.fxmisc.richtext.model.TwoDimensional.position.

Creates a two dimensional position in some entity (e.g. area, list of lists, list of some object with length) where the major value is the index within the outer list) and the minor value is either the index within the inner list or some amount of length in a list of objects that have length.

Annotations
@Override
org.fxmisc.richtext.model back to summary

private Class TwoLevelNavigator.Pos

extends Object
implements Position
Class Inheritance
All Implemented Interfaces
org.fxmisc.richtext.model.TwoDimensional.Position

Field Summary

Modifier and TypeField and Description
private final int
private final int

Constructor Summary

AccessConstructor and Description
private
Pos(int major, int minor)

Method Summary

Modifier and TypeMethod and Description
private TwoDimensional.Position
backward(int offset, TwoDimensional.Bias bias)

public TwoDimensional.Position
clamp()

Implements org.fxmisc.richtext.model.TwoDimensional.Position.clamp.

Returns a new position which clamps the minor position to be valid given the major position.

private TwoDimensional.Position
forward(int offset, TwoDimensional.Bias bias)

public int
getMajor()

Implements org.fxmisc.richtext.model.TwoDimensional.Position.getMajor.

The major dimension, e.g. paragraph number within a document

public int
getMinor()

Implements org.fxmisc.richtext.model.TwoDimensional.Position.getMinor.

The minor dimension, e.g. segment index or column offset within a paragraph.

public TwoDimensional
getTargetObject()

Implements org.fxmisc.richtext.model.TwoDimensional.Position.getTargetObject.

The TwoDimensional object that this position refers to.

public TwoDimensional.Position
offsetBy(int amount, TwoDimensional.Bias bias)

Implements org.fxmisc.richtext.model.TwoDimensional.Position.offsetBy.

Returns a new position that offsets this position by the given amount

public boolean
sameAs(TwoDimensional.Position other)

Implements org.fxmisc.richtext.model.TwoDimensional.Position.sameAs.

Returns true if the given position is equal to this position, that is they both point to the same place in the same two-dimensional object.

public int
toOffset()

Implements org.fxmisc.richtext.model.TwoDimensional.Position.toOffset.

Converts this position to an overall offset within the original TwoDimensional item (to which getTargetObject refers).

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

majorback to summary
private final int major
minorback to summary
private final int minor

Constructor Detail

Posback to summary
private Pos(int major, int minor)

Method Detail

backwardback to summary
private TwoDimensional.Position backward(int offset, TwoDimensional.Bias bias)
clampback to summary
public TwoDimensional.Position clamp()

Implements org.fxmisc.richtext.model.TwoDimensional.Position.clamp.

Doc from org.fxmisc.richtext.model.TwoDimensional.Position.clamp.

Returns a new position which clamps the minor position to be valid given the major position. (i.e. if the position is beyond the end of a given paragraph, moves the position back to the end of the paragraph).

Annotations
@Override
forwardback to summary
private TwoDimensional.Position forward(int offset, TwoDimensional.Bias bias)
getMajorback to summary
public int getMajor()

Implements org.fxmisc.richtext.model.TwoDimensional.Position.getMajor.

Doc from org.fxmisc.richtext.model.TwoDimensional.Position.getMajor.

The major dimension, e.g. paragraph number within a document

Annotations
@Override
getMinorback to summary
public int getMinor()

Implements org.fxmisc.richtext.model.TwoDimensional.Position.getMinor.

Doc from org.fxmisc.richtext.model.TwoDimensional.Position.getMinor.

The minor dimension, e.g. segment index or column offset within a paragraph.

Annotations
@Override
getTargetObjectback to summary
public TwoDimensional getTargetObject()

Implements org.fxmisc.richtext.model.TwoDimensional.Position.getTargetObject.

Doc from org.fxmisc.richtext.model.TwoDimensional.Position.getTargetObject.

The TwoDimensional object that this position refers to.

Annotations
@Override
offsetByback to summary
public TwoDimensional.Position offsetBy(int amount, TwoDimensional.Bias bias)

Implements org.fxmisc.richtext.model.TwoDimensional.Position.offsetBy.

Doc from org.fxmisc.richtext.model.TwoDimensional.Position.offsetBy.

Returns a new position that offsets this position by the given amount

Annotations
@Override
sameAsback to summary
public boolean sameAs(TwoDimensional.Position other)

Implements org.fxmisc.richtext.model.TwoDimensional.Position.sameAs.

Doc from org.fxmisc.richtext.model.TwoDimensional.Position.sameAs.

Returns true if the given position is equal to this position, that is they both point to the same place in the same two-dimensional object. Otherwise returns false.

Annotations
@Override
toOffsetback to summary
public int toOffset()

Implements org.fxmisc.richtext.model.TwoDimensional.Position.toOffset.

Doc from org.fxmisc.richtext.model.TwoDimensional.Position.toOffset.

Converts this position to an overall offset within the original TwoDimensional item (to which getTargetObject refers). For example, moving a caret to a relative position (paragraph 2, column 3) might result in the offset value (absolute position) of 28.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override