Package rma.swing

Class ColorProducer

java.lang.Object
rma.swing.ColorProducer

public class ColorProducer extends Object
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

    Constructors
    Constructor
    Description
    Creates a default color collection: BLUE, RED, GREEN, GRAY, MAGENTA, YELLOW, CYAN
    Creates a collection of colors from the one given
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Introduces a new color into the collection
    void
    introduce(Color color, int index)
    Introduces a new color into the collection at the specified index
    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
    Accesses the Color at the current index without moving to the next
    void
    Resets the index to the beginning of the collection
    void
    restart(int index)
    Resets the index to the specified index, bounded within the collection size
    void
    Resets the collection used to iterate, and sets the index back to its start

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ColorProducer

      public ColorProducer()
      Creates a default color collection: BLUE, RED, GREEN, GRAY, MAGENTA, YELLOW, CYAN
    • ColorProducer

      public ColorProducer(Collection<Color> colors)
      Creates a collection of colors from the one given
      Parameters:
      colors - a collection of colors to establish
  • Method Details

    • peek

      public Color peek()
      Accesses the Color at the current index without moving to the next
      Returns:
      the color at the current index
    • next

      public Color 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

      public void restart(Collection<Color> colors)
      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

      public void introduce(Color color)
      Introduces a new color into the collection
      Parameters:
      color - the color to introduce
    • introduce

      public void introduce(Color color, int index)
      Introduces a new color into the collection at the specified index
      Parameters:
      color - the color to introduce
      index - the index to place it at