 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.gui.log;
26 import java.awt.Graphics2D;
27 import java.awt.geom.RectangularShape;
28 import java.util.ArrayList;
29 import java.util.Collections;
30 import java.util.List;
31 import org.jetbrains.annotations.NotNull;
32 import org.jetbrains.annotations.Nullable;
51 private final List<TextSegment>
segments =
new ArrayList<>();
93 length = segment.getText().length();
102 length += segment.getText().length();
111 final List<TextSegment> tmp = Collections.unmodifiableList(
segments);
129 throw new IllegalStateException(
"line is empty");
180 position += segment.getText().length();
191 for (
int i = 0; i <
segments.size(); i++) {
193 final RectangularShape rectangle = segment.
getSize();
194 final int width =
showFirstSegment || i > 0 ? (int)Math.round(rectangle.getWidth()) : 0;
195 if (x != 0 && x+width > renderWidth) {
205 minY = (int)Math.min(minY, Math.round(rectangle.getY()));
206 maxY = (int)Math.max(maxY, Math.round(rectangle.getY()+rectangle.getHeight()));
221 public boolean isVisible(
final boolean showSentCommands) {
230 if (positions < 0 &&
position+positions < 0) {
231 throw new IllegalArgumentException(
"cannot shift line position "+
position+
" by "+positions);
235 segment.updatePosition(positions);
246 public void drawLine(@NotNull
final Graphics2D g,
final int y,
final int beginSelection,
final int endSelection) {
248 segment.draw(g, y, beginSelection, endSelection);
258 public void appendSelection(@NotNull
final StringBuilder sb,
final int beginSelection,
final int endSelection) {
260 segment.appendSelection(sb, beginSelection, endSelection);
String getText()
Returns the text to display.
final List< TextSegment > segments
The segments this line consists of.
static final int MSG_TYPE_JXCLIENT
Internally used drawextinfo message type: a message has been generated by the client.
RectangularShape getSize()
Returns the size of this segment in pixels.
int getHeight()
Returns the height of this line.
int position
The absolute buffer position of the first character of this line.
int getEndPosition()
Returns the absolute buffer position of the first character after this line.
Encapsulates the message type numbers for drawextinfo messages.
int length
The total number of characters in this line.
int calculateHeight(final int linePosition, final int renderWidth, final boolean showSentCommands, final boolean showFirstSegment)
Determines the height in pixels.
void drawLine(@NotNull final Graphics2D g, final int y, final int beginSelection, final int endSelection)
Draws this line to a Graphics2D instance.
void addTextSegment(@NotNull final TextSegment segment)
Appends a TextSegment to the end of the line.
One segment of a Line which should be displayed without changing attributes.
Manages the contents of one text line.
void updatePosition(final int positions)
Shifts the position of this line.
Iterable< TextSegment > segments()
Returns all segments of the line.
final int type
The message type of this line.
void removeLastTextSegment()
Removes the last segment.
TextSegment getLastTextSegment()
Returns the last segment.
boolean isVisible(final boolean showSentCommands)
Returns whether this line is visible.
static final int MSG_SUBTYPE_JXCLIENT_COMMAND
A command that has been sent to the server.
final int subtype
The message subtype of this line.
int getStartPosition()
Returns the absolute buffer position of the first character of this line.
boolean showFirstSegment
Whether to show the first segment (the timestamp).
void setExtends(final int x, final int y, final int position)
Sets the extends to display the segment.
static final int MIN_LINE_HEIGHT
The minimal height of a line in pixels.
void appendSelection(@NotNull final StringBuilder sb, final int beginSelection, final int endSelection)
Appends the selected text to a StringBuilder instance.
int height
The total height of this line.
Line(final int type, final int subtype, @NotNull final TextSegment segment)
Creates a new instance.