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);