001    /**
002       ##############################################################################
003       ##                                                                          ##
004       ## EnvInfo                                                                  ##
005       ##                                                                          ##
006       ## Copyright (C) 2009  Frederic Roudaut  <frederic.roudaut@free.fr>         ##
007       ##                                                                          ##
008       ## This class is an adaption of the one done by Nicolas Richasse for his    ##
009       ## Java Iperf frontend.                                                     ##
010       ##                                                                          ##
011       ##                                                                          ##
012       ## This program is free software: you can redistribute it and/or modify     ##
013       ## it under the terms of the GNU General Public License as published by     ##
014       ## the Free Software Foundation, either version 3 of the License, or        ##
015       ## (at your option) any later version.                                      ##
016       ##                                                                          ##
017       ## This program is distributed in the hope that it will be useful,          ##
018       ## but WITHOUT ANY WARRANTY; without even the implied warranty of           ##
019       ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            ##
020       ## GNU General Public License for more details.                             ##
021       ##                                                                          ##
022       ## You should have received a copy of the GNU General Public License        ##
023       ## along with this program.  If not, see <http://www.gnu.org/licenses/>.    ##
024       ##                                                                          ##
025       ##                                                                          ##
026       ##############################################################################
027    **/
028    
029    package com.envInfo;
030    
031    import java.awt.Color;
032    
033    /**
034     * Class used to generate colors for the Memory charts.
035     * <br/><br/>
036     * This class is an adaption of the one done by Nicolas Richasse for his   
037     * Java Iperf frontend.
038     *
039     **/
040    public class SeriesColorGenerator 
041    {
042        private static Color[] allColors = 
043        { Color.green, Color.red, Color.yellow, Color.blue, Color.gray, Color.magenta, Color.white, Color.orange, Color.cyan, Color.darkGray, Color.lightGray, Color.pink};
044        private static int currentIndex = 0;
045            
046        /**
047         * Return a new Color.
048         * @return a new Color.
049         *
050         */
051        public static Color nextColor()
052        {
053            Color res = allColors[currentIndex];
054            currentIndex = (currentIndex+1)%allColors.length;
055            return res;
056        }
057            
058        /**
059         * Reset all the colors choice.
060         *
061         */
062        public static void reset()
063        {
064            currentIndex = 0;
065        }
066    }