Class TextSegment

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

public class TextSegment extends Object
One segment of a Line which should be displayed without changing attributes.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TextSegment(@NotNull String text, @NotNull Font font, boolean bold, boolean italic, boolean underline, @NotNull FontID fontID, @NotNull Color color, @NotNull RectangularShape size, int ascentOffset, int underlineOffset, @NotNull Color selectionColor)
    Creates a new segment.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    appendSelection(@NotNull StringBuilder sb, int beginSelection, int endSelection)
    Appends the selected text to a StringBuilder instance.
    void
    draw(@NotNull Graphics2D g, int y, int beginSelection, int endSelection)
    Draws this segment to a Graphics instance.
    @NotNull String
    Returns a string representation of this text segment.
    int
    Returns the height to display the segment.
    int
    Returns the absolute position of the first character.
    Returns the size of this segment in pixels.
    @NotNull String
    Returns the text to display.
    int
    Returns the width to display the segment.
    int
    getWidth(int chars, @NotNull FontRenderContext context)
    Returns the display width of a prefix of this segment's text.
    int
    Returns the x-coordinate to display the segment.
    int
    Returns the y-coordinate to display the segment.
    boolean
    matches(boolean bold, boolean italic, boolean underline, @NotNull FontID fontID, @NotNull Color color, @NotNull Color selectionColor)
    Returns whether this segment matches the given attributes.
    void
    setExtends(int x, int y, int position)
    Sets the extends to display the segment.
    @NotNull String
     
    void
    updatePosition(int positions)
    Shifts the position of this line.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TextSegment

      public TextSegment(@NotNull @NotNull String text, @NotNull @NotNull Font font, boolean bold, boolean italic, boolean underline, @NotNull @NotNull FontID fontID, @NotNull @NotNull Color color, @NotNull @NotNull RectangularShape size, int ascentOffset, int underlineOffset, @NotNull @NotNull Color selectionColor)
      Creates a new segment.
      Parameters:
      text - the text to display
      font - the font of the text
      bold - whether bold face is enabled
      italic - whether italic face is enabled
      underline - whether underlining is enabled
      fontID - the font to use
      color - the color to use
      size - the size of this segment in pixels
      ascentOffset - the distance of the ascent from the top of the segment
      underlineOffset - the distance of the underline from the top of the segment
      selectionColor - the selection color to use
  • Method Details

    • getText

      @NotNull public @NotNull String getText()
      Returns the text to display.
      Returns:
      the text to display
    • getPosition

      public int getPosition()
      Returns the absolute position of the first character.
      Returns:
      the absolute position of the first character
    • setExtends

      public void setExtends(int x, int y, int position)
      Sets the extends to display the segment.
      Parameters:
      x - the x-coordinate
      y - the y-coordinate
      position - the absolute position of the first character
    • updatePosition

      public void updatePosition(int positions)
      Shifts the position of this line.
      Parameters:
      positions - the number of positions to shift
    • getX

      public int getX()
      Returns the x-coordinate to display the segment.
      Returns:
      the x-coordinate
    • getY

      public int getY()
      Returns the y-coordinate to display the segment.
      Returns:
      the y-coordinate
    • getWidth

      public int getWidth()
      Returns the width to display the segment.
      Returns:
      the width
    • getWidth

      public int getWidth(int chars, @NotNull @NotNull FontRenderContext context)
      Returns the display width of a prefix of this segment's text.
      Parameters:
      chars - the number of characters in the prefix
      context - the font render context to use
      Returns:
      the width
    • getHeight

      public int getHeight()
      Returns the height to display the segment.
      Returns:
      the height
    • draw

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

      @NotNull public @NotNull RectangularShape getSize()
      Returns the size of this segment in pixels.
      Returns:
      the size
    • matches

      public boolean matches(boolean bold, boolean italic, boolean underline, @NotNull @NotNull FontID fontID, @NotNull @NotNull Color color, @NotNull @NotNull Color selectionColor)
      Returns whether this segment matches the given attributes.
      Parameters:
      bold - the bold attribute
      italic - the italic attribute
      underline - the underline attribute
      fontID - the font attribute
      color - the color attribute
      selectionColor - the selection color attribute
      Returns:
      whether all attributes do match
    • toString

      @NotNull public @NotNull String toString()
      Overrides:
      toString in class Object
    • format

      @NotNull public @NotNull String format()
      Returns a string representation of this text segment.
      Returns:
      the string representation
    • 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