Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/main/java/com/houarizegai/calculator/util/ColorUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ private ColorUtil() {
* Converts a hexadecimal color code to a Color object.
*
* @param colorHex the hexadecimal color code to convert
* @return the Color object representing the hexadecimal color code, or null if the input is null
* @return the Color object representing the given hexadecimal color code, or null if the input is null
* @throws NumberFormatException if the input is not a valid hexadecimal color code
* @example
* Color color = hex2Color("#FF0000");
* // color is now a Color object representing the color red
* @throws StringIndexOutOfBoundsException if the input is not of the expected length
*
* Example:
* <pre>{@code
* Color color = hex2Color("FFA500");
* }</pre>
*/
public static Color hex2Color(String colorHex) {
// test 1
Expand All @@ -27,6 +30,20 @@ public static Color hex2Color(String colorHex) {
Integer.valueOf(colorHex.substring(2, 4), 16),
Integer.valueOf(colorHex.substring(4, 6), 16)))
.orElse(null);
/**
* Converts a hexadecimal color code to a Color object.
*
* @param colorHex the hexadecimal color code to convert
* @param dType the type of color representation
* @return the Color object representing the given hexadecimal color code, or null if the input is null
* @throws NumberFormatException if the input hexadecimal color code is not in the expected format
* @throws NullPointerException if the input colorHex is null
*
* Example:
* <pre>{@code
* Color color = hex2Color("FFA500", "RGB");
* }</pre>
*/

}

Expand Down