List of usage examples for com.vaadin.shared.ui.colorpicker Color getGreen
public int getGreen()
From source file:com.haulmont.cuba.web.gui.components.converters.ColorStringConverter.java
License:Apache License
@Override public String convertToModel(Color value, Class<? extends String> targetType, Locale locale) throws ConversionException { if (value == null) { return null; }/*from www .java2s . co m*/ String redString = Integer.toHexString(value.getRed()); redString = redString.length() < 2 ? "0" + redString : redString; String greenString = Integer.toHexString(value.getGreen()); greenString = greenString.length() < 2 ? "0" + greenString : greenString; String blueString = Integer.toHexString(value.getBlue()); blueString = blueString.length() < 2 ? "0" + blueString : blueString; return redString + greenString + blueString; }
From source file:com.haulmont.cuba.web.gui.components.WebColorPicker.java
License:Apache License
@Override protected String convertToModel(Color componentRawValue) throws ConversionException { if (componentRawValue == null) { return null; }//from ww w. j av a2 s . c om String redString = Integer.toHexString(componentRawValue.getRed()); redString = redString.length() < 2 ? "0" + redString : redString; String greenString = Integer.toHexString(componentRawValue.getGreen()); greenString = greenString.length() < 2 ? "0" + greenString : greenString; String blueString = Integer.toHexString(componentRawValue.getBlue()); blueString = blueString.length() < 2 ? "0" + blueString : blueString; return redString + greenString + blueString; }
From source file:eu.maxschuster.vaadin.colorpickerfield.converter.AbstractRgbaColorConverter.java
License:Apache License
@Override protected String serializeColor(Color color) throws ConversionException { double alpha = intToDouble(color.getAlpha()); String alphaString;//from w w w .j a va 2 s .c om if (alpha == (long) alpha) { alphaString = String.format("%d", (long) alpha); } else { alphaString = String.format("%s", alpha); } return String.format("rgba(%d,%d,%d,%s)", color.getRed(), color.getGreen(), color.getBlue(), alphaString); }
From source file:eu.maxschuster.vaadin.colorpickerfield.converter.AbstractRgbColorConverter.java
License:Apache License
@Override protected String serializeColor(Color color) throws ConversionException { return String.format("rgb(%d,%d,%d)", color.getRed(), color.getGreen(), color.getBlue()); }
From source file:org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper.java
License:Open Source License
/** * Get color picked value as string.//ww w. j a va 2 s.c o m * * @param preview * the color picker preview * @return String of color picked value. */ public static String getColorPickedString(final SpColorPickerPreview preview) { final Color color = preview.getColor(); return "rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue() + ")"; }