Example usage for com.vaadin.shared.ui.colorpicker Color getBlue

List of usage examples for com.vaadin.shared.ui.colorpicker Color getBlue

Introduction

In this page you can find the example usage for com.vaadin.shared.ui.colorpicker Color getBlue.

Prototype

public int getBlue() 

Source Link

Document

Returns the blue value of the color.

Usage

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;
    }// www  . jav  a2  s.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;
    }//ww  w. j a va 2 s.  c o m

    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;//w  ww.java  2  s  .c  o m
    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./*  w w w.  java2s  . 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() + ")";
}