public class ColorList extends Object implements ColorIndex, Iterable<RGBColor>
Note that a color may be duplicated in more than one position in the list. There is no check on uniqueness.
Constructor and Description |
---|
ColorList() |
ColorList(Color... colors)
Create for one or more colors of type
Color . |
ColorList(RGBColor... colors)
Create for one or more colors of type
RGBColor . |
ColorList(java.util.stream.Stream<RGBColor> colors)
Create for one or more colors of type
RGBColor . |
Modifier and Type | Method and Description |
---|---|
void |
add(Color color)
Appends a
Color to the list. |
void |
add(int index,
RGBColor color)
Inserts a
Color into the list, at a particular index. |
void |
add(RGBColor color)
Like
add(Color) but adds a RGBColor . |
void |
addAll(ColorList colors)
Appends
Color s to the list. |
void |
addMultiple(RGBColor color,
int numberTimes)
Append multiple entries for the same color to the end of the list.
|
List<RGBColor> |
asList()
Exposes the underlying
List in the data-structure. |
ColorList |
deepCopy()
Creates a new list, containing the duplicates of same elements as the current list.
|
RGBColor |
get(int index)
The color for a particular index.
|
Iterator<RGBColor> |
iterator() |
int |
numberUniqueColors()
The number of unique colors being described by the index.
|
RGBColor |
remove(int index)
Remove an element at a particular index.
|
ColorList |
shallowCopy()
Creates a new list, containing the same elements as the current list.
|
void |
shuffle()
Randomize the order of the colors in the list.
|
int |
size()
The number of elements (colors) in the list.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public ColorList(Color... colors)
Color
.colors
- the colorspublic ColorList(RGBColor... colors)
RGBColor
.colors
- the colorspublic ColorList(java.util.stream.Stream<RGBColor> colors)
RGBColor
.colors
- the colorspublic ColorList()
public RGBColor get(int index)
ColorIndex
get
in interface ColorIndex
index
- the indexindex
.public int numberUniqueColors()
ColorIndex
numberUniqueColors
in interface ColorIndex
public void shuffle()
This is a mutable operation, that will change the relationship between colors and indices.
public ColorList shallowCopy()
public ColorList deepCopy()
public int size()
public void add(Color color)
Color
to the list.
The color is added to the end of the list, so existing relationships between colors and indices remains unchanged.
color
- the color to addpublic void add(RGBColor color)
add(Color)
but adds a RGBColor
.color
- the color to addpublic void add(int index, RGBColor color)
Color
into the list, at a particular index.
Note that this likely changes the relationship between existing colors and indices.
index
- the index to insert the color at.color
- the color to insert.public void addAll(ColorList colors)
Color
s to the list.
The colors are added to the end of the list, so existing relationships between colors and indices remains unchanged.
colors
- the colors to addpublic void addMultiple(RGBColor color, int numberTimes)
color
- the color to add multiple timesnumberTimes
- how many times to add it.public RGBColor remove(int index)
index
- the index to remove at.Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.