Package rma.swing
Class ColorProducer
java.lang.Object
rma.swing.ColorProducer
ColorProducer
establishes a collection of Colors to iterate through, cycling
back to the first item after the last item is accessed
Useful for accessing an unknown number of Colors in a specified order
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a default color collection: BLUE, RED, GREEN, GRAY, MAGENTA, YELLOW, CYANColorProducer
(Collection<Color> colors) Creates a collection of colors from the one given -
Method Summary
Modifier and TypeMethodDescriptionvoid
Introduces a new color into the collectionvoid
Introduces a new color into the collection at the specified indexnext()
Accesses the Color at the current index and moves to the next one Will cycle back to the beginning of the list if moved beyondpeek()
Accesses the Color at the current index without moving to the nextvoid
restart()
Resets the index to the beginning of the collectionvoid
restart
(int index) Resets the index to the specified index, bounded within the collection sizevoid
restart
(Collection<Color> colors) Resets the collection used to iterate, and sets the index back to its start
-
Constructor Details
-
ColorProducer
public ColorProducer()Creates a default color collection: BLUE, RED, GREEN, GRAY, MAGENTA, YELLOW, CYAN -
ColorProducer
Creates a collection of colors from the one given- Parameters:
colors
- a collection of colors to establish
-
-
Method Details
-
peek
Accesses the Color at the current index without moving to the next- Returns:
- the color at the current index
-
next
Accesses the Color at the current index and moves to the next one Will cycle back to the beginning of the list if moved beyond- Returns:
- the color at the current index
-
restart
public void restart()Resets the index to the beginning of the collection -
restart
public void restart(int index) Resets the index to the specified index, bounded within the collection size- Parameters:
index
- the index to set
-
restart
Resets the collection used to iterate, and sets the index back to its start- Parameters:
colors
- the collection to use in place of the current one
-
introduce
Introduces a new color into the collection- Parameters:
color
- the color to introduce
-
introduce
Introduces a new color into the collection at the specified index- Parameters:
color
- the color to introduceindex
- the index to place it at
-