22 package com.realtime.crossfire.jxclient.gui.log;
24 import java.awt.Color;
25 import java.awt.font.FontRenderContext;
26 import java.util.ArrayList;
27 import java.util.Collections;
28 import java.util.Iterator;
29 import java.util.List;
30 import org.jetbrains.annotations.NotNull;
31 import org.jetbrains.annotations.Nullable;
38 public class Line implements Iterable<Segment> {
45 private final List<Segment>
segments =
new ArrayList<>();
61 public void addSegment(@NotNull
final String text,
final boolean bold,
final boolean italic,
final boolean underline, @NotNull
final FontID font, @Nullable
final Color color) {
62 segments.add(
new TextSegment(text, bold, italic, underline, font, color));
71 return Collections.unmodifiableList(segments).iterator();
80 return segments.isEmpty() ? null : segments.get(segments.size()-1);
87 segments.remove(segments.size()-1);
115 public void updateAttributes(
final int begin,
final int end,
final int y, @NotNull
final Fonts fonts, @NotNull
final FontRenderContext context) {
116 for (
int i = begin; i < end; i++) {
117 final Segment segment = segments.get(i);
Manages the contents of one text line.
Segment getLastSegment()
Returns the last segment.
void setHeight(final int height)
Returns the height of this line.
void removeLastSegment()
Removes the last segment.
int height
The total height of this line.
int getHeight()
Returns the height of this line.
void updateAttributes(final int begin, final int end, final int y, @NotNull final Fonts fonts, @NotNull final FontRenderContext context)
Updates the cached attributes of some Segments.
One segment of a Line which should be displayed without changing text attributes. ...
One segment of a Line which should be displayed without changing attributes.
void updateAttributes(@NotNull Fonts fonts, @NotNull FontRenderContext context)
Updates the cached attributes of this segment.
void addSegment(@NotNull final String text, final boolean bold, final boolean italic, final boolean underline, @NotNull final FontID font, @Nullable final Color color)
Appends a Segment to the end of the line.
Iterator< Segment > iterator()
void setY(int y)
Sets the y-coordinate to display the segment.
final List< Segment > segments
The segments this line consists of.