Package me.araopj.cscreen.components
Class CList
- java.lang.Object
-
- me.araopj.cscreen.components.CList
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCounter()Adds a counter to each item in the list.voidaddItem(String item)Adds an item to the list.voiddisplay()Displays the screen representation of the list.StringgetItem(int index)Gets the item at the specified index.voidremove(int index)Removes the item at the specified index.voidremoveAll()Removes all items from the list.voidset(int index, String item)Sets the item at the specified index.protected voidsetCharSets(Symbol symbol)Sets the character sets used for drawing the list.protected static voidsetCorners(char[] chars, char corner, char corner2, char[] chars2, char corner3, char corner4)Sets the corner characters for the screen borders.voidsetTitle(String title, Position pos)Sets the title of the list and its position.voidsetWidth(int width)Sets the width of the list.voiduseBoxSet()Sets the character sets to use box drawing characters for the list.
-
-
-
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.
-
-