Color () { int colorIndex = getColorIndex(); if (colorIndex >= COLOR_CUBE_MIN_INDEX && colorIndex < GRAY_MIN_INDEX) { int encodedColor = colorIndex - COLOR_CUBE_MIN_INDEX; //noinspection UseJBColor return new Color(CUBE_STEPS[(encodedColor / 36) % 6], CUBE_STEPS[(encodedColor / 6) % 6], CUBE_STEPS[encodedColor % 6]); } else if (colorIndex >= GRAY_MIN_INDEX && colorIndex <= 255) { int colorPart = GRAYSCALE_STEPS[colorIndex - GRAY_MIN_INDEX]; //noinspection UseJBColor return new Color(colorPart, colorPart, colorPart); } return null; }