Package com.vaadin.shared.ui.colorpicker

Examples of com.vaadin.shared.ui.colorpicker.Color


            @Override
            public void colorChanged(ColorChangeEvent event) {

                // Get the new background color
                Color color = event.getColor();

                // Get the stylesheet of the page
                Styles styles = Page.getCurrent().getStyles();

                // inject the new background color
                styles.add(".v-app .v-textarea.text-label { background-color:"
                        + color.getCSS() + "; }");
            }
        });
        return bgColor;
    }
View Full Code Here


            @Override
            public void colorChanged(ColorChangeEvent event) {

                // Get the new text color
                Color color = event.getColor();

                // Get the stylesheet of the page
                Styles styles = Page.getCurrent().getStyles();

                // inject the new color as a style
                styles.add(".v-app .v-textarea.text-label { color:"
                        + color.getCSS() + "; }");
            }
        });

        return textColor;
    }
View Full Code Here

    @Test
    public void convertHSL2RGB() {

        int rgb = Color.HSLtoRGB(100, 50, 50);
        Color c = new Color(rgb);
        assertEquals(106, c.getRed());
        assertEquals(191, c.getGreen());
        assertEquals(64, c.getBlue());
        assertEquals("#6abf40", c.getCSS());

        rgb = Color.HSLtoRGB(0, 50, 50);
        c = new Color(rgb);
        assertEquals(191, c.getRed());
        assertEquals(64, c.getGreen());
        assertEquals(64, c.getBlue());
        assertEquals("#bf4040", c.getCSS());

        rgb = Color.HSLtoRGB(50, 0, 50);
        c = new Color(rgb);
        assertEquals(128, c.getRed());
        assertEquals(128, c.getGreen());
        assertEquals(128, c.getBlue());
        assertEquals("#808080", c.getCSS());

        rgb = Color.HSLtoRGB(50, 100, 0);
        c = new Color(rgb);
        assertEquals(0, c.getRed(), 0);
        assertEquals(0, c.getGreen(), 0);
        assertEquals(0, c.getBlue(), 0);
        assertEquals("#000000", c.getCSS());
    }
View Full Code Here

        setContent(layout);

        layout.addComponent(new Label(
                "HSV initial values when opening the tab for the first time"));
        ColorPickerArea colorpicker = new ColorPickerArea();
        colorpicker.setColor(new Color(Integer.parseInt("00b4f0", 16)));
        colorpicker.setDefaultCaptionEnabled(false);
        colorpicker.setId("colorpicker");
        layout.addComponent(colorpicker);

    }
View Full Code Here

        Label divider2 = new Label("<hr>", ContentMode.HTML);
        layoutLeft.addComponent(divider2);

        HorizontalLayout layout4 = createHorizontalLayout();

        addShadeButton(new Color(Integer.parseInt("000000", 16)), layout4);
        addShadeButton(new Color(Integer.parseInt("333333", 16)), layout4);
        addShadeButton(new Color(Integer.parseInt("666666", 16)), layout4);
        addShadeButton(new Color(Integer.parseInt("999999", 16)), layout4);
        addShadeButton(new Color(Integer.parseInt("cccccc", 16)), layout4);
        addShadeButton(new Color(Integer.parseInt("ffffff", 16)), layout4);

        Panel panel4 = new Panel(
                "Button-like colorpickers with disabled caption (no effect on fg/bg colors)",
                layout4);
        layoutLeft.addComponent(panel4);

        HorizontalLayout layout5 = createHorizontalLayout();

        addShadeArea(new Color(Integer.parseInt("000000", 16)), layout5);
        addShadeArea(new Color(Integer.parseInt("111111", 16)), layout5);
        addShadeArea(new Color(Integer.parseInt("222222", 16)), layout5);
        addShadeArea(new Color(Integer.parseInt("333333", 16)), layout5);
        addShadeArea(new Color(Integer.parseInt("444444", 16)), layout5);
        addShadeArea(new Color(Integer.parseInt("555555", 16)), layout5);
        addShadeArea(new Color(Integer.parseInt("666666", 16)), layout5);
        addShadeArea(new Color(Integer.parseInt("777777", 16)), layout5);
        addShadeArea(new Color(Integer.parseInt("888888", 16)), layout5);
        addShadeArea(new Color(Integer.parseInt("999999", 16)), layout5);
        addShadeArea(new Color(Integer.parseInt("aaaaaa", 16)), layout5);
        addShadeArea(new Color(Integer.parseInt("bbbbbb", 16)), layout5);
        addShadeArea(new Color(Integer.parseInt("cccccc", 16)), layout5);
        addShadeArea(new Color(Integer.parseInt("dddddd", 16)), layout5);
        addShadeArea(new Color(Integer.parseInt("eeeeee", 16)), layout5);
        addShadeArea(new Color(Integer.parseInt("ffffff", 16)), layout5);

        Panel panel5 = new Panel(
                "Area colorpickers with no given caption (no effect on fg/bg colors)",
                layout5);
        layoutLeft.addComponent(panel5);
