1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * distributed under the License is distributed on an "AS IS" BASIS,14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15 * See the License for the specific language governing permissions and16 * limitations under the License.17 */1819package org.apache.hadoop.chukwa.hicc;
202122publicclassColorPicker {
23private String color = "#ff5757";
24privateint index = 0;
2526publicColorPicker() {
27 color = "#ff5757";
28 }
2930public String get(int counter) {
31if ((counter % 6) == 0) {
32 String purple = Integer.toHexString(256 - (counter % 255));
33 color = "#" + purple + "57" + purple;
34 } elseif ((counter % 5) == 0) {
35 String red = Integer.toHexString(256 - (counter % 255));
36 color = "#" + red +"5757";
37 } elseif ((counter % 4) == 0) {
38 String yellow = Integer.toHexString(256 - (counter % 255 * 20));
39 color = "#FF" + yellow + "00";
40 } elseif ((counter % 3) == 0) {
41 String green = Integer.toHexString(256 - (counter % 255));
42 color = "#57" + green + "57";
43 } elseif ((counter % 2) == 0) {
44 String cyan = Integer.toHexString(256 - (counter % 255));
45 color = "#57" + cyan + cyan;
46 } else {
47 String blue = Integer.toHexString(256 - (counter % 255));
48 color = "#5757" + blue + "";
49 }
50returnthis.color;
51 }
5253public String getNext() {
54 index++;
55return get(index);
56 }
57 }