Class Line
java.lang.Object
com.realtime.crossfire.jxclient.gui.log.Line
Manages the contents of one text line. A text line consists of a sequence of
TextSegments.-
Constructor Summary
ConstructorsConstructorDescriptionLine(int type, int subtype, @NotNull TextSegment segment) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTextSegment(@NotNull TextSegment segment) Appends aTextSegmentto the end of the line.voidappendSelection(@NotNull StringBuilder sb, int beginSelection, int endSelection) Appends the selected text to aStringBuilderinstance.intcalculateHeight(int linePosition, int renderWidth, boolean showSentCommands, boolean showFirstSegment) Determines the height in pixels.voiddrawLine(@NotNull Graphics2D g, int y, int beginSelection, int endSelection) Draws this line to aGraphics2Dinstance.intReturns the absolute buffer position of the first character after this line.intReturns the height of this line.@Nullable TextSegmentReturns the last segment.intReturns the absolute buffer position of the first character of this line.booleanisVisible(boolean showSentCommands) Returns whether this line is visible.voidRemoves the last segment.@NotNull Iterable<TextSegment>segments()Returns all segments of the line.voidupdatePosition(int positions) Shifts the position of this line.
-
Constructor Details
-
Line
Creates a new instance.- Parameters:
type- the message typesubtype- the message subtypesegment- the timestamp of this line
-
-
Method Details
-
addTextSegment
Appends aTextSegmentto the end of the line.- Parameters:
segment- the text segment
-
segments
Returns all segments of the line.- Returns:
- the segments
-
getLastTextSegment
Returns the last segment.- Returns:
- the last segment or
nullif the line is empty
-
removeLastTextSegment
public void removeLastTextSegment()Removes the last segment. The line must not be empty. -
getHeight
public int getHeight()Returns the height of this line. Returns-1untilcalculateHeight(int, int, boolean, boolean)was called.- Returns:
- the height of this line
-
getStartPosition
public int getStartPosition()Returns the absolute buffer position of the first character of this line.- Returns:
- the buffer position
-
getEndPosition
public int getEndPosition()Returns the absolute buffer position of the first character after this line.- Returns:
- the buffer position
-
calculateHeight
public int calculateHeight(int linePosition, int renderWidth, boolean showSentCommands, boolean showFirstSegment) Determines the height in pixels.- Parameters:
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)- Returns:
- the height in pixels
-
isVisible
public boolean isVisible(boolean showSentCommands) Returns whether this line is visible.- Parameters:
showSentCommands- whether to show commands sent to the server- Returns:
- whether this line is visible
-
updatePosition
public void updatePosition(int positions) Shifts the position of this line.- Parameters:
positions- the number of positions to shift
-
drawLine
Draws this line to aGraphics2Dinstance.- Parameters:
g- the graphics to draw toy- the y-coordinate to start drawingbeginSelection- the first selected characterendSelection- the first character after the selection
-
appendSelection
public void appendSelection(@NotNull @NotNull StringBuilder sb, int beginSelection, int endSelection) Appends the selected text to aStringBuilderinstance.- Parameters:
sb- the string builder instancebeginSelection- the first selected characterendSelection- the first character after the selection
-