* Returns the XML attributes describing the specified color.
* @param color color to described as XML attributes.
* @return the XML attributes describing the specified color.
*/
private static XmlAttributes getColorAttributes(Color color) {
XmlAttributes attributes; // Stores the color's description.
StringBuilder buffer; // Used to build the color's string representation.
buffer = new StringBuilder();
// Red component.
if(color.getRed() < 16)
buffer.append('0');
buffer.append(Integer.toString(color.getRed(), 16));
// Green component.
if(color.getGreen() < 16)
buffer.append('0');
buffer.append(Integer.toString(color.getGreen(), 16));
// Blue component.
if(color.getBlue() < 16)
buffer.append('0');
buffer.append(Integer.toString(color.getBlue(), 16));
// Builds the XML attributes.
attributes = new XmlAttributes();
attributes.add(ATTRIBUTE_COLOR, buffer.toString());
if(color.getAlpha() != 255) {
buffer.setLength(0);
if(color.getAlpha() < 16)
buffer.append('0');
buffer.append(Integer.toString(color.getAlpha(), 16));
attributes.add(ATTRIBUTE_ALPHA, buffer.toString());
}
return attributes;
}