public class TextSelection.Span extends Object implements Iterable<TextSelection.Char>
Constructor and Description |
---|
Span(Component c)
Creates a new span for the given component.
|
Modifier and Type | Method and Description |
---|---|
void |
add(TextSelection.Char character)
Adds a character to the span, updating the bounds.
|
TextSelection.Char |
charAt(int x,
int y)
Gets the char at the given coordinate or null if there isn't a char there.
|
TextSelection.Char |
first()
Gets the first Char in the span, or null if span is empty.
|
Rectangle |
getBounds()
Gets the bounds of the span.
|
int |
getEndPos()
Gets th end position of the text.
|
TextSelection.Span |
getIntersection(int x,
int y,
int w,
int h)
Obtains an intersection span including only the characters that intersect the given rectangle.
|
TextSelection.Span |
getIntersection(int x,
int y,
int w,
int h,
boolean withFlow)
Obtains an intersection span including only the characters that intersect the given rectangle.
|
TextSelection.Span |
getIntersection(Rectangle bounds)
Obtains an intersection span including only the characters that intersect the given rectangle.
|
TextSelection.Span |
getIntersection(Rectangle bounds,
boolean withFlow)
Obtains an intersection span including only the characters that intersect the given rectangle.
|
int |
getStartPos()
Gets the start position of the text.
|
boolean |
isEmpty()
Returns true if the span is empty.
|
Iterator<TextSelection.Char> |
iterator()
Returns an
Iterator for the elements in this object. |
TextSelection.Char |
last()
Gets the last Char in the span, or null if the span is empty.
|
int |
size()
Gets the number of Chars in the span.
|
TextSelection.Span |
subspan(int start,
int end)
Gets a subspan containing the Chars between start (inclusive), and end (exclusive).
|
String |
toString()
Returns a string representation of the object.
|
TextSelection.Span |
translate(int tx,
int ty)
Creates a translated span based on this one.
|
public Span(Component c)
c
- public int getStartPos()
public int getEndPos()
public Iterator<TextSelection.Char> iterator()
Iterable
Iterator
for the elements in this object.iterator
in interface Iterable<TextSelection.Char>
Iterator
instance.public String toString()
Object
public void add(TextSelection.Char character)
character
- public TextSelection.Span getIntersection(int x, int y, int w, int h)
x
- The x-coord of the intersection box, relative to TextSelection.getSelectionRoot()
y
- The y-coord of the intersection box to TextSelection.getSelectionRoot()
w
- The width of the intersection box.h
- The height of the intersection box.public TextSelection.Span getIntersection(int x, int y, int w, int h, boolean withFlow)
x
- The x-coord of the intersection box, relative to TextSelection.getSelectionRoot()
y
- The y-coord of the intersection box to TextSelection.getSelectionRoot()
w
- The width of the intersection box.h
- The height of the intersection box.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).public TextSelection.Span getIntersection(Rectangle bounds, boolean withFlow)
bounds
- The bounds of the intersection box, relative to TextSelection.getSelectionRoot()
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).public TextSelection.Span getIntersection(Rectangle bounds)
bounds
- The bounds of the intersection box, relative to TextSelection.getSelectionRoot()
public TextSelection.Char charAt(int x, int y)
x
- x-coordinate relative to TextSelection.getSelectionRoot()
y
- y-coordinate relative to TextSelection.getSelectionRoot()
public TextSelection.Char first()
public TextSelection.Char last()
public int size()
public TextSelection.Span subspan(int start, int end)
start
- The start position of the Char to retrieve.end
- The end position of the Char to retrieve.public Rectangle getBounds()
public TextSelection.Span translate(int tx, int ty)
tx
- x translation in pixels.ty
- y translation in pixels.public boolean isEmpty()