Package org.pepstock.charba.client.data
Class Labels
- java.lang.Object
-
- org.pepstock.charba.client.data.Labels
-
public final class Labels extends Object
Contains the labels of the chart.
Is able to manage also multi-line labels.- Author:
- Andrea "Stock" Stocchero
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(String value)
Adds a single line labelvoid
add(String... values)
Adds a multi-line labelstatic Labels
build()
Builds new label objectString
getString(int index)
Returns a label at a specific index.
If at index there is multi-line label, returns labels withConstants.LINE_SEPARATOR
as separator.
If the index is out of bounds, throws an exception.List<String>
getStrings(int index)
Returns a multi line label at a specific index.ObjectType
getType(int index)
Returns the type of a label at specific index.int
indexOf(String... values)
Returns the index of the first occurrence of the specified element in the labels, or -1 if this labels instance does not contain the element.boolean
isEmpty()
Returnstree
if no label is loaded.void
load(String... values)
Loads single line labels.void
load(List<String> values)
Loads single line labels.void
remove(int index)
Removes an item of labels by indexint
size()
Returns the amount of loaded labels.
-
-
-
Method Detail
-
build
public static Labels build()
Builds new label object- Returns:
- new label object
-
load
public void load(String... values)
Loads single line labels.- Parameters:
values
- array of labels
-
load
public void load(List<String> values)
Loads single line labels.- Parameters:
values
- array of labels
-
add
public void add(String value)
Adds a single line label- Parameters:
value
- a single label
-
add
public void add(String... values)
Adds a multi-line label- Parameters:
values
- array of string which represents a multi line label
-
remove
public void remove(int index)
Removes an item of labels by index- Parameters:
index
- index of label
-
size
public int size()
Returns the amount of loaded labels.- Returns:
- the amount of loaded labels
-
isEmpty
public boolean isEmpty()
Returnstree
if no label is loaded.- Returns:
tree
if no label is loaded
-
indexOf
public int indexOf(String... values)
Returns the index of the first occurrence of the specified element in the labels, or -1 if this labels instance does not contain the element.- Parameters:
values
- element to search for, if an array, the elements will be joined withConstants.LINE_SEPARATOR
- Returns:
- the index of the first occurrence of the specified element in the labels, or -1 if this labels instance does not contain the element
-
getString
public String getString(int index)
Returns a label at a specific index.
If at index there is multi-line label, returns labels withConstants.LINE_SEPARATOR
as separator.
If the index is out of bounds, throws an exception.- Parameters:
index
- index of label- Returns:
- a label at a specific index
-
getStrings
public List<String> getStrings(int index)
Returns a multi line label at a specific index. An unmodifiable list of strings is returned.
If the index is out of bounds, throws an exception.- Parameters:
index
- index of label- Returns:
- a unmodifiable list of strings
-
getType
public ObjectType getType(int index)
Returns the type of a label at specific index.- Parameters:
index
- index of label- Returns:
- the type of label or null if out of range
-
-