@Test public void testRandomHexColor() throws Exception { String color = MathUtil.randomHexColor(); Assert.assertEquals('#', color.charAt(0)); Assert.assertEquals(7, color.length()); }
public static String randomHexColor() { List<Integer> colorList = Lists.newArrayList(RandomUtils.nextInt(256), RandomUtils.nextInt(256), RandomUtils.nextInt(256)); StringBuilder sb = new StringBuilder("#"); for (int color : colorList) { String hex = Integer.toHexString(color); if (hex.length() == 1) { hex = '0' + hex; } sb.append(hex); } return sb.toString(); }
MathUtil { public static String randomHexColor() { List<Integer> colorList = Lists.newArrayList(RandomUtils.nextInt(256), RandomUtils.nextInt(256), RandomUtils.nextInt(256)); StringBuilder sb = new StringBuilder("#"); for (int color : colorList) { String hex = Integer.toHexString(color); if (hex.length() == 1) { hex = '0' + hex; } sb.append(hex); } return sb.toString(); } }
MathUtil { public static String randomHexColor() { List<Integer> colorList = Lists.newArrayList(RandomUtils.nextInt(256), RandomUtils.nextInt(256), RandomUtils.nextInt(256)); StringBuilder sb = new StringBuilder("#"); for (int color : colorList) { String hex = Integer.toHexString(color); if (hex.length() == 1) { hex = '0' + hex; } sb.append(hex); } return sb.toString(); }  }
MathUtil { public static String randomHexColor() { List<Integer> colorList = Lists.newArrayList(RandomUtils.nextInt(256), RandomUtils.nextInt(256), RandomUtils.nextInt(256)); StringBuilder sb = new StringBuilder("#"); for (int color : colorList) { String hex = Integer.toHexString(color); if (hex.length() == 1) { hex = '0' + hex; } sb.append(hex); } return sb.toString(); }  static double clip(double value, double min, double max); static double interpolate(double x, double x1, double y1, double x2, double y2); static String randomHexColor(); }
MathUtil { public static String randomHexColor() { List<Integer> colorList = Lists.newArrayList(RandomUtils.nextInt(256), RandomUtils.nextInt(256), RandomUtils.nextInt(256)); StringBuilder sb = new StringBuilder("#"); for (int color : colorList) { String hex = Integer.toHexString(color); if (hex.length() == 1) { hex = '0' + hex; } sb.append(hex); } return sb.toString(); }  static double clip(double value, double min, double max); static double interpolate(double x, double x1, double y1, double x2, double y2); static String randomHexColor();  }