Class TextSelection.Span
- All Implemented Interfaces:
Iterable<TextSelection.Char>
- Enclosing class:
TextSelection
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(TextSelection.Char character) Adds a character to the span, updating the bounds.charAt(int x, int y) Gets the char at the given coordinate or null if there isn't a char there.first()Gets the first Char in the span, or null if span is empty.Gets the bounds of the span.intGets th end position of the text.getIntersection(int x, int y, int w, int h) Obtains an intersection span including only the characters that intersect the given rectangle.getIntersection(int x, int y, int w, int h, boolean withFlow) Obtains an intersection span including only the characters that intersect the given rectangle.getIntersection(Rectangle bounds) Obtains an intersection span including only the characters that intersect the given rectangle.getIntersection(Rectangle bounds, boolean withFlow) Obtains an intersection span including only the characters that intersect the given rectangle.intGets the start position of the text.booleanisEmpty()Returns true if the span is empty.iterator()last()Gets the last Char in the span, or null if the span is empty.intsize()Gets the number of Chars in the span.subspan(int start, int end) Gets a subspan containing the Chars between start (inclusive), and end (exclusive).toString()translate(int tx, int ty) Creates a translated span based on this one.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
Span
Creates a new span for the given component.
Parameters
c
-
-
Method Details
-
getStartPos
public int getStartPos()Gets the start position of the text. -
getEndPos
public int getEndPos()Gets th end position of the text. (exclusive). -
iterator
- Specified by:
iteratorin interfaceIterable<TextSelection.Char>
-
toString
-
add
Adds a character to the span, updating the bounds.
Parameters
character
-
getIntersection
Obtains an intersection span including only the characters that intersect the given rectangle.
Parameters
-
x: The x-coord of the intersection box, relative to#getSelectionRoot() -
y: The y-coord of the intersection box to#getSelectionRoot() -
w: The width of the intersection box. -
h: The height of the intersection box.
Returns
A new span containing only characters that intersect the given bounds.
-
-
getIntersection
Obtains an intersection span including only the characters that intersect the given rectangle.
Parameters
-
x: The x-coord of the intersection box, relative to#getSelectionRoot() -
y: The y-coord of the intersection box to#getSelectionRoot() -
w: The width of the intersection box. -
h: The height of the intersection box. -
withFlow: @param withFlow If true, this will also include any characters that should logically be selected if the user dragged over the given rectangle. E.g. If the selection began above the span, and stretches below it, the entire span should be selected (included in the intersection).
Returns
A new span with the intersection.
-
-
getIntersection
Obtains an intersection span including only the characters that intersect the given rectangle.
Parameters
-
bounds: The bounds of the intersection box, relative to#getSelectionRoot() -
withFlow: @param withFlow If true, this will also include any characters that should logically be selected if the user dragged over the given rectangle. E.g. If the selection began above the span, and stretches below it, the entire span should be selected (included in the intersection).
Returns
A new span with the intersection.
-
-
getIntersection
Obtains an intersection span including only the characters that intersect the given rectangle.
Parameters
bounds: The bounds of the intersection box, relative to#getSelectionRoot()
Returns
A new span with the intersection.
-
charAt
Gets the char at the given coordinate or null if there isn't a char there.
Parameters
-
x: x-coordinate relative to#getSelectionRoot() -
y: y-coordinate relative to#getSelectionRoot()
-
-
first
Gets the first Char in the span, or null if span is empty.
Returns
The first Char, or null.
-
last
Gets the last Char in the span, or null if the span is empty.
Returns
The last Char or null.
-
size
public int size()Gets the number of Chars in the span. -
subspan
Gets a subspan containing the Chars between start (inclusive), and end (exclusive).
Parameters
-
start: The start position of the Char to retrieve. -
end: The end position of the Char to retrieve.
Returns
A new span including only the Chars at the given positions.
-
-
getBounds
Gets the bounds of the span.
Returns
the bounds
-
translate
Creates a translated span based on this one.
Parameters
-
tx: x translation in pixels. -
ty: y translation in pixels.
Returns
A new span translated.
-
-
isEmpty
public boolean isEmpty()Returns true if the span is empty.
-