Class Line

  • All Implemented Interfaces:
    java.lang.Iterable<Segment>

    public class Line
    extends java.lang.Object
    implements java.lang.Iterable<Segment>
    Manages the contents of one text line. A text line consists of a sequence of Segments.
    • Constructor Summary

      Constructors 
      Constructor Description
      Line()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addSegment​(@NotNull java.lang.String text, boolean bold, boolean italic, boolean underline, @NotNull FontID font, @Nullable java.awt.Color color)
      Appends a Segment to the end of the line.
      int getHeight()
      Returns the height of this line.
      @Nullable Segment getLastSegment()
      Returns the last segment.
      @NotNull java.util.Iterator<Segment> iterator()  
      void removeLastSegment()
      Removes the last segment.
      void setHeight​(int height)
      Returns the height of this line.
      void updateAttributes​(int begin, int end, int y, @NotNull Fonts fonts, @NotNull java.awt.font.FontRenderContext context)
      Updates the cached attributes of some Segments.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • Line

        public Line()
    • Method Detail

      • addSegment

        public void addSegment​(@NotNull
                               @NotNull java.lang.String text,
                               boolean bold,
                               boolean italic,
                               boolean underline,
                               @NotNull
                               @NotNull FontID font,
                               @Nullable
                               @Nullable java.awt.Color color)
        Appends a Segment to the end of the line.
        Parameters:
        text - the text to display
        bold - whether bold face is enabled
        italic - whether italic face is enabled
        underline - whether underlining is enabled
        font - the font to use
        color - the color to use; null means "default color"
      • iterator

        @NotNull
        public @NotNull java.util.Iterator<Segment> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<Segment>
      • getLastSegment

        @Nullable
        public @Nullable Segment getLastSegment()
        Returns the last segment.
        Returns:
        the last segment or null if the line is empty
      • removeLastSegment

        public void removeLastSegment()
        Removes the last segment. The line must not be empty.
      • getHeight

        public int getHeight()
        Returns the height of this line. Returns -1 until setHeight(int) was called.
        Returns:
        the height of this line
      • setHeight

        public void setHeight​(int height)
        Returns the height of this line.
        Parameters:
        height - the height
      • updateAttributes

        public void updateAttributes​(int begin,
                                     int end,
                                     int y,
                                     @NotNull
                                     @NotNull Fonts fonts,
                                     @NotNull
                                     @NotNull java.awt.font.FontRenderContext context)
        Updates the cached attributes of some Segments.
        Parameters:
        begin - the index of the first segment to update
        end - the index of the first segment not to update
        y - the top border of the line's bounding box
        fonts - the fonts instance to use
        context - the font render context to use