Class CList

  • Direct Known Subclasses:
    CTable

    public class CList
    extends Object
    The `CList` class represents a customizable list for displaying information on a screen.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected List<String> list  
      protected char[][] screen  
      protected int width  
    • Constructor Summary

      Constructors 
      Constructor Description
      CList()
      Constructs an empty `CList`.
      CList​(String[] arr)
      Constructs a `CList` with an array of items.
      CList​(String[] arr, int width)
      Constructs a `CList` with an array of items and a specified width.
    • Field Detail

      • screen

        protected char[][] screen
      • width

        protected int width
    • Constructor Detail

      • CList

        public CList​(String[] arr,
                     int width)
        Constructs a `CList` with an array of items and a specified width.
        Parameters:
        arr - Array of items to initialize the list.
        width - The width of the list.
      • CList

        public CList()
        Constructs an empty `CList`.
      • CList

        public CList​(String[] arr)
        Constructs a `CList` with an array of items.
        Parameters:
        arr - Array of items to initialize the list.
    • Method Detail

      • setCharSets

        protected void setCharSets​(Symbol symbol)
        Sets the character sets used for drawing the list.
        Parameters:
        symbol - The symbol to be used for drawing.
      • useBoxSet

        public void useBoxSet()
        Sets the character sets to use box drawing characters for the list.
      • setWidth

        public void setWidth​(int width)
        Sets the width of the list.
        Parameters:
        width - The new width of the list.
      • setCorners

        protected static void setCorners​(char[] chars,
                                         char corner,
                                         char corner2,
                                         char[] chars2,
                                         char corner3,
                                         char corner4)
        Sets the corner characters for the screen borders.
        Parameters:
        chars - The array of characters representing the top or bottom border.
        corner - The character for the top-left corner.
        corner2 - The character for the top-right corner.
        chars2 - The array of characters representing the bottom border.
        corner3 - The character for the bottom-left corner.
        corner4 - The character for the bottom-right corner.
      • setTitle

        public void setTitle​(String title,
                             Position pos)
        Sets the title of the list and its position.
        Parameters:
        title - The title to be set.
        pos - The position of the title (START, CENTER, or END).
      • display

        public void display()
        Displays the screen representation of the list.
      • addCounter

        public void addCounter()
        Adds a counter to each item in the list.
      • addItem

        public void addItem​(String item)
        Adds an item to the list.
        Parameters:
        item - The item to be added.
      • getItem

        public String getItem​(int index)
        Gets the item at the specified index.
        Parameters:
        index - The index of the item to retrieve.
        Returns:
        The item at the specified index.
      • remove

        public void remove​(int index)
        Removes the item at the specified index.
        Parameters:
        index - The index of the item to be removed.
      • removeAll

        public void removeAll()
        Removes all items from the list.
      • set

        public void set​(int index,
                        String item)
        Sets the item at the specified index.
        Parameters:
        index - The index of the item to be set.
        item - The new value for the item.