View Full Code Here

            String[] colors = new String[changedColors.size()];
            String[] XCoords = new String[changedColors.size()];
            String[] YCoords = new String[changedColors.size()];
            int counter = 0;
            for (Point p : changedColors.keySet()) {
                Color c = changedColors.get(p);
                if (c == null) {
                    continue;
                }

                String color = c.getCSS();

                colors[counter] = color;
                XCoords[counter] = String.valueOf((int) p.getX());
                YCoords[counter] = String.valueOf((int) p.getY());
                counter++;
View Full Code Here

                        saturation = ((row + 1f) / (rows / 2f));
                    } else {
                        value = 1f - ((row - (rows / 2f)) / (rows / 2f));
                    }

                    colors[row][col] = new Color(Color.HSVtoRGB(hue,
                            saturation, value));
                }

                // The last row should have the black&white gradient
                else {
                    float hue = 0f;
                    float saturation = 0f;
                    float value = 1f - ((float) col / (float) columns);

                    colors[row][col] = new Color(Color.HSVtoRGB(hue,
                            saturation, value));
                }
            }
        }
View Full Code Here

                    index -= ((rows * columns) / 2);
                    value = 1f - index
                            / (((float) rows * (float) columns) / 2f);
                }

                colors[row][col] = new Color(Color.HSVtoRGB(hue, saturation,
                        value));
            }
        }

        return colors;
View Full Code Here

        }

        if (event.getProperty().getValue() == ColorRangePropertyId.ALL) {
            grid.setColorGrid(createAllColors(14, 10));
        } else if (event.getProperty().getValue() == ColorRangePropertyId.RED) {
            grid.setColorGrid(createColors(new Color(0xFF, 0, 0), 14, 10));
        } else if (event.getProperty().getValue() == ColorRangePropertyId.GREEN) {
            grid.setColorGrid(createColors(new Color(0, 0xFF, 0), 14, 10));
        } else if (event.getProperty().getValue() == ColorRangePropertyId.BLUE) {
            grid.setColorGrid(createColors(new Color(0, 0, 0xFF), 14, 10));
        }
    }
View Full Code Here

        redSlider.addValueChangeListener(new ValueChangeListener() {
            @Override
            public void valueChange(ValueChangeEvent event) {
                double red = (Double) event.getProperty().getValue();
                if (!updatingColors) {
                    Color newColor = new Color((int) red, selectedColor
                            .getGreen(), selectedColor.getBlue());
                    setColor(newColor);
                }
            }
        });

        sliders.addComponent(redSlider);

        greenSlider.addValueChangeListener(new ValueChangeListener() {
            @Override
            public void valueChange(ValueChangeEvent event) {
                double green = (Double) event.getProperty().getValue();
                if (!updatingColors) {
                    Color newColor = new Color(selectedColor.getRed(),
                            (int) green, selectedColor.getBlue());
                    setColor(newColor);
                }
            }
        });
        sliders.addComponent(greenSlider);

        blueSlider.addValueChangeListener(new ValueChangeListener() {
            @Override
            public void valueChange(ValueChangeEvent event) {
                double blue = (Double) event.getProperty().getValue();
                if (!updatingColors) {
                    Color newColor = new Color(selectedColor.getRed(),
                            selectedColor.getGreen(), (int) blue);
                    setColor(newColor);
                }
            }
        });
View Full Code Here

TOP

Related Classes of com.vaadin.shared.ui.colorpicker.Color

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.