org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities より
/**
* Method colorToInteger.
* converts from a Color to an Integer representation
* @param c
* @return Integer
*/
public static Integer colorToInteger(Color c) {
return new Integer(
(c.getBlue() << 16) | (c.getGreen() << 8) | c.getRed());
}
/**
* Method integerToColor.
* converts from an Integer to a Color representation
*
* Note: Normally, colors should be instantiated
* using the AbstractResourceManager.
*
* @param i
* @return Color
*/
public static Color integerToColor(Integer i) {
if (i == null)
return null;
int color = i.intValue();
return new Color(
null,
(color & 0x000000FF),
(color & 0x0000FF00) >> 8,
(color & 0x00FF0000) >> 16);
}
/**
* Method RGBToInteger
* converts from an RGB to an Integer representation
* @param rgb
* @return Integer
*/
public static Integer RGBToInteger(RGB rgb) {
return new Integer((rgb.blue << 16) | (rgb.green << 8) | rgb.red);
}
/**
* Method integerToRGB
* converts from an Integer to an RGB representation
* @param color
* @return RGB
*/
public static RGB integerToRGB(Integer color) {
int n = color.intValue();
return new RGB(
(n & 0x000000FF),
(n & 0x0000FF00) >> 8,
(n & 0x00FF0000) >> 16);
}
最終更新:2009年11月30日 21:10