Java examples for 2D Graphics:Color
get Appointment Color
import java.awt.Color; public class Main{ public static void main(String[] argv) throws Exception{ int nr = 2; System.out.println(getAppointmentColor(nr)); }//from w ww.j a va 2s . c o m final static public Color getAppointmentColor(int nr) { String string = RaplaColors.getAppointmentColor(nr); Color color = getColorForHex(string); return color; } public static Color getColorForHex(String hexString) throws NumberFormatException { if (hexString == null || hexString.indexOf('#') != 0 || hexString.length() != 7) throw new NumberFormatException("Can't parse HexValue " + hexString); String rString = hexString.substring(1, 3).toUpperCase(); String gString = hexString.substring(3, 5).toUpperCase(); String bString = hexString.substring(5, 7).toUpperCase(); int r = RaplaColors.decode(rString); int g = RaplaColors.decode(gString); int b = RaplaColors.decode(bString); return new Color(r, g, b); } }