public class Line
extends java.lang.Object
TextSegments
.Constructor and Description |
---|
Line(int type,
int subtype,
@NotNull TextSegment segment)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addTextSegment(@NotNull TextSegment segment)
Appends a
TextSegment to the end of the line. |
void |
appendSelection(@NotNull java.lang.StringBuilder sb,
int beginSelection,
int endSelection)
Appends the selected text to a
StringBuilder instance. |
int |
calculateHeight(int linePosition,
int renderWidth,
boolean showSentCommands,
boolean showFirstSegment)
Determines the height in pixels.
|
void |
drawLine(@NotNull java.awt.Graphics2D g,
int y,
int beginSelection,
int endSelection)
Draws this line to a
Graphics2D instance. |
int |
getEndPosition()
Returns the absolute buffer position of the first character after this
line.
|
int |
getHeight()
Returns the height of this line.
|
@Nullable TextSegment |
getLastTextSegment()
Returns the last segment.
|
int |
getStartPosition()
Returns the absolute buffer position of the first character of this
line.
|
boolean |
isVisible(boolean showSentCommands)
Returns whether this line is visible.
|
void |
removeLastTextSegment()
Removes the last segment.
|
@NotNull java.lang.Iterable<TextSegment> |
segments()
Returns all segments of the line.
|
void |
updatePosition(int positions)
Shifts the position of this line.
|
public Line(int type, int subtype, @NotNull @NotNull TextSegment segment)
type
- the message typesubtype
- the message subtypesegment
- the timestamp of this linepublic void addTextSegment(@NotNull @NotNull TextSegment segment)
TextSegment
to the end of the line.segment
- the text segment@NotNull public @NotNull java.lang.Iterable<TextSegment> segments()
@Nullable public @Nullable TextSegment getLastTextSegment()
null
if the line is emptypublic void removeLastTextSegment()
public int getHeight()
-1
until
calculateHeight(int, int, boolean, boolean)
was called.public int getStartPosition()
public int getEndPosition()
public int calculateHeight(int linePosition, int renderWidth, boolean showSentCommands, boolean showFirstSegment)
linePosition
- the absolute buffer position of the first character
of the linerenderWidth
- the width to rendershowSentCommands
- whether to show commands sent to the servershowFirstSegment
- whether to show the first segment (the
timestamp)public boolean isVisible(boolean showSentCommands)
showSentCommands
- whether to show commands sent to the serverpublic void updatePosition(int positions)
positions
- the number of positions to shiftpublic void drawLine(@NotNull @NotNull java.awt.Graphics2D g, int y, int beginSelection, int endSelection)
Graphics2D
instance.g
- the graphics to draw toy
- the y-coordinate to start drawingbeginSelection
- the first selected characterendSelection
- the first character after the selectionpublic void appendSelection(@NotNull @NotNull java.lang.StringBuilder sb, int beginSelection, int endSelection)
StringBuilder
instance.sb
- the string builder instancebeginSelection
- the first selected characterendSelection
- the first character after the selection