001/*******************************************************************************
002 * This software is provided as a supplement to the authors' textbooks on digital
003 *  image processing published by Springer-Verlag in various languages and editions.
004 * Permission to use and distribute this software is granted under the BSD 2-Clause 
005 * "Simplified" License (see http://opensource.org/licenses/BSD-2-Clause). 
006 * Copyright (c) 2006-2016 Wilhelm Burger, Mark J. Burge. All rights reserved. 
007 * Visit http://imagingbook.com for additional details.
008 *******************************************************************************/
009
010package imagingbook.lib.color;
011
012import imagingbook.lib.color.CssColor;
013import java.awt.Color;
014
015public class CssColorSequencer {
016        
017        private int nextColorIndex = 0;
018        
019        static Color[] ColorSet = CssColor.PreferredColors;
020        
021        public CssColorSequencer() {
022        }
023        
024        public CssColorSequencer(int firstIndex) {
025                nextColorIndex = firstIndex % ColorSet.length;
026        }
027        
028        public Color nextColor() {
029                Color c = ColorSet[nextColorIndex];
030                nextColorIndex = (nextColorIndex + 1) % ColorSet.length;
031                return c;
032        }
033        
034}