Top Description Inners Methods
org.fxmisc.richtext.model

public Interface TwoDimensional

Known Direct Subinterfaces
org.fxmisc.richtext.model.StyledDocument, org.fxmisc.richtext.model.StyleSpans
Known Direct Implementers
org.fxmisc.richtext.model.TwoLevelNavigator, org.fxmisc.richtext.GenericStyledArea

TwoDimensional is an interface for any item which can be navigated in two dimensions, such as a List of Lists. In short, it allows one to find a position within this object.

There are two basic kinds of two dimensional objects.

  1. One has a type of List<List<Object>>. The major dimension's value indicates the index of the "inner list" within the "outer list" while the minor dimension's value indicates the index of the object within an "inner list."
  2. One has a type of List<ObjectWithLengthMethod as in List<String>. The major dimension's value indicates the index within the list while the minor dimension's value indicates how far into that length-object a position is (e.g. how many characters into a String is a position).

Not all two dimensional objects are rectangular, so the valid values of the minor dimension depends on the major dimension.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
TwoDimensional.Bias

Determines whether to add 1 when the end of an inner list is reached

For example, given the following two dimensional object (a list of lists of objects) where the inner lists values show the absolute index of that specific item within the outer list...

public static interface
TwoDimensional.Position

A two dimensional position, with a major offset (such as a paragraph index within a document) and a minor dimension (such as a segment index or column position within a paragraph).

Method Summary

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

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)

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.

Method Detail

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

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.

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

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.

org.fxmisc.richtext.model back to summary

public final Enum TwoDimensional.Bias

extends Enum<TwoDimensional.Bias>
Class Inheritance

Determines whether to add 1 when the end of an inner list is reached

For example, given the following two dimensional object (a list of lists of objects) where the inner lists values show the absolute index of that specific item within the outer list...


[                 // outer list
     [0, 1, 2, 3],   // inner list 1
     [4, 5, 6]       // inner list 2
]                 // outer list
...navigating to listOfListsObject.offsetTo(3, BACKWARD) will return 3 whereas listOfListsObject.offsetTo(3, FORWARD) will return 4, the "next item" in the two dimensional object. The Bias does not apply if the index is any non-last-index in the inner list. Thus, listOfListsObject.offsetTo(1, BACKWARD) and listOfListsObject.offsetTo(1, FORWARD) will return the same value, 1, since the position is not at the end of the list.

Field Summary

Modifier and TypeField and Description
public static final TwoDimensional.Bias
Backward

When the returned value would be equal to the last index in an "inner list" or the length of some object with length, returns the value unmodified.

public static final TwoDimensional.Bias
Forward

When the returned value would be equal to the last index in an "inner list" or the length of some object with length, returns the value + 1.

Constructor Summary

AccessConstructor and Description
private
Bias()

Method Summary

Modifier and TypeMethod and Description
public static TwoDimensional.Bias
public static TwoDimensional.Bias[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

Backwardback to summary
public static final TwoDimensional.Bias Backward

When the returned value would be equal to the last index in an "inner list" or the length of some object with length, returns the value unmodified. See Bias for more clarification.

Forwardback to summary
public static final TwoDimensional.Bias Forward

When the returned value would be equal to the last index in an "inner list" or the length of some object with length, returns the value + 1. See Bias for more clarification.

Constructor Detail

Biasback to summary
private Bias()

Method Detail

valueOfback to summary
public static TwoDimensional.Bias valueOf(String name)
valuesback to summary
public static TwoDimensional.Bias[] values()
org.fxmisc.richtext.model back to summary

public Interface TwoDimensional.Position

Known Direct Implementers
org.fxmisc.richtext.model.TwoLevelNavigator.Pos, org.fxmisc.richtext.model.ReadOnlyStyledDocument.Pos

A two dimensional position, with a major offset (such as a paragraph index within a document) and a minor dimension (such as a segment index or column position within a paragraph). Major and minor positions begin at 0.

Method Summary

Modifier and TypeMethod and Description
public TwoDimensional.Position
clamp()

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

public int
getMajor()

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

public int
getMinor()

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

public TwoDimensional
getTargetObject()

The TwoDimensional object that this position refers to.

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

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

public boolean
sameAs(TwoDimensional.Position other)

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()

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

Method Detail

clampback to summary
public 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).

getMajorback to summary
public int getMajor()

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

getMinorback to summary
public int getMinor()

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

getTargetObjectback to summary
public TwoDimensional getTargetObject()

The TwoDimensional object that this position refers to.

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

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

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

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.

toOffsetback to summary
public int 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.