java.lang.Object
com.realtime.crossfire.jxclient.gui.log.Line

public class Line extends Object
Manages the contents of one text line. A text line consists of a sequence of TextSegments.
  • Constructor Details

    • Line

      public Line(int type, int subtype, @NotNull @NotNull TextSegment segment)
      Creates a new instance.
      Parameters:
      type - the message type
      subtype - the message subtype
      segment - the timestamp of this line
  • Method Details

    • addTextSegment

      public void addTextSegment(@NotNull @NotNull TextSegment segment)
      Appends a TextSegment to the end of the line.
      Parameters:
      segment - the text segment
    • segments

      @NotNull public @NotNull Iterable<TextSegment> segments()
      Returns all segments of the line.
      Returns:
      the segments
    • getLastTextSegment

      @Nullable public @Nullable TextSegment getLastTextSegment()
      Returns the last segment.
      Returns:
      the last segment or null if 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 -1 until calculateHeight(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 line
      renderWidth - the width to render
      showSentCommands - whether to show commands sent to the server
      showFirstSegment - 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

      public void drawLine(@NotNull @NotNull Graphics2D g, int y, int beginSelection, int endSelection)
      Draws this line to a Graphics2D instance.
      Parameters:
      g - the graphics to draw to
      y - the y-coordinate to start drawing
      beginSelection - the first selected character
      endSelection - the first character after the selection
    • appendSelection

      public void appendSelection(@NotNull @NotNull StringBuilder sb, int beginSelection, int endSelection)
      Appends the selected text to a StringBuilder instance.
      Parameters:
      sb - the string builder instance
      beginSelection - the first selected character
      endSelection - the first character after the selection