WProperties extends Properties { public static String color2Hexadecimal(Color c, boolean alpha) { int val = c == null ? 0 : alpha ? c.getRGB() : c.getRGB() & 0x00ffffff; return Integer.toHexString(val); } WProperties(); @Override synchronized Object setProperty(String key, String value); @Override String getProperty(String key); void resetProperty(String key, String defaultValue); void resetServiceProperty(String key, String defaultValue); void putIntProperty(String key, int value); int getIntProperty(String key, int def); void putLongProperty(String key, long value); long getLongProperty(String key, long def); void putBooleanProperty(String key, boolean value); boolean getBooleanProperty(String key, boolean def); void putFloatProperty(String key, float value); float getFloatProperty(String key, float def); void putDoubleProperty(String key, double value); double getDoubleProperty(String key, double def); Color getColorProperty(String key); void putColorProperty(String key, Color color); void putByteArrayProperty(String key, byte[] value); byte[] getByteArrayProperty(String key, byte[] def); static String color2Hexadecimal(Color c, boolean alpha); static Color hexadecimal2Color(String hexColor); static void setProperty(WProperties properties, String key, Preferences prefNode, String defaultValue);  }
@Test public void testColor2Hexadecimal() { Assert.assertEquals("magenta without alpha => " + MAGENTA, MAGENTA, WProperties.color2Hexadecimal(Color.MAGENTA, false)); Assert.assertEquals("magenta with alpha => " + MAGENTA_ALPHA, MAGENTA_ALPHA, WProperties.color2Hexadecimal(Color.MAGENTA, true)); Assert.assertEquals("grey with alpha => " + GREY_ALPHA, GREY_ALPHA, WProperties.color2Hexadecimal(COLOR_ALPHA, true)); Assert.assertEquals("grey withtout alpha => " + GREY, GREY, WProperties.color2Hexadecimal(COLOR_ALPHA, false)); }