/** * helper to get red from a string value. * * @param color color string * @return extracted red value */ private float getRFromString(@Nonnull final String color) { if (isShortMode(color)) { return (Integer.parseInt(color.substring(1, 2), HEX_BASE) * SCALE_SHORT_MODE) / MAX_INT_VALUE; } else { return Integer.parseInt(color.substring(1, 3), HEX_BASE) / MAX_INT_VALUE; } }
/** * helper to get green from a string value. * * @param color color string * @return extracted green */ private float getGFromString(@Nonnull final String color) { if (isShortMode(color)) { return (Integer.parseInt(color.substring(2, 3), HEX_BASE) * SCALE_SHORT_MODE) / MAX_INT_VALUE; } else { return Integer.parseInt(color.substring(3, 5), HEX_BASE) / MAX_INT_VALUE; } }
/** * helper to get blue from a string value. * * @param color color string * @return extracted blue */ private float getBFromString(@Nonnull final String color) { if (isShortMode(color)) { return (Integer.parseInt(color.substring(3, 4), HEX_BASE) * SCALE_SHORT_MODE) / MAX_INT_VALUE; } else { return Integer.parseInt(color.substring(5, 7), HEX_BASE) / MAX_INT_VALUE; } }
/** * helper to get alpha from a string value. * * @param color color string * @return alpha value */ private float getAFromString(@Nonnull final String color) { if (isShortMode(color)) { return (Integer.parseInt(color.substring(4, 5), HEX_BASE) * SCALE_SHORT_MODE) / MAX_INT_VALUE; } else { return Integer.parseInt(color.substring(7, 9), HEX_BASE) / MAX_INT_VALUE; } }