* title.
*/
private void configureColor(ConfigType type, String title) {
// Fetch the current color given the configuration type. This assumes
// it exists, otherwise, it's a bad error.
ColorConfigElement config =
(ColorConfigElement) currentParams.getElement(type);
if (config == null) {
LOGGER.info("Unable to find config element " + type);
config = new HairColorConfigElement();
config.setR(1.0f);
config.setG(1.0f);
config.setB(1.0f);
}
// Create the initial color, each color component is a floating point
// value between 0.0 and 1.0, inclusive. Show the dialog.
Color rgb = new Color(config.getR(), config.getG(), config.getB());
Color hairColor = JColorChooser.showDialog(this, title, rgb);
if (hairColor == null) {
return;
}
// Take the new values from the dialog and set the configuration
// element. We need to convert the integer values between 0 and 255 to
// floating point values between 0.0 and 1.0.
config.setR(hairColor.getRed() / 255.0f);
config.setG(hairColor.getGreen() / 255.0f);
config.setB(hairColor.getBlue() / 255.0f);
currentParams.setElement(type, config);
apply();
}